3 Parses /etc/mke2fs.conf
5 Author: Raphael Pinson <raphink@gmail.com>
8 This lens tries to keep as close as possible to `man 5 mke2fs.conf` where possible.
11 This file is licenced under the LGPL v2+, like the rest of Augeas.
16 About: Configuration files
17 This lens applies to /etc/mke2fs.conf. See <filter>.
24 (************************************************************************
25 * Group: USEFUL PRIMITIVES
26 *************************************************************************)
29 let comment = IniFile.comment IniFile.comment_re IniFile.comment_default
32 let sep = IniFile.sep /=[ \t]*/ "="
35 let empty = IniFile.empty
38 The configuration parser of e2fsprogs recognizes different values
39 for booleans, so list all the recognized values *)
40 let boolean = ("y"|"yes"|"true"|"t"|"1"|"on"|"n"|"no"|"false"|"nil"|"0"|"off")
43 let fspath = /[^ \t\n"]+/
46 (************************************************************************
48 *************************************************************************)
52 A generic entry for lens lns *)
53 let entry (kw:regexp) (lns:lens) = Build.key_value_line kw sep lns
57 A list of values with given lens *)
58 let list_sto (kw:regexp) (lns:lens) =
59 entry kw (Quote.do_dquote_opt_nil (Build.opt_list [lns] Sep.comma))
62 Store a regexp as entry value *)
63 let entry_sto (kw:regexp) (val:regexp) =
64 entry kw (Quote.do_dquote_opt_nil (store val))
65 | entry kw (Util.del_str "\"\"")
68 (************************************************************************
69 * Group: COMMON ENTRIES
70 *************************************************************************)
72 (* View: common_entries_list
73 Entries with a list value *)
74 let common_entries_list = ("base_features"|"default_features"|"default_mntopts")
76 (* View: common_entries_int
77 Entries with an integer value *)
78 let common_entries_int = ("cluster_size"|"flex_bg_size"|"force_undo"
79 |"inode_ratio"|"inode_size"|"num_backup_sb")
81 (* View: common_entries_bool
82 Entries with a boolean value *)
83 let common_entries_bool = ("auto_64-bit_support"|"discard"
84 |"enable_periodic_fsck"|"lazy_itable_init"
85 |"lazy_journal_init"|"packed_meta_blocks")
87 (* View: common_entries_string
88 Entries with a string value *)
89 let common_entries_string = ("encoding"|"journal_location")
91 (* View: common_entries_double
92 Entries with a double value *)
93 let common_entries_double = ("reserved_ratio")
96 Entries shared between <defaults> and <fs_types> sections *)
97 let common_entry = list_sto common_entries_list (key Rx.word)
98 | entry_sto common_entries_int Rx.integer
99 | entry_sto common_entries_bool boolean
100 | entry_sto common_entries_string Rx.word
101 | entry_sto common_entries_double Rx.decimal
102 | entry_sto "blocksize" ("-"? . Rx.integer)
103 | entry_sto "hash_alg" ("legacy"|"half_md4"|"tea")
104 | entry_sto "errors" ("continue"|"remount-ro"|"panic")
105 | list_sto "features"
106 ([del /\^/ "^" . label "disable"]?
109 (key Rx.word . Util.del_str "="
112 (************************************************************************
113 * Group: DEFAULTS SECTION
114 *************************************************************************)
116 (* View: defaults_entry
117 Possible entries under the <defaults> section *)
118 let defaults_entry = entry_sto "fs_type" Rx.word
119 | entry_sto "undo_dir" fspath
121 (* View: defaults_title
122 Title for the <defaults> section *)
123 let defaults_title = IniFile.title "defaults"
126 A defaults section *)
127 let defaults = IniFile.record defaults_title
128 ((Util.indent . (defaults_entry|common_entry)) | comment)
131 (************************************************************************
132 * Group: FS_TYPES SECTION
133 *************************************************************************)
135 (* View: fs_types_record
136 Fs group records under the <fs_types> section *)
137 let fs_types_record = [ label "filesystem"
138 . Util.indent . store Rx.word
139 . del /[ \t]*=[ \t]*\{[ \t]*\n/ " = {\n"
140 . ((Util.indent . common_entry) | empty | comment)*
141 . del /[ \t]*\}[ \t]*\n/ " }\n" ]
143 (* View: fs_types_title
144 Title for the <fs_types> section *)
145 let fs_types_title = IniFile.title "fs_types"
148 A fs_types section *)
149 let fs_types = IniFile.record fs_types_title
150 (fs_types_record | comment)
153 (************************************************************************
154 * Group: OPTIONS SECTION
155 *************************************************************************)
157 (* View: options_entries_int
158 Entries with an integer value *)
159 let options_entries_int = ("proceed_delay"|"sync_kludge")
161 (* View: options_entries_bool
162 Entries with a boolean value *)
163 let options_entries_bool = ("old_bitmaps")
165 (* View: options_entry
166 Possible entries under the <options> section *)
167 let options_entry = entry_sto options_entries_int Rx.integer
168 | entry_sto options_entries_bool boolean
170 (* View: defaults_title
171 Title for the <options> section *)
172 let options_title = IniFile.title "options"
176 let options = IniFile.record options_title
177 ((Util.indent . options_entry) | comment)
180 (************************************************************************
181 * Group: LENS AND FILTER
182 *************************************************************************)
187 let lns = (empty|comment)* . (defaults|fs_types|options)*
189 (* Variable: filter *)
190 let filter = incl "/etc/mke2fs.conf"
192 let xfm = transform lns filter