Re: [PATCH] mke2fs: Support floating point values in mke2fs.conf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for the feedback Lukas. I will send out another patch with
updated description and man page.

--
Aditya



On Tue, May 10, 2011 at 11:08 AM, Lukas Czerner <lczerner@xxxxxxxxxx> wrote:
> On Tue, 10 May 2011, Lukas Czerner wrote:
>
>> On Tue, 10 May 2011, Aditya Kali wrote:
>>
>> > This patch adds profile_get_double function in profile.c that allows reading
>> > floating point values from profile files. The floating point support is used
>> > to read reserved_ratio (reserved for super user block percentage) from
>> > mke2fs.conf.
>>
>> Hi Aditya,
>>
>> thanks for the patch, however I have couple of comments. First of all
>> the commit subject does not really reflect the change, because the point
>> of this commit is not to teach e2fsprogs to be able to read double from
>> profile but rather add new option to mke2fs.conf for specifying
>> super-user reservation ratio. I am sorry it this seems like nitpicking,
>> but it is really useful to be able to at least guess what the commit
>> does from its subject.
>>
>> Also it would be nice to have this option described in the mke2fs
>> manual page as well.
>
> Sorry, I meant mke2fs.conf man page. Other than that the patch looks
> good and works as expected.
>
>>
>> Thanks!
>> -Lukas
>>
>> >
>> > Signed-off-by: Aditya Kali <adityakali@xxxxxxxxxx>
>> > ---
>> > Âe2fsck/profile.c   |  37 +++++++++++++++++++++++++++++++++++++
>> > Âe2fsck/profile.h   |  Â5 +++++
>> > Âmisc/mke2fs.c    Â|  26 +++++++++++++++++++++++++-
>> > Âtests/mke2fs.conf.in | Â Â1 +
>> > Â4 files changed, 68 insertions(+), 1 deletions(-)
>> >
>> > diff --git a/e2fsck/profile.c b/e2fsck/profile.c
>> > index 5e9dc53..327bfb4 100644
>> > --- a/e2fsck/profile.c
>> > +++ b/e2fsck/profile.c
>> > @@ -1596,6 +1596,43 @@ profile_get_uint(profile_t profile, const char *name, const char *subname,
>> > Â Â return 0;
>> > Â}
>> >
>> > +errcode_t
>> > +profile_get_double(profile_t profile, const char *name, const char *subname,
>> > + Â Â Â Â Â Â Âconst char *subsubname, double def_val, double *ret_double)
>> > +{
>> > +  const char   Â*value;
>> > +  errcode_t     retval;
>> > +  char    Â*end_value;
>> > +  double   Âdouble_val;
>> > +
>> > + Â *ret_double = def_val;
>> > + Â if (profile == 0)
>> > + Â Â Â Â Â return 0;
>> > +
>> > + Â retval = profile_get_value(profile, name, subname, subsubname, &value);
>> > + Â if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) {
>> > + Â Â Â Â Â *ret_double = def_val;
>> > + Â Â Â Â Â return 0;
>> > + Â } else if (retval)
>> > + Â Â Â Â Â return retval;
>> > +
>> > + Â if (value[0] == 0)
>> > + Â Â Â Â Â /* Empty string is no good. Â*/
>> > + Â Â Â Â Â return PROF_BAD_INTEGER;
>> > + Â errno = 0;
>> > + Â double_val = strtod(value, &end_value);
>> > +
>> > + Â /* Overflow or underflow. Â*/
>> > + Â if (errno != 0)
>> > + Â Â Â Â Â return PROF_BAD_INTEGER;
>> > + Â /* Garbage in string. Â*/
>> > + Â if (end_value != value + strlen(value))
>> > + Â Â Â Â Â return PROF_BAD_INTEGER;
>> > +
>> > + Â *ret_double = double_val;
>> > + Â return 0;
>> > +}
>> > +
>> > Âstatic const char *const conf_yes[] = {
>> > Â Â Â"y", "yes", "true", "t", "1", "on",
>> > Â Â Â0,
>> > diff --git a/e2fsck/profile.h b/e2fsck/profile.h
>> > index 0c17732..4cc10eb 100644
>> > --- a/e2fsck/profile.h
>> > +++ b/e2fsck/profile.h
>> > @@ -78,6 +78,11 @@ long profile_get_uint
>> > Â Â Â Â Â Â const char *subsubname, unsigned int def_val,
>> > Â Â Â Â Â Â unsigned int *ret_int);
>> >
>> > +long profile_get_double
>> > + Â (profile_t profile, const char *name, const char *subname,
>> > + Â Â Â Â Â const char *subsubname, double def_val,
>> > + Â Â Â Â Â double *ret_float);
>> > +
>> > Âlong profile_get_boolean
>> > Â Â (profile_t profile, const char *name, const char *subname,
>> > Â Â Â Â Â Â Â Â Â Â const char *subsubname, int def_val,
>> > diff --git a/misc/mke2fs.c b/misc/mke2fs.c
>> > index 23f8c10..313423b 100644
>> > --- a/misc/mke2fs.c
>> > +++ b/misc/mke2fs.c
>> > @@ -1072,6 +1072,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;
>> > @@ -1144,7 +1156,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 */
>> > @@ -1667,6 +1679,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;
>> > diff --git a/tests/mke2fs.conf.in b/tests/mke2fs.conf.in
>> > index 070d5d5..fbe2e2a 100644
>> > --- a/tests/mke2fs.conf.in
>> > +++ b/tests/mke2fs.conf.in
>> > @@ -3,6 +3,7 @@
>> > Â Â blocksize = 4096
>> > Â Â inode_size = 256
>> > Â Â inode_ratio = 16384
>> > + Â reserved_ratio = 5.0
>> > Â Â enable_periodic_fsck = true
>> > Â Â lazy_itable_init = false
>> > Â Â default_mntopts = ^acl
>> >
>>
>>
>
> --
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux