r11232: Added ab's POSIX statvfs vfs call. Sorry for the delay ab.
authorJeremy Allison <jra@samba.org>
Thu, 20 Oct 2005 17:33:17 +0000 (17:33 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:05:08 +0000 (11:05 -0500)
Jeremy.

examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source/Makefile.in
source/include/vfs.h
source/include/vfs_macros.h
source/modules/vfs_full_audit.c
source/smbd/trans2.c
source/smbd/vfs-wrap.c
source/smbd/vfs.c
source/utils/net_lookup.c
source/utils/ntlm_auth.c

index 065c9ecbc1a8f1f833ce6653069a61c7502b8bc0..e6b7d032fcfcb26642dfd3dd5211e5e9a704cfcb 100644 (file)
@@ -71,6 +71,11 @@ static int skel_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fs
        return vfswrap_get_shadow_copy_data(NULL, fsp, shadow_copy_data, labels);
 }
 
+static int skel_statvfs(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, struct vfs_statvfs_struct *statbuf)
+{
+       return vfswrap_statvfs(NULL, conn, path, statbuf);
+}
+
 static SMB_STRUCT_DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
        return vfswrap_opendir(NULL, conn, fname, mask, attr);
@@ -534,6 +539,7 @@ static vfs_op_tuple skel_op_tuples[] = {
        {SMB_VFS_OP(skel_get_quota),                    SMB_VFS_OP_GET_QUOTA,           SMB_VFS_LAYER_OPAQUE},
        {SMB_VFS_OP(skel_set_quota),                    SMB_VFS_OP_SET_QUOTA,           SMB_VFS_LAYER_OPAQUE},
        {SMB_VFS_OP(skel_get_shadow_copy_data),         SMB_VFS_OP_GET_SHADOW_COPY_DATA,SMB_VFS_LAYER_OPAQUE},
+       {SMB_VFS_OP(skel_statvfs),                      SMB_VFS_OP_STATVFS,             SMB_VFS_LAYER_OPAQUE},
 
        /* Directory operations */
 
index 0879683fdcd294655d548c420ed428c694642242..14fa2276e1fa7c050450b5ba721e94f65f8b83c6 100644 (file)
@@ -70,6 +70,11 @@ static int skel_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fs
        return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
 }
 
+static int skel_statvfs(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, struct vfs_statvfs_struct *statbuf)
+{
+       return SMB_VFS_NEXT_STATVFS(handle, conn, path, statbuf);
+}
+
 static SMB_STRUCT_DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
        return SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr);
@@ -503,6 +508,7 @@ static vfs_op_tuple skel_op_tuples[] = {
        {SMB_VFS_OP(skel_get_quota),                    SMB_VFS_OP_GET_QUOTA,           SMB_VFS_LAYER_TRANSPARENT},
        {SMB_VFS_OP(skel_set_quota),                    SMB_VFS_OP_SET_QUOTA,           SMB_VFS_LAYER_TRANSPARENT},
        {SMB_VFS_OP(skel_get_shadow_copy_data),         SMB_VFS_OP_GET_SHADOW_COPY_DATA,SMB_VFS_LAYER_TRANSPARENT},
+       {SMB_VFS_OP(skel_statvfs),                      SMB_VFS_OP_STATVFS,             SMB_VFS_LAYER_TRANSPARENT},
 
        /* Directory operations */
 
index 77e79d5b17350f127829724313b02c66bfa8e91d..f6564d7d52888f908e6721a26878065d1b3b412c 100644 (file)
@@ -400,7 +400,7 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \
               lib/sysquotas_xfs.o lib/sysquotas_4A.o \
               smbd/change_trust_pw.o smbd/fake_file.o \
               smbd/quotas.o smbd/ntquotas.o $(AFS_OBJ) smbd/msdfs.o \
-              $(AFS_SETTOKEN_OBJ) smbd/aio.o \
+              $(AFS_SETTOKEN_OBJ) smbd/aio.o smbd/statvfs.o \
               $(MANGLE_OBJ) @VFS_STATIC@
 
 SMBD_OBJ_BASE = $(PARAM_OBJ) $(SMBD_OBJ_SRV) $(LIBSMB_OBJ) \
index 3bd0fda9a43beac79be705fdc0a24361b665422c..cde2039d1a1bdff893f9749b3782f099a3f5a0ed 100644 (file)
@@ -3,7 +3,7 @@
    VFS structures and parameters
    Copyright (C) Jeremy Allison                         1999-2005
    Copyright (C) Tim Potter                            1999
-   Copyright (C) Alexander Bokovoy                     2002
+   Copyright (C) Alexander Bokovoy                     2002-2005
    Copyright (C) Stefan (metze) Metzmacher             2003
    
    This program is free software; you can redistribute it and/or modify
@@ -60,7 +60,8 @@
    Also include aio calls. JRA. */
 /* Changed to version 13 as the internal structure of files_struct has changed. JRA */
 /* Changed to version 14 as the we had to change DIR to SMB_STRUCT_DIR. JRA */
-#define SMB_VFS_INTERFACE_VERSION 14
+/* Changed to version 15 as the we added the statvfs call. JRA */
+#define SMB_VFS_INTERFACE_VERSION 15
 
 
 /* to bug old modules which are trying to compile with the old functions */
@@ -82,6 +83,7 @@ struct vfs_handle_struct;
 struct connection_struct;
 struct files_struct;
 struct security_descriptor_info;
+struct vfs_statvfs_struct;
 
 /*
     Available VFS operations. These values must be in sync with vfs_ops struct
@@ -101,7 +103,7 @@ typedef enum _vfs_op_type {
        SMB_VFS_OP_GET_QUOTA,
        SMB_VFS_OP_SET_QUOTA,
        SMB_VFS_OP_GET_SHADOW_COPY_DATA,
-
+       SMB_VFS_OP_STATVFS,
 
        /* Directory operations */
 
@@ -222,6 +224,7 @@ struct vfs_ops {
                int (*get_quota)(struct vfs_handle_struct *handle, struct connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
                int (*set_quota)(struct vfs_handle_struct *handle, struct connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
                int (*get_shadow_copy_data)(struct vfs_handle_struct *handle, struct files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, BOOL labels);
+               int (*statvfs)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, struct vfs_statvfs_struct *statbuf);
                
                /* Directory operations */
                
@@ -334,6 +337,7 @@ struct vfs_ops {
                struct vfs_handle_struct *get_quota;
                struct vfs_handle_struct *set_quota;
                struct vfs_handle_struct *get_shadow_copy_data;
+               struct vfs_handle_struct *statvfs;
 
                /* Directory operations */
 
@@ -478,7 +482,7 @@ typedef enum _vfs_op_layer {
     using this information.
 */
 
-typedef struct _vfs_op_tuple {
+typedef struct vfs_op_tuple {
        void* op;
        vfs_op_type type;
        vfs_op_layer layer;
@@ -495,6 +499,34 @@ typedef struct vfs_handle_struct {
 } vfs_handle_struct;
 
 
+typedef struct vfs_statvfs_struct {
+       /* For undefined recommended transfer size return -1 in that field */
+       uint32 OptimalTransferSize;  /* bsize on some os, iosize on other os */
+       uint32 BlockSize; 
+
+       /*
+        The next three fields are in terms of the block size.
+        (above). If block size is unknown, 4096 would be a
+        reasonable block size for a server to report. 
+        Note that returning the blocks/blocksavail removes need
+        to make a second call (to QFSInfo level 0x103 to get this info.
+        UserBlockAvail is typically less than or equal to BlocksAvail,
+        if no distinction is made return the same value in each.
+       */
+
+       SMB_BIG_UINT TotalBlocks;
+       SMB_BIG_UINT BlocksAvail;       /* bfree */
+       SMB_BIG_UINT UserBlocksAvail;   /* bavail */
+
+       /* For undefined Node fields or FSID return -1 */
+       SMB_BIG_UINT TotalFileNodes;
+       SMB_BIG_UINT FreeFileNodes;
+       SMB_BIG_UINT FsIdentifier;   /* fsid */
+       /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
+       /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call   */
+} vfs_statvfs_struct;
+
+
 #define SMB_VFS_HANDLE_GET_DATA(handle, datap, type, ret) { \
        if (!(handle)||((datap=(type *)(handle)->data)==NULL)) { \
                DEBUG(0,("%s() failed to get vfs_handle->data!\n",FUNCTION_MACRO)); \
index e6bfb1f527c817f874d86e9742527730514e4930..33810c301f9494e206d98031bca5e8dd49e69b49 100644 (file)
@@ -34,6 +34,7 @@
 #define SMB_VFS_GET_QUOTA(conn, qtype, id, qt) ((conn)->vfs.ops.get_quota((conn)->vfs.handles.get_quota, (conn), (qtype), (id), (qt)))
 #define SMB_VFS_SET_QUOTA(conn, qtype, id, qt) ((conn)->vfs.ops.set_quota((conn)->vfs.handles.set_quota, (conn), (qtype), (id), (qt)))
 #define SMB_VFS_GET_SHADOW_COPY_DATA(fsp,shadow_copy_data,labels) ((fsp)->conn->vfs.ops.get_shadow_copy_data((fsp)->conn->vfs.handles.get_shadow_copy_data,(fsp),(shadow_copy_data),(labels)))
+#define SMB_VFS_STATVFS(conn, path, statbuf) ((conn)->vfs.ops.statvfs((conn)->vfs.handles.statvfs, (conn), (path), (statbuf)))
 
 /* Directory operations */
 #define SMB_VFS_OPENDIR(conn, fname, mask, attr) ((conn)->vfs.ops.opendir((conn)->vfs.handles.opendir, (conn), (fname), (mask), (attr)))
 #define SMB_VFS_OPAQUE_GET_QUOTA(conn, qtype, id, qt) ((conn)->vfs_opaque.ops.get_quota((conn)->vfs_opaque.handles.get_quota, (conn), (qtype), (id), (qt)))
 #define SMB_VFS_OPAQUE_SET_QUOTA(conn, qtype, id, qt) ((conn)->vfs_opaque.ops.set_quota((conn)->vfs_opaque.handles.set_quota, (conn), (qtype), (id), (qt)))
 #define SMB_VFS_OPAQUE_GET_SHADOW_COPY_DATA(fsp,shadow_copy_data,labels) ((fsp)->conn->vfs_opaque.ops.get_shadow_copy_data((fsp)->conn->vfs_opaque.handles.get_shadow_copy_data,(fsp),(shadow_copy_data),(labels)))
+#define SMB_VFS_OPAQUE_STATVFS(conn, path, statbuf) ((conn)->vfs_opaque.ops.statvfs((conn)->vfs_opaque.handles.statvfs, (conn), (path), (statbuf)))
 
 /* Directory operations */
 #define SMB_VFS_OPAQUE_OPENDIR(conn, fname, mask, attr) ((conn)->vfs_opaque.ops.opendir((conn)->vfs_opaque.handles.opendir, (conn), (fname), (mask), (attr)))
 #define SMB_VFS_NEXT_GET_QUOTA(handle, conn, qtype, id, qt) ((handle)->vfs_next.ops.get_quota((handle)->vfs_next.handles.get_quota, (conn), (qtype), (id), (qt)))
 #define SMB_VFS_NEXT_SET_QUOTA(handle, conn, qtype, id, qt) ((handle)->vfs_next.ops.set_quota((handle)->vfs_next.handles.set_quota, (conn), (qtype), (id), (qt)))
 #define SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data ,labels) ((handle)->vfs_next.ops.get_shadow_copy_data((handle)->vfs_next.handles.get_shadow_copy_data,(fsp),(shadow_copy_data),(labels)))
+#define SMB_VFS_NEXT_STATVFS(handle, conn, path, statbuf) ((handle)->vfs_next.ops.statvfs((handle)->vfs_next.handles.statvfs, (conn), (path), (statbuf)))
 
 /* Directory operations */
 #define SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr) ((handle)->vfs_next.ops.opendir((handle)->vfs_next.handles.opendir, (conn), (fname), (mask), (attr)))
index 99d524448252fee78f1566ce92dfc9b1eb903996..d9d898dc0eac19df7163580ef4b5abbe2052fc99 100644 (file)
@@ -85,6 +85,10 @@ static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
                                 struct files_struct *fsp,
                                 SHADOW_COPY_DATA *shadow_copy_data, BOOL labels);
+static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
+                               struct connection_struct *conn,
+                               const char *path,
+                               struct vfs_statvfs_struct *statbuf);
 
 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn,
                          const char *fname, const char *mask, uint32 attr);
@@ -317,6 +321,8 @@ static vfs_op_tuple audit_op_tuples[] = {
         SMB_VFS_LAYER_LOGGER},
        {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
         SMB_VFS_LAYER_LOGGER},
+       {SMB_VFS_OP(smb_full_audit_statvfs),    SMB_VFS_OP_STATVFS,
+        SMB_VFS_LAYER_LOGGER},
 
        /* Directory operations */
 
@@ -518,6 +524,7 @@ static struct {
        { SMB_VFS_OP_GET_QUOTA, "get_quota" },
        { SMB_VFS_OP_SET_QUOTA, "set_quota" },
        { SMB_VFS_OP_GET_SHADOW_COPY_DATA,      "get_shadow_copy_data" },
+       { SMB_VFS_OP_STATVFS,   "statvfs" },
        { SMB_VFS_OP_OPENDIR,   "opendir" },
        { SMB_VFS_OP_READDIR,   "readdir" },
        { SMB_VFS_OP_SEEKDIR,   "seekdir" },
@@ -864,6 +871,20 @@ static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
        return result;
 }
 
+static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
+                               struct connection_struct *conn,
+                               const char *path,
+                               struct vfs_statvfs_struct *statbuf)
+{
+       int result;
+
+       result = SMB_VFS_NEXT_STATVFS(handle, conn, path, statbuf);
+
+       do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
+
+       return result;
+}
+
 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn,
                          const char *fname, const char *mask, uint32 attr)
 {
index cfb630a5727e4c08a79a801417582392076e602f..155f8b384c6a98fc2d5fc8a04200cfd16e147671 100644 (file)
@@ -4,6 +4,7 @@
    Copyright (C) Jeremy Allison                        1994-2003
    Copyright (C) Stefan (metze) Metzmacher     2003
    Copyright (C) Volker Lendecke               2005
+   Copyright (C) Steve French                  2005
 
    Extensively modified by Andrew Tridgell, 1995
 
@@ -2403,6 +2404,38 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                                        CIFS_UNIX_POSIX_PATHNAMES_CAP))); /* We have POSIX ACLs and pathname capability. */
                        break;
 
+               case SMB_QUERY_POSIX_FS_INFO:
+               {
+                       int rc;
+                       vfs_statvfs_struct svfs;
+
+                       if (!lp_unix_extensions())
+                               return ERROR_DOS(ERRDOS,ERRunknownlevel);
+                       
+                       rc = SMB_VFS_STATVFS(conn, ".", &svfs);
+
+                       if (!rc) {
+                               data_len = 56;
+                               SIVAL(pdata,0,svfs.OptimalTransferSize);
+                               SIVAL(pdata,4,svfs.BlockSize);
+                               SBIG_UINT(pdata,8,svfs.TotalBlocks);
+                               SBIG_UINT(pdata,16,svfs.BlocksAvail);
+                               SBIG_UINT(pdata,24,svfs.UserBlocksAvail);
+                               SBIG_UINT(pdata,32,svfs.TotalFileNodes);
+                               SBIG_UINT(pdata,40,svfs.FreeFileNodes);
+                               SBIG_UINT(pdata,48,svfs.FsIdentifier);
+                               DEBUG(5,("call_trans2qfsinfo : SMB_QUERY_POSIX_FS_INFO succsessful\n"));
+#ifdef EOPNOTSUPP
+                       } else if (rc == EOPNOTSUPP) {
+                               return ERROR_DOS(ERRDOS, ERRunknownlevel);
+#endif /* EOPNOTSUPP */
+                       } else {
+                               DEBUG(0,("vfs_statvfs() failed for service [%s]\n",lp_servicename(SNUM(conn))));
+                               return ERROR_DOS(ERRSRV,ERRerror);
+                       }
+                       break;
+               }
+
                case SMB_MAC_QUERY_FS_INFO:
                        /*
                         * Thursby MAC extension... ONLY on NTFS filesystems
index c203af0c55049df4c41655783f13b9e10ed4eb7c..bbb7b5bb3086681636a8fe877a326439210f7fb0 100644 (file)
@@ -86,6 +86,11 @@ int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle, struct files_
        return -1;  /* Not implemented. */
 }
     
+int vfswrap_statvfs(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, vfs_statvfs_struct *statbuf)
+{
+       return sys_statvfs(path, statbuf);
+}
+
 /* Directory operations */
 
 SMB_STRUCT_DIR *vfswrap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
index 67970f203acf2332eb9ad0cf044658a28ed3d70c..52966d59aea6b0fefc0eb0fc91b4a07a5c0c78fe 100644 (file)
@@ -57,6 +57,7 @@ static struct vfs_ops default_vfs = {
                vfswrap_get_quota,
                vfswrap_set_quota,
                vfswrap_get_shadow_copy_data,
+               vfswrap_statvfs,
        
                /* Directory operations */
        
index 9ddfe62508129681ee149125038ac555ed86376f..7f79b6d4f1e645a6f34ff4e474922a9005d7fd28 100644 (file)
@@ -60,6 +60,7 @@ static int net_lookup_host(int argc, const char **argv)
        return 0;
 }
 
+#ifdef HAVE_LDAP
 static void print_ldap_srvlist(char *srvlist)
 {
        char *cur, *next;
@@ -80,7 +81,7 @@ static void print_ldap_srvlist(char *srvlist)
                cur = next;
        } while (next);
 }
-               
+#endif
 
 static int net_lookup_ldap(int argc, const char **argv)
 {
index 41203dac749d53fed30ea2c3dbba60a4edf8b88c..d61abb64654ab36326e8a4c1e95fe55459fe7900 100644 (file)
@@ -795,7 +795,6 @@ static void manage_gss_spnego_request(enum stdio_helper_mode stdio_helper_mode,
        DATA_BLOB token;
        NTSTATUS status;
        ssize_t len;
-       TALLOC_CTX *mem_ctx = talloc_init("manage_gss_spnego_request");
 
        char *user = NULL;
        char *domain = NULL;
@@ -898,6 +897,7 @@ static void manage_gss_spnego_request(enum stdio_helper_mode stdio_helper_mode,
 #ifdef HAVE_KRB5
                if (strcmp(request.negTokenInit.mechTypes[0], OID_KERBEROS5_OLD) == 0) {
 
+                       TALLOC_CTX *mem_ctx = talloc_init("manage_gss_spnego_request");
                        char *principal;
                        DATA_BLOB ap_rep;
                        DATA_BLOB session_key;