[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / support / sys-statvfs.c
index 51416e57cbe7341a0ada9dd9209ea7841b35bea6..e03152a773d95d4f12fe1fc7ad78b240b1cb8f60 100644 (file)
 #include "mph.h"
 #include "map.h"
 
+#ifdef HAVE_PATHCONF_H
+#include <pathconf.h>
+#endif
+
 #ifdef HAVE_SYS_STATVFS_H
 #include <sys/statvfs.h>
+#elif defined (HAVE_STATFS) || defined (HAVE_FSTATFS)
+#include <sys/vfs.h>
 #endif /* def HAVE_SYS_STATVFS_H */
 
 #ifdef HAVE_GETFSSTAT
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 #include <sys/ucred.h>
 #include <sys/mount.h>
 #include <unistd.h>     /* for pathconf */
@@ -142,32 +150,36 @@ Mono_Posix_ToStatvfs (void *_from, struct Mono_Posix_Statvfs *to)
        // so this shouldn't lose anything.
        memcpy (&to->f_fsid, &from->f_fsid, sizeof(to->f_fsid));
 
+#if HAVE_STRUCT_STATFS_F_FLAGS
        if (Mono_Posix_ToMountFlags (from->f_flags, &to->f_flag) != 0)
                return -1;
+#endif  /* def HAVE_STRUCT_STATFS_F_FLAGS */
 
        return 0;
 }
 
 int
-Mono_Posix_FromStatvfs (struct Mono_Posix_Statvfs *from, void *to)
+Mono_Posix_FromStatvfs (struct Mono_Posix_Statvfs *from, void *_to)
 {
        struct statfs *to = _to;
+       guint64 flag;
 
        to->f_bsize   = from->f_bsize;
-       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 */
 
        // 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));
 
-       if (Mono_Posix_FromMountFlags (from->f_flags, &to->f_flag) != 0)
+#if HAVE_STRUCT_STATFS_F_FLAGS
+       if (Mono_Posix_FromMountFlags (from->f_flag, &flag) != 0)
                return -1;
+       to->f_flags = flag;
+#endif  /* def HAVE_STRUCT_STATFS_F_FLAGS */
 
        return 0;
 }
@@ -218,7 +230,7 @@ Mono_Posix_Syscall_fstatvfs (gint32 fd, struct Mono_Posix_Statvfs *buf)
                return -1;
        }
 
-       if ((r = statfs (path, &s)) == 0 &&
+       if ((r = fstatfs (fd, &s)) == 0 &&
                        (r = Mono_Posix_ToStatvfs (&s, buf)) == 0) {
                set_fnamemax (fd, buf);
        }