1 (* 'df' command for virtual domains.
2 (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version,
9 with the OCaml linking exception described in ../COPYING.LIB.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 (* Part of the parser for LVM2 metadata. *)
23 type metadata = metastmt list
25 and metastmt = string * metavalue
28 | Metadata of metadata (* name { ... } *)
29 | String of string (* name = "..." *)
32 | List of metavalue list (* name = [...] *)
34 let rec output_metadata chan md =
35 _output_metadata chan "" md
37 and _output_metadata chan prefix = function
39 | (name, value) :: rest ->
40 output_string chan prefix;
41 output_string chan name;
42 output_string chan " = ";
43 output_metavalue chan prefix value;
44 output_string chan "\n";
45 _output_metadata chan prefix rest
47 and output_metavalue chan prefix = function
49 output_string chan "{\n";
50 _output_metadata chan (prefix ^ " ") md;
51 output_string chan prefix;
52 output_string chan "}";
55 output_string chan str;
58 output_string chan (Int63.to_string i)
60 output_string chan (string_of_float f)
62 | List [x] -> output_metavalue chan prefix x
64 output_metavalue chan prefix x;
65 output_string chan ", ";
66 output_metavalue chan prefix (List xs)