From 65163f9e553f391a9189721485d0998edbdd7b6e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH 1/1] Generate uniquifier so that private data functions will work. --- lib/diskimage_ext2.ml | 15 +++++++++------ lib/diskimage_linux_swap.ml | 15 +++++++++------ lib/diskimage_linux_swsuspend.ml | 15 +++++++++------ lib/diskimage_lvm2.ml | 17 ++++++++++------- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/lib/diskimage_ext2.ml b/lib/diskimage_ext2.ml index ade7940..09c7c58 100644 --- a/lib/diskimage_ext2.ml +++ b/lib/diskimage_ext2.ml @@ -127,7 +127,7 @@ let rec probe dev = let fs_dev = new blocksize_overlay block_size dev in { - fs_cb = callbacks; + fs_cb = callbacks (); fs_dev = fs_dev; fs_blocksize = block_size; @@ -153,11 +153,14 @@ let rec probe dev = and offset_is_free _ _ = false -and callbacks = { - fs_cb_name = id; - fs_cb_printable_name = "Linux ext2/3"; - fs_cb_offset_is_free = offset_is_free; -} +and callbacks = + let i = ref 0 in + fun () -> { + fs_cb_uq = (incr i; !i); + fs_cb_name = id; + fs_cb_printable_name = "Linux ext2/3"; + fs_cb_offset_is_free = offset_is_free; + } (* Register the plugin. *) let () = register_plugin ~filesystem:probe id diff --git a/lib/diskimage_linux_swap.ml b/lib/diskimage_linux_swap.ml index a3c1b23..072e4e6 100644 --- a/lib/diskimage_linux_swap.ml +++ b/lib/diskimage_linux_swap.ml @@ -40,7 +40,7 @@ let rec probe dev = let fs_dev = new blocksize_overlay blocksize dev in { - fs_cb = callbacks; + fs_cb = callbacks (); fs_dev = fs_dev; fs_blocksize = blocksize; @@ -65,11 +65,14 @@ let rec probe dev = *) and offset_is_free _ offset = offset >= blocksize -and callbacks = { - fs_cb_name = id; - fs_cb_printable_name = "Linux swap"; - fs_cb_offset_is_free = offset_is_free; -} +and callbacks = + let i = ref 0 in + fun () -> { + fs_cb_uq = (incr i; !i); + fs_cb_name = id; + fs_cb_printable_name = "Linux swap"; + fs_cb_offset_is_free = offset_is_free; + } (* Register the plugin. *) let () = register_plugin ~filesystem:probe id diff --git a/lib/diskimage_linux_swsuspend.ml b/lib/diskimage_linux_swsuspend.ml index 4fec7b3..93da753 100644 --- a/lib/diskimage_linux_swsuspend.ml +++ b/lib/diskimage_linux_swsuspend.ml @@ -40,7 +40,7 @@ let rec probe dev = let fs_dev = new blocksize_overlay blocksize dev in { - fs_cb = callbacks; + fs_cb = callbacks (); fs_dev = fs_dev; fs_blocksize = blocksize; @@ -65,11 +65,14 @@ let rec probe dev = *) and offset_is_free _ _ = false -and callbacks = { - fs_cb_name = id; - fs_cb_printable_name = "Linux s/w suspend"; - fs_cb_offset_is_free = offset_is_free; -} +and callbacks = + let i = ref 0 in + fun () -> { + fs_cb_uq = (incr i; !i); + fs_cb_name = id; + fs_cb_printable_name = "Linux s/w suspend"; + fs_cb_offset_is_free = offset_is_free; + } (* Register the plugin. *) let () = register_plugin ~filesystem:probe id diff --git a/lib/diskimage_lvm2.ml b/lib/diskimage_lvm2.ml index 2c2fa60..da61600 100644 --- a/lib/diskimage_lvm2.ml +++ b/lib/diskimage_lvm2.ml @@ -107,7 +107,7 @@ let rec probe dev = let uuid, _ = read_pv_label dev in if !debug then eprintf "LVM2 detected PV UUID %s\n%!" uuid; - { pv_cb = callbacks; pv_uuid = uuid; pv_dev = dev } + { pv_cb = callbacks (); pv_uuid = uuid; pv_dev = dev } with exn -> if !debug then prerr_endline (Printexc.to_string exn); raise Not_found @@ -423,7 +423,7 @@ and list_lvs pvs = (* Finally we can set up devices for the LVs. *) let lvs = List.map ( - fun (vgname, (pvuuid, vgmeta, pvdevs, extent_size, lvs)) -> + fun (vgname, (pvuuids, vgmeta, pvdevs, extent_size, lvs)) -> try List.map ( fun (lvname, segments) -> @@ -456,11 +456,14 @@ and list_lvs pvs = *) and offset_is_free _ _ = false -and callbacks = { - lvm_cb_name = id; - lvm_cb_list_lvs = list_lvs; - lvm_cb_offset_is_free = offset_is_free; -} +and callbacks = + let i = ref 0 in + fun () -> { + lvm_cb_uq = (incr i; !i); + lvm_cb_name = id; + lvm_cb_list_lvs = list_lvs; + lvm_cb_offset_is_free = offset_is_free; + } (* Register the plugin. *) let () = register_plugin ~lvm:probe id -- 1.8.3.1