1 (* (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 (* Don't use the functions and types in here directly. The safe ones
20 * are reexported through the Diskimage module, see diskimage.mli.
27 (** {2 Device model} *)
29 class virtual device :
31 method virtual name : string
32 method virtual size : Int63.t
33 method read : Int63.t -> Int63.t -> string
34 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
35 method virtual blocksize : Int63.t
36 method virtual map_block : Int63.t -> (device * Int63.t) list
37 method virtual contiguous : Int63.t -> Int63.t
40 class block_device : string -> Int63.t ->
44 method read : Int63.t -> Int63.t -> string
45 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
46 method blocksize : Int63.t
47 method map_block : Int63.t -> (device * Int63.t) list
48 method contiguous : Int63.t -> Int63.t
49 method close : unit -> unit
52 class offset_device : string -> Int63.t -> Int63.t -> Int63.t -> device ->
56 method read : Int63.t -> Int63.t -> string
57 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
58 method blocksize : Int63.t
59 method map_block : Int63.t -> (device * Int63.t) list
60 method contiguous : Int63.t -> Int63.t
63 class blocksize_overlay : Int63.t -> device ->
67 method read : Int63.t -> Int63.t -> string
68 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
69 method blocksize : Int63.t
70 method map_block : Int63.t -> (device * Int63.t) list
71 method contiguous : Int63.t -> Int63.t
74 val null_device : device
80 (lv * filesystem) list;
86 d_content : disk_content;
90 [ `Filesystem of filesystem
91 | `Partitions of partitions
92 | `PhysicalVolume of pv
97 parts_cb : partitioner_callbacks;
99 parts : partition list;
102 part_status : partition_status;
105 part_content : partition_content;
108 and partition_status = Bootable | Nonbootable | Malformed | NullEntry
109 and partition_content =
110 [ `Filesystem of filesystem
111 | `PhysicalVolume of pv
116 fs_cb : filesystem_callbacks;
118 fs_blocksize : Int63.t;
119 fs_blocks_total : Int63.t;
121 fs_blocks_reserved : Int63.t;
122 fs_blocks_avail : Int63.t;
123 fs_blocks_used : Int63.t;
124 fs_inodes_total : Int63.t;
125 fs_inodes_reserved : Int63.t;
126 fs_inodes_avail : Int63.t;
127 fs_inodes_used : Int63.t;
131 pv_cb : lvm_callbacks;
139 (** {2 Table of callbacks from each type of plug-in} *)
141 and partitioner_probe = device -> partitions
143 and partitioner_callbacks = {
144 parts_cb_name : string;
145 parts_cb_offset_is_free : partitions -> Int63.t -> bool;
148 and filesystem_probe = device -> filesystem
150 and filesystem_callbacks = {
152 fs_cb_printable_name : string;
153 fs_cb_offset_is_free : filesystem -> Int63.t -> bool;
156 and lvm_probe = device -> pv
158 and lvm_callbacks = {
159 lvm_cb_name : string;
160 lvm_cb_list_lvs : pv list -> lv list;
161 lvm_cb_offset_is_free : pv -> Int63.t -> bool;
164 val name_of_filesystem : filesystem -> string
166 (** {3 Plug-in registration} *)
168 val register_plugin :
169 ?partitioner:partitioner_probe ->
170 ?filesystem:filesystem_probe ->
174 (** {3 Plug-in-specific data management. *)
180 (** {2 Internal functions used by the plug-ins} *)
182 val canonical_uuid : string -> string
183 (** Convert a UUID which may contain '-' characters to canonical form. *)
185 val group_by : ?cmp:('a -> 'a -> int) -> ('a * 'b) list -> ('a * 'b list) list
186 (** Group a sorted list of pairs by the first element of the pair. *)
188 val sort_uniq : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
189 (** [sort_uniq xs] returns the list [xs], sorted and with all duplicate
192 val uniq : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
193 (** [uniq xs] removes adjacent duplicate elements from a list, like
194 the Unix uniq(1) command. *)
196 val range : int -> int -> int list
197 (** [range a b] returns the list of integers [a <= i < b].
198 If [a >= b] then the empty list is returned.
203 val open_machine : string -> (string * string) list -> machine
204 val close_machine : machine -> unit
205 val scan_machine : machine -> machine
209 val create_ownership : machine -> ownership
212 [ `Filesystem of filesystem
213 | `Partitions of partitions
214 | `PhysicalVolume of pv ]
216 val get_owners_lookup : machine -> ownership -> block_device ->
217 (Int63.t -> (owner * Int63.t) list)
218 val offset_is_free : (owner * Int63.t) list -> bool