Imported Upstream version 1.3.0
[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
38 (************************************************************************
39  * Group:                 RECORD TYPES
40  *************************************************************************)
41
42
43 (* View: entry
44     A generic entry for lens lns *)
45 let entry (kw:regexp) (lns:lens) = Build.key_value_line kw sep lns
46
47
48 (* View: list_sto
49     A list of values with given lens *)
50 let list_sto (kw:regexp) (lns:lens) = counter "item" .
51                                           entry kw
52                                             (Build.opt_list 
53                                               [lns]
54                                               Sep.comma)
55
56 (* View: entry_sto
57     Store a regexp as entry value *)
58 let entry_sto (kw:regexp) (val:regexp) = entry kw (store val)
59
60
61 (************************************************************************
62  * Group:                 COMMON ENTRIES
63  *************************************************************************)
64 (* View: common_entry
65      Entries shared between <defaults> and <fs_types> sections *)
66 let common_entry   = list_sto ("base_features"|"default_features")
67                         (key Rx.word)
68                    | entry_sto "blocksize" ("-"? . Rx.integer)
69                    | entry_sto "hash_alg" ("legacy"|"half_md4"|"tea")
70                    | entry_sto ("inode_ratio"|"inode_size") Rx.integer
71
72 (************************************************************************
73  * Group:                 DEFAULTS SECTION
74  *************************************************************************)
75
76 (* View: defaults_entry
77     Possible entries under the <defaults> section *)
78 let defaults_entry = entry_sto "force_undo" ("true"|"false")
79                    | entry_sto "fs_type" Rx.word
80                    | entry_sto "undo_dir" Rx.fspath
81                    | list_sto "default_mntopts" (key Rx.word)
82                    | entry_sto "enable_periodic_fsck" Rx.integer
83                    
84 (* View: defaults_title
85     Title for the <defaults> section *)
86 let defaults_title  = IniFile.title "defaults"
87
88 (* View: defaults
89     A defaults section *)
90 let defaults = IniFile.record defaults_title
91                   ((Util.indent . (defaults_entry|common_entry)) | comment)
92
93
94 (************************************************************************
95  * Group:                 FS_TYPES SECTION
96  *************************************************************************)
97
98 (* View: fs_types_entry
99     Possible entries under a <fs_types_record> group *)
100 let fs_types_entry =list_sto "features"
101                         ([del /\^/ "^" . label "disable"]?
102                                            . key Rx.word)
103                    | list_sto "options"
104                         (key Rx.word . Util.del_str "="
105                        . store Rx.word)
106                    | entry_sto "lazy_itable_init" ("true"|"false")
107                    | entry_sto ("flex_bg_size"|"auto_64-bit_support")
108                        Rx.integer
109
110 (* View: fs_types_record
111      Fs group records under the <fs_types> section *)
112 let fs_types_record = [ label "filesystem"
113                      . Util.indent . store Rx.word
114                      . del /[ \t]*=[ \t]*\{[ \t]*\n/ " = {\n"
115                      . ((Util.indent . (fs_types_entry|common_entry)) | empty | comment)*
116                      . del /[ \t]*\}[ \t]*\n/ " }\n" ]
117
118 (* View: fs_types_title
119     Title for the <fs_types> section *)
120 let fs_types_title = IniFile.title "fs_types"
121
122 (* View: fs_types
123     A fs_types section *)
124 let fs_types = IniFile.record fs_types_title
125                   (fs_types_record | comment)
126
127
128 (************************************************************************
129  * Group:                 LENS AND FILTER
130  *************************************************************************)
131
132 (* View: lns
133      The mke2fs lens
134 *)
135 let lns = (empty|comment)* . (defaults|fs_types)*
136
137 (* Variable: filter *)
138 let filter = incl "/etc/mke2fs.conf"
139
140 let xfm = transform lns filter
141
142