private int _OnWriteHandle( string path, byte[] buf, ulong size, long offset, IntPtr fi, out int bytesRead) { Errno errno; try { PathInfo info = new PathInfo(); PathInfo.CopyFromPtr(fi, info); errno = _filesystem.OnWriteHandle (path, info, buf, offset, out bytesRead); if (errno == 0) { PathInfo.CopyToPtr(info, fi); } } catch (Exception e) { Trace.WriteLine(e.ToString()); bytesRead = 0; errno = Errno.EIO; } return(Interop.ConvertErrno(errno)); }
public int _OnLockHandle(string file, IntPtr fi, int cmd, IntPtr lockp) { Errno errno; try { PathInfo info = new PathInfo(); PathInfo.CopyFromPtr(fi, info); FcntlCommand _cmd = NativeConvert.ToFcntlCommand(cmd); Flock @lock; Interop.CopyFlock(lockp, out @lock); errno = _filesystem.OnLockHandle(file, info, _cmd, ref @lock); if (errno == 0) { Interop.CopyFlock(ref @lock, lockp); PathInfo.CopyToPtr(info, fi); } } catch (Exception e) { Trace.WriteLine(e.ToString()); errno = Errno.EIO; } return(Interop.ConvertErrno(errno)); }
private int _OnGetHandleStatus(string path, IntPtr buf, IntPtr fi) { Trace.WriteLine("_OnGetHandleStatus"); Errno errno; try { PathInfo info = new PathInfo(); PathInfo.CopyFromPtr(fi, info); Stat b; Interop.CopyStat(buf, out b); errno = _filesystem.OnGetHandleStatus(path, info, out b); if (errno == 0) { Interop.CopyStat(ref b, buf); PathInfo.CopyToPtr(info, fi); } } catch (Exception e) { Trace.WriteLine(e.ToString()); errno = Errno.EIO; } return(Interop.ConvertErrno(errno)); }
private void GetDirectoryEnumerator( string path, IntPtr fi, out long offset, out Errno errno) { PathInfo info = new PathInfo(); PathInfo.CopyFromPtr(fi, info); offset = -1; IEnumerable <DirectoryEntry> paths; errno = _filesystem.OnReadDirectory(path, info, out paths); if (errno != 0) { return; } if (paths == null) { Trace.WriteLine("OnReadDirectory: errno = 0 but paths is null!"); errno = Errno.EIO; return; } IEnumerator <DirectoryEntry> e = paths.GetEnumerator(); if (e == null) { Trace.WriteLine("OnReadDirectory: errno = 0 but enumerator is null!"); errno = Errno.EIO; return; } int key; lock (directoryLock) { do { key = directoryKeys.Next(1, int.MaxValue); } while (directoryReaders.ContainsKey(key.ToString())); directoryReaders[key.ToString()] = new EntryEnumerator(e); } PathInfo.CopyToPtr(info, fi); offset = key; errno = 0; }
private int _OnReleaseHandle(string path, IntPtr fi) { Errno errno; try { PathInfo info = new PathInfo(); PathInfo.CopyFromPtr(fi, info); errno = _filesystem.OnReleaseHandle(path, info); } catch (Exception e) { Trace.WriteLine(e.ToString()); errno = Errno.EIO; } return(Interop.ConvertErrno(errno)); }
private int _OnTruncateHandle(string path, long length, IntPtr fi) { Errno errno; try { PathInfo info = new PathInfo(); PathInfo.CopyFromPtr(fi, info); errno = _filesystem.OnTruncateHandle(path, info, length); if (errno == 0) { PathInfo.CopyToPtr(info, fi); } } catch (Exception e) { Trace.WriteLine(e.ToString()); errno = Errno.EIO; } return(Interop.ConvertErrno(errno)); }
private int _OnCreateHandle(string path, uint mode, IntPtr fi) { Errno errno; try { PathInfo info = new PathInfo(); PathInfo.CopyFromPtr(fi, info); FilePermissions _mode = NativeConvert.ToFilePermissions(mode); errno = _filesystem.OnCreateHandle(path, info, _mode); if (errno == 0) { PathInfo.CopyToPtr(info, fi); } } catch (Exception e) { Trace.WriteLine(e.ToString()); errno = Errno.EIO; } return(Interop.ConvertErrno(errno)); }
private int _OnSynchronizeHandle( string path, bool onlyUserData, IntPtr fi) { Errno errno; try { PathInfo info = new PathInfo(); PathInfo.CopyFromPtr(fi, info); errno = _filesystem.OnSynchronizeHandle(path, info, onlyUserData); if (errno == 0) { PathInfo.CopyToPtr(info, fi); } } catch (Exception e) { Trace.WriteLine(e.ToString()); errno = Errno.EIO; } return(Interop.ConvertErrno(errno)); }
private int _OnOpenDirectory(string path, IntPtr fi) { Trace.WriteLine("_OnOpenDirectory"); Errno errno; try { PathInfo info = new PathInfo(); PathInfo.CopyFromPtr(fi, info); errno = _filesystem.OnOpenDirectory(path, info); if (errno == 0) { PathInfo.CopyToPtr(info, fi); } } catch (Exception e) { Trace.WriteLine(e.ToString()); errno = Errno.EIO; } return(Interop.ConvertErrno(errno)); }