1 (* (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc.
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version,
8 with the OCaml linking exception described in ../COPYING.LIB.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 (* Don't use the functions and types in here directly. The safe ones
21 * are reexported through the Diskimage module, see diskimage.mli.
28 (** {2 Device model} *)
30 class virtual device :
32 method virtual name : string
33 method virtual size : Int63.t
34 method read : Int63.t -> Int63.t -> string
35 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
36 method virtual blocksize : Int63.t
37 method virtual map_block : Int63.t -> (device * Int63.t) list
38 method virtual contiguous : Int63.t -> Int63.t
41 class block_device : string -> Int63.t ->
45 method read : Int63.t -> Int63.t -> string
46 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
47 method blocksize : Int63.t
48 method map_block : Int63.t -> (device * Int63.t) list
49 method contiguous : Int63.t -> Int63.t
50 method close : unit -> unit
53 class offset_device : string -> Int63.t -> Int63.t -> Int63.t -> device ->
57 method read : Int63.t -> Int63.t -> string
58 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
59 method blocksize : Int63.t
60 method map_block : Int63.t -> (device * Int63.t) list
61 method contiguous : Int63.t -> Int63.t
64 class blocksize_overlay : Int63.t -> device ->
68 method read : Int63.t -> Int63.t -> string
69 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
70 method blocksize : Int63.t
71 method map_block : Int63.t -> (device * Int63.t) list
72 method contiguous : Int63.t -> Int63.t
75 val null_device : device
81 (lv * filesystem) list;
87 d_content : disk_content;
91 [ `Filesystem of filesystem
92 | `Partitions of partitions
93 | `PhysicalVolume of pv
98 parts_cb : partitioner_callbacks;
100 parts : partition list;
103 part_status : partition_status;
106 part_content : partition_content;
109 and partition_status = Bootable | Nonbootable | Malformed | NullEntry
110 and partition_content =
111 [ `Filesystem of filesystem
112 | `PhysicalVolume of pv
117 fs_cb : filesystem_callbacks;
119 fs_blocksize : Int63.t;
120 fs_blocks_total : Int63.t;
122 fs_blocks_reserved : Int63.t;
123 fs_blocks_avail : Int63.t;
124 fs_blocks_used : Int63.t;
125 fs_inodes_total : Int63.t;
126 fs_inodes_reserved : Int63.t;
127 fs_inodes_avail : Int63.t;
128 fs_inodes_used : Int63.t;
132 pv_cb : lvm_callbacks;
140 (** {2 Table of callbacks from each type of plug-in} *)
142 and partitioner_probe = device -> partitions
144 and partitioner_callbacks = {
146 parts_cb_name : string;
147 parts_cb_offset_is_free : partitions -> Int63.t -> bool;
150 and filesystem_probe = device -> filesystem
152 and filesystem_callbacks = {
155 fs_cb_printable_name : string;
156 fs_cb_offset_is_free : filesystem -> Int63.t -> bool;
159 and lvm_probe = device -> pv
161 and lvm_callbacks = {
163 lvm_cb_name : string;
164 lvm_cb_list_lvs : pv list -> lv list;
165 lvm_cb_offset_is_free : pv -> Int63.t -> bool;
168 val name_of_filesystem : filesystem -> string
170 (** {3 Plug-in registration} *)
172 val register_plugin :
173 ?partitioner:partitioner_probe ->
174 ?filesystem:filesystem_probe ->
178 (** {3 Plug-in-specific data management. *)
180 val private_data_functions :
181 ('key -> int) -> ('key -> 'data -> unit) * ('key -> 'data)
183 (** {2 Internal functions used by the plug-ins} *)
185 val canonical_uuid : string -> string
186 (** Convert a UUID which may contain '-' characters to canonical form. *)
188 val group_by : ?cmp:('a -> 'a -> int) -> ('a * 'b) list -> ('a * 'b list) list
189 (** Group a sorted list of pairs by the first element of the pair. *)
191 val sort_uniq : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
192 (** [sort_uniq xs] returns the list [xs], sorted and with all duplicate
195 val uniq : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
196 (** [uniq xs] removes adjacent duplicate elements from a list, like
197 the Unix uniq(1) command. *)
199 val range : int -> int -> int list
200 (** [range a b] returns the list of integers [a <= i < b].
201 If [a >= b] then the empty list is returned.
206 val open_machine : string -> (string * string) list -> machine
207 val open_machine_from_devices : string -> (string * block_device) list ->
209 val close_machine : machine -> unit
210 val scan_machine : machine -> machine
214 val create_ownership : machine -> ownership
217 [ `Filesystem of filesystem
218 | `Partitions of partitions
219 | `PhysicalVolume of pv ]
221 val get_owners_lookup : machine -> ownership -> block_device ->
222 (Int63.t -> (owner * Int63.t) list)
223 val offset_is_free : (owner * Int63.t) list -> bool