* map.c, map.h: Add FromMountFlags, ToMountFlags. (MountFlags is used in
authorJonathan Pryor <jpryor@novell.com>
Thu, 12 May 2005 20:35:07 +0000 (20:35 -0000)
committerJonathan Pryor <jpryor@novell.com>
Thu, 12 May 2005 20:35:07 +0000 (20:35 -0000)
    `struct statvfs', which is POSIX).
  * sys-statvfs.c: Use ToMountFlags to convert the OS flags value into the
    managed equivalent.

svn path=/trunk/mono/; revision=44465

support/ChangeLog
support/map.c
support/map.h
support/sys-statvfs.c

index 31180e095b9ddfb413318d3e31439234b33833e6..ff57639f73e24ec8ef4d09cf9d2c8d7fd6c6c600 100644 (file)
@@ -1,3 +1,10 @@
+2005-05-12  Jonathan Pryor  <jonpryor@vt.edu>
+
+       * map.c, map.h: Add FromMountFlags, ToMountFlags.  (MountFlags is used in
+         `struct statvfs', which is POSIX).
+       * sys-statvfs.c: Use ToMountFlags to convert the OS flags value into the
+         managed equivalent.
+
 2005-05-03  Geoff Norton  <gnorton@customerdna.com>
 
        * sys-xattr.c:  Mac OS/X Tiger supports xattr but has a different API for supporting
index c9f47a440960c228505b597a33b3b0c942f3332e..e483d86e0ca7426ad72c410aa32f833d0ebeaa0a 100644 (file)
@@ -6021,3 +6021,119 @@ int Mono_Posix_ToXattrFlags (int x, int *r)
        return 0;
 }
 
+int Mono_Posix_FromMountFlags (guint64 x, guint64 *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if ((x & Mono_Posix_MountFlags_ST_RDONLY) == Mono_Posix_MountFlags_ST_RDONLY)
+#ifdef ST_RDONLY
+               *r |= ST_RDONLY;
+#else /* def ST_RDONLY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_RDONLY */
+       if ((x & Mono_Posix_MountFlags_ST_NOSUID) == Mono_Posix_MountFlags_ST_NOSUID)
+#ifdef ST_NOSUID
+               *r |= ST_NOSUID;
+#else /* def ST_NOSUID */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_NOSUID */
+       if ((x & Mono_Posix_MountFlags_ST_NODEV) == Mono_Posix_MountFlags_ST_NODEV)
+#ifdef ST_NODEV
+               *r |= ST_NODEV;
+#else /* def ST_NODEV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_NODEV */
+       if ((x & Mono_Posix_MountFlags_ST_SYNCHRONOUS) == Mono_Posix_MountFlags_ST_SYNCHRONOUS)
+#ifdef ST_SYNCHRONOUS
+               *r |= ST_SYNCHRONOUS;
+#else /* def ST_SYNCHRONOUS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_SYNCHRONOUS */
+       if ((x & Mono_Posix_MountFlags_ST_MANDLOCK) == Mono_Posix_MountFlags_ST_MANDLOCK)
+#ifdef ST_MANDLOCK
+               *r |= ST_MANDLOCK;
+#else /* def ST_MANDLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_MANDLOCK */
+       if ((x & Mono_Posix_MountFlags_ST_WRITE) == Mono_Posix_MountFlags_ST_WRITE)
+#ifdef ST_WRITE
+               *r |= ST_WRITE;
+#else /* def ST_WRITE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_WRITE */
+       if ((x & Mono_Posix_MountFlags_ST_APPEND) == Mono_Posix_MountFlags_ST_APPEND)
+#ifdef ST_APPEND
+               *r |= ST_APPEND;
+#else /* def ST_APPEND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_APPEND */
+       if ((x & Mono_Posix_MountFlags_ST_IMMUTABLE) == Mono_Posix_MountFlags_ST_IMMUTABLE)
+#ifdef ST_IMMUTABLE
+               *r |= ST_IMMUTABLE;
+#else /* def ST_IMMUTABLE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_IMMUTABLE */
+       if ((x & Mono_Posix_MountFlags_ST_NOATIME) == Mono_Posix_MountFlags_ST_NOATIME)
+#ifdef ST_NOATIME
+               *r |= ST_NOATIME;
+#else /* def ST_NOATIME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_NOATIME */
+       if ((x & Mono_Posix_MountFlags_ST_NODIRATIME) == Mono_Posix_MountFlags_ST_NODIRATIME)
+#ifdef ST_NODIRATIME
+               *r |= ST_NODIRATIME;
+#else /* def ST_NODIRATIME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_NODIRATIME */
+       return 0;
+}
+
+int Mono_Posix_ToMountFlags (guint64 x, guint64 *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef ST_RDONLY
+       if ((x & ST_RDONLY) == ST_RDONLY)
+               *r |= Mono_Posix_MountFlags_ST_RDONLY;
+#endif /* ndef ST_RDONLY */
+#ifdef ST_NOSUID
+       if ((x & ST_NOSUID) == ST_NOSUID)
+               *r |= Mono_Posix_MountFlags_ST_NOSUID;
+#endif /* ndef ST_NOSUID */
+#ifdef ST_NODEV
+       if ((x & ST_NODEV) == ST_NODEV)
+               *r |= Mono_Posix_MountFlags_ST_NODEV;
+#endif /* ndef ST_NODEV */
+#ifdef ST_SYNCHRONOUS
+       if ((x & ST_SYNCHRONOUS) == ST_SYNCHRONOUS)
+               *r |= Mono_Posix_MountFlags_ST_SYNCHRONOUS;
+#endif /* ndef ST_SYNCHRONOUS */
+#ifdef ST_MANDLOCK
+       if ((x & ST_MANDLOCK) == ST_MANDLOCK)
+               *r |= Mono_Posix_MountFlags_ST_MANDLOCK;
+#endif /* ndef ST_MANDLOCK */
+#ifdef ST_WRITE
+       if ((x & ST_WRITE) == ST_WRITE)
+               *r |= Mono_Posix_MountFlags_ST_WRITE;
+#endif /* ndef ST_WRITE */
+#ifdef ST_APPEND
+       if ((x & ST_APPEND) == ST_APPEND)
+               *r |= Mono_Posix_MountFlags_ST_APPEND;
+#endif /* ndef ST_APPEND */
+#ifdef ST_IMMUTABLE
+       if ((x & ST_IMMUTABLE) == ST_IMMUTABLE)
+               *r |= Mono_Posix_MountFlags_ST_IMMUTABLE;
+#endif /* ndef ST_IMMUTABLE */
+#ifdef ST_NOATIME
+       if ((x & ST_NOATIME) == ST_NOATIME)
+               *r |= Mono_Posix_MountFlags_ST_NOATIME;
+#endif /* ndef ST_NOATIME */
+#ifdef ST_NODIRATIME
+       if ((x & ST_NODIRATIME) == ST_NODIRATIME)
+               *r |= Mono_Posix_MountFlags_ST_NODIRATIME;
+#endif /* ndef ST_NODIRATIME */
+       return 0;
+}
+
index 48da17137c42ebc0c647e53a92d3690d87c552ca..aad68be6016e52aabd86712ee6610d6dbd6ff0a3 100644 (file)
@@ -640,6 +640,19 @@ int Mono_Posix_ToPollEvents (short x, short *r);
 int Mono_Posix_FromXattrFlags (int x, int *r);
 int Mono_Posix_ToXattrFlags (int x, int *r);
 
+#define Mono_Posix_MountFlags_ST_RDONLY 0x00000001
+#define Mono_Posix_MountFlags_ST_NOSUID 0x00000002
+#define Mono_Posix_MountFlags_ST_NODEV 0x00000004
+#define Mono_Posix_MountFlags_ST_SYNCHRONOUS 0x00000010
+#define Mono_Posix_MountFlags_ST_MANDLOCK 0x00000040
+#define Mono_Posix_MountFlags_ST_WRITE 0x00000080
+#define Mono_Posix_MountFlags_ST_APPEND 0x00000100
+#define Mono_Posix_MountFlags_ST_IMMUTABLE 0x00000200
+#define Mono_Posix_MountFlags_ST_NOATIME 0x00000400
+#define Mono_Posix_MountFlags_ST_NODIRATIME 0x00000800
+int Mono_Posix_FromMountFlags (guint64 x, guint64 *r);
+int Mono_Posix_ToMountFlags (guint64 x, guint64 *r);
+
 G_END_DECLS
 
 #endif /* ndef INC_Mono_Posix_map_H */
index d2f8486017235b4031129b39cadc68237cd2300b..d3f571ef5421516224a5b49427fc860f7a993f7d 100644 (file)
@@ -53,7 +53,7 @@ copy_statvfs (struct Mono_Posix_Statvfs *to, struct statvfs *from)
   to->f_ffree   = from->f_ffree;
   to->f_favail  = from->f_favail;
   to->f_fsid    = from->f_fsid;
-  to->f_flag    = from->f_flag;
+  Mono_Posix_ToMountFlags (from->f_flag, &to->f_flag);
   to->f_namemax =      from->f_namemax;
 }
 #endif /* ndef HAVE_SYS_STATVFS_H */
@@ -118,7 +118,7 @@ copy_statfs (struct Mono_Posix_Statvfs *to, struct statfs *from)
   to->f_files   = from->f_files;
   to->f_ffree   = from->f_ffree;
   to->f_favail  = from->f_ffree; /* OSX doesn't have f_avail */
-  to->f_flag    = from->f_flags;
+  Mono_Posix_ToMountFlags (from->f_flag, &to->f_flag);
        // from->f_fsid is an int32[2], to->f_fsid is a uint64, 
        // so this shouldn't lose anything.
        memcpy (&to->f_fsid, &from->f_fsid, sizeof(to->f_fsid));