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

Derrell Lipman derrell at samba.org
Tue Feb 10 03:47:55 GMT 2009


The branch, v3-3-test has been updated
       via  df15e8f84d108f8e9df1408155b0f9ccc44da3fe (commit)
      from  c8e295a1b5216c1190ec5d555606b3eadabab82a (commit)

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


- Log -----------------------------------------------------------------
commit df15e8f84d108f8e9df1408155b0f9ccc44da3fe
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date:   Mon Feb 9 22:46:29 2009 -0500

    [Bug 6069] Add a fstatvfs function for libsmbclient
    
    - Complete the implementation of the f_flag field. We now return a flag
      indicatin UNIX CIFS, CASE SENSITIVE, and/or DFS support.
    
    Derrell

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

Summary of changes:
 examples/libsmbclient/testfstatvfs.c |  101 ++++++++++++++++++++++++++++++++++
 source/libsmb/libsmb_stat.c          |   27 ++++++++-
 2 files changed, 126 insertions(+), 2 deletions(-)
 create mode 100644 examples/libsmbclient/testfstatvfs.c


Changeset truncated at 500 lines:

diff --git a/examples/libsmbclient/testfstatvfs.c b/examples/libsmbclient/testfstatvfs.c
new file mode 100644
index 0000000..9db70cf
--- /dev/null
+++ b/examples/libsmbclient/testfstatvfs.c
@@ -0,0 +1,101 @@
+#include <sys/types.h>
+#include <sys/statvfs.h>
+#include <stdio.h> 
+#include <unistd.h>
+#include <string.h> 
+#include <time.h> 
+#include <errno.h>
+#include <libsmbclient.h> 
+#include "get_auth_data_fn.h"
+
+
+int main(int argc, char * argv[]) 
+{ 
+    int             i;
+    int             fd;
+    int             ret;
+    int             debug = 0;
+    char *          p;
+    char            path[2048];
+    struct stat     statbuf;
+    struct statvfs  statvfsbuf;
+    
+    smbc_init(get_auth_data_fn, debug); 
+    
+    for (;;)
+    {
+        fprintf(stdout, "Path: ");
+        *path = '\0';
+        fgets(path, sizeof(path) - 1, stdin);
+        if (strlen(path) == 0)
+        {
+            return 0;
+        }
+
+        p = path + strlen(path) - 1;
+        if (*p == '\n')
+        {
+            *p = '\0';
+        }
+    
+        /* Determine if it's a file or a folder */
+        if (smbc_stat(path, &statbuf) < 0)
+        {
+            perror("smbc_stat");
+            continue;
+        }
+
+        if (S_ISREG(statbuf.st_mode))
+        {
+            if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
+            {
+                perror("smbc_open");
+                continue;
+            }
+        }
+        else
+        {
+            if ((fd = smbc_opendir(path)) < 0)
+            {
+                perror("smbc_opendir");
+                continue;
+            }
+        }
+
+        ret = smbc_fstatvfs(fd, &statvfsbuf);
+
+        smbc_close(fd);
+
+        if (ret < 0)
+        {
+            perror("fstatvfs");
+        }
+        else if (statvfsbuf.f_flag == 0)
+        {
+            printf("No capabilities found\n");
+        }
+        else
+        {
+            printf("Capabilities: ");
+
+            if (statvfsbuf.f_flag & SMBC_VFS_CAP_UNIXCIFS)
+            {
+                printf("UNIXCIFS ");
+            }
+
+            if (statvfsbuf.f_flag & SMBC_VFS_CAP_CASE_SENSITIVE)
+            {
+                printf("CASE_SENSITIVE ");
+            }
+
+            if (statvfsbuf.f_flag & SMBC_VFS_CAP_DFS)
+            {
+                printf("DFS ");
+            }
+
+            printf("\n");
+        }
+    }
+
+    return 0; 
+}
diff --git a/source/libsmb/libsmb_stat.c b/source/libsmb/libsmb_stat.c
index a9c3647..71dc1d1 100644
--- a/source/libsmb/libsmb_stat.c
+++ b/source/libsmb/libsmb_stat.c
@@ -310,14 +310,37 @@ SMBC_fstatvfs_ctx(SMBCCTX *context,
                   SMBCFILE *file,
                   struct statvfs *st)
 {
+	uint32 fs_attrs = 0;
+	struct cli_state *cli = file->srv->cli;
+
         /* Initialize all fields (at least until we actually use them) */
         memset(st, 0, sizeof(*st));
 
         /* See if the server has UNIX CIFS support */
-        if (SERVER_HAS_UNIX_CIFS(file->srv->cli))
-        {
+        if (SERVER_HAS_UNIX_CIFS(cli)) {
                 st->f_flag |= SMBC_VFS_CAP_UNIXCIFS;
         }
 
+        /* See if the share is case sensitive */
+        if (!cli_get_fs_attr_info(cli, &fs_attrs)) {
+                /*
+                 * We can't determine the case sensitivity of
+                 * 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;
+                }
+        } else {
+                if (fs_attrs & FILE_CASE_SENSITIVE_SEARCH) {
+                        st->f_flag |= SMBC_VFS_CAP_CASE_SENSITIVE;
+                }
+        }
+
+        /* See if DFS is supported */
+	if ((cli->capabilities & CAP_DFS) && cli->dfsroot) {
+                st->f_flag |= SMBC_VFS_CAP_DFS;
+        }
+
         return 0;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list