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.
23 (** {2 Device model} *)
25 class virtual device :
27 method virtual name : string
28 method virtual size : Int63.t
29 method read : Int63.t -> Int63.t -> string
30 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
31 method virtual blocksize : Int63.t
32 method virtual map_block : Int63.t -> (device * Int63.t) list
33 method virtual contiguous : Int63.t -> Int63.t
36 class block_device : string -> Int63.t ->
40 method read : Int63.t -> Int63.t -> string
41 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
42 method blocksize : Int63.t
43 method map_block : Int63.t -> (device * Int63.t) list
44 method contiguous : Int63.t -> Int63.t
45 method close : unit -> unit
48 class offset_device : string -> Int63.t -> Int63.t -> Int63.t -> device ->
52 method read : Int63.t -> Int63.t -> string
53 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
54 method blocksize : Int63.t
55 method map_block : Int63.t -> (device * Int63.t) list
56 method contiguous : Int63.t -> Int63.t
59 class blocksize_overlay : Int63.t -> device ->
63 method read : Int63.t -> Int63.t -> string
64 method read_bitstring : Int63.t -> Int63.t -> Bitmatch.bitstring
65 method blocksize : Int63.t
66 method map_block : Int63.t -> (device * Int63.t) list
67 method contiguous : Int63.t -> Int63.t
70 val null_device : device
76 (lv * filesystem) list;
82 d_content : disk_content;
86 [ `Filesystem of filesystem
87 | `Partitions of partitions
88 | `PhysicalVolume of pv
93 parts_plugin_id : parts_plugin_id;
95 parts : partition list;
98 part_status : partition_status;
101 part_content : partition_content;
104 and partition_status = Bootable | Nonbootable | Malformed | NullEntry
105 and partition_content =
106 [ `Filesystem of filesystem
107 | `PhysicalVolume of pv
112 fs_plugin_id : fs_plugin_id;
114 fs_blocksize : Int63.t;
115 fs_blocks_total : Int63.t;
117 fs_blocks_reserved : Int63.t;
118 fs_blocks_avail : Int63.t;
119 fs_blocks_used : Int63.t;
120 fs_inodes_total : Int63.t;
121 fs_inodes_reserved : Int63.t;
122 fs_inodes_avail : Int63.t;
123 fs_inodes_used : Int63.t;
127 lvm_plugin_id : lvm_plugin_id;
135 and parts_plugin_id = string
136 and fs_plugin_id = string
137 and lvm_plugin_id = string
139 (** {2 Internal functions used by the plug-ins} *)
141 val canonical_uuid : string -> string
142 (** Convert a UUID which may contain '-' characters to canonical form. *)
144 val group_by : ?cmp:('a -> 'a -> int) -> ('a * 'b) list -> ('a * 'b list) list
145 (** Group a sorted list of pairs by the first element of the pair. *)
147 val sort_uniq : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
148 (** [sort_uniq xs] returns the list [xs], sorted and with all duplicate
151 val uniq : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
152 (** [uniq xs] removes adjacent duplicate elements from a list, like
153 the Unix uniq(1) command. *)
155 val range : int -> int -> int list
156 (** [range a b] returns the list of integers [a <= i < b].
157 If [a >= b] then the empty list is returned.