s3 libsmbclient: Fix fstatvfs to be more portable
authorTim Prouty <tprouty@samba.org>
Fri, 13 Feb 2009 18:58:54 +0000 (10:58 -0800)
committerTim Prouty <tprouty@samba.org>
Fri, 13 Feb 2009 20:59:30 +0000 (12:59 -0800)
The statvfs struct isn't guaranteed to be portable across operating
systems.  Since libsmbclient isn't actually calling statvfs and just
using the statvfs struct to store similar information, this patch adds
a new portable smbc_statvfs struct.  This fixes a few of the failures
in the build farm introduced by:
ae259575c447e61665c8e7070c476914161b953f

Derrell, please check.

examples/libsmbclient/testfstatvfs.c
examples/libsmbclient/teststatvfs.c
source3/include/libsmb_internal.h
source3/include/libsmbclient.h
source3/libsmb/libsmb_compat.c
source3/libsmb/libsmb_stat.c

index b4dafefff60a4dc2991c9cf9b2659004b832a08e..815afac8665fc54b272bdb603c8a0c8e58c69419 100644 (file)
@@ -1,5 +1,4 @@
 #include <sys/types.h>
-#include <sys/statvfs.h>
 #include <stdio.h> 
 #include <unistd.h>
 #include <string.h> 
@@ -18,7 +17,7 @@ int main(int argc, char * argv[])
     char *          p;
     char            path[2048];
     struct stat     statbuf;
-    struct statvfs  statvfsbuf;
+    struct smbc_statvfs  statvfsbuf;
     
     smbc_init(get_auth_data_fn, debug); 
     
index 8812002d5ce25742cf0066d871a3678f5f50ec18..b9509d2e07a4a6a638ef79d35c8d93ca4c5f8090 100644 (file)
@@ -1,5 +1,4 @@
 #include <sys/types.h>
-#include <sys/statvfs.h>
 #include <stdio.h> 
 #include <unistd.h>
 #include <string.h> 
@@ -18,7 +17,7 @@ int main(int argc, char * argv[])
     char *          p;
     char            path[2048];
     struct stat     statbuf;
-    struct statvfs  statvfsbuf;
+    struct smbc_statvfs  statvfsbuf;
     
     smbc_init(get_auth_data_fn, debug); 
     
index 166685c38015646509f8dde8c2906c7dc78cbbb2..d3683eb3dc83d19e3683a56046c79a25c5dd0cb1 100644 (file)
@@ -506,13 +506,13 @@ SMBC_fstat_ctx(SMBCCTX *context,
 int
 SMBC_statvfs_ctx(SMBCCTX *context,
                  char *path,
-                 struct statvfs *st);
+                 struct smbc_statvfs *st);
 
 
 int
 SMBC_fstatvfs_ctx(SMBCCTX *context,
                   SMBCFILE *file,
-                  struct statvfs *st);
+                  struct smbc_statvfs *st);
 
 
 /* Functions in libsmb_xattr.c */
index d35d9de6eaffecdd473bbe0827e1697a124f885d..3bea0897d1f877d751ed70fd7960c23a6425a9bd 100644 (file)
@@ -75,7 +75,6 @@ extern "C" {
 /* Make sure we have the following includes for now ... */
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/statvfs.h>
 #include <fcntl.h>
 #include <utime.h>
 
@@ -174,6 +173,22 @@ typedef enum smbc_smb_encrypt_level
     SMBC_ENCRYPTLEVEL_REQUIRE   = 2
 } smbc_smb_encrypt_level;
 
+/**
+ * Use a system independent statvfs struct for smbclient.
+ */
+struct smbc_statvfs {
+       fsblkcnt_t      f_bavail;
+       fsblkcnt_t      f_bfree;
+       fsblkcnt_t      f_blocks;
+       fsfilcnt_t      f_favail;
+       fsfilcnt_t      f_ffree;
+       fsfilcnt_t      f_files;
+       unsigned long   f_bsize;
+       unsigned long   f_flag;
+       unsigned long   f_frsize;
+       unsigned long   f_fsid;
+       unsigned long   f_namemax;
+};
 
 /**
  * Capabilities set in the f_flag field of struct statvfs, from
@@ -872,13 +887,13 @@ void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
 
 typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
                                char *path,
-                               struct statvfs *st);
+                               struct smbc_statvfs *st);
 smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
 void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
 
 typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
                                 SMBCFILE *file,
-                                struct statvfs *st);
+                                struct smbc_statvfs *st);
 smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
 void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
 
@@ -1640,7 +1655,7 @@ int smbc_fstat(int fd, struct stat *st);
  */
 int
 smbc_statvfs(char *url,
-             struct statvfs *st);
+             struct smbc_statvfs *st);
 
 /**@ingroup attribute
  * Get file system information via an file descriptor.
@@ -1663,7 +1678,7 @@ smbc_statvfs(char *url,
  */
 int
 smbc_fstatvfs(int fd,
-              struct statvfs *st);
+              struct smbc_statvfs *st);
 
 
 /**@ingroup attribute
index 56d113f31a221736c07454f2e7154b8711185def..95485dc102161bd5725337a04801edb5e11cbdd1 100644 (file)
@@ -331,14 +331,14 @@ smbc_fstat(int fd,
 
 int
 smbc_statvfs(char *path,
-             struct statvfs *st)
+             struct smbc_statvfs *st)
 {
         return smbc_getFunctionStatVFS(statcont)(statcont, path, st);
 }
 
 int
 smbc_fstatvfs(int fd,
-              struct statvfs *st)
+              struct smbc_statvfs *st)
 {
        SMBCFILE * file = find_fd(fd);
         return smbc_getFunctionFstatVFS(statcont)(statcont, file, st);
index d589f7ef712b61b32a9b157f0eacdbd3de1e5fed..0ad40e878a96087453c482bec26c0675e9bea9a9 100644 (file)
@@ -308,7 +308,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
 int
 SMBC_statvfs_ctx(SMBCCTX *context,
                  char *path,
-                 struct statvfs *st)
+                 struct smbc_statvfs *st)
 {
         int             ret;
         bool            bIsDir;
@@ -360,7 +360,7 @@ SMBC_statvfs_ctx(SMBCCTX *context,
 int
 SMBC_fstatvfs_ctx(SMBCCTX *context,
                   SMBCFILE *file,
-                  struct statvfs *st)
+                  struct smbc_statvfs *st)
 {
        uint32 fs_attrs = 0;
        struct cli_state *cli = file->srv->cli;