vfs_fake_dfq: add more mocking options
authorUri Simchoni <uri@samba.org>
Thu, 26 May 2016 18:59:38 +0000 (21:59 +0300)
committerJeremy Allison <jra@samba.org>
Fri, 27 May 2016 18:36:06 +0000 (20:36 +0200)
Add support for mocking FS user/group quotas (default quota and
quota flags).

Make the default block size 4096 instead of 0. This
turns the default into "no quota" instead of "punt to
lower VFS module" (that is, if the mock module is asked
to retrieve quota of a user/group/default for which there
is no config).

Add support for ENOSYS error

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11937

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_fake_dfq.c

index e476e16c3e83e8577c019ef680390c03531f6c4e..bf498600ef30cfcea0fdcb34449bef373677f44f 100644 (file)
@@ -110,6 +110,12 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
                section = talloc_asprintf(talloc_tos(), "g%llu",
                                          (unsigned long long)id.gid);
                break;
+       case SMB_USER_FS_QUOTA_TYPE:
+               section = talloc_strdup(talloc_tos(), "udflt");
+               break;
+       case SMB_GROUP_FS_QUOTA_TYPE:
+               section = talloc_strdup(talloc_tos(), "gdflt");
+               break;
        default:
                break;
        }
@@ -118,7 +124,7 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
                goto dflt;
        }
 
-       bsize = dfq_load_param(snum, rpath, section, "block size", 0);
+       bsize = dfq_load_param(snum, rpath, section, "block size", 4096);
        if (bsize == 0) {
                goto dflt;
        }
@@ -129,6 +135,12 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
                goto out;
        }
 
+       if (dfq_load_param(snum, rpath, section, "nosys", 0) != 0) {
+               errno = ENOSYS;
+               rc = -1;
+               goto out;
+       }
+
        ZERO_STRUCTP(qt);
 
        qt->bsize = bsize;
@@ -140,6 +152,7 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
        qt->isoftlimit =
            dfq_load_param(snum, rpath, section, "inode soft limit", 0);
        qt->curinodes = dfq_load_param(snum, rpath, section, "cur inodes", 0);
+       qt->qflags = dfq_load_param(snum, rpath, section, "qflags", QUOTAS_DENY_DISK);
 
        if (dfq_load_param(snum, rpath, section, "edquot", 0) != 0) {
                errno = EDQUOT;