diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2008-04-15 13:51:57 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2008-04-15 13:51:57 +0100 |
commit | 2f24ddc7c65beb0df82f208bf7410ea09102f7a8 (patch) | |
tree | b1d4e38297ffebbf82615d75cda1dd76edcf7d6e /virt-df/virt_df.ml | |
parent | be71668a1a4b6c87da3e82458ca97a199a24aa32 (diff) | |
download | virt-top-2f24ddc7c65beb0df82f208bf7410ea09102f7a8.tar.gz virt-top-2f24ddc7c65beb0df82f208bf7410ea09102f7a8.tar.xz virt-top-2f24ddc7c65beb0df82f208bf7410ea09102f7a8.zip |
Refactor the types so we have distinct PV & LV types.
Diffstat (limited to 'virt-df/virt_df.ml')
-rw-r--r-- | virt-df/virt_df.ml | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/virt-df/virt_df.ml b/virt-df/virt_df.ml index 1cd0617..f8f34ab 100644 --- a/virt-df/virt_df.ml +++ b/virt-df/virt_df.ml @@ -98,7 +98,7 @@ and disk_content = [ `Unknown (* Not probed or unknown. *) | `Partitions of partitions (* Contains partitions. *) | `Filesystem of filesystem (* Contains a filesystem directly. *) - | `PhysicalVolume of string (* Contains an LVM PV. *) + | `PhysicalVolume of pv (* Contains an LVM PV. *) ] (* Partitions. *) @@ -117,7 +117,7 @@ and partition_status = Bootable | Nonbootable | Malformed | NullEntry and partition_content = [ `Unknown (* Not probed or unknown. *) | `Filesystem of filesystem (* Filesystem. *) - | `PhysicalVolume of string (* Contains an LVM PV. *) + | `PhysicalVolume of pv (* Contains an LVM PV. *) ] (* Filesystems (also swap devices). *) @@ -135,6 +135,19 @@ and filesystem = { fs_inodes_used : int64; (* Inodes in use. *) } +(* Physical volumes. *) +and pv = { + lvm_plugin_id : lvm_plugin_id; (* The LVM plug-in. *) + pv_uuid : string; (* UUID. *) +} + +(* Logical volumes. *) +and lv = { + lv_dev : device; (* Logical volume device. *) +} + +and lvm_plugin_id = string + (* Convert partition, filesystem types to printable strings for debugging. *) let string_of_partition { part_status = status; part_type = typ; part_dev = dev } = @@ -211,14 +224,15 @@ let probe_for_pv dev = let rec loop = function | [] -> None | (lvm_name, (probe_fn, _)) :: rest -> - if probe_fn dev then Some lvm_name else loop rest + try Some (probe_fn lvm_name dev) + with Not_found -> loop rest in let r = loop !lvm_types in if debug then ( match r with | None -> eprintf "no PV found on %s\n%!" dev#name - | Some lvm_name -> - eprintf "%s contains a %s PV\n%!" dev#name lvm_name + | Some { lvm_plugin_id = name } -> + eprintf "%s contains a %s PV\n%!" dev#name name ); r |