[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-4928-g0acc962

Derrell Lipman derrell at samba.org
Tue Feb 10 15:29:04 GMT 2009


The branch, v3-3-test has been updated
       via  0acc962e3968253a3f64b5a92def177ced44994d (commit)
      from  97f1514ce95800f1296b1979f1b34dcc5d56a376 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit 0acc962e3968253a3f64b5a92def177ced44994d
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date:   Tue Feb 10 10:28:32 2009 -0500

    [Bug 6069] Add a fstatvfs function for libsmbclient
    
    - Reverse the sense of the flags. Since the fstatvfs() function on POSIX-like
      systems would almost certainly indicate case sensitivity (for example),
      leave the bit turned off if the result is the POSIX-like result just as if
      issued on a typical local file system on a POSIX system.
    
    Derrell

-----------------------------------------------------------------------

Summary of changes:
 examples/libsmbclient/testfstatvfs.c |   30 +++++++++++++++++++-----------
 source/include/libsmbclient.h        |   12 ++++++------
 source/libsmb/libsmb_stat.c          |   25 +++++++++++++++++--------
 3 files changed, 42 insertions(+), 25 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/libsmbclient/testfstatvfs.c b/examples/libsmbclient/testfstatvfs.c
index 9db70cf..fbb51f1 100644
--- a/examples/libsmbclient/testfstatvfs.c
+++ b/examples/libsmbclient/testfstatvfs.c
@@ -70,27 +70,35 @@ int main(int argc, char * argv[])
         {
             perror("fstatvfs");
         }
-        else if (statvfsbuf.f_flag == 0)
-        {
-            printf("No capabilities found\n");
-        }
         else
         {
-            printf("Capabilities: ");
+            printf("Features: ");
 
-            if (statvfsbuf.f_flag & SMBC_VFS_CAP_UNIXCIFS)
+            if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
+            {
+                printf("NO_UNIXCIFS ");
+            }
+            else
             {
-                printf("UNIXCIFS ");
+                printf("unixcifs ");
             }
 
-            if (statvfsbuf.f_flag & SMBC_VFS_CAP_CASE_SENSITIVE)
+            if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
             {
-                printf("CASE_SENSITIVE ");
+                printf("CASE_INSENSITIVE ");
+            }
+            else
+            {
+                printf("case_sensitive ");
             }
 
-            if (statvfsbuf.f_flag & SMBC_VFS_CAP_DFS)
+            if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_DFS)
+            {
+                printf("NO_DFS ");
+            }
+            else
             {
-                printf("DFS ");
+                printf("dfs ");
             }
 
             printf("\n");
diff --git a/source/include/libsmbclient.h b/source/include/libsmbclient.h
index 575bef6..ec7e742 100644
--- a/source/include/libsmbclient.h
+++ b/source/include/libsmbclient.h
@@ -179,16 +179,16 @@ typedef enum smbc_smb_encrypt_level
  * smbc_statvfs(). These may be OR-ed together to reflect a full set of
  * available capabilities.
  */
-typedef enum smbc_vfs_capability
+typedef enum smbc_vfs_feature
 {
     /* Defined by POSIX or in Linux include files (low-order bits) */
-    SMBC_VFS_CAP_RDONLY         = (1 << 0),
+    SMBC_VFS_FEATURE_RDONLY         = (1 << 0),
 
     /* Specific to libsmbclient (high-order bits) */
-    SMBC_VFS_CAP_DFS            = (1 << 29),
-    SMBC_VFS_CAP_CASE_SENSITIVE = (1 << 30),
-    SMBC_VFS_CAP_UNIXCIFS       = (1 << 31)
-} smbc_vfs_capability;
+    SMBC_VFS_FEATURE_NO_DFS           = (1 << 29),
+    SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 30),
+    SMBC_VFS_FEATURE_NO_UNIXCIFS      = (1 << 31)
+} smbc_vfs_feature;
 
 typedef int smbc_bool;
 
diff --git a/source/libsmb/libsmb_stat.c b/source/libsmb/libsmb_stat.c
index 71dc1d1..e5eac59 100644
--- a/source/libsmb/libsmb_stat.c
+++ b/source/libsmb/libsmb_stat.c
@@ -316,9 +316,18 @@ SMBC_fstatvfs_ctx(SMBCCTX *context,
         /* Initialize all fields (at least until we actually use them) */
         memset(st, 0, sizeof(*st));
 
+        /*
+         * The state of each flag is such that the same bits are unset as
+         * would typically be unset on a local file system on a POSIX OS. Thus
+         * the bit is on, for example, only for case-insensitive file systems
+         * since most POSIX file systems are case sensitive and fstatvfs()
+         * would typically return zero in these bits on such a local file
+         * system.
+         */
+
         /* See if the server has UNIX CIFS support */
-        if (SERVER_HAS_UNIX_CIFS(cli)) {
-                st->f_flag |= SMBC_VFS_CAP_UNIXCIFS;
+        if (! SERVER_HAS_UNIX_CIFS(cli)) {
+                st->f_flag |= SMBC_VFS_FEATURE_NO_UNIXCIFS;
         }
 
         /* See if the share is case sensitive */
@@ -328,18 +337,18 @@ SMBC_fstatvfs_ctx(SMBCCTX *context,
                  * the share. We have no choice but to use the
                  * user-specified case sensitivity setting.
                  */
-                if (smbc_getOptionCaseSensitive(context)) {
-                        st->f_flag |= SMBC_VFS_CAP_CASE_SENSITIVE;
+                if (! smbc_getOptionCaseSensitive(context)) {
+                        st->f_flag |= SMBC_VFS_FEATURE_CASE_INSENSITIVE;
                 }
         } else {
-                if (fs_attrs & FILE_CASE_SENSITIVE_SEARCH) {
-                        st->f_flag |= SMBC_VFS_CAP_CASE_SENSITIVE;
+                if (! (fs_attrs & FILE_CASE_SENSITIVE_SEARCH)) {
+                        st->f_flag |= SMBC_VFS_FEATURE_CASE_INSENSITIVE;
                 }
         }
 
         /* See if DFS is supported */
-	if ((cli->capabilities & CAP_DFS) && cli->dfsroot) {
-                st->f_flag |= SMBC_VFS_CAP_DFS;
+	if (! (cli->capabilities & CAP_DFS) ||  ! cli->dfsroot) {
+                st->f_flag |= SMBC_VFS_FEATURE_NO_DFS;
         }
 
         return 0;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list