From f49c1098c1ecb91d31e0a470524043d955df91e4 Mon Sep 17 00:00:00 2001 From: Pino Toscano <ptoscano@redhat.com> Date: Fri, 16 Aug 2019 14:19:27 +0200 Subject: [PATCH 1/4] Mke2fs: fix handling of booleans Add a proper regexp to represent them, according to the mke2fs.conf(5) documentation. Fix the lazy_itable_init, and auto_64-bit_support keys of fs_types to use this regexp, as they are parsed as boolean. --- lenses/mke2fs.aug | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lenses/mke2fs.aug b/lenses/mke2fs.aug index dc8954902..08a5b7113 100644 --- a/lenses/mke2fs.aug +++ b/lenses/mke2fs.aug @@ -34,6 +34,11 @@ let sep = IniFile.sep /=[ \t]*/ "=" (* View: empty *) let empty = IniFile.empty +(* View: boolean + The configuration parser of e2fsprogs recognizes different values + for booleans, so list all the recognized values *) +let boolean = ("y"|"yes"|"true"|"t"|"1"|"on"|"n"|"no"|"false"|"nil"|"0"|"off") + (************************************************************************ * Group: RECORD TYPES @@ -103,8 +108,9 @@ let fs_types_entry =list_sto "features" | list_sto "options" (key Rx.word . Util.del_str "=" . store Rx.word) - | entry_sto "lazy_itable_init" ("true"|"false") - | entry_sto ("flex_bg_size"|"auto_64-bit_support") + | entry_sto ("lazy_itable_init"|"auto_64-bit_support") + boolean + | entry_sto "flex_bg_size" Rx.integer (* View: fs_types_record From 058c8560206ea6e26953a725d49cd6f74afe6f94 Mon Sep 17 00:00:00 2001 From: Pino Toscano <ptoscano@redhat.com> Date: Fri, 16 Aug 2019 15:04:13 +0200 Subject: [PATCH 2/4] Mke2fs: refactor fs_entry options According to the mke2fs.conf(5) documentation, all the entries that appear in the various tags in the [fs_types] stanza may be used also in the [default] section; hence: - fold fs_types_entry into common_entry - move almost all the options (except fs_type, and undo_dir) from defaults_entry to common_entry so the options apply to both cases. Also, in an attempt to make the list of options slightly maintainable, add few lists with names of options with common types (list, int, bool). --- lenses/mke2fs.aug | 46 ++++++++++++++++++++---------------- lenses/tests/test_mke2fs.aug | 2 +- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/lenses/mke2fs.aug b/lenses/mke2fs.aug index 08a5b7113..10899e724 100644 --- a/lenses/mke2fs.aug +++ b/lenses/mke2fs.aug @@ -66,13 +66,33 @@ let entry_sto (kw:regexp) (val:regexp) = entry kw (store val) (************************************************************************ * Group: COMMON ENTRIES *************************************************************************) + +(* View: common_entries_list + Entries with a list value *) +let common_entries_list = ("base_features"|"default_features"|"default_mntopts") + +(* View: common_entries_int + Entries with an integer value *) +let common_entries_int = ("enable_periodic_fsck"|"flex_bg_size"|"force_undo" + |"inode_ratio"|"inode_size") + +(* View: common_entries_bool + Entries with a boolean value *) +let common_entries_bool = ("lazy_itable_init"|"auto_64-bit_support") + (* View: common_entry Entries shared between <defaults> and <fs_types> sections *) -let common_entry = list_sto ("base_features"|"default_features") - (key Rx.word) +let common_entry = list_sto common_entries_list (key Rx.word) + | entry_sto common_entries_int Rx.integer + | entry_sto common_entries_bool boolean | entry_sto "blocksize" ("-"? . Rx.integer) | entry_sto "hash_alg" ("legacy"|"half_md4"|"tea") - | entry_sto ("inode_ratio"|"inode_size") Rx.integer + | list_sto "features" + ([del /\^/ "^" . label "disable"]? + . key Rx.word) + | list_sto "options" + (key Rx.word . Util.del_str "=" + . store Rx.word) (************************************************************************ * Group: DEFAULTS SECTION @@ -80,11 +100,8 @@ let common_entry = list_sto ("base_features"|"default_features") (* View: defaults_entry Possible entries under the <defaults> section *) -let defaults_entry = entry_sto "force_undo" ("true"|"false") - | entry_sto "fs_type" Rx.word +let defaults_entry = entry_sto "fs_type" Rx.word | entry_sto "undo_dir" Rx.fspath - | list_sto "default_mntopts" (key Rx.word) - | entry_sto "enable_periodic_fsck" Rx.integer (* View: defaults_title Title for the <defaults> section *) @@ -100,25 +117,12 @@ let defaults = IniFile.record defaults_title * Group: FS_TYPES SECTION *************************************************************************) -(* View: fs_types_entry - Possible entries under a <fs_types_record> group *) -let fs_types_entry =list_sto "features" - ([del /\^/ "^" . label "disable"]? - . key Rx.word) - | list_sto "options" - (key Rx.word . Util.del_str "=" - . store Rx.word) - | entry_sto ("lazy_itable_init"|"auto_64-bit_support") - boolean - | entry_sto "flex_bg_size" - Rx.integer - (* View: fs_types_record Fs group records under the <fs_types> section *) let fs_types_record = [ label "filesystem" . Util.indent . store Rx.word . del /[ \t]*=[ \t]*\{[ \t]*\n/ " = {\n" - . ((Util.indent . (fs_types_entry|common_entry)) | empty | comment)* + . ((Util.indent . common_entry) | empty | comment)* . del /[ \t]*\}[ \t]*\n/ " }\n" ] (* View: fs_types_title diff --git a/lenses/tests/test_mke2fs.aug b/lenses/tests/test_mke2fs.aug index f1ddbe9ec..69c23b4ea 100644 --- a/lenses/tests/test_mke2fs.aug +++ b/lenses/tests/test_mke2fs.aug @@ -77,7 +77,7 @@ module Test_mke2fs = { "blocksize" = "-1" } } } -test Mke2fs.fs_types_entry +test Mke2fs.common_entry put "features = has_journal,^extent\n" after set "/features/has_journal/disable" ""; rm "/features/extent/disable" = "features = ^has_journal,extent\n" From c26bc02d3d4c597d24387eff6b5429731e36570a Mon Sep 17 00:00:00 2001 From: Pino Toscano <ptoscano@redhat.com> Date: Fri, 16 Aug 2019 16:54:31 +0200 Subject: [PATCH 3/4] Mke2fs: add more defaults/fs_types entries Add more common entries for the [defaults] stanza, or inside a [fs_types] tag, fixing the types to match documentation/code. This does not cover all the possible entries available though. --- lenses/mke2fs.aug | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lenses/mke2fs.aug b/lenses/mke2fs.aug index 10899e724..106dbe98f 100644 --- a/lenses/mke2fs.aug +++ b/lenses/mke2fs.aug @@ -73,20 +73,33 @@ let common_entries_list = ("base_features"|"default_features"|"default_mntopts") (* View: common_entries_int Entries with an integer value *) -let common_entries_int = ("enable_periodic_fsck"|"flex_bg_size"|"force_undo" - |"inode_ratio"|"inode_size") +let common_entries_int = ("cluster_size"|"flex_bg_size"|"force_undo" + |"inode_ratio"|"inode_size"|"num_backup_sb") (* View: common_entries_bool Entries with a boolean value *) -let common_entries_bool = ("lazy_itable_init"|"auto_64-bit_support") +let common_entries_bool = ("auto_64-bit_support"|"discard" + |"enable_periodic_fsck"|"lazy_itable_init" + |"lazy_journal_init"|"packed_meta_blocks") + +(* View: common_entries_string + Entries with a string value *) +let common_entries_string = ("encoding"|"journal_location") + +(* View: common_entries_double + Entries with a double value *) +let common_entries_double = ("reserved_ratio") (* View: common_entry Entries shared between <defaults> and <fs_types> sections *) let common_entry = list_sto common_entries_list (key Rx.word) | entry_sto common_entries_int Rx.integer | entry_sto common_entries_bool boolean + | entry_sto common_entries_string Rx.word + | entry_sto common_entries_double Rx.decimal | entry_sto "blocksize" ("-"? . Rx.integer) | entry_sto "hash_alg" ("legacy"|"half_md4"|"tea") + | entry_sto "errors" ("continue"|"remount-ro"|"panic") | list_sto "features" ([del /\^/ "^" . label "disable"]? . key Rx.word) From 8a19daa1abe359897cdfa98d8bd18c4f8b9307c0 Mon Sep 17 00:00:00 2001 From: Pino Toscano <ptoscano@redhat.com> Date: Fri, 16 Aug 2019 17:02:59 +0200 Subject: [PATCH 4/4] Mke2fs: handle the [options] stanza Handle the two documented tags of it. --- lenses/mke2fs.aug | 24 +++++++++++++++++++++++- lenses/tests/test_mke2fs.aug | 10 +++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lenses/mke2fs.aug b/lenses/mke2fs.aug index 106dbe98f..8a095758f 100644 --- a/lenses/mke2fs.aug +++ b/lenses/mke2fs.aug @@ -148,6 +148,28 @@ let fs_types = IniFile.record fs_types_title (fs_types_record | comment) +(************************************************************************ + * Group: OPTIONS SECTION + *************************************************************************) + +(* View: options_entries_int + Entries with an integer value *) +let options_entries_int = ("proceed_delay"|"sync_kludge") + +(* View: options_entry + Possible entries under the <options> section *) +let options_entry = entry_sto options_entries_int Rx.integer + +(* View: defaults_title + Title for the <options> section *) +let options_title = IniFile.title "options" + +(* View: options + A options section *) +let options = IniFile.record options_title + ((Util.indent . options_entry) | comment) + + (************************************************************************ * Group: LENS AND FILTER *************************************************************************) @@ -155,7 +177,7 @@ let fs_types = IniFile.record fs_types_title (* View: lns The mke2fs lens *) -let lns = (empty|comment)* . (defaults|fs_types)* +let lns = (empty|comment)* . (defaults|fs_types|options)* (* Variable: filter *) let filter = incl "/etc/mke2fs.conf" diff --git a/lenses/tests/test_mke2fs.aug b/lenses/tests/test_mke2fs.aug index 69c23b4ea..67dcfb20d 100644 --- a/lenses/tests/test_mke2fs.aug +++ b/lenses/tests/test_mke2fs.aug @@ -33,6 +33,10 @@ module Test_mke2fs = inode_ratio = 1048576 blocksize = -1 } + +[options] + proceed_delay = 1 + sync_kludge = 1 " test Mke2fs.lns get conf = @@ -74,7 +78,11 @@ module Test_mke2fs = { "inode_ratio" = "4096" } } { "filesystem" = "largefile" { "inode_ratio" = "1048576" } - { "blocksize" = "-1" } } } + { "blocksize" = "-1" } } + {} } + { "options" + { "proceed_delay" = "1" } + { "sync_kludge" = "1" } } test Mke2fs.common_entry