public UnixDriveInfo (string mountPoint) { if (mountPoint == null) throw new ArgumentNullException ("mountPoint"); fstab = Syscall.getfsfile (mountPoint); if (fstab == null) throw new ArgumentException ("mountPoint isn't valid: " + mountPoint); // throws ArgumentException if driveName isn't valid // though .NET also has a DriveNotFoundException class, so maybe that's // more appropriate? }
public static Fstab getfsspec (string special_file) { _Fstab fsbuf; int r; lock (fstab_lock) { r = sys_getfsspec (special_file, out fsbuf); } if (r != 0) return null; Fstab fs = new Fstab (); CopyFstab (fs, ref fsbuf); return fs; }
public static Fstab getfsfile (string mount_point) { _Fstab fsbuf; int r; lock (fstab_lock) { r = sys_getfsfile (mount_point, out fsbuf); } if (r != 0) return null; Fstab fs = new Fstab (); CopyFstab (fs, ref fsbuf); return fs; }
public static Fstab getfsent () { _Fstab fsbuf; int r; lock (fstab_lock) { r = sys_getfsent (out fsbuf); } if (r != 0) return null; Fstab fs = new Fstab (); CopyFstab (fs, ref fsbuf); return fs; }
private static void CopyFstab (Fstab to, ref _Fstab from) { try { to.fs_spec = UnixMarshal.PtrToString (from.fs_spec); to.fs_file = UnixMarshal.PtrToString (from.fs_file); to.fs_vfstype = UnixMarshal.PtrToString (from.fs_vfstype); to.fs_mntops = UnixMarshal.PtrToString (from.fs_mntops); to.fs_type = UnixMarshal.PtrToString (from.fs_type); to.fs_freq = from.fs_freq; to.fs_passno = from.fs_passno; } finally { Stdlib.free (from._fs_buf_); from._fs_buf_ = IntPtr.Zero; } }
private UnixDriveInfo (Fstab fstab) { this.fstab = fstab; }