s3: Improve statvfs support
authorBrad Smith <brad@comstyle.com>
Sat, 10 Mar 2012 18:16:06 +0000 (19:16 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 11 Mar 2012 13:18:04 +0000 (14:18 +0100)
Autobuild-User: Volker Lendecke <vl@samba.org>
Autobuild-Date: Sun Mar 11 14:18:04 CET 2012 on sn-devel-104

source3/modules/vfs_default.c
source3/smbd/statvfs.c

index fd0ff0aa71e5de4c5d52bba993434965e87cb1b6..1dbd308368d463fac66a52a314ec5b4b32dddb2c 100644 (file)
@@ -108,15 +108,15 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle,
        connection_struct *conn = handle->conn;
        uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
        struct smb_filename *smb_fname_cpath = NULL;
+       struct vfs_statvfs_struct statbuf;
        NTSTATUS status;
-       int ret = -1;
+       int ret;
 
-#if defined(DARWINOS) || (defined(BSD) && defined(BSD_STATVFS_BSIZE))
-       struct vfs_statvfs_struct statbuf;
        ZERO_STRUCT(statbuf);
-       sys_statvfs(conn->connectpath, &statbuf);
-       caps = statbuf.FsCapabilities;
-#endif
+       ret = sys_statvfs(conn->connectpath, &statbuf);
+       if (ret == 0) {
+               caps = statbuf.FsCapabilities;
+       }
 
        *p_ts_res = TIMESTAMP_SET_SECONDS;
 
index 1e72a8e48b73675acbd123244382ec49a9aaf803..5cefe2d4c23031bca62d0a3b2753eec479a7d1ab 100644 (file)
@@ -151,12 +151,17 @@ static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf)
                statbuf->TotalFileNodes = statvfs_buf.f_files;
                statbuf->FreeFileNodes = statvfs_buf.f_ffree;
                statbuf->FsIdentifier = statvfs_buf.f_fsid;
-
-               /* Good defaults for Linux filesystems are case sensitive
-                * and case preserving.
+               /* Try to extrapolate some of the fs flags into the
+                * capabilities
                 */
                statbuf->FsCapabilities =
                    FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
+#ifdef ST_QUOTA
+               if (statvfs_buf.f_flag & ST_QUOTA)
+                       statbuf->FsCapabilities |= FILE_VOLUME_QUOTAS;
+#endif
+               if (statvfs_buf.f_flag & ST_RDONLY)
+                       statbuf->FsCapabilities |= FILE_READ_ONLY_VOLUME;
        }
        return result;
 }