예제 #1
0
        public static UnixDriveInfo GetForSpecialFile(string specialFile)
        {
            if (specialFile == null)
            {
                throw new ArgumentNullException("specialFile");
            }
            Fstab fstab = Syscall.getfsspec(specialFile);

            if (fstab == null)
            {
                throw new ArgumentException(string.Concat("specialFile isn't valid: ", specialFile));
            }
            return(new UnixDriveInfo(fstab));
        }
예제 #2
0
        public UnixDriveInfo(string mountPoint)
        {
            if (mountPoint == null)
            {
                throw new ArgumentNullException("mountPoint");
            }
            Fstab fstab = Syscall.getfsfile(mountPoint);

            if (fstab == null)
            {
                this.mount_point  = mountPoint;
                this.block_device = string.Empty;
                this.fstype       = "Unknown";
            }
            else
            {
                this.FromFstab(fstab);
            }
        }
예제 #3
0
        public static UnixDriveInfo[] GetDrives()
        {
            ArrayList arrayLists = new ArrayList();
            object    fstabLock  = Syscall.fstab_lock;

            Monitor.Enter(fstabLock);
            try
            {
                if (Syscall.setfsent() != 1)
                {
                    throw new IOException("Error calling setfsent(3)", new UnixIOException());
                }
                try
                {
                    while (true)
                    {
                        Fstab fstab  = Syscall.getfsent();
                        Fstab fstab1 = fstab;
                        if (fstab == null)
                        {
                            break;
                        }
                        if (fstab1.fs_file.StartsWith("/"))
                        {
                            arrayLists.Add(new UnixDriveInfo(fstab1));
                        }
                    }
                }
                finally
                {
                    Syscall.endfsent();
                }
            }
            finally
            {
                Monitor.Exit(fstabLock);
            }
            return((UnixDriveInfo[])arrayLists.ToArray(typeof(UnixDriveInfo)));
        }
예제 #4
0
 private void FromFstab(Fstab fstab)
 {
     this.fstype       = fstab.fs_vfstype;
     this.mount_point  = fstab.fs_file;
     this.block_device = fstab.fs_spec;
 }
예제 #5
0
 private UnixDriveInfo(Fstab fstab)
 {
     this.FromFstab(fstab);
 }