s3 libsmbclient: Fix fstatvfs to be more portable
[samba.git] / source3 / include / libsmbclient.h
index b2d9483a0b9ad9098a7ed143dae521ec0012aaf4..3bea0897d1f877d751ed70fd7960c23a6425a9bd 100644 (file)
@@ -173,6 +173,38 @@ 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
+ * smbc_statvfs(). These may be OR-ed together to reflect a full set of
+ * available capabilities.
+ */
+typedef enum smbc_vfs_feature
+{
+    /* Defined by POSIX or in Linux include files (low-order bits) */
+    SMBC_VFS_FEATURE_RDONLY         = (1 << 0),
+
+    /* Specific to libsmbclient (high-order bits) */
+    SMBC_VFS_FEATURE_DFS              = (1 << 29),
+    SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 30),
+    SMBC_VFS_FEATURE_NO_UNIXCIFS      = (1 << 31)
+} smbc_vfs_feature;
 
 typedef int smbc_bool;
 
@@ -853,6 +885,18 @@ typedef int (*smbc_fstat_fn)(SMBCCTX *c,
 smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
 void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
 
+typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
+                               char *path,
+                               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 smbc_statvfs *st);
+smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
+void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
+
 typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
                                  SMBCFILE *f,
                                  off_t size);
@@ -1591,6 +1635,52 @@ int smbc_stat(const char *url, struct stat *st);
 int smbc_fstat(int fd, struct stat *st);
 
 
+/**@ingroup attribute
+ * Get file system information for a specified path.
+ * 
+ * @param url       The smb url to get information for
+ *
+ * @param st        pointer to a buffer that will be filled with 
+ *                  standard Unix struct statvfs information.
+ * 
+ * @return          EBADF  filedes is bad.
+ *                  - EACCES Permission denied.
+ *                  - EBADF fd is not a valid file descriptor
+ *                  - EINVAL Problems occurred in the underlying routines
+ *                   or smbc_init not called.
+ *                  - ENOMEM Out of memory
+ *
+ * @see             Unix fstatvfs()
+ *
+ */
+int
+smbc_statvfs(char *url,
+             struct smbc_statvfs *st);
+
+/**@ingroup attribute
+ * Get file system information via an file descriptor.
+ * 
+ * @param fd        Open file handle from smbc_open(), smbc_creat(),
+ *                  or smbc_opendir()
+ *
+ * @param st        pointer to a buffer that will be filled with 
+ *                  standard Unix struct statvfs information.
+ * 
+ * @return          EBADF  filedes is bad.
+ *                  - EACCES Permission denied.
+ *                  - EBADF fd is not a valid file descriptor
+ *                  - EINVAL Problems occurred in the underlying routines
+ *                   or smbc_init not called.
+ *                  - ENOMEM Out of memory
+ *
+ * @see             Unix fstatvfs()
+ *
+ */
+int
+smbc_fstatvfs(int fd,
+              struct smbc_statvfs *st);
+
+
 /**@ingroup attribute
  * Truncate a file given a file descriptor
  *