diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 5ff3f9fe..69f94f07 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -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) diff --git a/misc/mke2fs.conf.5.in b/misc/mke2fs.conf.5.in index 1710d700..b0f1cccc 100644 --- a/misc/mke2fs.conf.5.in +++ b/misc/mke2fs.conf.5.in @@ -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