3 Parses automounter file based maps
5 Author: Dominic Cleal <dcleal@redhat.com>
11 This file is licenced under the LGPL v2+, like the rest of Augeas.
16 About: Configuration files
17 This lens applies to /etc/auto.*, auto_*, excluding known scripts.
20 The <Test_Automounter> file contains various examples and tests.
26 (************************************************************************
27 * Group: USEFUL PRIMITIVES
28 *************************************************************************)
34 let empty = Util.empty
37 let comment = Util.comment
40 let path = /[^-+#: \t\n][^#: \t\n]*/
43 let hostname = /[^-:#\(\), \n\t][^:#\(\), \n\t]*/
45 (* An option label can't contain comma, comment, equals, or space *)
46 let optlabel = /[^,#:\(\)= \n\t]+/
47 let spec = /[^,#:\(\)= \n\t][^ \n\t]*/
50 let weight = Rx.integer
53 let map_name = /[^: \t\n]+/
55 (* View: entry_multimount_sep
56 Separator for multimount entries, permits line spanning with "\" *)
57 let entry_multimount_sep = del /[ \t]+(\\\\[ \t]*\n[ \t]+)?/ " "
59 (************************************************************************
61 *************************************************************************)
64 Key for a map entry *)
65 let entry_mkey = store path
68 Path component of an entry location *)
69 let entry_path = [ label "path" . store path ]
72 Host component with optional weight of an entry location *)
73 let entry_host = [ label "host" . store hostname
74 . ( Util.del_str "(" . [ label "weight"
75 . store weight ] . Util.del_str ")" )? ]
77 (* View: comma_sep_list
78 Parses options for filesystems *)
79 let comma_sep_list (l:string) =
80 let value = [ label "value" . Util.del_str "=" . store Rx.neg1 ] in
81 let lns = [ label l . store optlabel . value? ] in
82 Build.opt_list lns Sep.comma
84 (* View: entry_options *)
85 let entry_options = Util.del_str "-" . comma_sep_list "opt" . Util.del_ws_tab
87 (* View: entry_location
88 A single location with one or more hosts, and one path *)
89 let entry_location = ( entry_host . ( Sep.comma . entry_host )* )?
90 . Sep.colon . entry_path
92 (* View: entry_locations
93 Multiple locations (each with one or more hosts), separated by spaces *)
94 let entry_locations = [ label "location" . counter "location"
95 . [ seq "location" . entry_location ]
96 . ( [ Util.del_ws_spc . seq "location" . entry_location ] )* ]
98 (* View: entry_multimount
99 Parses one of many mountpoints given for a multimount line *)
100 let entry_multimount = entry_mkey . Util.del_ws_tab . entry_options? . entry_locations
102 (* View: entry_multimounts
103 Parses multiple mountpoints given on an entry line *)
104 let entry_multimounts = [ label "mount" . counter "mount"
105 . [ seq "mount" . entry_multimount ]
106 . ( [ entry_multimount_sep . seq "mount" . entry_multimount ] )* ]
109 A single map entry from start to finish, including multi-mounts *)
110 let entry = [ seq "entry" . entry_mkey . Util.del_ws_tab . entry_options?
111 . ( entry_locations | entry_multimounts ) . Util.eol ]
114 An include line starting with a "+" and a map name *)
115 let include = [ seq "entry" . store "+" . Util.del_opt_ws ""
116 . [ label "map" . store map_name ] . Util.eol ]
119 let lns = ( empty | comment | entry | include ) *
122 Exclude scripts/executable maps from here *)
123 let filter = incl "/etc/auto.*"
125 . excl "/etc/auto.master"
126 . excl "/etc/auto_master"
127 . excl "/etc/auto.net"
128 . excl "/etc/auto.smb"
131 let xfm = transform lns filter