|
|
78c0ed |
From 59fb794a4c47b811998273323cd49cc91f9db7e2 Mon Sep 17 00:00:00 2001
|
|
|
78c0ed |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
78c0ed |
Date: Wed, 12 Jan 2022 16:11:22 +0000
|
|
|
78c0ed |
Subject: [PATCH 8/8] Include mke2fs lens and test from upstream
|
|
|
78c0ed |
|
|
|
78c0ed |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1807010
|
|
|
78c0ed |
---
|
|
|
78c0ed |
lenses/mke2fs.aug | 108 ++++++++++++++++++++++++++---------
|
|
|
78c0ed |
lenses/tests/test_mke2fs.aug | 46 ++++++++++++++-
|
|
|
78c0ed |
2 files changed, 124 insertions(+), 30 deletions(-)
|
|
|
78c0ed |
|
|
|
78c0ed |
diff --git a/lenses/mke2fs.aug b/lenses/mke2fs.aug
|
|
|
78c0ed |
index dc895490..46a7136e 100644
|
|
|
78c0ed |
--- a/lenses/mke2fs.aug
|
|
|
78c0ed |
+++ b/lenses/mke2fs.aug
|
|
|
78c0ed |
@@ -34,6 +34,14 @@ let sep = IniFile.sep /=[ \t]*/ "="
|
|
|
78c0ed |
(* View: empty *)
|
|
|
78c0ed |
let empty = IniFile.empty
|
|
|
78c0ed |
|
|
|
78c0ed |
+(* View: boolean
|
|
|
78c0ed |
+ The configuration parser of e2fsprogs recognizes different values
|
|
|
78c0ed |
+ for booleans, so list all the recognized values *)
|
|
|
78c0ed |
+let boolean = ("y"|"yes"|"true"|"t"|"1"|"on"|"n"|"no"|"false"|"nil"|"0"|"off")
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: fspath *)
|
|
|
78c0ed |
+let fspath = /[^ \t\n"]+/
|
|
|
78c0ed |
+
|
|
|
78c0ed |
|
|
|
78c0ed |
(************************************************************************
|
|
|
78c0ed |
* Group: RECORD TYPES
|
|
|
78c0ed |
@@ -47,27 +55,59 @@ let entry (kw:regexp) (lns:lens) = Build.key_value_line kw sep lns
|
|
|
78c0ed |
|
|
|
78c0ed |
(* View: list_sto
|
|
|
78c0ed |
A list of values with given lens *)
|
|
|
78c0ed |
-let list_sto (kw:regexp) (lns:lens) = counter "item" .
|
|
|
78c0ed |
- entry kw
|
|
|
78c0ed |
- (Build.opt_list
|
|
|
78c0ed |
- [lns]
|
|
|
78c0ed |
- Sep.comma)
|
|
|
78c0ed |
+let list_sto (kw:regexp) (lns:lens) =
|
|
|
78c0ed |
+ entry kw (Quote.do_dquote_opt_nil (Build.opt_list [lns] Sep.comma))
|
|
|
78c0ed |
|
|
|
78c0ed |
(* View: entry_sto
|
|
|
78c0ed |
Store a regexp as entry value *)
|
|
|
78c0ed |
-let entry_sto (kw:regexp) (val:regexp) = entry kw (store val)
|
|
|
78c0ed |
+let entry_sto (kw:regexp) (val:regexp) =
|
|
|
78c0ed |
+ entry kw (Quote.do_dquote_opt_nil (store val))
|
|
|
78c0ed |
+ | entry kw (Util.del_str "\"\"")
|
|
|
78c0ed |
|
|
|
78c0ed |
|
|
|
78c0ed |
(************************************************************************
|
|
|
78c0ed |
* Group: COMMON ENTRIES
|
|
|
78c0ed |
*************************************************************************)
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: common_entries_list
|
|
|
78c0ed |
+ Entries with a list value *)
|
|
|
78c0ed |
+let common_entries_list = ("base_features"|"default_features"|"default_mntopts")
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: common_entries_int
|
|
|
78c0ed |
+ Entries with an integer value *)
|
|
|
78c0ed |
+let common_entries_int = ("cluster_size"|"flex_bg_size"|"force_undo"
|
|
|
78c0ed |
+ |"inode_ratio"|"inode_size"|"num_backup_sb")
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: common_entries_bool
|
|
|
78c0ed |
+ Entries with a boolean value *)
|
|
|
78c0ed |
+let common_entries_bool = ("auto_64-bit_support"|"discard"
|
|
|
78c0ed |
+ |"enable_periodic_fsck"|"lazy_itable_init"
|
|
|
78c0ed |
+ |"lazy_journal_init"|"packed_meta_blocks")
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: common_entries_string
|
|
|
78c0ed |
+ Entries with a string value *)
|
|
|
78c0ed |
+let common_entries_string = ("encoding"|"journal_location")
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: common_entries_double
|
|
|
78c0ed |
+ Entries with a double value *)
|
|
|
78c0ed |
+let common_entries_double = ("reserved_ratio")
|
|
|
78c0ed |
+
|
|
|
78c0ed |
(* View: common_entry
|
|
|
78c0ed |
Entries shared between <defaults> and <fs_types> sections *)
|
|
|
78c0ed |
-let common_entry = list_sto ("base_features"|"default_features")
|
|
|
78c0ed |
- (key Rx.word)
|
|
|
78c0ed |
+let common_entry = list_sto common_entries_list (key Rx.word)
|
|
|
78c0ed |
+ | entry_sto common_entries_int Rx.integer
|
|
|
78c0ed |
+ | entry_sto common_entries_bool boolean
|
|
|
78c0ed |
+ | entry_sto common_entries_string Rx.word
|
|
|
78c0ed |
+ | entry_sto common_entries_double Rx.decimal
|
|
|
78c0ed |
| entry_sto "blocksize" ("-"? . Rx.integer)
|
|
|
78c0ed |
| entry_sto "hash_alg" ("legacy"|"half_md4"|"tea")
|
|
|
78c0ed |
- | entry_sto ("inode_ratio"|"inode_size") Rx.integer
|
|
|
78c0ed |
+ | entry_sto "errors" ("continue"|"remount-ro"|"panic")
|
|
|
78c0ed |
+ | list_sto "features"
|
|
|
78c0ed |
+ ([del /\^/ "^" . label "disable"]?
|
|
|
78c0ed |
+ . key Rx.word)
|
|
|
78c0ed |
+ | list_sto "options"
|
|
|
78c0ed |
+ (key Rx.word . Util.del_str "="
|
|
|
78c0ed |
+ . store Rx.word)
|
|
|
78c0ed |
|
|
|
78c0ed |
(************************************************************************
|
|
|
78c0ed |
* Group: DEFAULTS SECTION
|
|
|
78c0ed |
@@ -75,11 +115,8 @@ let common_entry = list_sto ("base_features"|"default_features")
|
|
|
78c0ed |
|
|
|
78c0ed |
(* View: defaults_entry
|
|
|
78c0ed |
Possible entries under the <defaults> section *)
|
|
|
78c0ed |
-let defaults_entry = entry_sto "force_undo" ("true"|"false")
|
|
|
78c0ed |
- | entry_sto "fs_type" Rx.word
|
|
|
78c0ed |
- | entry_sto "undo_dir" Rx.fspath
|
|
|
78c0ed |
- | list_sto "default_mntopts" (key Rx.word)
|
|
|
78c0ed |
- | entry_sto "enable_periodic_fsck" Rx.integer
|
|
|
78c0ed |
+let defaults_entry = entry_sto "fs_type" Rx.word
|
|
|
78c0ed |
+ | entry_sto "undo_dir" fspath
|
|
|
78c0ed |
|
|
|
78c0ed |
(* View: defaults_title
|
|
|
78c0ed |
Title for the <defaults> section *)
|
|
|
78c0ed |
@@ -95,24 +132,12 @@ let defaults = IniFile.record defaults_title
|
|
|
78c0ed |
* Group: FS_TYPES SECTION
|
|
|
78c0ed |
*************************************************************************)
|
|
|
78c0ed |
|
|
|
78c0ed |
-(* View: fs_types_entry
|
|
|
78c0ed |
- Possible entries under a <fs_types_record> group *)
|
|
|
78c0ed |
-let fs_types_entry =list_sto "features"
|
|
|
78c0ed |
- ([del /\^/ "^" . label "disable"]?
|
|
|
78c0ed |
- . key Rx.word)
|
|
|
78c0ed |
- | list_sto "options"
|
|
|
78c0ed |
- (key Rx.word . Util.del_str "="
|
|
|
78c0ed |
- . store Rx.word)
|
|
|
78c0ed |
- | entry_sto "lazy_itable_init" ("true"|"false")
|
|
|
78c0ed |
- | entry_sto ("flex_bg_size"|"auto_64-bit_support")
|
|
|
78c0ed |
- Rx.integer
|
|
|
78c0ed |
-
|
|
|
78c0ed |
(* View: fs_types_record
|
|
|
78c0ed |
Fs group records under the <fs_types> section *)
|
|
|
78c0ed |
let fs_types_record = [ label "filesystem"
|
|
|
78c0ed |
. Util.indent . store Rx.word
|
|
|
78c0ed |
. del /[ \t]*=[ \t]*\{[ \t]*\n/ " = {\n"
|
|
|
78c0ed |
- . ((Util.indent . (fs_types_entry|common_entry)) | empty | comment)*
|
|
|
78c0ed |
+ . ((Util.indent . common_entry) | empty | comment)*
|
|
|
78c0ed |
. del /[ \t]*\}[ \t]*\n/ " }\n" ]
|
|
|
78c0ed |
|
|
|
78c0ed |
(* View: fs_types_title
|
|
|
78c0ed |
@@ -125,6 +150,33 @@ let fs_types = IniFile.record fs_types_title
|
|
|
78c0ed |
(fs_types_record | comment)
|
|
|
78c0ed |
|
|
|
78c0ed |
|
|
|
78c0ed |
+(************************************************************************
|
|
|
78c0ed |
+ * Group: OPTIONS SECTION
|
|
|
78c0ed |
+ *************************************************************************)
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: options_entries_int
|
|
|
78c0ed |
+ Entries with an integer value *)
|
|
|
78c0ed |
+let options_entries_int = ("proceed_delay"|"sync_kludge")
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: options_entries_bool
|
|
|
78c0ed |
+ Entries with a boolean value *)
|
|
|
78c0ed |
+let options_entries_bool = ("old_bitmaps")
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: options_entry
|
|
|
78c0ed |
+ Possible entries under the <options> section *)
|
|
|
78c0ed |
+let options_entry = entry_sto options_entries_int Rx.integer
|
|
|
78c0ed |
+ | entry_sto options_entries_bool boolean
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: defaults_title
|
|
|
78c0ed |
+ Title for the <options> section *)
|
|
|
78c0ed |
+let options_title = IniFile.title "options"
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+(* View: options
|
|
|
78c0ed |
+ A options section *)
|
|
|
78c0ed |
+let options = IniFile.record options_title
|
|
|
78c0ed |
+ ((Util.indent . options_entry) | comment)
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+
|
|
|
78c0ed |
(************************************************************************
|
|
|
78c0ed |
* Group: LENS AND FILTER
|
|
|
78c0ed |
*************************************************************************)
|
|
|
78c0ed |
@@ -132,7 +184,7 @@ let fs_types = IniFile.record fs_types_title
|
|
|
78c0ed |
(* View: lns
|
|
|
78c0ed |
The mke2fs lens
|
|
|
78c0ed |
*)
|
|
|
78c0ed |
-let lns = (empty|comment)* . (defaults|fs_types)*
|
|
|
78c0ed |
+let lns = (empty|comment)* . (defaults|fs_types|options)*
|
|
|
78c0ed |
|
|
|
78c0ed |
(* Variable: filter *)
|
|
|
78c0ed |
let filter = incl "/etc/mke2fs.conf"
|
|
|
78c0ed |
diff --git a/lenses/tests/test_mke2fs.aug b/lenses/tests/test_mke2fs.aug
|
|
|
78c0ed |
index f1ddbe9e..bcf2fe61 100644
|
|
|
78c0ed |
--- a/lenses/tests/test_mke2fs.aug
|
|
|
78c0ed |
+++ b/lenses/tests/test_mke2fs.aug
|
|
|
78c0ed |
@@ -33,6 +33,10 @@ module Test_mke2fs =
|
|
|
78c0ed |
inode_ratio = 1048576
|
|
|
78c0ed |
blocksize = -1
|
|
|
78c0ed |
}
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+[options]
|
|
|
78c0ed |
+ proceed_delay = 1
|
|
|
78c0ed |
+ sync_kludge = 1
|
|
|
78c0ed |
"
|
|
|
78c0ed |
|
|
|
78c0ed |
test Mke2fs.lns get conf =
|
|
|
78c0ed |
@@ -74,10 +78,48 @@ module Test_mke2fs =
|
|
|
78c0ed |
{ "inode_ratio" = "4096" } }
|
|
|
78c0ed |
{ "filesystem" = "largefile"
|
|
|
78c0ed |
{ "inode_ratio" = "1048576" }
|
|
|
78c0ed |
- { "blocksize" = "-1" } } }
|
|
|
78c0ed |
+ { "blocksize" = "-1" } }
|
|
|
78c0ed |
+ {} }
|
|
|
78c0ed |
+ { "options"
|
|
|
78c0ed |
+ { "proceed_delay" = "1" }
|
|
|
78c0ed |
+ { "sync_kludge" = "1" } }
|
|
|
78c0ed |
|
|
|
78c0ed |
|
|
|
78c0ed |
-test Mke2fs.fs_types_entry
|
|
|
78c0ed |
+ let quoted_conf = "[defaults]
|
|
|
78c0ed |
+ base_features = \"sparse_super,filetype,resize_inode,dir_index,ext_attr\"
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+[fs_types]
|
|
|
78c0ed |
+ ext4dev = {
|
|
|
78c0ed |
+ features = \"has_journal,^extent\"
|
|
|
78c0ed |
+ default_mntopts = \"user_xattr\"
|
|
|
78c0ed |
+ encoding = \"utf8\"
|
|
|
78c0ed |
+ encoding = \"\"
|
|
|
78c0ed |
+ }
|
|
|
78c0ed |
+"
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+ test Mke2fs.lns get quoted_conf =
|
|
|
78c0ed |
+ { "defaults"
|
|
|
78c0ed |
+ { "base_features"
|
|
|
78c0ed |
+ { "sparse_super" }
|
|
|
78c0ed |
+ { "filetype" }
|
|
|
78c0ed |
+ { "resize_inode" }
|
|
|
78c0ed |
+ { "dir_index" }
|
|
|
78c0ed |
+ { "ext_attr" } }
|
|
|
78c0ed |
+ {} }
|
|
|
78c0ed |
+ { "fs_types"
|
|
|
78c0ed |
+ { "filesystem" = "ext4dev"
|
|
|
78c0ed |
+ { "features"
|
|
|
78c0ed |
+ { "has_journal" }
|
|
|
78c0ed |
+ { "extent"
|
|
|
78c0ed |
+ { "disable" } } }
|
|
|
78c0ed |
+ { "default_mntopts"
|
|
|
78c0ed |
+ { "user_xattr" } }
|
|
|
78c0ed |
+ { "encoding" = "utf8" }
|
|
|
78c0ed |
+ { "encoding" }
|
|
|
78c0ed |
+ } }
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+
|
|
|
78c0ed |
+test Mke2fs.common_entry
|
|
|
78c0ed |
put "features = has_journal,^extent\n"
|
|
|
78c0ed |
after set "/features/has_journal/disable" "";
|
|
|
78c0ed |
rm "/features/extent/disable" = "features = ^has_journal,extent\n"
|
|
|
78c0ed |
--
|
|
|
78c0ed |
2.31.1
|
|
|
78c0ed |
|