diff options
author | Aditya Kali <adityakali@google.com> | 2011-05-10 14:51:31 -0700 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-05-14 23:34:48 -0400 |
commit | d3859af33f5bbbc432dedb20e85a5ae62e0fff03 (patch) | |
tree | 13a9df80c232e127d5a03845bf0f9381baa3607c /misc/mke2fs.c | |
parent | 598d20cc3c0f71561402e13c07aaf5880b85fa37 (diff) | |
download | e2fsprogs-d3859af33f5bbbc432dedb20e85a5ae62e0fff03.tar.gz |
mke2fs: Allow specifying reserved_ratio via mke2fs.conf
This patch adds support for specifying 'reserved_ratio' (percent blocks
reserved for super user, same as '-m' command line option) in mke2fs.conf.
It adds profile_get_double function in profile.c that allows reading
floating point values from profile files.
Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc/mke2fs.c')
-rw-r--r-- | misc/mke2fs.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 9798b888..ddfa929c 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1082,6 +1082,18 @@ static int get_int_from_profile(char **fs_types, const char *opt, int def_val) return ret; } +static double get_double_from_profile(char **fs_types, const char *opt, + double def_val) +{ + double ret; + char **cpp; + + profile_get_double(profile, "defaults", opt, 0, def_val, &ret); + for (cpp = fs_types; *cpp; cpp++) + profile_get_double(profile, "fs_types", *cpp, opt, ret, &ret); + return ret; +} + static int get_bool_from_profile(char **fs_types, const char *opt, int def_val) { int ret; @@ -1154,7 +1166,7 @@ static void PRS(int argc, char *argv[]) int inode_ratio = 0; int inode_size = 0; unsigned long flex_bg_size = 0; - double reserved_ratio = 5.0; + double reserved_ratio = -1.0; int lsector_size = 0, psector_size = 0; int show_version_only = 0; unsigned long long num_inodes = 0; /* unsigned long long to catch too-large input */ @@ -1675,6 +1687,18 @@ profile_error: EXT3_FEATURE_COMPAT_HAS_JOURNAL; } + /* Get reserved_ratio from profile if not specified on cmd line. */ + if (reserved_ratio < 0.0) { + reserved_ratio = get_double_from_profile( + fs_types, "reserved_ratio", 5.0); + if (reserved_ratio > 50 || reserved_ratio < 0) { + com_err(program_name, 0, + _("invalid reserved blocks percent - %lf"), + reserved_ratio); + exit(1); + } + } + if (fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) { reserved_ratio = 0; |