* sys-statvfs.c: Fix Mac OS X build (statfs.f_frsize doesn't exist on OSX;
authorJonathan Pryor <jpryor@novell.com>
Thu, 30 Dec 2004 11:47:49 +0000 (11:47 -0000)
committerJonathan Pryor <jpryor@novell.com>
Thu, 30 Dec 2004 11:47:49 +0000 (11:47 -0000)
  f_fsid isn't an integral type; fstatfs needs to use fpathconf).

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

support/ChangeLog
support/sys-statvfs.c

index 037308c799056930bca97db013c55ae83d7287d8..45db24d1ef6d9ec8f12b166fb3bf51ba305f7372 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-30  Jonathan Pryor  <jonpryor@vt.edu>
+
+       * sys-statvfs.c: Fix Mac OS X build (statfs.f_frsize doesn't exist on OSX;
+         f_fsid isn't an integral type; fstatfs needs to use fpathconf).
+
 2004-12-29  Jonathan Pryor  <jonpryor@vt.edu>
 
        * unistd.c: Null-terminate the string returned by readlink(2).  This works
index ce18cc9a33cbc8f160dc22e9119f4e45242d52dd..95acf08ec3384990c80a2595dcb8683518df7796 100644 (file)
@@ -9,6 +9,8 @@
 
 #include <errno.h>
 
+#include <string.h>
+
 #include "mph.h"
 
 #ifdef HAVE_SYS_STATVFS_H
@@ -109,15 +111,17 @@ static void
 copy_statfs (struct Mono_Posix_Statvfs *to, struct statfs *from)
 {
   to->f_bsize   = from->f_bsize;
-  to->f_frsize  = from->f_frsize;
+  to->f_frsize  = from->f_bsize;
   to->f_blocks  = from->f_blocks;
   to->f_bfree   = from->f_bfree;
   to->f_bavail  = from->f_bavail;
   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_fsid    = from->f_fsid;
   to->f_flag    = from->f_flags;
+       // 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));
 }
 
 static void
@@ -125,6 +129,12 @@ set_namemax (const char *path, struct Mono_Posix_Statvfs *buf)
 {
   buf->f_namemax = pathconf (path, _PC_NAME_MAX);
 }
+
+static void
+set_fnamemax (int fd, struct Mono_Posix_Statvfs *buf)
+{
+  buf->f_namemax = fpathconf (fd, _PC_NAME_MAX);
+}
 #endif /* (def HAVE_STATFS || def HAVE_FSTATFS) && !def HAVE_STATVFS */
 
 #if !defined (HAVE_STATVFS) && defined (HAVE_STATFS)
@@ -161,8 +171,8 @@ Mono_Posix_Syscall_fstatvfs (gint32 fd, struct Mono_Posix_Statvfs *buf)
        }
 
        if ((r = fstatfs (fd, &s)) == 0) {
-               copy_statvfs (buf, &s);
-               set_namemax (path, buf);
+               copy_statfs (buf, &s);
+               set_fnamemax (fd, buf);
        }
 
        return r;