]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
mke2fs: support creation of filesystem with quota feature
authorAditya Kali <adityakali@google.com>
Wed, 20 Jul 2011 18:40:04 +0000 (11:40 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 31 Aug 2011 20:31:49 +0000 (16:31 -0400)
mke2fs also creates quota inodes (userquota: inode# 3 and
groupquota: inode #4) inodes while creating a filesystem when 'quota'
feature is set.
 # To set quota feature and initialize quota inodes during mke2fs:
 $mke2fs -t ext4 -O quota /dev/ram1

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

index 5f62323a7faa1fe4a503c42c9d9e0a819ff62e42..2f7908c5577ab4c0e47398659f384aad3ac7e5a1 100644 (file)
@@ -219,23 +219,25 @@ mklost+found: $(MKLPF_OBJS)
        $(Q) $(CC) $(ALL_LDFLAGS) -o mklost+found $(MKLPF_OBJS) $(LIBINTL)
 
 mke2fs: $(MKE2FS_OBJS) $(DEPLIBS) $(LIBE2P) $(DEPLIBBLKID) $(DEPLIBUUID) \
-               $(LIBEXT2FS) 
+               $(DEPLIBQUOTA) $(LIBEXT2FS)
        $(E) "  LD $@"
        $(Q) $(CC) $(ALL_LDFLAGS) -o mke2fs $(MKE2FS_OBJS) $(LIBS) $(LIBBLKID) \
-               $(LIBUUID) $(LIBEXT2FS) $(LIBE2P) $(LIBINTL)
+               $(LIBUUID) $(LIBQUOTA) $(LIBEXT2FS) $(LIBE2P) $(LIBINTL)
 
-mke2fs.static: $(MKE2FS_OBJS) $(STATIC_DEPLIBS) $(STATIC_LIBE2P) $(DEPSTATIC_LIBUUID) $(DEPSTATIC_LIBBLKID)
+mke2fs.static: $(MKE2FS_OBJS) $(STATIC_DEPLIBS) $(STATIC_LIBE2P) $(DEPSTATIC_LIBUUID) \
+               $(DEPSTATIC_LIBQUOTA) $(DEPSTATIC_LIBBLKID)
        $(E) "  LD $@"
        $(Q) $(CC) $(ALL_LDFLAGS) -static -o mke2fs.static $(MKE2FS_OBJS) \
                $(STATIC_LIBS) $(STATIC_LIBE2P) $(STATIC_LIBBLKID) \
-               $(STATIC_LIBUUID) $(LIBINTL)
+               $(STATIC_LIBUUID) $(STATIC_LIBQUOTA) $(LIBINTL)
 
 mke2fs.profiled: $(PROFILED_MKE2FS_OBJS) $(PROFILED_DEPLIBS) \
-       $(PROFILED_LIBE2P) $(PROFILED_DEPLIBBLKID) $(PROFILED_DEPLIBUUID) 
+       $(PROFILED_LIBE2P) $(PROFILED_DEPLIBBLKID) $(PROFILED_DEPLIBUUID) \
+       $(PROFILED_LIBQUOTA)
        $(E) "  LD $@"
        $(Q) $(CC) $(ALL_LDFLAGS) -g -pg -o mke2fs.profiled \
                $(PROFILED_MKE2FS_OBJS) $(PROFILED_LIBBLKID) \
-               $(PROFILED_LIBUUID) $(PROFILED_LIBE2P) $(LIBINTL) \
+               $(PROFILED_LIBUUID) $(PROFILED_LIBQUOTA) $(PROFILED_LIBE2P) $(LIBINTL) \
                $(PROFILED_LIBS)
 
 chattr: $(CHATTR_OBJS) $(DEPLIBS_E2P)
index 6901497e38eceef61f687ef1c4cceeba0f6302a4..821222ebcdc9a51587c4fee9876d8ffc2d4fe66c 100644 (file)
@@ -528,6 +528,11 @@ option).
 Filesystem can contain files that are greater than 2GB.  (Modern kernels
 set this feature automatically when a file > 2GB is created.)
 .TP
+.B quota
+Create quota inodes (inode# 3 for userquota and inode# 4 for group quota) and
+set them in the superblock.  With this feature, the quotas will be enabled
+automatically when the filesystem is mounted.
+.TP
 .B resize_inode
 Reserve space so the block group descriptor table may grow in the future.
 Useful for online resizing using
index e062bda0b8a44b08799838656a6904479cc3c755..cf9c338510f2cb7eaedeaae5d2eac039e34e6e66 100644 (file)
@@ -63,6 +63,7 @@ extern int optind;
 #include "prof_err.h"
 #include "../version.h"
 #include "nls-enable.h"
+#include "quota/mkquota.h"
 
 #define STRIDE_LENGTH 8
 
@@ -829,7 +830,8 @@ static __u32 ok_features[3] = {
                EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|
                EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|
                EXT4_FEATURE_RO_COMPAT_GDT_CSUM|
-               EXT4_FEATURE_RO_COMPAT_BIGALLOC
+               EXT4_FEATURE_RO_COMPAT_BIGALLOC|
+               EXT4_FEATURE_RO_COMPAT_QUOTA
 };
 
 
@@ -2137,6 +2139,19 @@ static void fix_cluster_bg_counts(ext2_filsys fs)
        ext2fs_free_blocks_count_set(fs->super, EXT2FS_C2B(fs, tot_free));
 }
 
+static int create_quota_inodes(ext2_filsys fs)
+{
+       quota_ctx_t qctx;
+
+       init_quota_context(&qctx, fs, -1);
+       compute_quota(qctx, -1);
+       write_quota_inode(qctx, USRQUOTA);
+       write_quota_inode(qctx, GRPQUOTA);
+       release_quota_context(&qctx);
+
+       return;
+}
+
 int main (int argc, char *argv[])
 {
        errcode_t       retval = 0;
@@ -2466,6 +2481,10 @@ no_journal:
        if (EXT2_HAS_RO_COMPAT_FEATURE(&fs_param,
                                       EXT4_FEATURE_RO_COMPAT_BIGALLOC))
                fix_cluster_bg_counts(fs);
+       if (EXT2_HAS_RO_COMPAT_FEATURE(&fs_param,
+                                      EXT4_FEATURE_RO_COMPAT_QUOTA))
+               create_quota_inodes(fs);
+
        if (!quiet)
                printf(_("Writing superblocks and "
                       "filesystem accounting information: "));