Conversation
|
It should be noted, I'm opening this against the github fork of VFSForGit (and not upstream) so we can mull over this before deciding whether or not to bother our counterparts at Microsoft with it. |
| const ulong BufSize = 4096; | ||
| byte[] targetBuffer = new byte[BufSize]; | ||
| long bytesRead = ReadLink(fullPathInMirror, targetBuffer, BufSize); | ||
| long bytesRead = Syscall.readlink(fullPathInMirror, targetBuffer); |
There was a problem hiding this comment.
I pulled Mono.Posix in in microsoft#800, and it would be remiss not to use it where appropriate!
| using (var stream = System.IO.File.OpenText(string.Format("/proc/{0}/cmdline", pid))) | ||
| { | ||
| string[] parts = stream.ReadToEnd().Split('\0'); | ||
| return parts.Length > 0 ? parts[0] : string.Empty; |
There was a problem hiding this comment.
Turns out I actually miss working on C# 😅 (It didn't help that last time I was using it for work, it was -- in part -- on services integrating with SharePoint. Y I K E S.)
| // TODO(Linux): set value from that defined in Linux library header | ||
| public const int PlaceholderIdLength = 128; | ||
|
|
||
| public const ulong PROJFS_CLOSE_WRITE = 0x00000008; |
There was a problem hiding this comment.
With these values and the one above, I wonder if we could do something like is done in GenerateGitVersionConstants.sh -- i.e., either extract these values from the C header file using sed, grep, etc., or build a small C program which includes the header and when run spits out the values, which we then put into a small C# ProjFS.Linux.Constants.cs file or something. Does that seem out of bounds?
There was a problem hiding this comment.
No, that seems very apt. We might have to do it with a C program because of definitions like:
#define himask(x) (((uint64_t)x) << 32)
…
#define PROJFS_CREATE_SELF himask(0x0001) /* File was created */I'll have a think about this, but yes, you're quite right -- this is fragile and we can do better.
There was a problem hiding this comment.
Once I work this out, I'll open a PR against the Microsoft upstream repo and invite review from our friends there, as well as yours again on the newest changes.
👋 @chrisd8088
Here's a first pass at implementing the VFS API entirely in C#. There's a companion PR at github/libprojfs#53 which adds one entry point we need.
What do you think? The translation ended up being fairly straightforward after reviewing the P/Invoke docs.