]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
mke2fs: Add extended option to select quota type
authorAditya Kali <adityakali@google.com>
Mon, 14 Nov 2011 15:55:54 +0000 (10:55 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 14 Nov 2011 15:55:54 +0000 (10:55 -0500)
mke2fs was creating both user and group quota inodes on enabling
the quota feature. This patch adds the extended option 'quotatype'
that can be used to exclusively specify the quota type that the
user wants to initialize.

 # Ex: Default behavior without extended option creates both
 # user and group quota inodes:
 $ mke2fs -t ext4 -O quota /dev/ram1

 # To enable only user quotas:
 $ mke2fs -t ext4 -O quota -E quotatype=usr /dev/ram1
 # To enable only group quotas:
 $ mke2fs -t ext4 -O quota -E quotatype=grp /dev/ram1

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/mke2fs.8.in
misc/mke2fs.c

index e249c6b492af737916bca82385c4013526de5b53..8e78249cca0c8ea47b749555e239633d38c7eebc 100644 (file)
@@ -266,6 +266,13 @@ as default.
 .TP
 .BI nodiscard
 Do not attempt to discard blocks at mkfs time.
+.TP
+.BI quotatype
+Specify which quota type ('usr' or 'grp') is to be initialized. This
+option has any effect only if
+.B quota
+feature is set. Without this extended option, the default behavior is to
+initialize both user and group quotas.
 .RE
 .TP
 .BI \-f " fragment-size"
index 0801c6e6be63290b7c69c5caaae762e0b4d76392..0ef253174ae8659a4f92cf8853b26d75d5b7fcc6 100644 (file)
@@ -95,6 +95,7 @@ int   journal_flags;
 int    lazy_itable_init;
 char   *bad_blocks_filename;
 __u32  fs_stride;
+int    quotatype = -1;  /* Initialize both user and group quotas by default */
 
 struct ext2_super_block fs_param;
 char *fs_uuid = NULL;
@@ -793,6 +794,23 @@ static void parse_extended_opts(struct ext2_super_block *param,
                        discard = 1;
                } else if (!strcmp(token, "nodiscard")) {
                        discard = 0;
+               } else if (!strcmp(token, "quotatype")) {
+                       if (!arg) {
+                               r_usage++;
+                               badopt = token;
+                               continue;
+                       }
+                       if (!strncmp(arg, "usr", 3)) {
+                               quotatype = 0;
+                       } else if (!strncmp(arg, "grp", 3)) {
+                               quotatype = 1;
+                       } else {
+                               fprintf(stderr,
+                                       _("Invalid quotatype parameter: %s\n"),
+                                       arg);
+                               r_usage++;
+                               continue;
+                       }
                } else {
                        r_usage++;
                        badopt = token;
@@ -811,7 +829,8 @@ static void parse_extended_opts(struct ext2_super_block *param,
                        "\tlazy_journal_init=<0 to disable, 1 to enable>\n"
                        "\ttest_fs\n"
                        "\tdiscard\n"
-                       "\tnodiscard\n\n"),
+                       "\tnodiscard\n"
+                       "\tquotatype=<usr OR grp>\n\n"),
                        badopt ? badopt : "");
                free(buf);
                exit(1);
@@ -2186,8 +2205,7 @@ static int create_quota_inodes(ext2_filsys fs)
 
        quota_init_context(&qctx, fs, -1);
        quota_compute_usage(qctx);
-       quota_write_inode(qctx, USRQUOTA);
-       quota_write_inode(qctx, GRPQUOTA);
+       quota_write_inode(qctx, quotatype);
        quota_release_context(&qctx);
 
        return 0;