5 Author: Gabriel de Perthuis <g2p.code+augeas@gmail.com>
8 This file is licensed under the LGPL v2+.
10 About: Configuration files
11 This lens applies to files in /etc/lvm/backup and /etc/lvm/archive.
14 The <Test_LVM> file contains various examples and tests.
20 (* See lvm2/libdm/libdm-config.c for tokenisation;
21 * libdm uses a blacklist but I prefer the safer whitelist approach. *)
23 * The left hand side of a definition *)
24 let identifier = /[a-zA-Z0-9_-]+/
26 (* strings can contain backslash-escaped dquotes, but I don't know
27 * how to get the message across to augeas *)
28 let str = [label "str". Quote.do_dquote (store /([^\"]|\\\\.)*/)]
29 let int = [label "int". store Rx.relinteger]
31 * A literal without structure *)
32 let flat_literal = int|str
34 (* allow multiline and mixed int/str, used for raids and stripes *)
36 * A list containing flat literals *)
38 label "list" . counter "list"
39 . del /\[[ \t\n]*/ "["
40 .([seq "list". flat_literal . del /,[ \t\n]*/ ", "]*
41 . [seq "list". flat_literal . del /[ \t\n]*/ ""])?
45 * Any value that appears on the right hand side of an assignment *)
46 let val = flat_literal | list
49 * A line that doesn't contain a statement *)
54 (* Build.block couldn't be reused, because of recursion and
55 * a different philosophy of whitespace handling. *)
57 * An assignment, or a block containing definitions *)
59 Util.indent . key identifier . (
60 del /[ \t]*\{\n/ " {\n"
61 .[label "dict".(nondef | def)*]
62 . Util.indent . Util.del_str "}\n"
63 |Sep.space_equal . val . Util.comment_or_eol)]
67 let lns = (nondef | def)*
70 incl "/etc/lvm/archive/*.vg"
71 . incl "/etc/lvm/backup/*"
72 . incl "/etc/lvm/lvm.conf"
75 let xfm = transform lns filter