1 (* Process /etc/multipath.conf *)
2 (* The lens is based on the multipath.conf(5) man page *)
7 let comment = Util.comment
9 let dels = Util.del_str
12 let ws = del /[ \t]+/ " "
13 let indent = del /[ \t]*/ ""
14 (* We require that braces are always followed by a newline *)
15 let obr = del /\{([ \t]*)\n/ "{\n"
16 let cbr = del /[ \t]*}[ \t]*\n/ "}\n"
18 let ikey (k:regexp) = indent . key k
20 let section (n:regexp) (b:lens) =
21 [ ikey n . ws . obr . (b|empty|comment)* . cbr ]
23 let kv (k:regexp) (v:regexp) =
24 [ ikey k . ws . store v . eol ]
26 (* FIXME: it would be much more concise to write *)
27 (* [ key k . ws . (bare | quoted) ] *)
28 (* but the typechecker trips over that *)
30 let delq = del /['"]/ "\"" in
31 let bare = del /["']?/ "" . store /[^"' \t\n]+/ . del /["']?/ "" in
32 let quoted = delq . store /.*[ \t].*/ . delq in
33 [ ikey k . ws . bare . eol ]
34 |[ ikey k . ws . quoted . eol ]
36 let wwid = kv "wwid" (Rx.word|"*")
38 (* Settings that can be changed in various places *)
40 kv "path_grouping_policy"
41 /failover|multibus|group_by_(serial|prio|node_name)/
42 |qstr /(getuid|prio)_callout/
43 |qstr /path_(selector|checker)|features/
44 |kv "failback" (Rx.integer | /immediate|manual/)
45 |kv "rr_weight" /priorities|uniform/
46 |kv "no_path_retry" (Rx.integer | /fail|queue/)
47 |kv "rr_min_io" Rx.integer
49 (* A device subsection *)
52 qstr /vendor|product|product_blacklist|hardware_handler/
54 section "device" setting
56 (* The defaults section *)
60 |kv "polling_interval" Rx.integer
61 |kv "udev_dir" Rx.fspath
63 |kv "user_friendly_names" /yes|no/
64 (* These are not in the manpage but in the example multipath.conf *)
66 |kv "max_fds" Rx.integer in
67 section "defaults" setting
69 (* The blacklist and blacklist_exceptions sections *)
75 section /blacklist(_exceptions)?/ setting
77 (* A multipath subsection *)
83 section "multipath" setting
85 (* The multipaths section *)
87 section "multipaths" multipath
89 (* The devices section *)
91 section "devices" device
93 let lns = (comment|empty|defaults|blacklist|devices|multipaths)*
95 let xfm = transform lns (incl "/etc/multipath.conf")