public Errno Lock(string path, OpenFlags openFlags, FcntlCommand cmd, ref Flock @lock) { { #if DEBUG new CrazyFsRequest(CrazyFsRequestName.Lock, new[] { new KeyValuePair <string, string>("path", path) }).Log(); #endif // ReSharper disable once InconsistentNaming var _lock = @lock; var e = ProcessFile(path, openFlags, fd => Syscall.fcntl(fd, cmd, ref _lock)); @lock = _lock; return(e); } }
private static Errno ProcessFile(string path, OpenFlags flags, FdCb cb) { var fd = Syscall.open(path, (Mono.Unix.Native.OpenFlags)flags); if (fd == -1) { return(Stdlib.GetLastError()); } var r = cb(fd); Errno res = 0; if (r == -1) { res = Stdlib.GetLastError(); } _ = Syscall.close(fd); return(res); }