Files
Servers/MoonlightServers.Daemon/Helpers/NativeMethods.cs

36 lines
1.3 KiB
C#

using System.Runtime.InteropServices;
namespace MoonlightServers.Daemon.Helpers;
internal static partial class NativeMethods
{
[StructLayout(LayoutKind.Sequential)]
internal struct StatVfsResult
{
public ulong bsize;
public ulong frsize;
public ulong blocks;
public ulong bfree;
public ulong bavail;
public ulong files;
public ulong ffree;
public ulong favail;
public ulong fsid;
public ulong flag;
public ulong namemax;
private ulong __spare0; // } kernel reserved padding —
private ulong __spare1; // } never read, exist only to
private ulong __spare2; // } match the 112-byte struct
private ulong __spare3; // } statvfs layout on x86-64
private ulong __spare4; // } Linux so the fields above
private ulong __spare5; // } land at the right offsets
}
// SetLastError = true tells the marshaller to capture errno immediately
// after the call, before any other code can clobber it. Retrieve it with
// Marshal.GetLastPInvokeError() which maps to the thread-local errno value.
[LibraryImport("libc", EntryPoint = "statvfs",
StringMarshalling = StringMarshalling.Utf8,
SetLastError = true)]
internal static partial int StatVfs(string path, out StatVfsResult buf);
}