1 (* 'df' command for virtual domains.
3 (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program 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
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 open Virt_df_gettext.Gettext
28 let sector_size64 = 512L
30 let pv_label_offset = sector_size64
32 (* Probe to see if it's an LVM2 PV. Look for the "LABELONE" label. *)
33 let rec probe_pv dev =
34 try ignore (read_pv_label dev); true
37 and read_pv_label dev =
38 (* Load the second sector. *)
39 let bits = dev#read_bitstring pv_label_offset sector_size in
41 Bitmatch.hexdump_bitstring stdout bits;
44 | labelone : 8*8 : bitstring; (* "LABELONE" *)
45 padding : 16*8 : bitstring;
46 lvm2_ver : 8*8 : bitstring; (* "LVM2 001" *)
47 uuid : 32*8 : bitstring (* UUID *)
48 when Bitmatch.string_of_bitstring labelone = "LABELONE" &&
49 Bitmatch.string_of_bitstring lvm2_ver = "LVM2 001" ->
52 invalid_arg (sprintf "read_pv_label: %s: not an LVM2 physical volume"
55 (* We are passed a list of devices which we previously identified
56 * as PVs belonging to us. From these produce a list of all LVs
57 * (as devices) and return them. Note that we don't try to detect
58 * what is on these LVs - that will be done in the main code.
60 let list_lvs devs = []
62 (* Register with main code. *)
64 lvm_type_register "LVM2" probe_pv list_lvs