vfs: add path parameter to get_quota
authorUri Simchoni <uri@samba.org>
Sun, 10 Jan 2016 11:29:25 +0000 (13:29 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 26 Jan 2016 14:58:12 +0000 (15:58 +0100)
Adding a path parameter would allow the VFS get_quota
function to be used for determining the quota/usage
when calculating size and free spacei.

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_ceph.c
source3/modules/vfs_default.c
source3/modules/vfs_default_quota.c
source3/modules/vfs_fake_dfq.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_time_audit.c
source3/smbd/ntquotas.c
source3/smbd/vfs.c

index 29fe6f44c21c35fcdbfdaaeefd523defdebd236c..a4309d4de6983ee1a58b51ee810fb050ed292339 100644 (file)
@@ -54,8 +54,9 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle, const char *path,
        return 0;
 }
 
-static int skel_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
-                         unid_t id, SMB_DISK_QUOTA *dq)
+static int skel_get_quota(vfs_handle_struct *handle, const char *path,
+                         enum SMB_QUOTA_TYPE qtype, unid_t id,
+                         SMB_DISK_QUOTA *dq)
 {
        errno = ENOSYS;
        return -1;
index c5a36a65a11f88383bb1a844a9dd9ec32a629127..2d1ed790cbb90ed1103260f72b0e4e83f9413c76 100644 (file)
@@ -55,10 +55,11 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle, const char *path,
        return SMB_VFS_NEXT_DISK_FREE(handle, path, bsize, dfree, dsize);
 }
 
-static int skel_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
-                         unid_t id, SMB_DISK_QUOTA *dq)
+static int skel_get_quota(vfs_handle_struct *handle, const char *path,
+                         enum SMB_QUOTA_TYPE qtype, unid_t id,
+                         SMB_DISK_QUOTA *dq)
 {
-       return SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, dq);
+       return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq);
 }
 
 static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
index 66e4fc6be6816fe7ad23782ba4ec09bdff814a31..c18ea5947acff094974e4d1c5377de8165cabd9f 100644 (file)
@@ -526,7 +526,9 @@ struct vfs_fn_pointers {
        void (*disconnect_fn)(struct vfs_handle_struct *handle);
        uint64_t (*disk_free_fn)(struct vfs_handle_struct *handle, const char *path, uint64_t *bsize,
                              uint64_t *dfree, uint64_t *dsize);
-       int (*get_quota_fn)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
+       int (*get_quota_fn)(struct vfs_handle_struct *handle, const char *path,
+                           enum SMB_QUOTA_TYPE qtype, unid_t id,
+                           SMB_DISK_QUOTA *qt);
        int (*set_quota_fn)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
        int (*get_shadow_copy_data_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, struct shadow_copy_data *shadow_copy_data, bool labels);
        int (*statvfs_fn)(struct vfs_handle_struct *handle, const char *path, struct vfs_statvfs_struct *statbuf);
@@ -931,7 +933,7 @@ void smb_vfs_call_disconnect(struct vfs_handle_struct *handle);
 uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
                                const char *path, uint64_t *bsize,
                                uint64_t *dfree, uint64_t *dsize);
-int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
+int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path,
                           enum SMB_QUOTA_TYPE qtype, unid_t id,
                           SMB_DISK_QUOTA *qt);
 int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
index eaf0c19371d07fb67f8a55b834ac6adaec8aae9c..16d5bfdb2704beb268ad0e2e1c4f81be4424c693 100644 (file)
 #define SMB_VFS_NEXT_DISK_FREE(handle, path, bsize, dfree ,dsize)\
        smb_vfs_call_disk_free((handle)->next, (path), (bsize), (dfree), (dsize))
 
-#define SMB_VFS_GET_QUOTA(conn, qtype, id, qt) \
-       smb_vfs_call_get_quota((conn)->vfs_handles, (qtype), (id), (qt))
-#define SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt) \
-       smb_vfs_call_get_quota((handle)->next, (qtype), (id), (qt))
+#define SMB_VFS_GET_QUOTA(conn, path, qtype, id, qt)                           \
+       smb_vfs_call_get_quota((conn)->vfs_handles, (path), (qtype), (id), (qt))
+#define SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt)                    \
+       smb_vfs_call_get_quota((handle)->next, (path), (qtype), (id), (qt))
 
 #define SMB_VFS_SET_QUOTA(conn, qtype, id, qt) \
        smb_vfs_call_set_quota((conn)->vfs_handles, (qtype), (id), (qt))
index 0113faa1247cae74773901a6a4425f01fb224c41..2bc387af794606d1cc9bed4aa90698f3a3e114e1 100644 (file)
@@ -185,7 +185,9 @@ static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle,
        }
 }
 
-static int cephwrap_get_quota(struct vfs_handle_struct *handle,  enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
+static int cephwrap_get_quota(struct vfs_handle_struct *handle,
+                             const char *path, enum SMB_QUOTA_TYPE qtype,
+                             unid_t id, SMB_DISK_QUOTA *qt)
 {
        /* libceph: Ceph does not implement this */
 #if 0
index 819a1a1ca6fce4dc2d336d4851d7b3f7d8a05f7e..0f8e067363ff45dd6b185653fea6f0b0eb23feae 100644 (file)
@@ -64,13 +64,15 @@ static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, const char *path,
        return result;
 }
 
-static int vfswrap_get_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
+static int vfswrap_get_quota(struct vfs_handle_struct *handle, const char *path,
+                            enum SMB_QUOTA_TYPE qtype, unid_t id,
+                            SMB_DISK_QUOTA *qt)
 {
 #ifdef HAVE_SYS_QUOTAS
        int result;
 
        START_PROFILE(syscall_get_quota);
-       result = sys_get_quota(handle->conn->connectpath, qtype, id, qt);
+       result = sys_get_quota(path, qtype, id, qt);
        END_PROFILE(syscall_get_quota);
        return result;
 #else
index a71d3c297a1ea0bdb615dfb5cff4be1e2355e2c5..c8d718cb5b906704c8f384e6248af31d5731cb2b 100644 (file)
 #define DEFAULT_QUOTA_GID_NOLIMIT(handle) \
        lp_parm_bool(SNUM((handle)->conn),DEFAULT_QUOTA_NAME,"gid nolimit",DEFAULT_QUOTA_GID_NOLIMIT_DEFAULT)
 
-static int default_quota_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq)
+static int default_quota_get_quota(vfs_handle_struct *handle, const char *path,
+                                  enum SMB_QUOTA_TYPE qtype, unid_t id,
+                                  SMB_DISK_QUOTA *dq)
 {
        int ret = -1;
 
-       if ((ret=SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, dq))!=0) {
+       if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq)) != 0) {
                return ret;
        }
 
@@ -122,7 +124,8 @@ static int default_quota_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYP
                                unid_t qid;
                                uint32_t qflags = dq->qflags;
                                qid.uid = DEFAULT_QUOTA_UID(handle);
-                               SMB_VFS_NEXT_GET_QUOTA(handle, SMB_USER_QUOTA_TYPE, qid, dq);
+                               SMB_VFS_NEXT_GET_QUOTA(
+                                   handle, path, SMB_USER_QUOTA_TYPE, qid, dq);
                                dq->qflags = qflags;
                        }
                        break;
@@ -132,7 +135,9 @@ static int default_quota_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYP
                                unid_t qid;
                                uint32_t qflags = dq->qflags;
                                qid.gid = DEFAULT_QUOTA_GID(handle);
-                               SMB_VFS_NEXT_GET_QUOTA(handle, SMB_GROUP_QUOTA_TYPE, qid, dq);
+                               SMB_VFS_NEXT_GET_QUOTA(handle, path,
+                                                      SMB_GROUP_QUOTA_TYPE,
+                                                      qid, dq);
                                dq->qflags = qflags;
                        }
                        break;
index b375a95b2a225cbdca8ebe09ee079424fa36e28b..c7a4f06dfd8e573a354bbb90d023bf26457ce2eb 100644 (file)
@@ -27,9 +27,9 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
 
-static int dfq_get_quota_do(struct vfs_handle_struct *handle, const char *path,
-                           enum SMB_QUOTA_TYPE qtype, unid_t id,
-                           SMB_DISK_QUOTA *qt);
+static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
+                        enum SMB_QUOTA_TYPE qtype, unid_t id,
+                        SMB_DISK_QUOTA *qt);
 
 static uint64_t dfq_load_param(int snum, const char *path, const char *section,
                               const char *param, uint64_t def_val)
@@ -60,7 +60,7 @@ static bool dfq_disk_quotas(vfs_handle_struct *handle, const char *path,
        id.uid = geteuid();
 
        ZERO_STRUCT(D);
-       r = dfq_get_quota_do(handle, path, SMB_USER_QUOTA_TYPE, id, &D);
+       r = dfq_get_quota(handle, path, SMB_USER_QUOTA_TYPE, id, &D);
 
        /* Use softlimit to determine disk space, except when it has been
         * exceeded */
@@ -99,7 +99,7 @@ try_group_quota:
        id.gid = getegid();
 
        ZERO_STRUCT(D);
-       r = dfq_get_quota_do(handle, path, SMB_GROUP_QUOTA_TYPE, id, &D);
+       r = dfq_get_quota(handle, path, SMB_GROUP_QUOTA_TYPE, id, &D);
 
        /* Use softlimit to determine disk space, except when it has been
         * exceeded */
@@ -181,9 +181,9 @@ static uint64_t dfq_disk_free(vfs_handle_struct *handle, const char *path,
        return free_1k;
 }
 
-static int dfq_get_quota_do(struct vfs_handle_struct *handle, const char *path,
-                           enum SMB_QUOTA_TYPE qtype, unid_t id,
-                           SMB_DISK_QUOTA *qt)
+static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
+                        enum SMB_QUOTA_TYPE qtype, unid_t id,
+                        SMB_DISK_QUOTA *qt)
 {
        int rc = 0;
        int save_errno;
@@ -245,7 +245,7 @@ static int dfq_get_quota_do(struct vfs_handle_struct *handle, const char *path,
        goto out;
 
 dflt:
-       rc = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
+       rc = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
 
 out:
        save_errno = errno;
@@ -255,14 +255,6 @@ out:
        return rc;
 }
 
-static int dfq_get_quota(struct vfs_handle_struct *handle,
-                        enum SMB_QUOTA_TYPE qtype, unid_t id,
-                        SMB_DISK_QUOTA *qt)
-{
-       return dfq_get_quota_do(handle, handle->conn->connectpath, qtype, id,
-                               qt);
-}
-
 struct vfs_fn_pointers vfs_fake_dfq_fns = {
     /* Disk operations */
 
index 11f5d822a6013282748fa4625d1708fad59b2e2b..904b56905eefd18e3f9f9820d5e4c451fd37ddba 100644 (file)
@@ -666,14 +666,14 @@ static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
-                          enum SMB_QUOTA_TYPE qtype, unid_t id,
-                          SMB_DISK_QUOTA *qt)
+                                   const char *path, enum SMB_QUOTA_TYPE qtype,
+                                   unid_t id, SMB_DISK_QUOTA *qt)
 {
        int result;
 
-       result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
+       result = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
 
-       do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
+       do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "%s", path);
 
        return result;
 }
index 7efad1efa5d26327c740f481db6d58d0a2374a20..2fc6afdfef697244bbc99f8ea00cbaa4624e5c29 100644 (file)
@@ -178,15 +178,15 @@ static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
-                                   enum SMB_QUOTA_TYPE qtype, unid_t id,
-                                   SMB_DISK_QUOTA *qt)
+                                   const char *path, enum SMB_QUOTA_TYPE qtype,
+                                   unid_t id, SMB_DISK_QUOTA *qt)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
+       result = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
index 15fd35b92e4d9c7cb004e714bbdd3e058aa8f09c..aa2ec3b76a535b9badbb063b91b8c4272e14d726 100644 (file)
@@ -96,7 +96,7 @@ int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid
                         sid_string_dbg(psid)));
        }
 
-       ret = SMB_VFS_GET_QUOTA(fsp->conn, qtype, id, &D);
+       ret = SMB_VFS_GET_QUOTA(fsp->conn, ".", qtype, id, &D);
 
        if (psid)
                qt->sid    = *psid;
index 1a2ee3dc222effd7b4e8ffd84711ab3ee09259a4..89f0ae194f0874fd3fd55671fd34e12c854fcb0c 100644 (file)
@@ -1404,12 +1404,12 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
        return handle->fns->disk_free_fn(handle, path, bsize, dfree, dsize);
 }
 
-int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
+int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path,
                           enum SMB_QUOTA_TYPE qtype, unid_t id,
                           SMB_DISK_QUOTA *qt)
 {
        VFS_FIND(get_quota);
-       return handle->fns->get_quota_fn(handle, qtype, id, qt);
+       return handle->fns->get_quota_fn(handle, path, qtype, id, qt);
 }
 
 int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,