summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2012-02-25 09:28:43 +0100
committerVolker Lendecke <vl@samba.org>2012-02-25 09:42:24 +0100
commit71a6d334321d42fd0f02646d1649405ccf197c00 (patch)
treef05a45ad836c4f045e89fcb2ad457d21c392562d /source3/smbd
parent0fbefbcb54eb0610d4cbd3579914f884d0ae6fa5 (diff)
downloadsamba-71a6d334321d42fd0f02646d1649405ccf197c00.tar.gz
samba-71a6d334321d42fd0f02646d1649405ccf197c00.tar.bz2
samba-71a6d334321d42fd0f02646d1649405ccf197c00.zip
s3: Fix bug 8777, sys_statvfs() wrapper support for OpenBSD/FreeBSD/DragonFly
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/statvfs.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c
index 2de015a2df..bcdcd91c87 100644
--- a/source3/smbd/statvfs.c
+++ b/source3/smbd/statvfs.c
@@ -49,9 +49,7 @@ static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf)
}
return result;
}
-#endif
-
-#if defined(DARWINOS)
+#elif defined(DARWINOS)
#include <sys/attr.h>
@@ -125,6 +123,43 @@ static int darwin_statvfs(const char *path, vfs_statvfs_struct *statbuf)
return 0;
}
+#elif defined(BSD) && defined(MNT_RDONLY)
+static int bsd_statvfs(const char *path, vfs_statvfs_struct *statbuf)
+{
+ struct statfs statfs_buf;
+ int result;
+
+ result = statfs(path, &statfs_buf);
+ if (result != 0) {
+ return result;
+ }
+
+ statbuf->OptimalTransferSize = statfs_buf.f_iosize;
+ statbuf->BlockSize = statfs_buf.f_bsize;
+ statbuf->TotalBlocks = statfs_buf.f_blocks;
+ statbuf->BlocksAvail = statfs_buf.f_bfree;
+ statbuf->UserBlocksAvail = statfs_buf.f_bavail;
+ statbuf->TotalFileNodes = statfs_buf.f_files;
+ statbuf->FreeFileNodes = statfs_buf.f_ffree;
+ statbuf->FsIdentifier =
+ (((uint64_t) statfs_buf.f_fsid.val[0] << 32) & 0xffffffff00000000LL) |
+ (uint64_t) statfs_buf.f_fsid.val[1];
+ /* Try to extrapolate some of the fs flags into the
+ * capabilities
+ */
+ statbuf->FsCapabilities =
+ FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
+#ifdef MNT_ACLS
+ if (statfs_buf.f_flags & MNT_ACLS)
+ statbuf->FsCapabilities |= FILE_PERSISTENT_ACLS;
+#endif
+ if (statfs_buf.f_flags & MNT_QUOTA)
+ statbuf->FsCapabilities |= FILE_VOLUME_QUOTAS;
+ if (statfs_buf.f_flags & MNT_RDONLY)
+ statbuf->FsCapabilities |= FILE_READ_ONLY_VOLUME;
+
+ return 0;
+}
#endif
/*
@@ -139,6 +174,8 @@ int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf)
return linux_statvfs(path, statbuf);
#elif defined(DARWINOS)
return darwin_statvfs(path, statbuf);
+#elif defined(BSD) && defined(MNT_RDONLY)
+ return bsd_statvfs(path, statbuf);
#else
/* BB change this to return invalid level */
#ifdef EOPNOTSUPP