Feb 11 2010 · Mono
After spending some time attempting to P/Invoke the stat() function, I discovered the wonderful Mono.Unix.Native namespace (found in the Mono.Posix assembly) which has some great stuff for lower-level Unix/Linux work.
Here’s what I did to pull a file’s inode number:
static public ulong GetFileInodeNum(string path)
Mono.Unix.Native.Stat statOut = new Mono.Unix.Native.Stat();
int statRet = Mono.Unix.Native.Syscall.stat(path, out statOut);
if(statRet == -1)
throw new IOException("stat on " + path + " failed.");