Don't need the ': device' typecasts any more.
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 15 Apr 2008 10:26:46 +0000 (11:26 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 15 Apr 2008 10:26:46 +0000 (11:26 +0100)
virt-df/virt_df_ext2.ml
virt-df/virt_df_linux_swap.ml
virt-df/virt_df_lvm2.ml
virt-df/virt_df_mbr.ml

index 0ea8a25..2d1d1b8 100644 (file)
@@ -27,7 +27,7 @@ open Virt_df
 
 let superblock_offset = 1024L
 
 
 let superblock_offset = 1024L
 
-let probe_ext2 (dev : device) =
+let probe_ext2 dev =
   (* Load the superblock. *)
   let bits = dev#read_bitstring superblock_offset 1024 in
 
   (* Load the superblock. *)
   let bits = dev#read_bitstring superblock_offset 1024 in
 
index ad56149..afd671f 100644 (file)
@@ -23,7 +23,7 @@
 open Virt_df_gettext.Gettext
 open Virt_df
 
 open Virt_df_gettext.Gettext
 open Virt_df
 
-let probe_swap (dev : device) =
+let probe_swap dev =
   (* Load the "superblock" (ie. first 0x1000 bytes). *)
   let bits = dev#read_bitstring 0L 0x1000 in
 
   (* Load the "superblock" (ie. first 0x1000 bytes). *)
   let bits = dev#read_bitstring 0L 0x1000 in
 
index a79ec7f..4247dc3 100644 (file)
@@ -24,9 +24,33 @@ open Printf
 open Virt_df_gettext.Gettext
 open Virt_df
 
 open Virt_df_gettext.Gettext
 open Virt_df
 
-let probe_lvm2 (dev : device) =
-  raise Not_found
+let sector_size = 512
+let sector_size64 = 512L
+
+let pv_label_offset = sector_size64
+
+let rec probe_pv dev =
+  try ignore (read_pv_label dev); true
+  with _ -> false
+
+and read_pv_label dev =
+  (* Load the second sector. *)
+  let bits = dev#read_bitstring pv_label_offset sector_size in
+
+  bitmatch bits with
+  | labelone : 8*8 : bitstring;                (* "LABELONE" *)
+    padding : 16*8 : bitstring;
+    lvm2_ver : 8*8 : bitstring;                (* "LVM2 001" *)
+    uuid : 32*8 : bitstring            (* UUID *)
+      when Bitmatch.string_of_bitstring labelone = "LABELONE" &&
+       Bitmatch.string_of_bitstring lvm2_ver = "LVM2 001" ->
+    uuid
+  | _ ->
+    invalid_arg (sprintf "read_pv_label: %s: not an LVM2 physical volume"
+                  dev#name)
+
+let list_lvs devs = []
 
 (* Register with main code. *)
 let () =
 
 (* Register with main code. *)
 let () =
-  filesystem_type_register "LVM2" probe_lvm2
+  lvm_type_register "LVM2" probe_pv list_lvs
index b9a6cb7..b56189c 100644 (file)
@@ -66,7 +66,7 @@ end
 
     @raise Not_found if it is not an MBR.
  *)
 
     @raise Not_found if it is not an MBR.
  *)
-let rec probe_mbr (dev : device) =
+let rec probe_mbr dev =
   (* Adjust size to sectors. *)
   let size = dev#size /^ sector_size64 in
 
   (* Adjust size to sectors. *)
   let size = dev#size /^ sector_size64 in