* UnixMarshal.cs: Errno.EBADF should also trigger a ArgumentException.
[mono.git] / mcs / class / Mono.Posix / Mono.Unix / UnixDriveInfo.cs
index 2a0159e3eafcb6ae3f87e016017da7d459a9fb8e..91cd65165bb43240f132e9a89b39167d9cab83f0 100644 (file)
@@ -46,14 +46,14 @@ namespace Mono.Unix {
        // All methods & properties can throw IOException
        public sealed class UnixDriveInfo
        {
-               private Statvfs stat;
-               private Fstab   fstab;
+               private Native.Statvfs stat;
+               private Native.Fstab   fstab;
 
                public UnixDriveInfo (string mountPoint)
                {
                        if (mountPoint == null)
                                throw new ArgumentNullException ("mountPoint");
-                       fstab = Syscall.getfsfile (mountPoint);
+                       fstab = Native.Syscall.getfsfile (mountPoint);
                        if (fstab == null)
                                throw new ArgumentException ("mountPoint isn't valid: " + mountPoint);
                        // throws ArgumentException if driveName isn't valid
@@ -65,19 +65,19 @@ namespace Mono.Unix {
                {
                        if (specialFile == null)
                                throw new ArgumentNullException ("specialFile");
-                       Fstab f = Syscall.getfsspec (specialFile);
+                       Native.Fstab f = Native.Syscall.getfsspec (specialFile);
                        if (f == null)
                                throw new ArgumentException ("specialFile isn't valid: " + specialFile);
                        return new UnixDriveInfo (f);
                }
 
-               private UnixDriveInfo (Fstab fstab)
+               private UnixDriveInfo (Native.Fstab fstab)
                {
                        this.fstab = fstab;
                }
 
                public long AvailableFreeSpace {
-                       get {Refresh (); return (long) (stat.f_bavail * stat.f_bsize);}
+                       get {Refresh (); return Convert.ToInt64 (stat.f_bavail * stat.f_bsize);}
                }
 
                public string DriveFormat {
@@ -115,30 +115,29 @@ namespace Mono.Unix {
                        // set {}
                }
 
-               public ulong MaximumFilenameLength {
-                       get {Refresh (); return stat.f_namemax;}
+               public long MaximumFilenameLength {
+                       get {Refresh (); return Convert.ToInt64 (stat.f_namemax);}
                }
 
                public static UnixDriveInfo[] GetDrives ()
                {
                        // throws IOException, UnauthorizedAccessException (no permission)
                        ArrayList entries = new ArrayList ();
-                       Syscall.SetLastError ((Error) 0);
 
-                       lock (Syscall.fstab_lock) {
-                               int r = Syscall.setfsent ();
+                       lock (Native.Syscall.fstab_lock) {
+                               int r = Native.Syscall.setfsent ();
                                if (r != 1)
                                        throw new IOException ("Error calling setfsent(3)", new UnixIOException ());
                                try {
-                                       Fstab fs;
-                                       while ((fs = Syscall.getfsent()) != null) {
+                                       Native.Fstab fs;
+                                       while ((fs = Native.Syscall.getfsent()) != null) {
                                                // avoid virtual entries, such as "swap"
                                                if (fs.fs_file.StartsWith ("/"))
                                                        entries.Add (new UnixDriveInfo (fs));
                                        }
                                }
                                finally {
-                                       Syscall.endfsent ();
+                                       Native.Syscall.endfsent ();
                                }
                        }
                        return (UnixDriveInfo[]) entries.ToArray (typeof(UnixDriveInfo));
@@ -156,9 +155,9 @@ namespace Mono.Unix {
 
                private bool Refresh (bool throwException)
                {
-                       int r = Syscall.statvfs (fstab.fs_file, out stat);
+                       int r = Native.Syscall.statvfs (fstab.fs_file, out stat);
                        if (r == -1 && throwException) {
-                               Error e = Syscall.GetLastError ();
+                               Native.Errno e = Native.Syscall.GetLastError ();
                                throw new IOException (UnixMarshal.GetErrorDescription (e),
                                        UnixMarshal.CreateExceptionForError (e));
                        }