X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=virt-df%2Fvirt_df.mli;fp=virt-df%2Fvirt_df.mli;h=d13c5d3ad38836f9573092bfc9e150796a887dc9;hb=9611aba66734efe3e2f1e0792a90003b657a89f5;hp=2815d9b071f04fc00bab07f37b01cf6dc2f2956c;hpb=0354a927faf2b307371dbf2d9ca284eee7c0caa1;p=virt-df.git diff --git a/virt-df/virt_df.mli b/virt-df/virt_df.mli index 2815d9b..d13c5d3 100644 --- a/virt-df/virt_df.mli +++ b/virt-df/virt_df.mli @@ -21,16 +21,6 @@ used throughout the plug-ins and main code. *) -val ( +* ) : int32 -> int32 -> int32 -val ( -* ) : int32 -> int32 -> int32 -val ( ** ) : int32 -> int32 -> int32 -val ( /* ) : int32 -> int32 -> int32 -val ( +^ ) : int64 -> int64 -> int64 -val ( -^ ) : int64 -> int64 -> int64 -val ( *^ ) : int64 -> int64 -> int64 -val ( /^ ) : int64 -> int64 -> int64 -(** int32 and int64 infix operators for convenience. *) - val debug : bool ref (** If true, emit debug info to stderr*) val uri : string option ref (** Hypervisor/libvirt URI. *) val inodes : bool ref (** Display inodes. *) @@ -44,200 +34,3 @@ val csv_write : (out_channel -> string list -> unit) option ref (** If virt_df_csv.ml is compiled in then this hook is overridden with a function to write a single line to a CSV file. *) - -(** - {2 Domain/device model} - - The "domain/device model" that we currently understand looks - like this: - -{v -domains - | - \--- host partitions / disk image files - || - guest block devices - | - +--> guest partitions (eg. using MBR) - | | - \-(1)->+--- filesystems (eg. ext3) - | - \--- PVs for LVM - ||| - VGs and LVs -v} - - (1) Filesystems and PVs may also appear directly on guest - block devices. - - Partition schemes (eg. MBR) and filesystems register themselves - with this main module and they are queried first to get an idea - of the physical devices, partitions and filesystems potentially - available to the guest. - - Volume management schemes (eg. LVM2) register themselves here - and are called later with "spare" physical devices and partitions - to see if they contain LVM data. If this results in additional - logical volumes then these are checked for filesystems. - - Swap space is considered to be a dumb filesystem for the purposes - of this discussion. -*) - -class virtual device : - object - method virtual name : string - method virtual read : int64 -> int -> string - method read_bitstring : int64 -> int -> string * int * int - method virtual size : int64 - end - (** - A virtual (or physical!) device, encapsulating any translation - that has to be done to access the device. eg. For partitions - there is a simple offset, but for LVM you may need complicated - table lookups. - - We keep the underlying file descriptors open for the duration - of the program. There aren't likely to be many of them, and - the program is short-lived, and it's easier than trying to - track which device is using what fd. As a result, there is no - need for any close/deallocation function. - - Note the very rare use of OOP in OCaml! - *) - -class block_device : string -> - object - method name : string - method read : int64 -> int -> string - method read_bitstring : int64 -> int -> string * int * int - method size : int64 - end - (** A concrete device which just direct-maps a file or /dev device. *) - -class offset_device : string -> int64 -> int64 -> device -> - object - method name : string - method read : int64 -> int -> string - method read_bitstring : int64 -> int -> string * int * int - method size : int64 - end - (** A concrete device which maps a linear part of an underlying device. - - [new offset_device name start size dev] creates a new - device which maps bytes from [start] to [start+size-1] - of the underlying device [dev] (ie. in this device they - appear as bytes [0] to [size-1]). - - Useful for things like partitions. - *) - -val null_device : device - (** The null device. Any attempt to read generates an error. *) - -type domain = { - dom_name : string; (** Domain name. *) - dom_id : int option; (** Domain ID (if running). *) - dom_disks : disk list; (** Domain disks. *) - dom_lv_filesystems : - (lv * filesystem) list; (** Domain LV filesystems. *) -} -and disk = { - d_type : string option; (** The *) - d_device : string; (** The (eg "disk") *) - d_source : string; (** The *) - d_target : string; (** The (eg "hda") *) - d_dev : device; (** Disk device. *) - d_content : disk_content; (** What's on it. *) -} -and disk_content = - [ `Filesystem of filesystem (** Contains a direct filesystem. *) - | `Partitions of partitions (** Contains partitions. *) - | `PhysicalVolume of pv (** Contains an LVM PV. *) - | `Unknown (** Not probed or unknown. *) - ] -and partitions = { - parts_name : string; (** Name of partitioning scheme. *) - parts : partition list; (** Partitions. *) -} -and partition = { - part_status : partition_status; (** Bootable, etc. *) - part_type : int; (** Partition filesystem type. *) - part_dev : device; (** Partition device. *) - part_content : partition_content; (** What's on it. *) -} -and partition_status = Bootable | Nonbootable | Malformed | NullEntry -and partition_content = - [ `Filesystem of filesystem (** Filesystem. *) - | `PhysicalVolume of pv (** Contains an LVM PV. *) - | `Unknown (** Not probed or unknown. *) - ] -and filesystem = { - fs_name : string; (** Name of filesystem. *) - fs_block_size : int64; (** Block size (bytes). *) - fs_blocks_total : int64; (** Total blocks. *) - fs_is_swap : bool; (** If swap, following not valid. *) - fs_blocks_reserved : int64; (** Blocks reserved for super-user. *) - fs_blocks_avail : int64; (** Blocks free (available). *) - fs_blocks_used : int64; (** Blocks in use. *) - fs_inodes_total : int64; (** Total inodes. *) - fs_inodes_reserved : int64; (** Inodes reserved for super-user. *) - fs_inodes_avail : int64; (** Inodes free (available). *) - fs_inodes_used : int64; (** Inodes in use. *) -} -and pv = { - lvm_plugin_id : lvm_plugin_id; (** The LVM plug-in which detected - this. *) - pv_uuid : string; (** UUID. *) -} -and lv = { - lv_dev : device; (** Logical volume device. *) -} - -and lvm_plugin_id - -val string_of_partition : partition -> string -val string_of_filesystem : filesystem -> string -(** Convert a partition or filesystem struct to a string (for debugging). *) - -val canonical_uuid : string -> string -(** Convert a UUID which may contain '-' characters to canonical form. *) - -(** {2 Plug-in registration functions} *) - -val partition_type_register : string -> (device -> partitions) -> unit -(** Register a partition probing plug-in. *) - -val probe_for_partitions : device -> partitions option -(** Do a partition probe on a device. Returns [Some partitions] or [None]. *) - -val filesystem_type_register : string -> (device -> filesystem) -> unit -(** Register a filesystem probing plug-in. *) - -val probe_for_filesystem : device -> filesystem option -(** Do a filesystem probe on a device. Returns [Some filesystem] or [None]. *) - -val lvm_type_register : - string -> (lvm_plugin_id -> device -> pv) -> (device list -> lv list) -> unit -(** [lvm_type_register lvm_name probe_fn list_lvs_fn] - registers a new LVM type. [probe_fn] is a function which - should probe a device to find out if it contains a PV. - [list_lvs_fn] is a function which should take a list of - devices (PVs) and construct a list of LV devices. -*) - -val probe_for_pv : device -> pv option -(** Do a PV probe on a device. Returns [Some pv] or [None]. *) - -val list_lvs : lvm_plugin_id -> device list -> lv list -(** Construct LV devices from a list of PVs. *) - -(** {2 Utility functions} *) - -val group_by : ?cmp:('a -> 'a -> int) -> ('a * 'b) list -> ('a * 'b list) list -(** Group a sorted list of pairs by the first element of the pair. *) - -val range : int -> int -> int list -(** [range a b] returns the list of integers [a <= i < b]. - If [a >= b] then the empty list is returned. -*)