Whamcloud - gitweb
mke2fs: Add support for [devices] stanza in mke2fs.conf
authorTheodore Ts'o <tytso@mit.edu>
Tue, 14 Jun 2011 18:17:56 +0000 (14:17 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 14 Jun 2011 18:32:41 +0000 (14:32 -0400)
Add the [devices] stanza which allows device-specific defaults to be
specified in the mke2fs.conf file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/mke2fs.c
misc/mke2fs.conf.5.in

index 5ff3f9f..69f94f0 100644 (file)
@@ -1190,8 +1190,8 @@ static void PRS(int argc, char *argv[])
        errcode_t       retval;
        char *          oldpath = getenv("PATH");
        char *          extended_opts = 0;
-       const char *    fs_type = 0;
-       const char *    usage_types = 0;
+       char *          fs_type = 0;
+       char *          usage_types = 0;
        blk64_t         dev_size;
        blk64_t         fs_blocks_count = 0;
 #ifdef __linux__
@@ -1448,10 +1448,10 @@ profile_error:
                        super_only = 1;
                        break;
                case 't':
-                       fs_type = optarg;
+                       fs_type = strdup(optarg);
                        break;
                case 'T':
-                       usage_types = optarg;
+                       usage_types = strdup(optarg);
                        break;
                case 'U':
                        fs_uuid = optarg;
@@ -1589,6 +1589,13 @@ profile_error:
                proceed_question();
        }
 
+       if (!fs_type)
+               profile_get_string(profile, "devices", device_name,
+                                  "fs_type", 0, &fs_type);
+       if (!usage_types)
+               profile_get_string(profile, "devices", device_name,
+                                  "usage_types", 0, &usage_types);
+
        /*
         * We have the file system (or device) size, so we can now
         * determine the appropriate file system types so the fs can
@@ -1946,6 +1953,9 @@ profile_error:
         */
        ext2fs_r_blocks_count_set(&fs_param, reserved_ratio *
                                  ext2fs_blocks_count(&fs_param) / 100.0);
+
+       free(fs_type);
+       free(usage_types);
 }
 
 static int should_do_undo(const char *name)
index 1710d70..b0f1ccc 100644 (file)
@@ -65,7 +65,7 @@ file.  They will be described in more detail in future sections of this
 document.
 .TP 
 .I [defaults]
-Contains relations which define the default parameters 
+Contains relations which define the default parameters
 used by
 .BR mke2fs (8).
 In general, these defaults may be overridden by a definition in the
@@ -395,6 +395,20 @@ on a per-filesystem type basis.
 This relation is a boolean which specifies whether the
 .BR mke2fs (8)
 should attempt to discard device prior to filesystem creation.
+.SH THE [devices] STANZA
+Each tag in the
+.I [devices] 
+stanza names device name so that per-device defaults can be specified.
+.TP
+.I fs_type
+This relation specifies the default parameter for the
+.B \-t
+option, if this option isn't specified on the command line.
+.TP
+.I usage_types
+This relation specifies the default parameter for the
+.B \-T
+option, if this option isn't specified on the command line.
 .SH FILES
 .TP
 .I /etc/mke2fs.conf