Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / mke2fs.aug
1 (*
2 Module: Mke2fs
3   Parses /etc/mke2fs.conf
4
5 Author: Raphael Pinson <raphink@gmail.com>
6
7 About: Reference
8   This lens tries to keep as close as possible to `man 5 mke2fs.conf` where possible.
9
10 About: License
11    This file is licenced under the LGPL v2+, like the rest of Augeas.
12
13 About: Lens Usage
14    To be documented
15
16 About: Configuration files
17    This lens applies to /etc/mke2fs.conf. See <filter>.
18 *)
19
20
21 module Mke2fs =
22   autoload xfm
23
24 (************************************************************************
25  * Group:                 USEFUL PRIMITIVES
26  *************************************************************************)
27
28 (* View: comment *)
29 let comment = IniFile.comment IniFile.comment_re IniFile.comment_default
30
31 (* View: sep *)
32 let sep = IniFile.sep /=[ \t]*/ "="
33
34 (* View: empty *)
35 let empty = IniFile.empty
36
37 (* View: boolean
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")
41
42 (* View: fspath *)
43 let fspath = /[^ \t\n"]+/
44
45
46 (************************************************************************
47  * Group:                 RECORD TYPES
48  *************************************************************************)
49
50
51 (* View: entry
52     A generic entry for lens lns *)
53 let entry (kw:regexp) (lns:lens) = Build.key_value_line kw sep lns
54
55
56 (* View: list_sto
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))
60
61 (* View: entry_sto
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 "\"\"")
66
67
68 (************************************************************************
69  * Group:                 COMMON ENTRIES
70  *************************************************************************)
71
72 (* View: common_entries_list
73     Entries with a list value *)
74 let common_entries_list = ("base_features"|"default_features"|"default_mntopts")
75
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")
80
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")
86
87 (* View: common_entries_string
88     Entries with a string value *)
89 let common_entries_string = ("encoding"|"journal_location")
90
91 (* View: common_entries_double
92     Entries with a double value *)
93 let common_entries_double = ("reserved_ratio")
94
95 (* View: common_entry
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"]?
107                                            . key Rx.word)
108                    | list_sto "options"
109                         (key Rx.word . Util.del_str "="
110                        . store Rx.word)
111
112 (************************************************************************
113  * Group:                 DEFAULTS SECTION
114  *************************************************************************)
115
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
120                    
121 (* View: defaults_title
122     Title for the <defaults> section *)
123 let defaults_title  = IniFile.title "defaults"
124
125 (* View: defaults
126     A defaults section *)
127 let defaults = IniFile.record defaults_title
128                   ((Util.indent . (defaults_entry|common_entry)) | comment)
129
130
131 (************************************************************************
132  * Group:                 FS_TYPES SECTION
133  *************************************************************************)
134
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" ]
142
143 (* View: fs_types_title
144     Title for the <fs_types> section *)
145 let fs_types_title = IniFile.title "fs_types"
146
147 (* View: fs_types
148     A fs_types section *)
149 let fs_types = IniFile.record fs_types_title
150                   (fs_types_record | comment)
151
152
153 (************************************************************************
154  * Group:                 OPTIONS SECTION
155  *************************************************************************)
156
157 (* View: options_entries_int
158     Entries with an integer value *)
159 let options_entries_int = ("proceed_delay"|"sync_kludge")
160
161 (* View: options_entries_bool
162     Entries with a boolean value *)
163 let options_entries_bool = ("old_bitmaps")
164
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
169
170 (* View: defaults_title
171     Title for the <options> section *)
172 let options_title  = IniFile.title "options"
173
174 (* View: options
175     A options section *)
176 let options = IniFile.record options_title
177                   ((Util.indent . options_entry) | comment)
178
179
180 (************************************************************************
181  * Group:                 LENS AND FILTER
182  *************************************************************************)
183
184 (* View: lns
185      The mke2fs lens
186 *)
187 let lns = (empty|comment)* . (defaults|fs_types|options)*
188
189 (* Variable: filter *)
190 let filter = incl "/etc/mke2fs.conf"
191
192 let xfm = transform lns filter
193
194