(* libguestfs
- * Copyright (C) 2009-2010 Red Hat Inc.
+ * Copyright (C) 2009-2011 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*)
let non_daemon_functions = test_functions @ [
- ("launch", (RErr, [], []), -1, [FishAlias "run"],
+ ("launch", (RErr, [], []), -1, [FishAlias "run"; Progress],
[],
"launch the qemu subprocess",
"\
You should call this after configuring the handle
(eg. adding drives) but before performing any actions.");
- ("wait_ready", (RErr, [], []), -1, [NotInFish],
+ ("wait_ready", (RErr, [], []), -1, [NotInFish; DeprecatedBy "launch"],
[],
"wait until the qemu subprocess launches (no op)",
"\
"\
This function adds a virtual CD-ROM disk image to the guest.
-This is equivalent to the qemu parameter C<-cdrom filename>.
+This is equivalent to the qemu parameter I<-cdrom filename>.
Notes:
"add qemu parameters",
"\
This can be used to add arbitrary qemu command line parameters
-of the form C<-param value>. Actually it's not quite arbitrary - we
+of the form I<-param value>. Actually it's not quite arbitrary - we
prevent you from setting some parameters which would interfere with
parameters that we use.
"set autosync mode",
"\
If C<autosync> is true, this enables autosync. Libguestfs will make a
-best effort attempt to run C<guestfs_umount_all> followed by
-C<guestfs_sync> when the handle is closed
+best effort attempt to make filesystems consistent and synchronized
+when the handle is closed
(also if the program exits without closing handles).
This is enabled by default (since libguestfs 1.5.24, previously it was
[],
"set verbose mode",
"\
-If C<verbose> is true, this turns on verbose messages (to C<stderr>).
+If C<verbose> is true, this turns on verbose messages.
Verbose messages are disabled unless the environment variable
-C<LIBGUESTFS_DEBUG> is defined and set to C<1>.");
+C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
+
+Verbose messages are normally sent to C<stderr>, unless you
+register a callback to send them somewhere else (see
+C<guestfs_set_event_callback>).");
("get_verbose", (RBool "verbose", [], []), -1, [],
[],
["get_trace"]])],
"enable or disable command traces",
"\
-If the command trace flag is set to 1, then commands are
-printed on stderr before they are executed in a format
-which is very similar to the one used by guestfish. In
-other words, you can run a program with this enabled, and
-you will get out a script which you can feed to guestfish
-to perform the same set of actions.
+If the command trace flag is set to 1, then libguestfs
+calls, parameters and return values are traced.
If you want to trace C API calls into libguestfs (and
other libraries) then possibly a better way is to use
the external ltrace(1) command.
Command traces are disabled unless the environment variable
-C<LIBGUESTFS_TRACE> is defined and set to C<1>.");
+C<LIBGUESTFS_TRACE> is defined and set to C<1>.
+
+Trace messages are normally sent to C<stderr>, unless you
+register a callback to send them somewhere else (see
+C<guestfs_set_event_callback>).");
("get_trace", (RBool "trace", [], []), -1, [],
[],
[],
"get type of inspected operating system",
"\
-This function should only be called with a root device string
-as returned by C<guestfs_inspect_os>.
-
This returns the type of the inspected operating system.
Currently defined types are:
Any Microsoft Windows operating system.
+=item \"freebsd\"
+
+FreeBSD.
+
+=item \"netbsd\"
+
+NetBSD.
+
+=item \"hurd\"
+
+GNU/Hurd.
+
=item \"unknown\"
The operating system type could not be determined.
[],
"get architecture of inspected operating system",
"\
-This function should only be called with a root device string
-as returned by C<guestfs_inspect_os>.
-
This returns the architecture of the inspected operating system.
The possible return values are listed under
C<guestfs_file_architecture>.
[],
"get distro of inspected operating system",
"\
-This function should only be called with a root device string
-as returned by C<guestfs_inspect_os>.
-
This returns the distro (distribution) of the inspected operating
system.
Arch Linux.
+=item \"centos\"
+
+CentOS.
+
=item \"debian\"
-Debian or a Debian-derived distro such as Ubuntu.
+Debian.
=item \"fedora\"
Gentoo.
+=item \"linuxmint\"
+
+Linux Mint.
+
+=item \"mageia\"
+
+Mageia.
+
+=item \"mandriva\"
+
+Mandriva.
+
=item \"meego\"
MeeGo.
+=item \"opensuse\"
+
+OpenSUSE.
+
=item \"pardus\"
Pardus.
=item \"rhel\"
-Red Hat Enterprise Linux and some derivatives.
+Red Hat Enterprise Linux.
-=item \"windows\"
+=item \"scientificlinux\"
-Windows does not have distributions. This string is
-returned if the OS type is Windows.
+Scientific Linux.
+
+=item \"slackware\"
+
+Slackware.
+
+=item \"ttylinux\"
+
+ttylinux.
=item \"ubuntu\"
The distro could not be determined.
+=item \"windows\"
+
+Windows does not have distributions. This string is
+returned if the OS type is Windows.
+
=back
Future versions of libguestfs may return other strings here.
[],
"get major version of inspected operating system",
"\
-This function should only be called with a root device string
-as returned by C<guestfs_inspect_os>.
-
This returns the major version number of the inspected operating
system.
[],
"get minor version of inspected operating system",
"\
-This function should only be called with a root device string
-as returned by C<guestfs_inspect_os>.
-
This returns the minor version number of the inspected operating
system.
[],
"get product name of inspected operating system",
"\
-This function should only be called with a root device string
-as returned by C<guestfs_inspect_os>.
-
This returns the product name of the inspected operating
system. The product name is generally some freeform string
which can be displayed to the user, but should not be
[],
"get mountpoints of inspected operating system",
"\
-This function should only be called with a root device string
-as returned by C<guestfs_inspect_os>.
-
This returns a hash of where we think the filesystems
associated with this operating system should be mounted.
Callers should note that this is at best an educated guess
made by reading configuration files such as C</etc/fstab>.
+I<In particular note> that this may return filesystems
+which are non-existent or not mountable and callers should
+be prepared to handle or ignore failures if they try to
+mount them.
Each element in the returned hashtable has a key which
is the path of the mountpoint (eg. C</boot>) and a value
Non-mounted devices such as swap devices are I<not>
returned in this list.
+For operating systems like Windows which still use drive
+letters, this call will only return an entry for the first
+drive \"mounted on\" C</>. For information about the
+mapping of drive letters to partitions, see
+C<guestfs_inspect_get_drive_mappings>.
+
Please read L<guestfs(3)/INSPECTION> for more details.
See also C<guestfs_inspect_get_filesystems>.");
[],
"get filesystems associated with inspected operating system",
"\
-This function should only be called with a root device string
-as returned by C<guestfs_inspect_os>.
-
This returns a list of all the filesystems that we think
are associated with this operating system. This includes
the root filesystem, other ordinary filesystems, and
not all belong to a single logical operating system
(use C<guestfs_inspect_os> to look for OSes).");
- ("add_drive_opts", (RErr, [String "filename"], [Bool "readonly"; String "format"; String "iface"]), -1, [FishAlias "add"],
+ ("add_drive_opts", (RErr, [String "filename"], [Bool "readonly"; String "format"; String "iface"; String "name"]), -1, [FishAlias "add"],
[],
"add an image to examine or modify",
"\
This rarely-used option lets you emulate the behaviour of the
deprecated C<guestfs_add_drive_with_if> call (q.v.)
+=item C<name>
+
+The name the drive had in the original guest, e.g. /dev/sdb. This is used as a
+hint to the guest inspection process if it is available.
+
=back");
("inspect_get_windows_systemroot", (RString "systemroot", [Device "root"], []), -1, [],
[],
"get Windows systemroot of inspected operating system",
"\
-This function should only be called with a root device string
-as returned by C<guestfs_inspect_os>.
-
This returns the Windows systemroot of the inspected guest.
The systemroot is a directory path such as C</WINDOWS>.
Please read L<guestfs(3)/INSPECTION> for more details.");
-]
+ ("inspect_get_roots", (RStringList "roots", [], []), -1, [],
+ [],
+ "return list of operating systems found by last inspection",
+ "\
+This function is a convenient way to get the list of root
+devices, as returned from a previous call to C<guestfs_inspect_os>,
+but without redoing the whole inspection process.
-(* daemon_functions are any functions which cause some action
- * to take place in the daemon.
- *)
+This returns an empty list if either no root devices were
+found or the caller has not called C<guestfs_inspect_os>.
-let daemon_functions = [
- ("mount", (RErr, [Device "device"; String "mountpoint"], []), 1, [],
- [InitEmpty, Always, TestOutput (
- [["part_disk"; "/dev/sda"; "mbr"];
- ["mkfs"; "ext2"; "/dev/sda1"];
- ["mount"; "/dev/sda1"; "/"];
- ["write"; "/new"; "new file contents"];
- ["cat"; "/new"]], "new file contents")],
- "mount a guest disk at a position in the filesystem",
+Please read L<guestfs(3)/INSPECTION> for more details.");
+
+ ("debug_cmdline", (RStringList "cmdline", [], []), -1, [NotInDocs],
+ [],
+ "debug the QEMU command line (internal use only)",
"\
-Mount a guest disk at a position in the filesystem. Block devices
-are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
-the guest. If those block devices contain partitions, they will have
-the usual names (eg. C</dev/sda1>). Also LVM C</dev/VG/LV>-style
-names can be used.
+This returns the internal QEMU command line. 'debug' commands are
+not part of the formal API and can be removed or changed at any time.");
-The rules are the same as for L<mount(2)>: A filesystem must
-first be mounted on C</> before others can be mounted. Other
-filesystems can only be mounted on directories which already
-exist.
+ ("debug_drives", (RStringList "cmdline", [], []), -1, [NotInDocs],
+ [],
+ "debug the drives (internal use only)",
+ "\
+This returns the internal list of drives. 'debug' commands are
+not part of the formal API and can be removed or changed at any time.");
-The mounted filesystem is writable, if we have sufficient permissions
-on the underlying device.
+ ("add_domain", (RInt "nrdisks", [String "dom"], [String "libvirturi"; Bool "readonly"; String "iface"; Bool "live"; Bool "allowuuid"; String "readonlydisk"]), -1, [FishAlias "domain"],
+ [],
+ "add the disk(s) from a named libvirt domain",
+ "\
+This function adds the disk(s) attached to the named libvirt
+domain C<dom>. It works by connecting to libvirt, requesting
+the domain and domain XML from libvirt, parsing it for disks,
+and calling C<guestfs_add_drive_opts> on each one.
+
+The number of disks added is returned. This operation is atomic:
+if an error is returned, then no disks are added.
+
+This function does some minimal checks to make sure the libvirt
+domain is not running (unless C<readonly> is true). In a future
+version we will try to acquire the libvirt lock on each disk.
+
+Disks must be accessible locally. This often means that adding disks
+from a remote libvirt connection (see L<http://libvirt.org/remote.html>)
+will fail unless those disks are accessible via the same device path
+locally too.
+
+The optional C<libvirturi> parameter sets the libvirt URI
+(see L<http://libvirt.org/uri.html>). If this is not set then
+we connect to the default libvirt URI (or one set through an
+environment variable, see the libvirt documentation for full
+details).
+
+The optional C<live> flag controls whether this call will try
+to connect to a running virtual machine C<guestfsd> process if
+it sees a suitable E<lt>channelE<gt> element in the libvirt
+XML definition. The default (if the flag is omitted) is never
+to try. See L<guestfs(3)/ATTACHING TO RUNNING DAEMONS> for more
+information.
+
+If the C<allowuuid> flag is true (default is false) then a UUID
+I<may> be passed instead of the domain name. The C<dom> string is
+treated as a UUID first and looked up, and if that lookup fails
+then we treat C<dom> as a name as usual.
+
+The optional C<readonlydisk> parameter controls what we do for
+disks which are marked E<lt>readonly/E<gt> in the libvirt XML.
+Possible values are:
-B<Important note:>
-When you use this call, the filesystem options C<sync> and C<noatime>
-are set implicitly. This was originally done because we thought it
-would improve reliability, but it turns out that I<-o sync> has a
-very large negative performance impact and negligible effect on
-reliability. Therefore we recommend that you avoid using
-C<guestfs_mount> in any code that needs performance, and instead
-use C<guestfs_mount_options> (use an empty string for the first
-parameter if you don't want any options).");
+=over 4
- ("sync", (RErr, [], []), 2, [],
- [ InitEmpty, Always, TestRun [["sync"]]],
- "sync disks, writes are flushed through to the disk image",
- "\
-This syncs the disk, so that any writes are flushed through to the
-underlying disk image.
+=item readonlydisk = \"error\"
-You should always call this if you have modified a disk image, before
-closing the handle.");
+If C<readonly> is false:
- ("touch", (RErr, [Pathname "path"], []), 3, [],
- [InitBasicFS, Always, TestOutputTrue (
- [["touch"; "/new"];
- ["exists"; "/new"]])],
- "update file timestamps or create a new file",
- "\
-Touch acts like the L<touch(1)> command. It can be used to
-update the timestamps on a file, or, if the file does not exist,
-to create a new zero-length file.
+The whole call is aborted with an error if any disk with
+the E<lt>readonly/E<gt> flag is found.
-This command only works on regular files, and will fail on other
-file types such as directories, symbolic links, block special etc.");
+If C<readonly> is true:
- ("cat", (RString "content", [Pathname "path"], []), 4, [ProtocolLimitWarning],
- [InitISOFS, Always, TestOutput (
- [["cat"; "/known-2"]], "abcdef\n")],
- "list the contents of a file",
- "\
-Return the contents of the file named C<path>.
+Disks with the E<lt>readonly/E<gt> flag are added read-only.
-Note that this function cannot correctly handle binary files
-(specifically, files containing C<\\0> character which is treated
-as end of string). For those you need to use the C<guestfs_read_file>
-or C<guestfs_download> functions which have a more complex interface.");
+=item readonlydisk = \"read\"
- ("ll", (RString "listing", [Pathname "directory"], []), 5, [],
- [], (* XXX Tricky to test because it depends on the exact format
- * of the 'ls -l' command, which changes between F10 and F11.
- *)
- "list the files in a directory (long format)",
- "\
-List the files in C<directory> (relative to the root directory,
-there is no cwd) in the format of 'ls -la'.
+If C<readonly> is false:
-This command is mostly useful for interactive sessions. It
-is I<not> intended that you try to parse the output string.");
+Disks with the E<lt>readonly/E<gt> flag are added read-only.
+Other disks are added read/write.
- ("ls", (RStringList "listing", [Pathname "directory"], []), 6, [],
- [InitBasicFS, Always, TestOutputList (
- [["touch"; "/new"];
- ["touch"; "/newer"];
- ["touch"; "/newest"];
- ["ls"; "/"]], ["lost+found"; "new"; "newer"; "newest"])],
- "list the files in a directory",
- "\
-List the files in C<directory> (relative to the root directory,
-there is no cwd). The '.' and '..' entries are not returned, but
-hidden files are shown.
+If C<readonly> is true:
-This command is mostly useful for interactive sessions. Programs
-should probably use C<guestfs_readdir> instead.");
+Disks with the E<lt>readonly/E<gt> flag are added read-only.
- ("list_devices", (RStringList "devices", [], []), 7, [],
- [InitEmpty, Always, TestOutputListOfDevices (
- [["list_devices"]], ["/dev/sda"; "/dev/sdb"; "/dev/sdc"; "/dev/sdd"])],
- "list the block devices",
- "\
-List all the block devices.
+=item readonlydisk = \"write\" (default)
-The full block device names are returned, eg. C</dev/sda>.
+If C<readonly> is false:
-See also C<guestfs_list_filesystems>.");
+Disks with the E<lt>readonly/E<gt> flag are added read/write.
- ("list_partitions", (RStringList "partitions", [], []), 8, [],
- [InitBasicFS, Always, TestOutputListOfDevices (
- [["list_partitions"]], ["/dev/sda1"]);
- InitEmpty, Always, TestOutputListOfDevices (
- [["part_init"; "/dev/sda"; "mbr"];
- ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
- ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
- ["part_add"; "/dev/sda"; "p"; "409600"; "-64"];
- ["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])],
- "list the partitions",
- "\
-List all the partitions detected on all block devices.
+If C<readonly> is true:
-The full partition device names are returned, eg. C</dev/sda1>
+Disks with the E<lt>readonly/E<gt> flag are added read-only.
-This does not return logical volumes. For that you will need to
-call C<guestfs_lvs>.
+=item readonlydisk = \"ignore\"
-See also C<guestfs_list_filesystems>.");
+If C<readonly> is true or false:
- ("pvs", (RStringList "physvols", [], []), 9, [Optional "lvm2"],
- [InitBasicFSonLVM, Always, TestOutputListOfDevices (
- [["pvs"]], ["/dev/sda1"]);
- InitEmpty, Always, TestOutputListOfDevices (
- [["part_init"; "/dev/sda"; "mbr"];
- ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
- ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
- ["part_add"; "/dev/sda"; "p"; "409600"; "-64"];
- ["pvcreate"; "/dev/sda1"];
- ["pvcreate"; "/dev/sda2"];
- ["pvcreate"; "/dev/sda3"];
- ["pvs"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])],
- "list the LVM physical volumes (PVs)",
- "\
-List all the physical volumes detected. This is the equivalent
-of the L<pvs(8)> command.
+Disks with the E<lt>readonly/E<gt> flag are skipped.
-This returns a list of just the device names that contain
-PVs (eg. C</dev/sda2>).
+=back
-See also C<guestfs_pvs_full>.");
+The other optional parameters are passed directly through to
+C<guestfs_add_drive_opts>.");
- ("vgs", (RStringList "volgroups", [], []), 10, [Optional "lvm2"],
- [InitBasicFSonLVM, Always, TestOutputList (
- [["vgs"]], ["VG"]);
- InitEmpty, Always, TestOutputList (
- [["part_init"; "/dev/sda"; "mbr"];
- ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
- ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
- ["part_add"; "/dev/sda"; "p"; "409600"; "-64"];
- ["pvcreate"; "/dev/sda1"];
- ["pvcreate"; "/dev/sda2"];
- ["pvcreate"; "/dev/sda3"];
- ["vgcreate"; "VG1"; "/dev/sda1 /dev/sda2"];
- ["vgcreate"; "VG2"; "/dev/sda3"];
- ["vgs"]], ["VG1"; "VG2"])],
- "list the LVM volume groups (VGs)",
+(*
+This interface is not quite baked yet. -- RWMJ 2010-11-11
+ ("add_libvirt_dom", (RInt "nrdisks", [Pointer ("virDomainPtr", "dom")], [Bool "readonly"; String "iface"; Bool "live"; String "readonlydisk"]), -1, [NotInFish],
+ [],
+ "add the disk(s) from a libvirt domain",
"\
-List all the volumes groups detected. This is the equivalent
-of the L<vgs(8)> command.
+This function adds the disk(s) attached to the libvirt domain C<dom>.
+It works by requesting the domain XML from libvirt, parsing it for
+disks, and calling C<guestfs_add_drive_opts> on each one.
-This returns a list of just the volume group names that were
-detected (eg. C<VolGroup00>).
+In the C API we declare C<void *dom>, but really it has type
+C<virDomainPtr dom>. This is so we don't need E<lt>libvirt.hE<gt>.
-See also C<guestfs_vgs_full>.");
+The number of disks added is returned. This operation is atomic:
+if an error is returned, then no disks are added.
- ("lvs", (RStringList "logvols", [], []), 11, [Optional "lvm2"],
- [InitBasicFSonLVM, Always, TestOutputList (
- [["lvs"]], ["/dev/VG/LV"]);
- InitEmpty, Always, TestOutputList (
- [["part_init"; "/dev/sda"; "mbr"];
- ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
- ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
- ["part_add"; "/dev/sda"; "p"; "409600"; "-64"];
- ["pvcreate"; "/dev/sda1"];
- ["pvcreate"; "/dev/sda2"];
- ["pvcreate"; "/dev/sda3"];
- ["vgcreate"; "VG1"; "/dev/sda1 /dev/sda2"];
- ["vgcreate"; "VG2"; "/dev/sda3"];
- ["lvcreate"; "LV1"; "VG1"; "50"];
- ["lvcreate"; "LV2"; "VG1"; "50"];
- ["lvcreate"; "LV3"; "VG2"; "50"];
- ["lvs"]], ["/dev/VG1/LV1"; "/dev/VG1/LV2"; "/dev/VG2/LV3"])],
- "list the LVM logical volumes (LVs)",
- "\
-List all the logical volumes detected. This is the equivalent
-of the L<lvs(8)> command.
+This function does some minimal checks to make sure the libvirt
+domain is not running (unless C<readonly> is true). In a future
+version we will try to acquire the libvirt lock on each disk.
-This returns a list of the logical volume device names
-(eg. C</dev/VolGroup00/LogVol00>).
+Disks must be accessible locally. This often means that adding disks
+from a remote libvirt connection (see L<http://libvirt.org/remote.html>)
+will fail unless those disks are accessible via the same device path
+locally too.
-See also C<guestfs_lvs_full>, C<guestfs_list_filesystems>.");
+The optional C<live> flag controls whether this call will try
+to connect to a running virtual machine C<guestfsd> process if
+it sees a suitable E<lt>channelE<gt> element in the libvirt
+XML definition. The default (if the flag is omitted) is never
+to try. See L<guestfs(3)/ATTACHING TO RUNNING DAEMONS> for more
+information.
- ("pvs_full", (RStructList ("physvols", "lvm_pv"), [], []), 12, [Optional "lvm2"],
- [], (* XXX how to test? *)
- "list the LVM physical volumes (PVs)",
- "\
-List all the physical volumes detected. This is the equivalent
-of the L<pvs(8)> command. The \"full\" version includes all fields.");
+The optional C<readonlydisk> parameter controls what we do for
+disks which are marked E<lt>readonly/E<gt> in the libvirt XML.
+See C<guestfs_add_domain> for possible values.
- ("vgs_full", (RStructList ("volgroups", "lvm_vg"), [], []), 13, [Optional "lvm2"],
- [], (* XXX how to test? *)
- "list the LVM volume groups (VGs)",
- "\
-List all the volumes groups detected. This is the equivalent
-of the L<vgs(8)> command. The \"full\" version includes all fields.");
+The other optional parameters are passed directly through to
+C<guestfs_add_drive_opts>.");
+*)
- ("lvs_full", (RStructList ("logvols", "lvm_lv"), [], []), 14, [Optional "lvm2"],
- [], (* XXX how to test? *)
- "list the LVM logical volumes (LVs)",
+ ("inspect_get_package_format", (RString "packageformat", [Device "root"], []), -1, [],
+ [],
+ "get package format used by the operating system",
"\
-List all the logical volumes detected. This is the equivalent
-of the L<lvs(8)> command. The \"full\" version includes all fields.");
+This function and C<guestfs_inspect_get_package_management> return
+the package format and package management tool used by the
+inspected operating system. For example for Fedora these
+functions would return C<rpm> (package format) and
+C<yum> (package management).
- ("read_lines", (RStringList "lines", [Pathname "path"], []), 15, [],
- [InitISOFS, Always, TestOutputList (
- [["read_lines"; "/known-4"]], ["abc"; "def"; "ghi"]);
- InitISOFS, Always, TestOutputList (
- [["read_lines"; "/empty"]], [])],
- "read file as lines",
- "\
-Return the contents of the file named C<path>.
+This returns the string C<unknown> if we could not determine the
+package format I<or> if the operating system does not have
+a real packaging system (eg. Windows).
-The file contents are returned as a list of lines. Trailing
-C<LF> and C<CRLF> character sequences are I<not> returned.
+Possible strings include:
+C<rpm>, C<deb>, C<ebuild>, C<pisi>, C<pacman>, C<pkgsrc>.
+Future versions of libguestfs may return other strings.
-Note that this function cannot correctly handle binary files
-(specifically, files containing C<\\0> character which is treated
-as end of line). For those you need to use the C<guestfs_read_file>
-function which has a more complex interface.");
+Please read L<guestfs(3)/INSPECTION> for more details.");
- ("aug_init", (RErr, [Pathname "root"; Int "flags"], []), 16, [Optional "augeas"],
- [], (* XXX Augeas code needs tests. *)
- "create a new Augeas handle",
+ ("inspect_get_package_management", (RString "packagemanagement", [Device "root"], []), -1, [],
+ [],
+ "get package management tool used by the operating system",
"\
-Create a new Augeas handle for editing configuration files.
-If there was any previous Augeas handle associated with this
-guestfs session, then it is closed.
+C<guestfs_inspect_get_package_format> and this function return
+the package format and package management tool used by the
+inspected operating system. For example for Fedora these
+functions would return C<rpm> (package format) and
+C<yum> (package management).
-You must call this before using any other C<guestfs_aug_*>
-commands.
+This returns the string C<unknown> if we could not determine the
+package management tool I<or> if the operating system does not have
+a real packaging system (eg. Windows).
-C<root> is the filesystem root. C<root> must not be NULL,
-use C</> instead.
+Possible strings include: C<yum>, C<up2date>,
+C<apt> (for all Debian derivatives),
+C<portage>, C<pisi>, C<pacman>, C<urpmi>, C<zypper>.
+Future versions of libguestfs may return other strings.
-The flags are the same as the flags defined in
-E<lt>augeas.hE<gt>, the logical I<or> of the following
-integers:
+Please read L<guestfs(3)/INSPECTION> for more details.");
+
+ ("inspect_list_applications", (RStructList ("applications", "application"), [Device "root"], []), -1, [],
+ [],
+ "get list of applications installed in the operating system",
+ "\
+Return the list of applications installed in the operating system.
+
+I<Note:> This call works differently from other parts of the
+inspection API. You have to call C<guestfs_inspect_os>, then
+C<guestfs_inspect_get_mountpoints>, then mount up the disks,
+before calling this. Listing applications is a significantly
+more difficult operation which requires access to the full
+filesystem. Also note that unlike the other
+C<guestfs_inspect_get_*> calls which are just returning
+data cached in the libguestfs handle, this call actually reads
+parts of the mounted filesystems during the call.
+
+This returns an empty list if the inspection code was not able
+to determine the list of applications.
+
+The application structure contains the following fields:
+
+=over 4
+
+=item C<app_name>
+
+The name of the application. For Red Hat-derived and Debian-derived
+Linux guests, this is the package name.
+
+=item C<app_display_name>
+
+The display name of the application, sometimes localized to the
+install language of the guest operating system.
+
+If unavailable this is returned as an empty string C<\"\">.
+Callers needing to display something can use C<app_name> instead.
+
+=item C<app_epoch>
+
+For package managers which use epochs, this contains the epoch of
+the package (an integer). If unavailable, this is returned as C<0>.
+
+=item C<app_version>
+
+The version string of the application or package. If unavailable
+this is returned as an empty string C<\"\">.
+
+=item C<app_release>
+
+The release string of the application or package, for package
+managers that use this. If unavailable this is returned as an
+empty string C<\"\">.
+
+=item C<app_install_path>
+
+The installation path of the application (on operating systems
+such as Windows which use installation paths). This path is
+in the format used by the guest operating system, it is not
+a libguestfs path.
+
+If unavailable this is returned as an empty string C<\"\">.
+
+=item C<app_trans_path>
+
+The install path translated into a libguestfs path.
+If unavailable this is returned as an empty string C<\"\">.
+
+=item C<app_publisher>
+
+The name of the publisher of the application, for package
+managers that use this. If unavailable this is returned
+as an empty string C<\"\">.
+
+=item C<app_url>
+
+The URL (eg. upstream URL) of the application.
+If unavailable this is returned as an empty string C<\"\">.
+
+=item C<app_source_package>
+
+For packaging systems which support this, the name of the source
+package. If unavailable this is returned as an empty string C<\"\">.
+
+=item C<app_summary>
+
+A short (usually one line) description of the application or package.
+If unavailable this is returned as an empty string C<\"\">.
+
+=item C<app_description>
+
+A longer description of the application or package.
+If unavailable this is returned as an empty string C<\"\">.
+
+=back
+
+Please read L<guestfs(3)/INSPECTION> for more details.");
+
+ ("inspect_get_hostname", (RString "hostname", [Device "root"], []), -1, [],
+ [],
+ "get hostname of the operating system",
+ "\
+This function returns the hostname of the operating system
+as found by inspection of the guest's configuration files.
+
+If the hostname could not be determined, then the
+string C<unknown> is returned.
+
+Please read L<guestfs(3)/INSPECTION> for more details.");
+
+ ("inspect_get_format", (RString "format", [Device "root"], []), -1, [],
+ [],
+ "get format of inspected operating system",
+ "\
+This returns the format of the inspected operating system. You
+can use it to detect install images, live CDs and similar.
+
+Currently defined formats are:
+
+=over 4
+
+=item \"installed\"
+
+This is an installed operating system.
+
+=item \"installer\"
+
+The disk image being inspected is not an installed operating system,
+but a I<bootable> install disk, live CD, or similar.
+
+=item \"unknown\"
+
+The format of this disk image is not known.
+
+=back
+
+Future versions of libguestfs may return other strings here.
+The caller should be prepared to handle any string.
+
+Please read L<guestfs(3)/INSPECTION> for more details.");
+
+ ("inspect_is_live", (RBool "live", [Device "root"], []), -1, [],
+ [],
+ "get live flag for install disk",
+ "\
+If C<guestfs_inspect_get_format> returns C<installer> (this
+is an install disk), then this returns true if a live image
+was detected on the disk.
+
+Please read L<guestfs(3)/INSPECTION> for more details.");
+
+ ("inspect_is_netinst", (RBool "netinst", [Device "root"], []), -1, [],
+ [],
+ "get netinst (network installer) flag for install disk",
+ "\
+If C<guestfs_inspect_get_format> returns C<installer> (this
+is an install disk), then this returns true if the disk is
+a network installer, ie. not a self-contained install CD but
+one which is likely to require network access to complete
+the install.
+
+Please read L<guestfs(3)/INSPECTION> for more details.");
+
+ ("inspect_is_multipart", (RBool "multipart", [Device "root"], []), -1, [],
+ [],
+ "get multipart flag for install disk",
+ "\
+If C<guestfs_inspect_get_format> returns C<installer> (this
+is an install disk), then this returns true if the disk is
+part of a set.
+
+Please read L<guestfs(3)/INSPECTION> for more details.");
+
+ ("set_attach_method", (RErr, [String "attachmethod"], []), -1, [FishAlias "attach-method"],
+ [],
+ "set the attach method",
+ "\
+Set the method that libguestfs uses to connect to the back end
+guestfsd daemon. Possible methods are:
+
+=over 4
+
+=item C<appliance>
+
+Launch an appliance and connect to it. This is the ordinary method
+and the default.
+
+=item C<unix:I<path>>
+
+Connect to the Unix domain socket I<path>.
+
+This method lets you connect to an existing daemon or (using
+virtio-serial) to a live guest. For more information, see
+L<guestfs(3)/ATTACHING TO RUNNING DAEMONS>.
+
+=back");
+
+ ("get_attach_method", (RString "attachmethod", [], []), -1, [],
+ [InitNone, Always, TestOutput (
+ [["get_attach_method"]], "appliance")],
+ "get the attach method",
+ "\
+Return the current attach method. See C<guestfs_set_attach_method>.");
+
+ ("inspect_get_product_variant", (RString "variant", [Device "root"], []), -1, [],
+ [],
+ "get product variant of inspected operating system",
+ "\
+This returns the product variant of the inspected operating
+system.
+
+For Windows guests, this returns the contents of the Registry key
+C<HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion>
+C<InstallationType> which is usually a string such as
+C<Client> or C<Server> (other values are possible). This
+can be used to distinguish consumer and enterprise versions
+of Windows that have the same version number (for example,
+Windows 7 and Windows 2008 Server are both version 6.1,
+but the former is C<Client> and the latter is C<Server>).
+
+For enterprise Linux guests, in future we intend this to return
+the product variant such as C<Desktop>, C<Server> and so on. But
+this is not implemented at present.
+
+If the product variant could not be determined, then the
+string C<unknown> is returned.
+
+Please read L<guestfs(3)/INSPECTION> for more details.
+See also C<guestfs_inspect_get_product_name>,
+C<guestfs_inspect_get_major_version>.");
+
+ ("inspect_get_windows_current_control_set", (RString "controlset", [Device "root"], []), -1, [],
+ [],
+ "get Windows CurrentControlSet of inspected operating system",
+ "\
+This returns the Windows CurrentControlSet of the inspected guest.
+The CurrentControlSet is a registry key name such as C<ControlSet001>.
+
+This call assumes that the guest is Windows and that the
+Registry could be examined by inspection. If this is not
+the case then an error is returned.
+
+Please read L<guestfs(3)/INSPECTION> for more details.");
+
+ ("inspect_get_drive_mappings", (RHashtable "drives", [Device "root"], []), -1, [],
+ [],
+ "get drive letter mappings",
+ "\
+This call is useful for Windows which uses a primitive system
+of assigning drive letters (like \"C:\") to partitions.
+This inspection API examines the Windows Registry to find out
+how disks/partitions are mapped to drive letters, and returns
+a hash table as in the example below:
+
+ C => /dev/vda2
+ E => /dev/vdb1
+ F => /dev/vdc1
+
+Note that keys are drive letters. For Windows, the key is
+case insensitive and just contains the drive letter, without
+the customary colon separator character.
+
+In future we may support other operating systems that also used drive
+letters, but the keys for those might not be case insensitive
+and might be longer than 1 character. For example in OS-9,
+hard drives were named C<h0>, C<h1> etc.
+
+For Windows guests, currently only hard drive mappings are
+returned. Removable disks (eg. DVD-ROMs) are ignored.
+
+For guests that do not use drive mappings, or if the drive mappings
+could not be determined, this returns an empty hash table.
+
+Please read L<guestfs(3)/INSPECTION> for more details.
+See also C<guestfs_inspect_get_mountpoints>,
+C<guestfs_inspect_get_filesystems>.");
+
+ ("inspect_get_icon", (RBufferOut "icon", [Device "root"], [Bool "favicon"; Bool "highquality"]), -1, [],
+ [],
+ "get the icon corresponding to this operating system",
+ "\
+This function returns an icon corresponding to the inspected
+operating system. The icon is returned as a buffer containing a
+PNG image (re-encoded to PNG if necessary).
+
+If it was not possible to get an icon this function returns a
+zero-length (non-NULL) buffer. I<Callers must check for this case>.
+
+Libguestfs will start by looking for a file called
+C</etc/favicon.png> or C<C:\\etc\\favicon.png>
+and if it has the correct format, the contents of this file will
+be returned. You can disable favicons by passing the
+optional C<favicon> boolean as false (default is true).
+
+If finding the favicon fails, then we look in other places in the
+guest for a suitable icon.
+
+If the optional C<highquality> boolean is true then
+only high quality icons are returned, which means only icons of
+high resolution with an alpha channel. The default (false) is
+to return any icon we can, even if it is of substandard quality.
+
+Notes:
+
+=over 4
+
+=item *
+
+Unlike most other inspection API calls, the guest's disks must be
+mounted up before you call this, since it needs to read information
+from the guest filesystem during the call.
+
+=item *
+
+B<Security:> The icon data comes from the untrusted guest,
+and should be treated with caution. PNG files have been
+known to contain exploits. Ensure that libpng (or other relevant
+libraries) are fully up to date before trying to process or
+display the icon.
+
+=item *
+
+The PNG image returned can be any size. It might not be square.
+Libguestfs tries to return the largest, highest quality
+icon available. The application must scale the icon to the
+required size.
+
+=item *
+
+Extracting icons from Windows guests requires the external
+C<wrestool> program from the C<icoutils> package, and
+several programs (C<bmptopnm>, C<pnmtopng>, C<pamcut>)
+from the C<netpbm> package. These must be installed separately.
+
+=item *
+
+Operating system icons are usually trademarks. Seek legal
+advice before using trademarks in applications.
+
+=back");
+
+ ("set_pgroup", (RErr, [Bool "pgroup"], []), -1, [FishAlias "pgroup"],
+ [],
+ "set process group flag",
+ "\
+If C<pgroup> is true, child processes are placed into
+their own process group.
+
+The practical upshot of this is that signals like C<SIGINT> (from
+users pressing C<^C>) won't be received by the child process.
+
+The default for this flag is false, because usually you want
+C<^C> to kill the subprocess.");
+
+ ("get_pgroup", (RBool "pgroup", [], []), -1, [],
+ [],
+ "get process group flag",
+ "\
+This returns the process group flag.");
+
+ ("set_smp", (RErr, [Int "smp"], []), -1, [FishAlias "smp"],
+ [],
+ "set number of virtual CPUs in appliance",
+ "\
+Change the number of virtual CPUs assigned to the appliance. The
+default is C<1>. Increasing this may improve performance, though
+often it has no effect.
+
+This function must be called before C<guestfs_launch>.");
+
+ ("get_smp", (RInt "smp", [], []), -1, [],
+ [],
+ "get number of virtual CPUs in appliance",
+ "\
+This returns the number of virtual CPUs assigned to the appliance.");
+
+]
+
+(* daemon_functions are any functions which cause some action
+ * to take place in the daemon.
+ *)
+
+let daemon_functions = [
+ ("mount", (RErr, [Device "device"; String "mountpoint"], []), 1, [],
+ [InitEmpty, Always, TestOutput (
+ [["part_disk"; "/dev/sda"; "mbr"];
+ ["mkfs"; "ext2"; "/dev/sda1"];
+ ["mount"; "/dev/sda1"; "/"];
+ ["write"; "/new"; "new file contents"];
+ ["cat"; "/new"]], "new file contents")],
+ "mount a guest disk at a position in the filesystem",
+ "\
+Mount a guest disk at a position in the filesystem. Block devices
+are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
+the guest. If those block devices contain partitions, they will have
+the usual names (eg. C</dev/sda1>). Also LVM C</dev/VG/LV>-style
+names can be used.
+
+The rules are the same as for L<mount(2)>: A filesystem must
+first be mounted on C</> before others can be mounted. Other
+filesystems can only be mounted on directories which already
+exist.
+
+The mounted filesystem is writable, if we have sufficient permissions
+on the underlying device.
+
+Before libguestfs 1.13.16, this call implicitly added the options
+C<sync> and C<noatime>. The C<sync> option greatly slowed
+writes and caused many problems for users. If your program
+might need to work with older versions of libguestfs, use
+C<guestfs_mount_options> instead (using an empty string for the
+first parameter if you don't want any options).");
+
+ ("sync", (RErr, [], []), 2, [],
+ [ InitEmpty, Always, TestRun [["sync"]]],
+ "sync disks, writes are flushed through to the disk image",
+ "\
+This syncs the disk, so that any writes are flushed through to the
+underlying disk image.
+
+You should always call this if you have modified a disk image, before
+closing the handle.");
+
+ ("touch", (RErr, [Pathname "path"], []), 3, [],
+ [InitScratchFS, Always, TestOutputTrue (
+ [["touch"; "/touch"];
+ ["exists"; "/touch"]])],
+ "update file timestamps or create a new file",
+ "\
+Touch acts like the L<touch(1)> command. It can be used to
+update the timestamps on a file, or, if the file does not exist,
+to create a new zero-length file.
+
+This command only works on regular files, and will fail on other
+file types such as directories, symbolic links, block special etc.");
+
+ ("cat", (RString "content", [Pathname "path"], []), 4, [ProtocolLimitWarning],
+ [InitISOFS, Always, TestOutput (
+ [["cat"; "/known-2"]], "abcdef\n")],
+ "list the contents of a file",
+ "\
+Return the contents of the file named C<path>.
+
+Note that this function cannot correctly handle binary files
+(specifically, files containing C<\\0> character which is treated
+as end of string). For those you need to use the C<guestfs_read_file>
+or C<guestfs_download> functions which have a more complex interface.");
+
+ ("ll", (RString "listing", [Pathname "directory"], []), 5, [],
+ [], (* XXX Tricky to test because it depends on the exact format
+ * of the 'ls -l' command, which changes between F10 and F11.
+ *)
+ "list the files in a directory (long format)",
+ "\
+List the files in C<directory> (relative to the root directory,
+there is no cwd) in the format of 'ls -la'.
+
+This command is mostly useful for interactive sessions. It
+is I<not> intended that you try to parse the output string.");
+
+ ("ls", (RStringList "listing", [Pathname "directory"], []), 6, [],
+ [InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/ls"];
+ ["touch"; "/ls/new"];
+ ["touch"; "/ls/newer"];
+ ["touch"; "/ls/newest"];
+ ["ls"; "/ls"]], ["new"; "newer"; "newest"])],
+ "list the files in a directory",
+ "\
+List the files in C<directory> (relative to the root directory,
+there is no cwd). The '.' and '..' entries are not returned, but
+hidden files are shown.
+
+This command is mostly useful for interactive sessions. Programs
+should probably use C<guestfs_readdir> instead.");
+
+ ("list_devices", (RStringList "devices", [], []), 7, [],
+ [InitEmpty, Always, TestOutputListOfDevices (
+ [["list_devices"]], ["/dev/sda"; "/dev/sdb"; "/dev/sdc"; "/dev/sdd"])],
+ "list the block devices",
+ "\
+List all the block devices.
+
+The full block device names are returned, eg. C</dev/sda>.
+
+See also C<guestfs_list_filesystems>.");
+
+ ("list_partitions", (RStringList "partitions", [], []), 8, [],
+ [InitBasicFS, Always, TestOutputListOfDevices (
+ [["list_partitions"]], ["/dev/sda1"; "/dev/sdb1"]);
+ InitEmpty, Always, TestOutputListOfDevices (
+ [["part_init"; "/dev/sda"; "mbr"];
+ ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
+ ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
+ ["part_add"; "/dev/sda"; "p"; "409600"; "-64"];
+ ["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"; "/dev/sdb1"])],
+ "list the partitions",
+ "\
+List all the partitions detected on all block devices.
+
+The full partition device names are returned, eg. C</dev/sda1>
+
+This does not return logical volumes. For that you will need to
+call C<guestfs_lvs>.
+
+See also C<guestfs_list_filesystems>.");
+
+ ("pvs", (RStringList "physvols", [], []), 9, [Optional "lvm2"],
+ [InitBasicFSonLVM, Always, TestOutputListOfDevices (
+ [["pvs"]], ["/dev/sda1"]);
+ InitEmpty, Always, TestOutputListOfDevices (
+ [["part_init"; "/dev/sda"; "mbr"];
+ ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
+ ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
+ ["part_add"; "/dev/sda"; "p"; "409600"; "-64"];
+ ["pvcreate"; "/dev/sda1"];
+ ["pvcreate"; "/dev/sda2"];
+ ["pvcreate"; "/dev/sda3"];
+ ["pvs"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])],
+ "list the LVM physical volumes (PVs)",
+ "\
+List all the physical volumes detected. This is the equivalent
+of the L<pvs(8)> command.
+
+This returns a list of just the device names that contain
+PVs (eg. C</dev/sda2>).
+
+See also C<guestfs_pvs_full>.");
+
+ ("vgs", (RStringList "volgroups", [], []), 10, [Optional "lvm2"],
+ [InitBasicFSonLVM, Always, TestOutputList (
+ [["vgs"]], ["VG"]);
+ InitEmpty, Always, TestOutputList (
+ [["part_init"; "/dev/sda"; "mbr"];
+ ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
+ ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
+ ["part_add"; "/dev/sda"; "p"; "409600"; "-64"];
+ ["pvcreate"; "/dev/sda1"];
+ ["pvcreate"; "/dev/sda2"];
+ ["pvcreate"; "/dev/sda3"];
+ ["vgcreate"; "VG1"; "/dev/sda1 /dev/sda2"];
+ ["vgcreate"; "VG2"; "/dev/sda3"];
+ ["vgs"]], ["VG1"; "VG2"])],
+ "list the LVM volume groups (VGs)",
+ "\
+List all the volumes groups detected. This is the equivalent
+of the L<vgs(8)> command.
+
+This returns a list of just the volume group names that were
+detected (eg. C<VolGroup00>).
+
+See also C<guestfs_vgs_full>.");
+
+ ("lvs", (RStringList "logvols", [], []), 11, [Optional "lvm2"],
+ [InitBasicFSonLVM, Always, TestOutputList (
+ [["lvs"]], ["/dev/VG/LV"]);
+ InitEmpty, Always, TestOutputList (
+ [["part_init"; "/dev/sda"; "mbr"];
+ ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
+ ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
+ ["part_add"; "/dev/sda"; "p"; "409600"; "-64"];
+ ["pvcreate"; "/dev/sda1"];
+ ["pvcreate"; "/dev/sda2"];
+ ["pvcreate"; "/dev/sda3"];
+ ["vgcreate"; "VG1"; "/dev/sda1 /dev/sda2"];
+ ["vgcreate"; "VG2"; "/dev/sda3"];
+ ["lvcreate"; "LV1"; "VG1"; "50"];
+ ["lvcreate"; "LV2"; "VG1"; "50"];
+ ["lvcreate"; "LV3"; "VG2"; "50"];
+ ["lvs"]], ["/dev/VG1/LV1"; "/dev/VG1/LV2"; "/dev/VG2/LV3"])],
+ "list the LVM logical volumes (LVs)",
+ "\
+List all the logical volumes detected. This is the equivalent
+of the L<lvs(8)> command.
+
+This returns a list of the logical volume device names
+(eg. C</dev/VolGroup00/LogVol00>).
+
+See also C<guestfs_lvs_full>, C<guestfs_list_filesystems>.");
+
+ ("pvs_full", (RStructList ("physvols", "lvm_pv"), [], []), 12, [Optional "lvm2"],
+ [], (* XXX how to test? *)
+ "list the LVM physical volumes (PVs)",
+ "\
+List all the physical volumes detected. This is the equivalent
+of the L<pvs(8)> command. The \"full\" version includes all fields.");
+
+ ("vgs_full", (RStructList ("volgroups", "lvm_vg"), [], []), 13, [Optional "lvm2"],
+ [], (* XXX how to test? *)
+ "list the LVM volume groups (VGs)",
+ "\
+List all the volumes groups detected. This is the equivalent
+of the L<vgs(8)> command. The \"full\" version includes all fields.");
+
+ ("lvs_full", (RStructList ("logvols", "lvm_lv"), [], []), 14, [Optional "lvm2"],
+ [], (* XXX how to test? *)
+ "list the LVM logical volumes (LVs)",
+ "\
+List all the logical volumes detected. This is the equivalent
+of the L<lvs(8)> command. The \"full\" version includes all fields.");
+
+ ("read_lines", (RStringList "lines", [Pathname "path"], []), 15, [],
+ [InitISOFS, Always, TestOutputList (
+ [["read_lines"; "/known-4"]], ["abc"; "def"; "ghi"]);
+ InitISOFS, Always, TestOutputList (
+ [["read_lines"; "/empty"]], [])],
+ "read file as lines",
+ "\
+Return the contents of the file named C<path>.
+
+The file contents are returned as a list of lines. Trailing
+C<LF> and C<CRLF> character sequences are I<not> returned.
+
+Note that this function cannot correctly handle binary files
+(specifically, files containing C<\\0> character which is treated
+as end of line). For those you need to use the C<guestfs_read_file>
+function which has a more complex interface.");
+
+ ("aug_init", (RErr, [Pathname "root"; Int "flags"], []), 16, [Optional "augeas"],
+ [], (* XXX Augeas code needs tests. *)
+ "create a new Augeas handle",
+ "\
+Create a new Augeas handle for editing configuration files.
+If there was any previous Augeas handle associated with this
+guestfs session, then it is closed.
+
+You must call this before using any other C<guestfs_aug_*>
+commands.
+
+C<root> is the filesystem root. C<root> must not be NULL,
+use C</> instead.
+
+The flags are the same as the flags defined in
+E<lt>augeas.hE<gt>, the logical I<or> of the following
+integers:
=over 4
=item C<AUG_TYPE_CHECK> = 4
-Typecheck lenses (can be expensive).
+Typecheck lenses.
+
+This option is only useful when debugging Augeas lenses. Use
+of this option may require additional memory for the libguestfs
+appliance. You may need to set the C<LIBGUESTFS_MEMSIZE>
+environment variable or call C<guestfs_set_memsize>.
=item C<AUG_NO_STDINC> = 8
C<path/*> and sorting the resulting nodes into alphabetical order.");
("rm", (RErr, [Pathname "path"], []), 29, [],
- [InitBasicFS, Always, TestRun
- [["touch"; "/new"];
- ["rm"; "/new"]];
- InitBasicFS, Always, TestLastFail
- [["rm"; "/new"]];
- InitBasicFS, Always, TestLastFail
- [["mkdir"; "/new"];
- ["rm"; "/new"]]],
+ [InitScratchFS, Always, TestRun
+ [["mkdir"; "/rm"];
+ ["touch"; "/rm/new"];
+ ["rm"; "/rm/new"]];
+ InitScratchFS, Always, TestLastFail
+ [["rm"; "/nosuchfile"]];
+ InitScratchFS, Always, TestLastFail
+ [["mkdir"; "/rm2"];
+ ["rm"; "/rm2"]]],
"remove a file",
"\
Remove the single file C<path>.");
("rmdir", (RErr, [Pathname "path"], []), 30, [],
- [InitBasicFS, Always, TestRun
- [["mkdir"; "/new"];
- ["rmdir"; "/new"]];
- InitBasicFS, Always, TestLastFail
- [["rmdir"; "/new"]];
- InitBasicFS, Always, TestLastFail
- [["touch"; "/new"];
- ["rmdir"; "/new"]]],
+ [InitScratchFS, Always, TestRun
+ [["mkdir"; "/rmdir"];
+ ["rmdir"; "/rmdir"]];
+ InitScratchFS, Always, TestLastFail
+ [["rmdir"; "/rmdir2"]];
+ InitScratchFS, Always, TestLastFail
+ [["mkdir"; "/rmdir3"];
+ ["touch"; "/rmdir3/new"];
+ ["rmdir"; "/rmdir3/new"]]],
"remove a directory",
"\
Remove the single directory C<path>.");
("rm_rf", (RErr, [Pathname "path"], []), 31, [],
- [InitBasicFS, Always, TestOutputFalse
- [["mkdir"; "/new"];
- ["mkdir"; "/new/foo"];
- ["touch"; "/new/foo/bar"];
- ["rm_rf"; "/new"];
- ["exists"; "/new"]]],
+ [InitScratchFS, Always, TestOutputFalse
+ [["mkdir"; "/rm_rf"];
+ ["mkdir"; "/rm_rf/foo"];
+ ["touch"; "/rm_rf/foo/bar"];
+ ["rm_rf"; "/rm_rf"];
+ ["exists"; "/rm_rf"]]],
"remove a file or directory recursively",
"\
Remove the file or directory C<path>, recursively removing the
command.");
("mkdir", (RErr, [Pathname "path"], []), 32, [],
- [InitBasicFS, Always, TestOutputTrue
- [["mkdir"; "/new"];
- ["is_dir"; "/new"]];
- InitBasicFS, Always, TestLastFail
- [["mkdir"; "/new/foo/bar"]]],
+ [InitScratchFS, Always, TestOutputTrue
+ [["mkdir"; "/mkdir"];
+ ["is_dir"; "/mkdir"]];
+ InitScratchFS, Always, TestLastFail
+ [["mkdir"; "/mkdir2/foo/bar"]]],
"create a directory",
"\
Create a directory named C<path>.");
("mkdir_p", (RErr, [Pathname "path"], []), 33, [],
- [InitBasicFS, Always, TestOutputTrue
- [["mkdir_p"; "/new/foo/bar"];
- ["is_dir"; "/new/foo/bar"]];
- InitBasicFS, Always, TestOutputTrue
- [["mkdir_p"; "/new/foo/bar"];
- ["is_dir"; "/new/foo"]];
- InitBasicFS, Always, TestOutputTrue
- [["mkdir_p"; "/new/foo/bar"];
- ["is_dir"; "/new"]];
+ [InitScratchFS, Always, TestOutputTrue
+ [["mkdir_p"; "/mkdir_p/foo/bar"];
+ ["is_dir"; "/mkdir_p/foo/bar"]];
+ InitScratchFS, Always, TestOutputTrue
+ [["mkdir_p"; "/mkdir_p2/foo/bar"];
+ ["is_dir"; "/mkdir_p2/foo"]];
+ InitScratchFS, Always, TestOutputTrue
+ [["mkdir_p"; "/mkdir_p3/foo/bar"];
+ ["is_dir"; "/mkdir_p3"]];
(* Regression tests for RHBZ#503133: *)
- InitBasicFS, Always, TestRun
- [["mkdir"; "/new"];
- ["mkdir_p"; "/new"]];
- InitBasicFS, Always, TestLastFail
- [["touch"; "/new"];
- ["mkdir_p"; "/new"]]],
+ InitScratchFS, Always, TestRun
+ [["mkdir"; "/mkdir_p4"];
+ ["mkdir_p"; "/mkdir_p4"]];
+ InitScratchFS, Always, TestLastFail
+ [["touch"; "/mkdir_p5"];
+ ["mkdir_p"; "/mkdir_p5"]]],
"create a directory and parents",
"\
Create a directory named C<path>, creating any parent directories
("sfdisk", (RErr, [Device "device";
Int "cyls"; Int "heads"; Int "sectors";
- StringList "lines"], []), 43, [DangerWillRobinson],
+ StringList "lines"], []), 43, [DeprecatedBy "part_add"],
[],
"create partitions on a block device",
"\
("write_file", (RErr, [Pathname "path"; String "content"; Int "size"], []), 44, [ProtocolLimitWarning; DeprecatedBy "write"],
(* Regression test for RHBZ#597135. *)
- [InitBasicFS, Always, TestLastFail
- [["write_file"; "/new"; "abc"; "10000"]]],
+ [InitScratchFS, Always, TestLastFail
+ [["write_file"; "/write_file"; "abc"; "10000"]]],
"create a file",
"\
This call creates a file called C<path>. The contents of the
contains the filesystem.");
("mounts", (RStringList "devices", [], []), 46, [],
- [InitBasicFS, Always, TestOutputListOfDevices (
- [["mounts"]], ["/dev/sda1"])],
+ [InitScratchFS, Always, TestOutputListOfDevices (
+ [["mounts"]], ["/dev/sdb1"])],
"show mounted filesystems",
"\
This returns the list of currently mounted filesystems. It returns
See also: C<guestfs_mountpoints>");
("umount_all", (RErr, [], []), 47, [FishAlias "unmount-all"],
- [InitBasicFS, Always, TestOutputList (
+ [InitScratchFS, Always, TestOutputList (
[["umount_all"];
["mounts"]], []);
(* check that umount_all can unmount nested mounts correctly: *)
Some internal mounts are not unmounted by this call.");
- ("lvm_remove_all", (RErr, [], []), 48, [DangerWillRobinson; Optional "lvm2"],
+ ("lvm_remove_all", (RErr, [], []), 48, [Optional "lvm2"],
[],
"remove all LVM LVs, VGs and PVs",
"\
The exact command which runs is C<file -zb path>. Note in
particular that the filename is not prepended to the output
-(the C<-b> option).
+(the I<-b> option).
-This command can also be used on C</dev/> devices
-(and partitions, LV names). You can for example use this
-to determine if a device contains a filesystem, although
-it's usually better to use C<guestfs_vfs_type>.
+The output depends on the output of the underlying L<file(1)>
+command and it can change in future in ways beyond our control.
+In other words, the output is not guaranteed by the ABI.
-If the C<path> does not begin with C</dev/> then
-this command only works for the content of regular files.
-For other file types (directory, symbolic link etc) it
-will just return the string C<directory> etc.");
+See also: L<file(1)>, C<guestfs_vfs_type>, C<guestfs_lstat>,
+C<guestfs_is_file>, C<guestfs_is_blockdev> (etc), C<guestfs_is_zero>.");
("command", (RString "output", [StringList "arguments"], []), 50, [ProtocolLimitWarning],
- [InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 1"]], "Result1");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 2"]], "Result2\n");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 3"]], "\nResult3");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 4"]], "\nResult4\n");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 5"]], "\nResult5\n\n");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 6"]], "\n\nResult6\n\n");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 7"]], "");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 8"]], "\n");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 9"]], "\n\n");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 10"]], "Result10-1\nResult10-2\n");
- InitBasicFS, Always, TestOutput (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command 11"]], "Result11-1\nResult11-2");
- InitBasicFS, Always, TestLastFail (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command"; "/test-command"]])],
+ [InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command"];
+ ["upload"; "test-command"; "/command/test-command"];
+ ["chmod"; "0o755"; "/command/test-command"];
+ ["command"; "/command/test-command 1"]], "Result1");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command2"];
+ ["upload"; "test-command"; "/command2/test-command"];
+ ["chmod"; "0o755"; "/command2/test-command"];
+ ["command"; "/command2/test-command 2"]], "Result2\n");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command3"];
+ ["upload"; "test-command"; "/command3/test-command"];
+ ["chmod"; "0o755"; "/command3/test-command"];
+ ["command"; "/command3/test-command 3"]], "\nResult3");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command4"];
+ ["upload"; "test-command"; "/command4/test-command"];
+ ["chmod"; "0o755"; "/command4/test-command"];
+ ["command"; "/command4/test-command 4"]], "\nResult4\n");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command5"];
+ ["upload"; "test-command"; "/command5/test-command"];
+ ["chmod"; "0o755"; "/command5/test-command"];
+ ["command"; "/command5/test-command 5"]], "\nResult5\n\n");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command6"];
+ ["upload"; "test-command"; "/command6/test-command"];
+ ["chmod"; "0o755"; "/command6/test-command"];
+ ["command"; "/command6/test-command 6"]], "\n\nResult6\n\n");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command7"];
+ ["upload"; "test-command"; "/command7/test-command"];
+ ["chmod"; "0o755"; "/command7/test-command"];
+ ["command"; "/command7/test-command 7"]], "");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command8"];
+ ["upload"; "test-command"; "/command8/test-command"];
+ ["chmod"; "0o755"; "/command8/test-command"];
+ ["command"; "/command8/test-command 8"]], "\n");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command9"];
+ ["upload"; "test-command"; "/command9/test-command"];
+ ["chmod"; "0o755"; "/command9/test-command"];
+ ["command"; "/command9/test-command 9"]], "\n\n");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command10"];
+ ["upload"; "test-command"; "/command10/test-command"];
+ ["chmod"; "0o755"; "/command10/test-command"];
+ ["command"; "/command10/test-command 10"]], "Result10-1\nResult10-2\n");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/command11"];
+ ["upload"; "test-command"; "/command11/test-command"];
+ ["chmod"; "0o755"; "/command11/test-command"];
+ ["command"; "/command11/test-command 11"]], "Result11-1\nResult11-2");
+ InitScratchFS, Always, TestLastFail (
+ [["mkdir"; "/command12"];
+ ["upload"; "test-command"; "/command12/test-command"];
+ ["chmod"; "0o755"; "/command12/test-command"];
+ ["command"; "/command12/test-command"]])],
"run a command from the guest filesystem",
"\
This call runs a command from the guest filesystem. The
locations.");
("command_lines", (RStringList "lines", [StringList "arguments"], []), 51, [ProtocolLimitWarning],
- [InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 1"]], ["Result1"]);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 2"]], ["Result2"]);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 3"]], ["";"Result3"]);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 4"]], ["";"Result4"]);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 5"]], ["";"Result5";""]);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 6"]], ["";"";"Result6";""]);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 7"]], []);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 8"]], [""]);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 9"]], ["";""]);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 10"]], ["Result10-1";"Result10-2"]);
- InitBasicFS, Always, TestOutputList (
- [["upload"; "test-command"; "/test-command"];
- ["chmod"; "0o755"; "/test-command"];
- ["command_lines"; "/test-command 11"]], ["Result11-1";"Result11-2"])],
+ [InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines"];
+ ["upload"; "test-command"; "/command_lines/test-command"];
+ ["chmod"; "0o755"; "/command_lines/test-command"];
+ ["command_lines"; "/command_lines/test-command 1"]], ["Result1"]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines2"];
+ ["upload"; "test-command"; "/command_lines2/test-command"];
+ ["chmod"; "0o755"; "/command_lines2/test-command"];
+ ["command_lines"; "/command_lines2/test-command 2"]], ["Result2"]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines3"];
+ ["upload"; "test-command"; "/command_lines3/test-command"];
+ ["chmod"; "0o755"; "/command_lines3/test-command"];
+ ["command_lines"; "/command_lines3/test-command 3"]], ["";"Result3"]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines4"];
+ ["upload"; "test-command"; "/command_lines4/test-command"];
+ ["chmod"; "0o755"; "/command_lines4/test-command"];
+ ["command_lines"; "/command_lines4/test-command 4"]], ["";"Result4"]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines5"];
+ ["upload"; "test-command"; "/command_lines5/test-command"];
+ ["chmod"; "0o755"; "/command_lines5/test-command"];
+ ["command_lines"; "/command_lines5/test-command 5"]], ["";"Result5";""]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines6"];
+ ["upload"; "test-command"; "/command_lines6/test-command"];
+ ["chmod"; "0o755"; "/command_lines6/test-command"];
+ ["command_lines"; "/command_lines6/test-command 6"]], ["";"";"Result6";""]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines7"];
+ ["upload"; "test-command"; "/command_lines7/test-command"];
+ ["chmod"; "0o755"; "/command_lines7/test-command"];
+ ["command_lines"; "/command_lines7/test-command 7"]], []);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines8"];
+ ["upload"; "test-command"; "/command_lines8/test-command"];
+ ["chmod"; "0o755"; "/command_lines8/test-command"];
+ ["command_lines"; "/command_lines8/test-command 8"]], [""]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines9"];
+ ["upload"; "test-command"; "/command_lines9/test-command"];
+ ["chmod"; "0o755"; "/command_lines9/test-command"];
+ ["command_lines"; "/command_lines9/test-command 9"]], ["";""]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines10"];
+ ["upload"; "test-command"; "/command_lines10/test-command"];
+ ["chmod"; "0o755"; "/command_lines10/test-command"];
+ ["command_lines"; "/command_lines10/test-command 10"]], ["Result10-1";"Result10-2"]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/command_lines11"];
+ ["upload"; "test-command"; "/command_lines11/test-command"];
+ ["chmod"; "0o755"; "/command_lines11/test-command"];
+ ["command_lines"; "/command_lines11/test-command 11"]], ["Result11-1";"Result11-2"])],
"run a command, returning lines",
"\
This is the same as C<guestfs_command>, but splits the
This is the same as the C<statvfs(2)> system call.");
("tune2fs_l", (RHashtable "superblock", [Device "device"], []), 55, [],
- [], (* XXX test *)
+ [InitScratchFS, Always, TestOutputHashtable (
+ [["tune2fs_l"; "/dev/sdb1"]],
+ ["Filesystem magic number", "0xEF53";
+ "Filesystem OS type", "Linux"])],
"get ext2/ext3/ext4 superblock details",
"\
This returns the contents of the ext2, ext3 or ext4 filesystem
This uses the L<blockdev(8)> command.");
- ("upload", (RErr, [FileIn "filename"; Dev_or_Path "remotefilename"], []), 66, [],
- [InitBasicFS, Always, TestOutput (
+ ("upload", (RErr, [FileIn "filename"; Dev_or_Path "remotefilename"], []), 66, [Progress],
+ [InitScratchFS, Always, TestOutput (
(* Pick a file from cwd which isn't likely to change. *)
- [["upload"; "../COPYING.LIB"; "/COPYING.LIB"];
- ["checksum"; "md5"; "/COPYING.LIB"]],
+ [["mkdir"; "/upload"];
+ ["upload"; "../../COPYING.LIB"; "/upload/COPYING.LIB"];
+ ["checksum"; "md5"; "/upload/COPYING.LIB"]],
Digest.to_hex (Digest.file "COPYING.LIB"))],
"upload a file from the local machine",
"\
See also C<guestfs_download>.");
("download", (RErr, [Dev_or_Path "remotefilename"; FileOut "filename"], []), 67, [Progress],
- [InitBasicFS, Always, TestOutput (
+ [InitScratchFS, Always, TestOutput (
(* Pick a file from cwd which isn't likely to change. *)
- [["upload"; "../COPYING.LIB"; "/COPYING.LIB"];
- ["download"; "/COPYING.LIB"; "testdownload.tmp"];
- ["upload"; "testdownload.tmp"; "/upload"];
- ["checksum"; "md5"; "/upload"]],
+ [["mkdir"; "/download"];
+ ["upload"; "../../COPYING.LIB"; "/download/COPYING.LIB"];
+ ["download"; "/download/COPYING.LIB"; "testdownload.tmp"];
+ ["upload"; "testdownload.tmp"; "/download/upload"];
+ ["checksum"; "md5"; "/download/upload"]],
Digest.to_hex (Digest.file "COPYING.LIB"))],
"download a file to the local machine",
"\
To get the checksums for many files, use C<guestfs_checksums_out>.");
("tar_in", (RErr, [FileIn "tarfile"; Pathname "directory"], []), 69, [],
- [InitBasicFS, Always, TestOutput (
- [["tar_in"; "../images/helloworld.tar"; "/"];
- ["cat"; "/hello"]], "hello\n")],
+ [InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/tar_in"];
+ ["tar_in"; "../images/helloworld.tar"; "/tar_in"];
+ ["cat"; "/tar_in/hello"]], "hello\n")],
"unpack tarfile to directory",
"\
This command uploads and unpacks local file C<tarfile> (an
or C<guestfs_txz_out>.");
("tgz_in", (RErr, [FileIn "tarball"; Pathname "directory"], []), 71, [],
- [InitBasicFS, Always, TestOutput (
- [["tgz_in"; "../images/helloworld.tar.gz"; "/"];
- ["cat"; "/hello"]], "hello\n")],
+ [InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/tgz_in"];
+ ["tgz_in"; "../images/helloworld.tar.gz"; "/tgz_in"];
+ ["cat"; "/tgz_in/hello"]], "hello\n")],
"unpack compressed tarball to directory",
"\
This command uploads and unpacks local file C<tarball> (a
allows you to set both the mount options and the vfstype
as for the L<mount(8)> I<-o> and I<-t> flags.");
- ("debug", (RString "result", [String "subcmd"; StringList "extraargs"], []), 76, [],
+ ("debug", (RString "result", [String "subcmd"; StringList "extraargs"], []), 76, [NotInDocs],
[],
"debugging and internals",
"\
("get_e2uuid", (RString "uuid", [Device "device"], []), 83, [DeprecatedBy "vfs_uuid"],
(* Regression test for RHBZ#597112. *)
(let uuid = uuidgen () in
- [InitBasicFS, Always, TestOutput (
- [["mke2journal"; "1024"; "/dev/sdb"];
- ["set_e2uuid"; "/dev/sdb"; uuid];
- ["get_e2uuid"; "/dev/sdb"]], uuid)]),
+ [InitNone, Always, TestOutput (
+ [["mke2journal"; "1024"; "/dev/sdc"];
+ ["set_e2uuid"; "/dev/sdc"; uuid];
+ ["get_e2uuid"; "/dev/sdc"]], uuid)]),
"get the ext2/3/4 filesystem UUID",
"\
This returns the ext2/3/4 filesystem UUID of the filesystem on
This command is entirely equivalent to running C<fsck -a -t fstype device>.");
("zero", (RErr, [Device "device"], []), 85, [Progress],
- [InitBasicFS, Always, TestOutput (
+ [InitBasicFS, Always, TestRun (
[["umount"; "/dev/sda1"];
- ["zero"; "/dev/sda1"];
- ["file"; "/dev/sda1"]], "data")],
+ ["zero"; "/dev/sda1"]])],
"write zeroes to the device",
"\
This command writes zeroes over the first few blocks of C<device>.
to securely wipe the device). It should be sufficient to remove
any partition tables, filesystem superblocks and so on.
-See also: C<guestfs_zero_device>, C<guestfs_scrub_device>.");
+If blocks are already zero, then this command avoids writing
+zeroes. This prevents the underlying device from becoming non-sparse
+or growing unnecessarily.
- ("grub_install", (RErr, [Pathname "root"; Device "device"], []), 86, [],
+See also: C<guestfs_zero_device>, C<guestfs_scrub_device>,
+C<guestfs_is_zero_device>");
+
+ ("grub_install", (RErr, [Pathname "root"; Device "device"], []), 86, [Optional "grub"],
(* See:
* https://bugzilla.redhat.com/show_bug.cgi?id=484986
* https://bugzilla.redhat.com/show_bug.cgi?id=479760
["write"; "/boot/grub/device.map"; "(hd0) /dev/vda"];
["grub_install"; "/"; "/dev/vda"];
["is_dir"; "/boot"]])],
- "install GRUB",
+ "install GRUB 1",
"\
-This command installs GRUB (the Grand Unified Bootloader) on
+This command installs GRUB 1 (the Grand Unified Bootloader) on
C<device>, with the root directory being C<root>.
-Note: If grub-install reports the error
+Notes:
+
+=over 4
+
+=item *
+
+There is currently no way in the API to install grub2, which
+is used by most modern Linux guests. It is possible to run
+the grub2 command from the guest, although see the
+caveats in L<guestfs(3)/RUNNING COMMANDS>.
+
+=item *
+
+This uses C<grub-install> from the host. Unfortunately grub is
+not always compatible with itself, so this only works in rather
+narrow circumstances. Careful testing with each guest version
+is advisable.
+
+=item *
+
+If grub-install reports the error
\"No suitable drive was found in the generated device map.\"
it may be that you need to create a C</boot/grub/device.map>
file first that contains the mapping between grub device names
(hd0) /dev/vda
-replacing C</dev/vda> with the name of the installation device.");
+replacing C</dev/vda> with the name of the installation device.
+
+=back");
("cp", (RErr, [Pathname "src"; Pathname "dest"], []), 87, [],
- [InitBasicFS, Always, TestOutput (
- [["write"; "/old"; "file content"];
- ["cp"; "/old"; "/new"];
- ["cat"; "/new"]], "file content");
- InitBasicFS, Always, TestOutputTrue (
- [["write"; "/old"; "file content"];
- ["cp"; "/old"; "/new"];
- ["is_file"; "/old"]]);
- InitBasicFS, Always, TestOutput (
- [["write"; "/old"; "file content"];
- ["mkdir"; "/dir"];
- ["cp"; "/old"; "/dir/new"];
- ["cat"; "/dir/new"]], "file content")],
+ [InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/cp"];
+ ["write"; "/cp/old"; "file content"];
+ ["cp"; "/cp/old"; "/cp/new"];
+ ["cat"; "/cp/new"]], "file content");
+ InitScratchFS, Always, TestOutputTrue (
+ [["mkdir"; "/cp2"];
+ ["write"; "/cp2/old"; "file content"];
+ ["cp"; "/cp2/old"; "/cp2/new"];
+ ["is_file"; "/cp2/old"]]);
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/cp3"];
+ ["write"; "/cp3/old"; "file content"];
+ ["mkdir"; "/cp3/dir"];
+ ["cp"; "/cp3/old"; "/cp3/dir/new"];
+ ["cat"; "/cp3/dir/new"]], "file content")],
"copy a file",
"\
This copies a file from C<src> to C<dest> where C<dest> is
either a destination filename or destination directory.");
("cp_a", (RErr, [Pathname "src"; Pathname "dest"], []), 88, [],
- [InitBasicFS, Always, TestOutput (
- [["mkdir"; "/olddir"];
- ["mkdir"; "/newdir"];
- ["write"; "/olddir/file"; "file content"];
- ["cp_a"; "/olddir"; "/newdir"];
- ["cat"; "/newdir/olddir/file"]], "file content")],
+ [InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/cp_a1"];
+ ["mkdir"; "/cp_a2"];
+ ["write"; "/cp_a1/file"; "file content"];
+ ["cp_a"; "/cp_a1"; "/cp_a2"];
+ ["cat"; "/cp_a2/cp_a1/file"]], "file content")],
"copy a file or directory recursively",
"\
This copies a file or directory from C<src> to C<dest>
recursively using the C<cp -a> command.");
("mv", (RErr, [Pathname "src"; Pathname "dest"], []), 89, [],
- [InitBasicFS, Always, TestOutput (
- [["write"; "/old"; "file content"];
- ["mv"; "/old"; "/new"];
- ["cat"; "/new"]], "file content");
- InitBasicFS, Always, TestOutputFalse (
- [["write"; "/old"; "file content"];
- ["mv"; "/old"; "/new"];
- ["is_file"; "/old"]])],
+ [InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/mv"];
+ ["write"; "/mv/old"; "file content"];
+ ["mv"; "/mv/old"; "/mv/new"];
+ ["cat"; "/mv/new"]], "file content");
+ InitScratchFS, Always, TestOutputFalse (
+ [["mkdir"; "/mv2"];
+ ["write"; "/mv2/old"; "file content"];
+ ["mv"; "/mv2/old"; "/mv2/new"];
+ ["is_file"; "/mv2/old"]])],
"move a file",
"\
This moves a file from C<src> to C<dest> where C<dest> is
or attached block device(s) in any other way.");
("equal", (RBool "equality", [Pathname "file1"; Pathname "file2"], []), 93, [],
- [InitBasicFS, Always, TestOutputTrue (
- [["write"; "/file1"; "contents of a file"];
- ["cp"; "/file1"; "/file2"];
- ["equal"; "/file1"; "/file2"]]);
- InitBasicFS, Always, TestOutputFalse (
- [["write"; "/file1"; "contents of a file"];
- ["write"; "/file2"; "contents of another file"];
- ["equal"; "/file1"; "/file2"]]);
- InitBasicFS, Always, TestLastFail (
- [["equal"; "/file1"; "/file2"]])],
+ [InitScratchFS, Always, TestOutputTrue (
+ [["mkdir"; "/equal"];
+ ["write"; "/equal/file1"; "contents of a file"];
+ ["cp"; "/equal/file1"; "/equal/file2"];
+ ["equal"; "/equal/file1"; "/equal/file2"]]);
+ InitScratchFS, Always, TestOutputFalse (
+ [["mkdir"; "/equal2"];
+ ["write"; "/equal2/file1"; "contents of a file"];
+ ["write"; "/equal2/file2"; "contents of another file"];
+ ["equal"; "/equal2/file1"; "/equal2/file2"]]);
+ InitScratchFS, Always, TestLastFail (
+ [["mkdir"; "/equal3"];
+ ["equal"; "/equal3/file1"; "/equal3/file2"]])],
"test if two files have equal contents",
"\
This compares the two files C<file1> and C<file2> and returns
("strings_e", (RStringList "stringsout", [String "encoding"; Pathname "path"], []), 95, [ProtocolLimitWarning],
[InitISOFS, Always, TestOutputList (
[["strings_e"; "b"; "/known-5"]], []);
- InitBasicFS, Always, TestOutputList (
- [["write"; "/new"; "\000h\000e\000l\000l\000o\000\n\000w\000o\000r\000l\000d\000\n"];
- ["strings_e"; "b"; "/new"]], ["hello"; "world"])],
+ InitScratchFS, Always, TestOutputList (
+ [["write"; "/strings_e"; "\000h\000e\000l\000l\000o\000\n\000w\000o\000r\000l\000d\000\n"];
+ ["strings_e"; "b"; "/strings_e"]], ["hello"; "world"])],
"print the printable strings in a file",
"\
This is like the C<guestfs_strings> command, but allows you to
("sfdisk_N", (RErr, [Device "device"; Int "partnum";
Int "cyls"; Int "heads"; Int "sectors";
- String "line"], []), 99, [DangerWillRobinson],
+ String "line"], []), 99, [DeprecatedBy "part_add"],
[],
"modify a single partition on a block device",
"\
See also: C<guestfs_part_add>");
- ("sfdisk_l", (RString "partitions", [Device "device"], []), 100, [],
+ ("sfdisk_l", (RString "partitions", [Device "device"], []), 100, [DeprecatedBy "part_list"],
[],
"display the partition table",
"\
"\
This command activates or (if C<activate> is false) deactivates
all logical volumes in all volume groups.
-If activated, then they are made known to the
-kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
-then those devices disappear.
This command is the same as running C<vgchange -a y|n>");
"\
This command activates or (if C<activate> is false) deactivates
all logical volumes in the listed volume groups C<volgroups>.
-If activated, then they are made known to the
-kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
-then those devices disappear.
This command is the same as running C<vgchange -a y|n volgroups...>
["mkdir"; "/b"];
["touch"; "/b/c"];
["find"; "/"]], ["a"; "b"; "b/c"; "lost+found"]);
- InitBasicFS, Always, TestOutputList (
- [["mkdir_p"; "/a/b/c"];
- ["touch"; "/a/b/c/d"];
- ["find"; "/a/b/"]], ["c"; "c/d"])],
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir_p"; "/find/b/c"];
+ ["touch"; "/find/b/c/d"];
+ ["find"; "/find/b/"]], ["c"; "c/d"])],
"find all files and directories",
"\
This command lists out all files and directories, recursively,
"check an ext2/ext3 filesystem",
"\
This runs C<e2fsck -p -f device>, ie. runs the ext2/ext3
-filesystem checker on C<device>, noninteractively (C<-p>),
-even if the filesystem appears to be clean (C<-f>).
+filesystem checker on C<device>, noninteractively (I<-p>),
+even if the filesystem appears to be clean (I<-f>).
This command is only needed because of C<guestfs_resize2fs>
(q.v.). Normally you should use C<guestfs_fsck>.");
* code in stubs.c, since all valid glob patterns must start with "/".
* There is no concept of "cwd" in libguestfs, hence no "."-relative names.
*)
- [InitBasicFS, Always, TestOutputList (
- [["mkdir_p"; "/a/b/c"];
- ["touch"; "/a/b/c/d"];
- ["touch"; "/a/b/c/e"];
- ["glob_expand"; "/a/b/c/*"]], ["/a/b/c/d"; "/a/b/c/e"]);
- InitBasicFS, Always, TestOutputList (
- [["mkdir_p"; "/a/b/c"];
- ["touch"; "/a/b/c/d"];
- ["touch"; "/a/b/c/e"];
- ["glob_expand"; "/a/*/c/*"]], ["/a/b/c/d"; "/a/b/c/e"]);
- InitBasicFS, Always, TestOutputList (
- [["mkdir_p"; "/a/b/c"];
- ["touch"; "/a/b/c/d"];
- ["touch"; "/a/b/c/e"];
- ["glob_expand"; "/a/*/x/*"]], [])],
+ [InitScratchFS, Always, TestOutputList (
+ [["mkdir_p"; "/glob_expand/b/c"];
+ ["touch"; "/glob_expand/b/c/d"];
+ ["touch"; "/glob_expand/b/c/e"];
+ ["glob_expand"; "/glob_expand/b/c/*"]], ["/glob_expand/b/c/d"; "/glob_expand/b/c/e"]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir_p"; "/glob_expand2/b/c"];
+ ["touch"; "/glob_expand2/b/c/d"];
+ ["touch"; "/glob_expand2/b/c/e"];
+ ["glob_expand"; "/glob_expand2/*/c/*"]], ["/glob_expand2/b/c/d"; "/glob_expand2/b/c/e"]);
+ InitScratchFS, Always, TestOutputList (
+ [["mkdir_p"; "/glob_expand3/b/c"];
+ ["touch"; "/glob_expand3/b/c/d"];
+ ["touch"; "/glob_expand3/b/c/e"];
+ ["glob_expand"; "/glob_expand3/*/x/*"]], [])],
"expand a wildcard path",
"\
This command searches for all the pathnames matching
with flags C<GLOB_MARK|GLOB_BRACE>.
See that manual page for more details.");
- ("scrub_device", (RErr, [Device "device"], []), 114, [DangerWillRobinson; Optional "scrub"],
+ ("scrub_device", (RErr, [Device "device"], []), 114, [Optional "scrub"],
[InitNone, Always, TestRun ( (* use /dev/sdc because it's smaller *)
[["scrub_device"; "/dev/sdc"]])],
"scrub (securely wipe) a device",
manual page for more details.");
("scrub_file", (RErr, [Pathname "file"], []), 115, [Optional "scrub"],
- [InitBasicFS, Always, TestRun (
- [["write"; "/file"; "content"];
- ["scrub_file"; "/file"]])],
+ [InitScratchFS, Always, TestRun (
+ [["write"; "/scrub_file"; "content"];
+ ["scrub_file"; "/scrub_file"]])],
"scrub (securely wipe) a file",
"\
This command writes patterns over a file to make data retrieval
manual page for more details.");
("mkdtemp", (RString "dir", [Pathname "template"], []), 117, [],
- [InitBasicFS, Always, TestRun (
- [["mkdir"; "/tmp"];
- ["mkdtemp"; "/tmp/tmpXXXXXX"]])],
+ [InitScratchFS, Always, TestRun (
+ [["mkdir"; "/mkdtemp"];
+ ["mkdtemp"; "/mkdtemp/tmpXXXXXX"]])],
"create a temporary directory",
"\
This command creates a temporary directory. The
This command is mostly useful for interactive sessions. It
is I<not> intended that you try to parse the output string.
-Use C<statvfs> from programs.");
+Use C<guestfs_statvfs> from programs.");
("df_h", (RString "output", [], []), 126, [],
[], (* XXX Tricky to test because it depends on the exact format
This command is mostly useful for interactive sessions. It
is I<not> intended that you try to parse the output string.
-Use C<statvfs> from programs.");
+Use C<guestfs_statvfs> from programs.");
- ("du", (RInt64 "sizekb", [Pathname "path"], []), 127, [],
+ ("du", (RInt64 "sizekb", [Pathname "path"], []), 127, [Progress],
[InitISOFS, Always, TestOutputInt (
[["du"; "/directory"]], 2 (* ISO fs blocksize is 2K *))],
"estimate file space usage",
Create a swap partition on C<device> with UUID C<uuid>.");
("mknod", (RErr, [Int "mode"; Int "devmajor"; Int "devminor"; Pathname "path"], []), 133, [Optional "mknod"],
- [InitBasicFS, Always, TestOutputStruct (
- [["mknod"; "0o10777"; "0"; "0"; "/node"];
+ [InitScratchFS, Always, TestOutputStruct (
+ [["mknod"; "0o10777"; "0"; "0"; "/mknod"];
(* NB: default umask 022 means 0777 -> 0755 in these tests *)
- ["stat"; "/node"]], [CompareWithInt ("mode", 0o10755)]);
- InitBasicFS, Always, TestOutputStruct (
- [["mknod"; "0o60777"; "66"; "99"; "/node"];
- ["stat"; "/node"]], [CompareWithInt ("mode", 0o60755)])],
+ ["stat"; "/mknod"]], [CompareWithInt ("mode", 0o10755)]);
+ InitScratchFS, Always, TestOutputStruct (
+ [["mknod"; "0o60777"; "66"; "99"; "/mknod2"];
+ ["stat"; "/mknod2"]], [CompareWithInt ("mode", 0o60755)])],
"make block, character or FIFO devices",
"\
This call creates block or character special devices, or
The mode actually set is affected by the umask.");
("mkfifo", (RErr, [Int "mode"; Pathname "path"], []), 134, [Optional "mknod"],
- [InitBasicFS, Always, TestOutputStruct (
- [["mkfifo"; "0o777"; "/node"];
- ["stat"; "/node"]], [CompareWithInt ("mode", 0o10755)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["mkfifo"; "0o777"; "/mkfifo"];
+ ["stat"; "/mkfifo"]], [CompareWithInt ("mode", 0o10755)])],
"make FIFO (named pipe)",
"\
This call creates a FIFO (named pipe) called C<path> with
The mode actually set is affected by the umask.");
("mknod_b", (RErr, [Int "mode"; Int "devmajor"; Int "devminor"; Pathname "path"], []), 135, [Optional "mknod"],
- [InitBasicFS, Always, TestOutputStruct (
- [["mknod_b"; "0o777"; "99"; "66"; "/node"];
- ["stat"; "/node"]], [CompareWithInt ("mode", 0o60755)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["mknod_b"; "0o777"; "99"; "66"; "/mknod_b"];
+ ["stat"; "/mknod_b"]], [CompareWithInt ("mode", 0o60755)])],
"make block device node",
"\
This call creates a block device node called C<path> with
The mode actually set is affected by the umask.");
("mknod_c", (RErr, [Int "mode"; Int "devmajor"; Int "devminor"; Pathname "path"], []), 136, [Optional "mknod"],
- [InitBasicFS, Always, TestOutputStruct (
- [["mknod_c"; "0o777"; "99"; "66"; "/node"];
- ["stat"; "/node"]], [CompareWithInt ("mode", 0o20755)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["mknod_c"; "0o777"; "99"; "66"; "/mknod_c"];
+ ["stat"; "/mknod_c"]], [CompareWithInt ("mode", 0o20755)])],
"make char device node",
"\
This call creates a char device node called C<path> with
get a simple list of names, use C<guestfs_ls>. To get a printable
directory for human consumption, use C<guestfs_ll>.");
- ("sfdiskM", (RErr, [Device "device"; StringList "lines"], []), 139, [DangerWillRobinson],
+ ("sfdiskM", (RErr, [Device "device"; StringList "lines"], []), 139, [DeprecatedBy "part_add"],
[],
"create partitions on a block device",
"\
For more details see L<https://bugzilla.redhat.com/show_bug.cgi?id=599503>
Autosync [see C<guestfs_set_autosync>, this is set by default on
-handles] means that C<guestfs_umount_all> is called when the handle
+handles] can cause C<guestfs_umount_all> to be called when the handle
is closed which can also trigger these issues.");
("rmmountpoint", (RErr, [String "exemptpath"], []), 149, [],
[InitISOFS, Always, TestOutputBuffer (
[["read_file"; "/known-4"]], "abc\ndef\nghi");
(* Test various near large, large and too large files (RHBZ#589039). *)
- InitBasicFS, Always, TestLastFail (
- [["touch"; "/a"];
- ["truncate_size"; "/a"; "4194303"]; (* GUESTFS_MESSAGE_MAX - 1 *)
- ["read_file"; "/a"]]);
- InitBasicFS, Always, TestLastFail (
- [["touch"; "/a"];
- ["truncate_size"; "/a"; "4194304"]; (* GUESTFS_MESSAGE_MAX *)
- ["read_file"; "/a"]]);
- InitBasicFS, Always, TestLastFail (
- [["touch"; "/a"];
- ["truncate_size"; "/a"; "41943040"]; (* GUESTFS_MESSAGE_MAX * 10 *)
- ["read_file"; "/a"]])],
+ InitScratchFS, Always, TestLastFail (
+ [["touch"; "/read_file"];
+ ["truncate_size"; "/read_file"; "4194303"]; (* GUESTFS_MESSAGE_MAX - 1 *)
+ ["read_file"; "/read_file"]]);
+ InitScratchFS, Always, TestLastFail (
+ [["touch"; "/read_file2"];
+ ["truncate_size"; "/read_file2"; "4194304"]; (* GUESTFS_MESSAGE_MAX *)
+ ["read_file"; "/read_file2"]]);
+ InitScratchFS, Always, TestLastFail (
+ [["touch"; "/read_file3"];
+ ["truncate_size"; "/read_file3"; "41943040"]; (* GUESTFS_MESSAGE_MAX * 10 *)
+ ["read_file"; "/read_file3"]])],
"read a file",
"\
This calls returns the contents of the file C<path> as a
returned path has no C<.>, C<..> or symbolic link path elements.");
("ln", (RErr, [String "target"; Pathname "linkname"], []), 164, [],
- [InitBasicFS, Always, TestOutputStruct (
- [["touch"; "/a"];
- ["ln"; "/a"; "/b"];
- ["stat"; "/b"]], [CompareWithInt ("nlink", 2)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["mkdir"; "/ln"];
+ ["touch"; "/ln/a"];
+ ["ln"; "/ln/a"; "/ln/b"];
+ ["stat"; "/ln/b"]], [CompareWithInt ("nlink", 2)])],
"create a hard link",
"\
This command creates a hard link using the C<ln> command.");
("ln_f", (RErr, [String "target"; Pathname "linkname"], []), 165, [],
- [InitBasicFS, Always, TestOutputStruct (
- [["touch"; "/a"];
- ["touch"; "/b"];
- ["ln_f"; "/a"; "/b"];
- ["stat"; "/b"]], [CompareWithInt ("nlink", 2)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["mkdir"; "/ln_f"];
+ ["touch"; "/ln_f/a"];
+ ["touch"; "/ln_f/b"];
+ ["ln_f"; "/ln_f/a"; "/ln_f/b"];
+ ["stat"; "/ln_f/b"]], [CompareWithInt ("nlink", 2)])],
"create a hard link",
"\
This command creates a hard link using the C<ln -f> command.
-The C<-f> option removes the link (C<linkname>) if it exists already.");
+The I<-f> option removes the link (C<linkname>) if it exists already.");
("ln_s", (RErr, [String "target"; Pathname "linkname"], []), 166, [],
- [InitBasicFS, Always, TestOutputStruct (
- [["touch"; "/a"];
- ["ln_s"; "a"; "/b"];
- ["lstat"; "/b"]], [CompareWithInt ("mode", 0o120777)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["mkdir"; "/ln_s"];
+ ["touch"; "/ln_s/a"];
+ ["ln_s"; "a"; "/ln_s/b"];
+ ["lstat"; "/ln_s/b"]], [CompareWithInt ("mode", 0o120777)])],
"create a symbolic link",
"\
This command creates a symbolic link using the C<ln -s> command.");
("ln_sf", (RErr, [String "target"; Pathname "linkname"], []), 167, [],
- [InitBasicFS, Always, TestOutput (
- [["mkdir_p"; "/a/b"];
- ["touch"; "/a/b/c"];
- ["ln_sf"; "../d"; "/a/b/c"];
- ["readlink"; "/a/b/c"]], "../d")],
+ [InitScratchFS, Always, TestOutput (
+ [["mkdir_p"; "/ln_sf/b"];
+ ["touch"; "/ln_sf/b/c"];
+ ["ln_sf"; "../d"; "/ln_sf/b/c"];
+ ["readlink"; "/ln_sf/b/c"]], "../d")],
"create a symbolic link",
"\
This command creates a symbolic link using the C<ln -sf> command,
-The C<-f> option removes the link (C<linkname>) if it exists already.");
+The I<-f> option removes the link (C<linkname>) if it exists already.");
("readlink", (RString "link", [Pathname "path"], []), 168, [],
[] (* XXX tested above *),
This command reads the target of a symbolic link.");
("fallocate", (RErr, [Pathname "path"; Int "len"], []), 169, [DeprecatedBy "fallocate64"],
- [InitBasicFS, Always, TestOutputStruct (
- [["fallocate"; "/a"; "1000000"];
- ["stat"; "/a"]], [CompareWithInt ("size", 1_000_000)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["fallocate"; "/fallocate"; "1000000"];
+ ["stat"; "/fallocate"]], [CompareWithInt ("size", 1_000_000)])],
"preallocate a file in the guest filesystem",
"\
This command preallocates a file (containing zero bytes) named
See C<guestfs_swapon_device>.");
("swapon_file", (RErr, [Pathname "file"], []), 172, [],
- [InitBasicFS, Always, TestRun (
- [["fallocate"; "/swap"; "8388608"];
- ["mkswap_file"; "/swap"];
- ["swapon_file"; "/swap"];
- ["swapoff_file"; "/swap"]])],
+ [InitScratchFS, Always, TestRun (
+ [["fallocate"; "/swapon_file"; "8388608"];
+ ["mkswap_file"; "/swapon_file"];
+ ["swapon_file"; "/swapon_file"];
+ ["swapoff_file"; "/swapon_file"];
+ ["rm"; "/swapon_file"]])],
"enable swap on file",
"\
This command enables swap to a file.
("swapon_label", (RErr, [String "label"], []), 174, [],
[InitEmpty, Always, TestRun (
- [["part_disk"; "/dev/sdb"; "mbr"];
- ["mkswap_L"; "swapit"; "/dev/sdb1"];
+ [["part_disk"; "/dev/sda"; "mbr"];
+ ["mkswap_L"; "swapit"; "/dev/sda1"];
["swapon_label"; "swapit"];
["swapoff_label"; "swapit"];
- ["zero"; "/dev/sdb"];
- ["blockdev_rereadpt"; "/dev/sdb"]])],
+ ["zero"; "/dev/sda"];
+ ["blockdev_rereadpt"; "/dev/sda"]])],
"enable swap on labeled swap partition",
"\
This command enables swap to a labeled swap partition.
("swapon_uuid", (RErr, [String "uuid"], []), 176, [Optional "linuxfsuuid"],
(let uuid = uuidgen () in
[InitEmpty, Always, TestRun (
- [["mkswap_U"; uuid; "/dev/sdb"];
+ [["mkswap_U"; uuid; "/dev/sdc"];
["swapon_uuid"; uuid];
["swapoff_uuid"; uuid]])]),
"enable swap on swap partition by UUID",
with the given UUID.");
("mkswap_file", (RErr, [Pathname "path"], []), 178, [],
- [InitBasicFS, Always, TestRun (
- [["fallocate"; "/swap"; "8388608"];
- ["mkswap_file"; "/swap"]])],
+ [InitScratchFS, Always, TestRun (
+ [["fallocate"; "/mkswap_file"; "8388608"];
+ ["mkswap_file"; "/mkswap_file"];
+ ["rm"; "/mkswap_file"]])],
"create a swap file",
"\
Create a swap file.
per libguestfs instance.");
("inotify_add_watch", (RInt64 "wd", [Pathname "path"; Int "mask"], []), 180, [Optional "inotify"],
- [InitBasicFS, Always, TestOutputList (
- [["inotify_init"; "0"];
- ["inotify_add_watch"; "/"; "1073741823"];
- ["touch"; "/a"];
- ["touch"; "/b"];
+ [InitScratchFS, Always, TestOutputList (
+ [["mkdir"; "/inotify_add_watch"];
+ ["inotify_init"; "0"];
+ ["inotify_add_watch"; "/inotify_add_watch"; "1073741823"];
+ ["touch"; "/inotify_add_watch/a"];
+ ["touch"; "/inotify_add_watch/b"];
["inotify_files"]], ["a"; "b"])],
"add an inotify watch",
"\
See the documentation about SELINUX in L<guestfs(3)>,
and C<guestfs_setcon>");
- ("mkfs_b", (RErr, [String "fstype"; Int "blocksize"; Device "device"], []), 187, [],
+ ("mkfs_b", (RErr, [String "fstype"; Int "blocksize"; Device "device"], []), 187, [DeprecatedBy "mkfs_opts"],
[InitEmpty, Always, TestOutput (
[["part_disk"; "/dev/sda"; "mbr"];
["mkfs_b"; "ext2"; "4096"; "/dev/sda1"];
[["case_sensitive_path"; "/Known-1"]], "/known-1");
InitISOFS, Always, TestLastFail (
[["case_sensitive_path"; "/Known-1/"]]);
- InitBasicFS, Always, TestOutput (
- [["mkdir"; "/a"];
- ["mkdir"; "/a/bbb"];
- ["touch"; "/a/bbb/c"];
- ["case_sensitive_path"; "/A/bbB/C"]], "/a/bbb/c");
- InitBasicFS, Always, TestOutput (
- [["mkdir"; "/a"];
- ["mkdir"; "/a/bbb"];
- ["touch"; "/a/bbb/c"];
- ["case_sensitive_path"; "/A////bbB/C"]], "/a/bbb/c");
- InitBasicFS, Always, TestLastFail (
- [["mkdir"; "/a"];
- ["mkdir"; "/a/bbb"];
- ["touch"; "/a/bbb/c"];
- ["case_sensitive_path"; "/A/bbb/../bbb/C"]])],
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/case_sensitive_path"];
+ ["mkdir"; "/case_sensitive_path/bbb"];
+ ["touch"; "/case_sensitive_path/bbb/c"];
+ ["case_sensitive_path"; "/CASE_SENSITIVE_path/bbB/C"]], "/case_sensitive_path/bbb/c");
+ InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/case_sensitive_path2"];
+ ["mkdir"; "/case_sensitive_path2/bbb"];
+ ["touch"; "/case_sensitive_path2/bbb/c"];
+ ["case_sensitive_path"; "/case_sensitive_PATH2////bbB/C"]], "/case_sensitive_path2/bbb/c");
+ InitScratchFS, Always, TestLastFail (
+ [["mkdir"; "/case_sensitive_path3"];
+ ["mkdir"; "/case_sensitive_path3/bbb"];
+ ["touch"; "/case_sensitive_path3/bbb/c"];
+ ["case_sensitive_path"; "/case_SENSITIVE_path3/bbb/../bbb/C"]])],
"return true path on case-insensitive filesystem",
"\
This can be used to resolve case insensitive paths on
See also C<guestfs_realpath>.");
("vfs_type", (RString "fstype", [Device "device"], []), 198, [],
- [InitBasicFS, Always, TestOutput (
- [["vfs_type"; "/dev/sda1"]], "ext2")],
+ [InitScratchFS, Always, TestOutput (
+ [["vfs_type"; "/dev/sdb1"]], "ext2")],
"get the Linux VFS type corresponding to a mounted device",
"\
This command gets the filesystem type corresponding to
For example a string such as C<ext3> or C<ntfs>.");
("truncate", (RErr, [Pathname "path"], []), 199, [],
- [InitBasicFS, Always, TestOutputStruct (
- [["write"; "/test"; "some stuff so size is not zero"];
- ["truncate"; "/test"];
- ["stat"; "/test"]], [CompareWithInt ("size", 0)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["write"; "/truncate"; "some stuff so size is not zero"];
+ ["truncate"; "/truncate"];
+ ["stat"; "/truncate"]], [CompareWithInt ("size", 0)])],
"truncate a file to zero size",
"\
This command truncates C<path> to a zero-length file. The
file must exist already.");
("truncate_size", (RErr, [Pathname "path"; Int64 "size"], []), 200, [],
- [InitBasicFS, Always, TestOutputStruct (
- [["touch"; "/test"];
- ["truncate_size"; "/test"; "1000"];
- ["stat"; "/test"]], [CompareWithInt ("size", 1000)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["touch"; "/truncate_size"];
+ ["truncate_size"; "/truncate_size"; "1000"];
+ ["stat"; "/truncate_size"]], [CompareWithInt ("size", 1000)])],
"truncate a file to a particular size",
"\
This command truncates C<path> to size C<size> bytes. The file
file of zeroes, use C<guestfs_fallocate64> instead.");
("utimens", (RErr, [Pathname "path"; Int64 "atsecs"; Int64 "atnsecs"; Int64 "mtsecs"; Int64 "mtnsecs"], []), 201, [],
- [InitBasicFS, Always, TestOutputStruct (
- [["touch"; "/test"];
- ["utimens"; "/test"; "12345"; "67890"; "9876"; "5432"];
- ["stat"; "/test"]], [CompareWithInt ("mtime", 9876)])],
+ (* Test directories, named pipes etc (RHBZ#761451, RHBZ#761460) *)
+ [InitScratchFS, Always, TestOutputStruct (
+ [["touch"; "/utimens-file"];
+ ["utimens"; "/utimens-file"; "12345"; "67890"; "9876"; "5432"];
+ ["stat"; "/utimens-file"]], [CompareWithInt ("mtime", 9876)]);
+ InitScratchFS, Always, TestOutputStruct (
+ [["mkdir"; "/utimens-dir"];
+ ["utimens"; "/utimens-dir"; "12345"; "67890"; "9876"; "5432"];
+ ["stat"; "/utimens-dir"]], [CompareWithInt ("mtime", 9876)]);
+ InitScratchFS, Always, TestOutputStruct (
+ [["mkfifo"; "0o644"; "/utimens-fifo"];
+ ["utimens"; "/utimens-fifo"; "12345"; "67890"; "9876"; "5432"];
+ ["stat"; "/utimens-fifo"]], [CompareWithInt ("mtime", 9876)]);
+ InitScratchFS, Always, TestOutputStruct (
+ [["ln_sf"; "/utimens-file"; "/utimens-link"];
+ ["utimens"; "/utimens-link"; "12345"; "67890"; "9876"; "5432"];
+ ["stat"; "/utimens-link"]], [CompareWithInt ("mtime", 9876)]);
+ InitScratchFS, Always, TestOutputStruct (
+ [["mknod_b"; "0o644"; "8"; "0"; "/utimens-block"];
+ ["utimens"; "/utimens-block"; "12345"; "67890"; "9876"; "5432"];
+ ["stat"; "/utimens-block"]], [CompareWithInt ("mtime", 9876)]);
+ InitScratchFS, Always, TestOutputStruct (
+ [["mknod_c"; "0o644"; "1"; "3"; "/utimens-char"];
+ ["utimens"; "/utimens-char"; "12345"; "67890"; "9876"; "5432"];
+ ["stat"; "/utimens-char"]], [CompareWithInt ("mtime", 9876)])],
"set timestamp of a file with nanosecond precision",
"\
This command sets the timestamps of a file with nanosecond
C<*secs> field is ignored in this case).");
("mkdir_mode", (RErr, [Pathname "path"; Int "mode"], []), 202, [],
- [InitBasicFS, Always, TestOutputStruct (
- [["mkdir_mode"; "/test"; "0o111"];
- ["stat"; "/test"]], [CompareWithInt ("mode", 0o40111)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["mkdir_mode"; "/mkdir_mode"; "0o111"];
+ ["stat"; "/mkdir_mode"]], [CompareWithInt ("mode", 0o40111)])],
"create a directory with a particular mode",
"\
This command creates a directory, setting the initial permissions
=over 4
-=item B<efi> | B<gpt>
+=item B<efi>
+
+=item B<gpt>
Intel EFI / GPT partition table.
from Linux and Intel-based Mac OS X. It also has limited backwards
compatibility with the C<mbr> format.
-=item B<mbr> | B<msdos>
+=item B<mbr>
+
+=item B<msdos>
The standard PC \"Master Boot Record\" (MBR) format used
by MS-DOS and Windows. This partition type will B<only> work
AIX disk labels.
-=item B<amiga> | B<rdb>
+=item B<amiga>
+
+=item B<rdb>
Amiga \"Rigid Disk Block\" format.
Creating a partition which covers the whole disk is not so easy.
Use C<guestfs_part_disk> to do that.");
- ("part_disk", (RErr, [Device "device"; String "parttype"], []), 210, [DangerWillRobinson],
+ ("part_disk", (RErr, [Device "device"; String "parttype"], []), 210, [],
[InitEmpty, Always, TestRun (
[["part_disk"; "/dev/sda"; "mbr"]]);
InitEmpty, Always, TestRun (
for a full list.");
("fill", (RErr, [Int "c"; Int "len"; Pathname "path"], []), 215, [Progress],
- [InitBasicFS, Always, TestOutputBuffer (
- [["fill"; "0x63"; "10"; "/test"];
- ["read_file"; "/test"]], "cccccccccc")],
+ [InitScratchFS, Always, TestOutputBuffer (
+ [["fill"; "0x63"; "10"; "/fill"];
+ ["read_file"; "/fill"]], "cccccccccc")],
"fill a file with octets",
"\
This command creates a new file called C<path>. The initial
=back");
- ("dd", (RErr, [Dev_or_Path "src"; Dev_or_Path "dest"], []), 217, [],
- [InitBasicFS, Always, TestOutputBuffer (
- [["write"; "/src"; "hello, world"];
- ["dd"; "/src"; "/dest"];
- ["read_file"; "/dest"]], "hello, world")],
+ ("dd", (RErr, [Dev_or_Path "src"; Dev_or_Path "dest"], []), 217, [DeprecatedBy "copy_device_to_device"],
+ [InitScratchFS, Always, TestOutputBuffer (
+ [["mkdir"; "/dd"];
+ ["write"; "/dd/src"; "hello, world"];
+ ["dd"; "/dd/src"; "/dd/dest"];
+ ["read_file"; "/dd/dest"]], "hello, world")],
"copy from source to destination using dd",
"\
This command copies from one source device or file C<src>
If the destination is a device, it must be as large or larger
than the source file or device, otherwise the copy will fail.
-This command cannot do partial copies (see C<guestfs_copy_size>).");
+This command cannot do partial copies
+(see C<guestfs_copy_device_to_device>).");
("filesize", (RInt64 "size", [Pathname "file"], []), 218, [],
- [InitBasicFS, Always, TestOutputInt (
- [["write"; "/file"; "hello, world"];
- ["filesize"; "/file"]], 12)],
+ [InitScratchFS, Always, TestOutputInt (
+ [["write"; "/filesize"; "hello, world"];
+ ["filesize"; "/filesize"]], 12)],
"return the size of the file in bytes",
"\
This command returns the size of C<file> in bytes.
See also C<guestfs_vgpvuuids>.");
- ("copy_size", (RErr, [Dev_or_Path "src"; Dev_or_Path "dest"; Int64 "size"], []), 227, [Progress],
- [InitBasicFS, Always, TestOutputBuffer (
- [["write"; "/src"; "hello, world"];
- ["copy_size"; "/src"; "/dest"; "5"];
- ["read_file"; "/dest"]], "hello")],
+ ("copy_size", (RErr, [Dev_or_Path "src"; Dev_or_Path "dest"; Int64 "size"], []), 227, [Progress; DeprecatedBy "copy_device_to_device"],
+ [InitScratchFS, Always, TestOutputBuffer (
+ [["mkdir"; "/copy_size"];
+ ["write"; "/copy_size/src"; "hello, world"];
+ ["copy_size"; "/copy_size/src"; "/copy_size/dest"; "5"];
+ ["read_file"; "/copy_size/dest"]], "hello")],
"copy size bytes from source to destination using dd",
"\
This command copies exactly C<size> bytes from one source device
Note this will fail if the source is too short or if the destination
is not large enough.");
- ("zero_device", (RErr, [Device "device"], []), 228, [DangerWillRobinson; Progress],
+ ("zero_device", (RErr, [Device "device"], []), 228, [Progress],
[InitBasicFSonLVM, Always, TestRun (
[["zero_device"; "/dev/VG/LV"]])],
"write zeroes to an entire device",
"\
This command writes zeroes over the entire C<device>. Compare
with C<guestfs_zero> which just zeroes the first few blocks of
-a device.");
+a device.
+
+If blocks are already zero, then this command avoids writing
+zeroes. This prevents the underlying device from becoming non-sparse
+or growing unnecessarily.");
("txz_in", (RErr, [FileIn "tarball"; Pathname "directory"], []), 229, [Optional "xz"],
- [InitBasicFS, Always, TestOutput (
- [["txz_in"; "../images/helloworld.tar.xz"; "/"];
- ["cat"; "/hello"]], "hello\n")],
+ [InitScratchFS, Always, TestOutput (
+ [["mkdir"; "/txz_in"];
+ ["txz_in"; "../images/helloworld.tar.xz"; "/txz_in"];
+ ["cat"; "/txz_in/hello"]], "hello\n")],
"unpack compressed tarball to directory",
"\
This command uploads and unpacks local file C<tarball> (an
This command packs the contents of C<directory> and downloads
it to local file C<tarball> (as an xz compressed tar archive).");
- ("ntfsresize", (RErr, [Device "device"], []), 231, [Optional "ntfsprogs"],
+ ("ntfsresize", (RErr, [Device "device"], []), 231, [Optional "ntfsprogs"; DeprecatedBy "ntfsresize_opts"],
[],
"resize an NTFS filesystem",
"\
This command resizes an NTFS filesystem, expanding or
shrinking it to the size of the underlying device.
+
+I<Note:> After the resize operation, the filesystem is marked
+as requiring a consistency check (for safety). You have to boot
+into Windows to perform this check and clear this condition.
+Furthermore, ntfsresize refuses to resize filesystems
+which have been marked in this way. So in effect it is
+not possible to call ntfsresize multiple times on a single
+filesystem without booting into Windows between each resize.
+
See also L<ntfsresize(8)>.");
("vgscan", (RErr, [], []), 232, [],
Return the current umask. By default the umask is C<022>
unless it has been set by calling C<guestfs_umask>.");
- ("debug_upload", (RErr, [FileIn "filename"; String "tmpname"; Int "mode"], []), 241, [],
+ ("debug_upload", (RErr, [FileIn "filename"; String "tmpname"; Int "mode"], []), 241, [NotInDocs],
[],
"upload a file to the appliance (internal use only)",
"\
to find out what it is for.");
("base64_in", (RErr, [FileIn "base64file"; Pathname "filename"], []), 242, [],
- [InitBasicFS, Always, TestOutput (
- [["base64_in"; "../images/hello.b64"; "/hello"];
- ["cat"; "/hello"]], "hello\n")],
+ [InitScratchFS, Always, TestOutput (
+ [["base64_in"; "../images/hello.b64"; "/base64_in"];
+ ["cat"; "/base64_in"]], "hello\n")],
"upload base64-encoded data to file",
"\
This command uploads base64-encoded data from C<base64file>
coreutils info file.");
("fill_pattern", (RErr, [String "pattern"; Int "len"; Pathname "path"], []), 245, [Progress],
- [InitBasicFS, Always, TestOutputBuffer (
- [["fill_pattern"; "abcdefghijklmnopqrstuvwxyz"; "28"; "/test"];
- ["read_file"; "/test"]], "abcdefghijklmnopqrstuvwxyzab")],
+ [InitScratchFS, Always, TestOutputBuffer (
+ [["fill_pattern"; "abcdefghijklmnopqrstuvwxyz"; "28"; "/fill_pattern"];
+ ["read_file"; "/fill_pattern"]], "abcdefghijklmnopqrstuvwxyzab")],
"fill a file with a repeating pattern of bytes",
"\
-This function is like C<guestfs_fill> except that it creates
-a new file of length C<len> containing the repeating pattern
-of bytes in C<pattern>. The pattern is truncated if necessary
-to ensure the length of the file is exactly C<len> bytes.");
-
- ("write", (RErr, [Pathname "path"; BufferIn "content"], []), 246, [ProtocolLimitWarning],
- [InitBasicFS, Always, TestOutput (
- [["write"; "/new"; "new file contents"];
- ["cat"; "/new"]], "new file contents");
- InitBasicFS, Always, TestOutput (
- [["write"; "/new"; "\nnew file contents\n"];
- ["cat"; "/new"]], "\nnew file contents\n");
- InitBasicFS, Always, TestOutput (
- [["write"; "/new"; "\n\n"];
- ["cat"; "/new"]], "\n\n");
- InitBasicFS, Always, TestOutput (
- [["write"; "/new"; ""];
- ["cat"; "/new"]], "");
- InitBasicFS, Always, TestOutput (
- [["write"; "/new"; "\n\n\n"];
- ["cat"; "/new"]], "\n\n\n");
- InitBasicFS, Always, TestOutput (
- [["write"; "/new"; "\n"];
- ["cat"; "/new"]], "\n")],
+This function is like C<guestfs_fill> except that it creates
+a new file of length C<len> containing the repeating pattern
+of bytes in C<pattern>. The pattern is truncated if necessary
+to ensure the length of the file is exactly C<len> bytes.");
+
+ ("write", (RErr, [Pathname "path"; BufferIn "content"], []), 246, [ProtocolLimitWarning],
+ [InitScratchFS, Always, TestOutput (
+ [["write"; "/write"; "new file contents"];
+ ["cat"; "/write"]], "new file contents");
+ InitScratchFS, Always, TestOutput (
+ [["write"; "/write2"; "\nnew file contents\n"];
+ ["cat"; "/write2"]], "\nnew file contents\n");
+ InitScratchFS, Always, TestOutput (
+ [["write"; "/write3"; "\n\n"];
+ ["cat"; "/write3"]], "\n\n");
+ InitScratchFS, Always, TestOutput (
+ [["write"; "/write4"; ""];
+ ["cat"; "/write4"]], "");
+ InitScratchFS, Always, TestOutput (
+ [["write"; "/write5"; "\n\n\n"];
+ ["cat"; "/write5"]], "\n\n\n");
+ InitScratchFS, Always, TestOutput (
+ [["write"; "/write6"; "\n"];
+ ["cat"; "/write6"]], "\n")],
"create a new file",
"\
This call creates a file called C<path>. The content of the
-file is the string C<content> (which can contain any 8 bit data).");
+file is the string C<content> (which can contain any 8 bit data).
+
+See also C<guestfs_write_append>.");
("pwrite", (RInt "nbytes", [Pathname "path"; BufferIn "content"; Int64 "offset"], []), 247, [ProtocolLimitWarning],
- [InitBasicFS, Always, TestOutput (
- [["write"; "/new"; "new file contents"];
- ["pwrite"; "/new"; "data"; "4"];
- ["cat"; "/new"]], "new data contents");
- InitBasicFS, Always, TestOutput (
- [["write"; "/new"; "new file contents"];
- ["pwrite"; "/new"; "is extended"; "9"];
- ["cat"; "/new"]], "new file is extended");
- InitBasicFS, Always, TestOutput (
- [["write"; "/new"; "new file contents"];
- ["pwrite"; "/new"; ""; "4"];
- ["cat"; "/new"]], "new file contents")],
+ [InitScratchFS, Always, TestOutput (
+ [["write"; "/pwrite"; "new file contents"];
+ ["pwrite"; "/pwrite"; "data"; "4"];
+ ["cat"; "/pwrite"]], "new data contents");
+ InitScratchFS, Always, TestOutput (
+ [["write"; "/pwrite2"; "new file contents"];
+ ["pwrite"; "/pwrite2"; "is extended"; "9"];
+ ["cat"; "/pwrite2"]], "new file is extended");
+ InitScratchFS, Always, TestOutput (
+ [["write"; "/pwrite3"; "new file contents"];
+ ["pwrite"; "/pwrite3"; ""; "4"];
+ ["cat"; "/pwrite3"]], "new file contents")],
"write to part of a file",
"\
This command writes to part of a file. It writes the data
This command is the same as C<guestfs_pvresize> except that it
allows you to specify the new size (in bytes) explicitly.");
- ("ntfsresize_size", (RErr, [Device "device"; Int64 "size"], []), 250, [Optional "ntfsprogs"],
+ ("ntfsresize_size", (RErr, [Device "device"; Int64 "size"], []), 250, [Optional "ntfsprogs"; DeprecatedBy "ntfsresize_opts"],
[],
"resize an NTFS filesystem (with size)",
"\
See also C<guestfs_available> and L<guestfs(3)/AVAILABILITY>.");
("fallocate64", (RErr, [Pathname "path"; Int64 "len"], []), 252, [],
- [InitBasicFS, Always, TestOutputStruct (
- [["fallocate64"; "/a"; "1000000"];
- ["stat"; "/a"]], [CompareWithInt ("size", 1_000_000)])],
+ [InitScratchFS, Always, TestOutputStruct (
+ [["fallocate64"; "/fallocate64"; "1000000"];
+ ["stat"; "/fallocate64"]], [CompareWithInt ("size", 1_000_000)])],
"preallocate a file in the guest filesystem",
"\
This command preallocates a file (containing zero bytes) named
If this block device contains LVM volume groups, then
calling C<guestfs_vgscan> followed by C<guestfs_vg_activate_all>
-will make them visible.");
+will make them visible.
+
+Use C<guestfs_list_dm_devices> to list all device mapper
+devices.");
("luks_open_ro", (RErr, [Device "device"; Key "key"; String "mapname"], []), 258, [Optional "luks"],
[],
device (ie. C</dev/mapper/mapname>) and I<not> the name
of the underlying block device.");
- ("luks_format", (RErr, [Device "device"; Key "key"; Int "keyslot"], []), 260, [Optional "luks"; DangerWillRobinson],
+ ("luks_format", (RErr, [Device "device"; Key "key"; Int "keyslot"], []), 260, [Optional "luks"],
[],
"format a block device as a LUKS encrypted device",
"\
initial key, which is added to key slot C<slot>. (LUKS
supports 8 key slots, numbered 0-7).");
- ("luks_format_cipher", (RErr, [Device "device"; Key "key"; Int "keyslot"; String "cipher"], []), 261, [Optional "luks"; DangerWillRobinson],
+ ("luks_format_cipher", (RErr, [Device "device"; Key "key"; Int "keyslot"; String "cipher"], []), 261, [Optional "luks"],
[],
"format a block device as a LUKS encrypted device",
"\
("is_chardev", (RBool "flag", [Pathname "path"], []), 267, [],
[InitISOFS, Always, TestOutputFalse (
[["is_chardev"; "/directory"]]);
- InitBasicFS, Always, TestOutputTrue (
- [["mknod_c"; "0o777"; "99"; "66"; "/test"];
- ["is_chardev"; "/test"]])],
+ InitScratchFS, Always, TestOutputTrue (
+ [["mknod_c"; "0o777"; "99"; "66"; "/is_chardev"];
+ ["is_chardev"; "/is_chardev"]])],
"test if character device",
"\
This returns C<true> if and only if there is a character device
("is_blockdev", (RBool "flag", [Pathname "path"], []), 268, [],
[InitISOFS, Always, TestOutputFalse (
[["is_blockdev"; "/directory"]]);
- InitBasicFS, Always, TestOutputTrue (
- [["mknod_b"; "0o777"; "99"; "66"; "/test"];
- ["is_blockdev"; "/test"]])],
+ InitScratchFS, Always, TestOutputTrue (
+ [["mknod_b"; "0o777"; "99"; "66"; "/is_blockdev"];
+ ["is_blockdev"; "/is_blockdev"]])],
"test if block device",
"\
This returns C<true> if and only if there is a block device
("is_fifo", (RBool "flag", [Pathname "path"], []), 269, [],
[InitISOFS, Always, TestOutputFalse (
[["is_fifo"; "/directory"]]);
- InitBasicFS, Always, TestOutputTrue (
- [["mkfifo"; "0o777"; "/test"];
- ["is_fifo"; "/test"]])],
+ InitScratchFS, Always, TestOutputTrue (
+ [["mkfifo"; "0o777"; "/is_fifo"];
+ ["is_fifo"; "/is_fifo"]])],
"test if FIFO (named pipe)",
"\
This returns C<true> if and only if there is a FIFO (named pipe)
(eg. \"/dev/sdb\").
The named partition must exist, for example as a string returned
-from C<guestfs_list_partitions>.");
+from C<guestfs_list_partitions>.
- ("upload_offset", (RErr, [FileIn "filename"; Dev_or_Path "remotefilename"; Int64 "offset"], []), 273, [],
+See also C<guestfs_part_to_partnum>.");
+
+ ("upload_offset", (RErr, [FileIn "filename"; Dev_or_Path "remotefilename"; Int64 "offset"], []), 273, [Progress],
(let md5 = Digest.to_hex (Digest.file "COPYING.LIB") in
- [InitBasicFS, Always, TestOutput (
- [["upload_offset"; "../COPYING.LIB"; "/COPYING.LIB"; "0"];
- ["checksum"; "md5"; "/COPYING.LIB"]], md5)]),
+ [InitScratchFS, Always, TestOutput (
+ [["upload_offset"; "../../COPYING.LIB"; "/upload_offset"; "0"];
+ ["checksum"; "md5"; "/upload_offset"]], md5)]),
"upload a file from the local machine with offset",
"\
Upload local file C<filename> to C<remotefilename> on the
(let md5 = Digest.to_hex (Digest.file "COPYING.LIB") in
let offset = string_of_int 100 in
let size = string_of_int ((Unix.stat "COPYING.LIB").Unix.st_size - 100) in
- [InitBasicFS, Always, TestOutput (
+ [InitScratchFS, Always, TestOutput (
(* Pick a file from cwd which isn't likely to change. *)
- [["upload"; "../COPYING.LIB"; "/COPYING.LIB"];
- ["download_offset"; "/COPYING.LIB"; "testdownload.tmp"; offset; size];
- ["upload_offset"; "testdownload.tmp"; "/COPYING.LIB"; offset];
- ["checksum"; "md5"; "/COPYING.LIB"]], md5)]),
+ [["mkdir"; "/download_offset"];
+ ["upload"; "../../COPYING.LIB"; "/download_offset/COPYING.LIB"];
+ ["download_offset"; "/download_offset/COPYING.LIB"; "testdownload.tmp"; offset; size];
+ ["upload_offset"; "testdownload.tmp"; "/download_offset/COPYING.LIB"; offset];
+ ["checksum"; "md5"; "/download_offset/COPYING.LIB"]], md5)]),
"download a file to the local machine with offset and size",
"\
Download file C<remotefilename> and save it as C<filename>
See also C<guestfs_download>, C<guestfs_pread>.");
("pwrite_device", (RInt "nbytes", [Device "device"; BufferIn "content"; Int64 "offset"], []), 275, [ProtocolLimitWarning],
- [InitPartition, Always, TestOutputList (
+ [InitPartition, Always, TestOutputListOfDevices (
[["pwrite_device"; "/dev/sda"; "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"; "446"];
["blockdev_rereadpt"; "/dev/sda"];
- ["list_partitions"]], [])],
+ ["list_partitions"]], ["/dev/sdb1"])],
"write to part of a device",
"\
This command writes to part of a device. It writes the data
See also C<guestfs_is_lv>.");
+ ("mkfs_opts", (RErr, [String "fstype"; Device "device"], [Int "blocksize"; String "features"; Int "inode"; Int "sectorsize"]), 278, [],
+ [InitEmpty, Always, TestOutput (
+ [["part_disk"; "/dev/sda"; "mbr"];
+ ["mkfs_opts"; "ext2"; "/dev/sda1"; ""; "NOARG"; ""; ""];
+ ["mount_options"; ""; "/dev/sda1"; "/"];
+ ["write"; "/new"; "new file contents"];
+ ["cat"; "/new"]], "new file contents")],
+ "make a filesystem",
+ "\
+This function creates a filesystem on C<device>. The filesystem
+type is C<fstype>, for example C<ext3>.
+
+The optional arguments are:
+
+=over 4
+
+=item C<blocksize>
+
+The filesystem block size. Supported block sizes depend on the
+filesystem type, but typically they are C<1024>, C<2048> or C<4096>
+for Linux ext2/3 filesystems.
+
+For VFAT and NTFS the C<blocksize> parameter is treated as
+the requested cluster size.
+
+For UFS block sizes, please see L<mkfs.ufs(8)>.
+
+=item C<features>
+
+This passes the I<-O> parameter to the external mkfs program.
+
+For certain filesystem types, this allows extra filesystem
+features to be selected. See L<mke2fs(8)> and L<mkfs.ufs(8)>
+for more details.
+
+You cannot use this optional parameter with the C<gfs> or
+C<gfs2> filesystem type.
+
+=item C<inode>
+
+This passes the I<-I> parameter to the external L<mke2fs(8)> program
+which sets the inode size (only for ext2/3/4 filesystems at present).
+
+=item C<sectorsize>
+
+This passes the I<-S> parameter to external L<mkfs.ufs(8)> program,
+which sets sector size for ufs filesystem.
+
+=back");
+
+ ("getxattr", (RBufferOut "xattr", [Pathname "path"; String "name"], []), 279, [Optional "linuxxattrs"],
+ [],
+ "get a single extended attribute",
+ "\
+Get a single extended attribute from file C<path> named C<name>.
+This call follows symlinks. If you want to lookup an extended
+attribute for the symlink itself, use C<guestfs_lgetxattr>.
+
+Normally it is better to get all extended attributes from a file
+in one go by calling C<guestfs_getxattrs>. However some Linux
+filesystem implementations are buggy and do not provide a way to
+list out attributes. For these filesystems (notably ntfs-3g)
+you have to know the names of the extended attributes you want
+in advance and call this function.
+
+Extended attribute values are blobs of binary data. If there
+is no extended attribute named C<name>, this returns an error.
+
+See also: C<guestfs_getxattrs>, C<guestfs_lgetxattr>, L<attr(5)>.");
+
+ ("lgetxattr", (RBufferOut "xattr", [Pathname "path"; String "name"], []), 280, [Optional "linuxxattrs"],
+ [],
+ "get a single extended attribute",
+ "\
+Get a single extended attribute from file C<path> named C<name>.
+If C<path> is a symlink, then this call returns an extended
+attribute from the symlink.
+
+Normally it is better to get all extended attributes from a file
+in one go by calling C<guestfs_getxattrs>. However some Linux
+filesystem implementations are buggy and do not provide a way to
+list out attributes. For these filesystems (notably ntfs-3g)
+you have to know the names of the extended attributes you want
+in advance and call this function.
+
+Extended attribute values are blobs of binary data. If there
+is no extended attribute named C<name>, this returns an error.
+
+See also: C<guestfs_lgetxattrs>, C<guestfs_getxattr>, L<attr(5)>.");
+
+ ("resize2fs_M", (RErr, [Device "device"], []), 281, [],
+ [],
+ "resize an ext2, ext3 or ext4 filesystem to the minimum size",
+ "\
+This command is the same as C<guestfs_resize2fs>, but the filesystem
+is resized to its minimum size. This works like the I<-M> option
+to the C<resize2fs> command.
+
+To get the resulting size of the filesystem you should call
+C<guestfs_tune2fs_l> and read the C<Block size> and C<Block count>
+values. These two numbers, multiplied together, give the
+resulting size of the minimal filesystem in bytes.");
+
+ ("internal_autosync", (RErr, [], []), 282, [NotInFish; NotInDocs],
+ [],
+ "internal autosync operation",
+ "\
+This command performs the autosync operation just before the
+handle is closed. You should not call this command directly.
+Instead, use the autosync flag (C<guestfs_set_autosync>) to
+control whether or not this operation is performed when the
+handle is closed.");
+
+ ("is_zero", (RBool "zeroflag", [Pathname "path"], []), 283, [],
+ [InitISOFS, Always, TestOutputTrue (
+ [["is_zero"; "/100kallzeroes"]]);
+ InitISOFS, Always, TestOutputFalse (
+ [["is_zero"; "/100kallspaces"]])],
+ "test if a file contains all zero bytes",
+ "\
+This returns true iff the file exists and the file is empty or
+it contains all zero bytes.");
+
+ ("is_zero_device", (RBool "zeroflag", [Device "device"], []), 284, [],
+ [InitBasicFS, Always, TestOutputTrue (
+ [["umount"; "/dev/sda1"];
+ ["zero_device"; "/dev/sda1"];
+ ["is_zero_device"; "/dev/sda1"]]);
+ InitBasicFS, Always, TestOutputFalse (
+ [["is_zero_device"; "/dev/sda1"]])],
+ "test if a device contains all zero bytes",
+ "\
+This returns true iff the device exists and contains all zero bytes.
+
+Note that for large devices this can take a long time to run.");
+
+ ("list_9p", (RStringList "mounttags", [], []), 285, [],
+ [],
+ "list 9p filesystems",
+ "\
+List all 9p filesystems attached to the guest. A list of
+mount tags is returned.");
+
+ ("mount_9p", (RErr, [String "mounttag"; String "mountpoint"], [String "options"]), 286, [],
+ [],
+ "mount 9p filesystem",
+ "\
+Mount the virtio-9p filesystem with the tag C<mounttag> on the
+directory C<mountpoint>.
+
+If required, C<trans=virtio> will be automatically added to the options.
+Any other options required can be passed in the optional C<options>
+parameter.");
+
+ ("list_dm_devices", (RStringList "devices", [], []), 287, [],
+ [],
+ "list device mapper devices",
+ "\
+List all device mapper devices.
+
+The returned list contains C</dev/mapper/*> devices, eg. ones created
+by a previous call to C<guestfs_luks_open>.
+
+Device mapper devices which correspond to logical volumes are I<not>
+returned in this list. Call C<guestfs_lvs> if you want to list logical
+volumes.");
+
+ ("ntfsresize_opts", (RErr, [Device "device"], [Int64 "size"; Bool "force"]), 288, [Optional "ntfsprogs"],
+ [],
+ "resize an NTFS filesystem",
+ "\
+This command resizes an NTFS filesystem, expanding or
+shrinking it to the size of the underlying device.
+
+The optional parameters are:
+
+=over 4
+
+=item C<size>
+
+The new size (in bytes) of the filesystem. If omitted, the filesystem
+is resized to fit the container (eg. partition).
+
+=item C<force>
+
+If this option is true, then force the resize of the filesystem
+even if the filesystem is marked as requiring a consistency check.
+
+After the resize operation, the filesystem is always marked
+as requiring a consistency check (for safety). You have to boot
+into Windows to perform this check and clear this condition.
+If you I<don't> set the C<force> option then it is not
+possible to call C<guestfs_ntfsresize_opts> multiple times on a
+single filesystem without booting into Windows between each resize.
+
+=back
+
+See also L<ntfsresize(8)>.");
+
+ ("btrfs_filesystem_resize", (RErr, [Pathname "mountpoint"], [Int64 "size"]), 289, [Optional "btrfs"],
+ [],
+ "resize a btrfs filesystem",
+ "\
+This command resizes a btrfs filesystem.
+
+Note that unlike other resize calls, the filesystem has to be
+mounted and the parameter is the mountpoint not the device
+(this is a requirement of btrfs itself).
+
+The optional parameters are:
+
+=over 4
+
+=item C<size>
+
+The new size (in bytes) of the filesystem. If omitted, the filesystem
+is resized to the maximum size.
+
+=back
+
+See also L<btrfs(8)>.");
+
+ ("write_append", (RErr, [Pathname "path"; BufferIn "content"], []), 290, [ProtocolLimitWarning],
+ [InitScratchFS, Always, TestOutput (
+ [["write"; "/write_append"; "line1\n"];
+ ["write_append"; "/write_append"; "line2\n"];
+ ["write_append"; "/write_append"; "line3a"];
+ ["write_append"; "/write_append"; "line3b\n"];
+ ["cat"; "/write_append"]], "line1\nline2\nline3aline3b\n")],
+ "append content to end of file",
+ "\
+This call appends C<content> to the end of file C<path>. If
+C<path> does not exist, then a new file is created.
+
+See also C<guestfs_write>.");
+
+ ("compress_out", (RErr, [String "ctype"; Pathname "file"; FileOut "zfile"], [Int "level"]), 291, [],
+ [],
+ "output compressed file",
+ "\
+This command compresses C<file> and writes it out to the local
+file C<zfile>.
+
+The compression program used is controlled by the C<ctype> parameter.
+Currently this includes: C<compress>, C<gzip>, C<bzip2>, C<xz> or C<lzop>.
+Some compression types may not be supported by particular builds of
+libguestfs, in which case you will get an error containing the
+substring \"not supported\".
+
+The optional C<level> parameter controls compression level. The
+meaning and default for this parameter depends on the compression
+program being used.");
+
+ ("compress_device_out", (RErr, [String "ctype"; Device "device"; FileOut "zdevice"], [Int "level"]), 292, [],
+ [],
+ "output compressed device",
+ "\
+This command compresses C<device> and writes it out to the local
+file C<zdevice>.
+
+The C<ctype> and optional C<level> parameters have the same meaning
+as in C<guestfs_compress_out>.");
+
+ ("part_to_partnum", (RInt "partnum", [Device "partition"], []), 293, [],
+ [InitPartition, Always, TestOutputInt (
+ [["part_to_partnum"; "/dev/sda1"]], 1);
+ InitEmpty, Always, TestLastFail (
+ [["part_to_partnum"; "/dev/sda"]])],
+ "convert partition name to partition number",
+ "\
+This function takes a partition name (eg. \"/dev/sdb1\") and
+returns the partition number (eg. C<1>).
+
+The named partition must exist, for example as a string returned
+from C<guestfs_list_partitions>.
+
+See also C<guestfs_part_to_dev>.");
+
+ ("copy_device_to_device", (RErr, [Device "src"; Device "dest"], [Int64 "srcoffset"; Int64 "destoffset"; Int64 "size"]), 294, [Progress],
+ [],
+ "copy from source device to destination device",
+ "\
+The four calls C<guestfs_copy_device_to_device>,
+C<guestfs_copy_device_to_file>,
+C<guestfs_copy_file_to_device>, and
+C<guestfs_copy_file_to_file>
+let you copy from a source (device|file) to a destination
+(device|file).
+
+Partial copies can be made since you can specify optionally
+the source offset, destination offset and size to copy. These
+values are all specified in bytes. If not given, the offsets
+both default to zero, and the size defaults to copying as much
+as possible until we hit the end of the source.
+
+The source and destination may be the same object. However
+overlapping regions may not be copied correctly.
+
+If the destination is a file, it is created if required. If
+the destination file is not large enough, it is extended.");
+
+ ("copy_device_to_file", (RErr, [Device "src"; Pathname "dest"], [Int64 "srcoffset"; Int64 "destoffset"; Int64 "size"]), 295, [Progress],
+ [],
+ "copy from source device to destination file",
+ "\
+See C<guestfs_copy_device_to_device> for a general overview
+of this call.");
+
+ ("copy_file_to_device", (RErr, [Pathname "src"; Device "dest"], [Int64 "srcoffset"; Int64 "destoffset"; Int64 "size"]), 296, [Progress],
+ [],
+ "copy from source file to destination device",
+ "\
+See C<guestfs_copy_device_to_device> for a general overview
+of this call.");
+
+ ("copy_file_to_file", (RErr, [Pathname "src"; Pathname "dest"], [Int64 "srcoffset"; Int64 "destoffset"; Int64 "size"]), 297, [Progress],
+ [InitScratchFS, Always, TestOutputBuffer (
+ [["mkdir"; "/copyff"];
+ ["write"; "/copyff/src"; "hello, world"];
+ ["copy_file_to_file"; "/copyff/src"; "/copyff/dest"; ""; ""; ""];
+ ["read_file"; "/copyff/dest"]], "hello, world")],
+ "copy from source file to destination file",
+ "\
+See C<guestfs_copy_device_to_device> for a general overview
+of this call.
+
+This is B<not> the function you want for copying files. This
+is for copying blocks within existing files. See C<guestfs_cp>,
+C<guestfs_cp_a> and C<guestfs_mv> for general file copying and
+moving functions.");
+
+ ("tune2fs", (RErr, [Device "device"], [Bool "force"; Int "maxmountcount"; Int "mountcount"; String "errorbehavior"; Int64 "group"; Int "intervalbetweenchecks"; Int "reservedblockspercentage"; String "lastmounteddirectory"; Int64 "reservedblockscount"; Int64 "user"]), 298, [],
+ [InitScratchFS, Always, TestOutputHashtable (
+ [["tune2fs"; "/dev/sdb1"; "false"; "0"; ""; "NOARG"; ""; "0"; ""; "NOARG"; ""; ""];
+ ["tune2fs_l"; "/dev/sdb1"]],
+ ["Check interval", "0 (<none>)";
+ "Maximum mount count", "-1"]);
+ InitScratchFS, Always, TestOutputHashtable (
+ [["tune2fs"; "/dev/sdb1"; "false"; "0"; ""; "NOARG"; ""; "86400"; ""; "NOARG"; ""; ""];
+ ["tune2fs_l"; "/dev/sdb1"]],
+ ["Check interval", "86400 (1 day)";
+ "Maximum mount count", "-1"]);
+ InitScratchFS, Always, TestOutputHashtable (
+ [["tune2fs"; "/dev/sdb1"; "false"; ""; ""; "NOARG"; "1"; ""; ""; "NOARG"; ""; "1"];
+ ["tune2fs_l"; "/dev/sdb1"]],
+ ["Reserved blocks uid", "1 (user bin)";
+ "Reserved blocks gid", "1 (group bin)"]);
+ InitScratchFS, Always, TestOutputHashtable (
+ [["tune2fs"; "/dev/sdb1"; "false"; ""; ""; "NOARG"; "0"; ""; ""; "NOARG"; ""; "0"];
+ ["tune2fs_l"; "/dev/sdb1"]],
+ ["Reserved blocks uid", "0 (user root)";
+ "Reserved blocks gid", "0 (group root)"])
+ ],
+ "adjust ext2/ext3/ext4 filesystem parameters",
+ "\
+This call allows you to adjust various filesystem parameters of
+an ext2/ext3/ext4 filesystem called C<device>.
+
+The optional parameters are:
+
+=over 4
+
+=item C<force>
+
+Force tune2fs to complete the operation even in the face of errors.
+This is the same as the tune2fs C<-f> option.
+
+=item C<maxmountcount>
+
+Set the number of mounts after which the filesystem is checked
+by L<e2fsck(8)>. If this is C<0> then the number of mounts is
+disregarded. This is the same as the tune2fs C<-c> option.
+
+=item C<mountcount>
+
+Set the number of times the filesystem has been mounted.
+This is the same as the tune2fs C<-C> option.
+
+=item C<errorbehavior>
+
+Change the behavior of the kernel code when errors are detected.
+Possible values currently are: C<continue>, C<remount-ro>, C<panic>.
+In practice these options don't really make any difference,
+particularly for write errors.
+
+This is the same as the tune2fs C<-e> option.
+
+=item C<group>
+
+Set the group which can use reserved filesystem blocks.
+This is the same as the tune2fs C<-g> option except that it
+can only be specified as a number.
+
+=item C<intervalbetweenchecks>
+
+Adjust the maximal time between two filesystem checks
+(in seconds). If the option is passed as C<0> then
+time-dependent checking is disabled.
+
+This is the same as the tune2fs C<-i> option.
+
+=item C<reservedblockspercentage>
+
+Set the percentage of the filesystem which may only be allocated
+by privileged processes.
+This is the same as the tune2fs C<-m> option.
+
+=item C<lastmounteddirectory>
+
+Set the last mounted directory.
+This is the same as the tune2fs C<-M> option.
+
+=item C<reservedblockscount>
+Set the number of reserved filesystem blocks.
+This is the same as the tune2fs C<-r> option.
+
+=item C<user>
+
+Set the user who can use the reserved filesystem blocks.
+This is the same as the tune2fs C<-u> option except that it
+can only be specified as a number.
+
+=back
+
+To get the current values of filesystem parameters, see
+C<guestfs_tune2fs_l>. For precise details of how tune2fs
+works, see the L<tune2fs(8)> man page.");
+
+ ("md_create", (RErr, [String "name"; DeviceList "devices"], [Int64 "missingbitmap"; Int "nrdevices"; Int "spare"; Int64 "chunk"; String "level"]), 299, [Optional "mdadm"],
+ [],
+ "create a Linux md (RAID) device",
+ "\
+Create a Linux md (RAID) device named C<name> on the devices
+in the list C<devices>.
+
+The optional parameters are:
+
+=over 4
+
+=item C<missingbitmap>
+
+A bitmap of missing devices. If a bit is set it means that a
+missing device is added to the array. The least significant bit
+corresponds to the first device in the array.
+
+As examples:
+
+If C<devices = [\"/dev/sda\"]> and C<missingbitmap = 0x1> then
+the resulting array would be C<[E<lt>missingE<gt>, \"/dev/sda\"]>.
+
+If C<devices = [\"/dev/sda\"]> and C<missingbitmap = 0x2> then
+the resulting array would be C<[\"/dev/sda\", E<lt>missingE<gt>]>.
+
+This defaults to C<0> (no missing devices).
+
+The length of C<devices> + the number of bits set in
+C<missingbitmap> must equal C<nrdevices> + C<spare>.
+
+=item C<nrdevices>
+
+The number of active RAID devices.
+
+If not set, this defaults to the length of C<devices> plus
+the number of bits set in C<missingbitmap>.
+
+=item C<spare>
+
+The number of spare devices.
+
+If not set, this defaults to C<0>.
+
+=item C<chunk>
+
+The chunk size in bytes.
+
+=item C<level>
+
+The RAID level, which can be one of:
+I<linear>, I<raid0>, I<0>, I<stripe>, I<raid1>, I<1>, I<mirror>,
+I<raid4>, I<4>, I<raid5>, I<5>, I<raid6>, I<6>, I<raid10>, I<10>.
+Some of these are synonymous, and more levels may be added in future.
+
+If not set, this defaults to C<raid1>.
+
+=back");
+
+ ("list_md_devices", (RStringList "devices", [], []), 300, [],
+ [],
+ "list Linux md (RAID) devices",
+ "\
+List all Linux md devices.");
+
+ ("md_detail", (RHashtable "info", [Device "md"], []), 301, [Optional "mdadm"],
+ [],
+ "obtain metadata for an MD device",
+ "\
+This command exposes the output of 'mdadm -DY <md>'. The following fields are
+usually present in the returned hash. Other fields may also be present.
+
+=over
+
+=item C<level>
+
+The raid level of the MD device.
+
+=item C<devices>
+
+The number of underlying devices in the MD device.
+
+=item C<metadata>
+
+The metadata version used.
+
+=item C<uuid>
+
+The UUID of the MD device.
+
+=item C<name>
+
+The name of the MD device.
+
+=back");
+
+ ("md_stop", (RErr, [Device "md"], []), 302, [Optional "mdadm"],
+ [],
+ "stop a Linux md (RAID) device",
+ "\
+This command deactivates the MD array named C<md>. The
+device is stopped, but it is not destroyed or zeroed.");
+
+ ("blkid", (RHashtable "info", [Device "device"], []), 303, [],
+ [InitScratchFS, Always, TestOutputHashtable (
+ [["blkid"; "/dev/sdb1"]],
+ ["TYPE", "ext2";
+ "USAGE", "filesystem";
+ "PART_ENTRY_NUMBER", "1";
+ "PART_ENTRY_TYPE", "0x83";
+ "PART_ENTRY_OFFSET", "128";
+ "PART_ENTRY_SIZE", "102145"])],
+ "print block device attributes",
+ "\
+This command returns block device attributes for C<device>. The following fields are
+usually present in the returned hash. Other fields may also be present.
+
+=over
+
+=item C<UUID>
+
+The uuid of this device.
+
+=item C<LABEL>
+
+The label of this device.
+
+=item C<VERSION>
+
+The version of blkid command.
+
+=item C<TYPE>
+
+The filesystem type or RAID of this device.
+
+=item C<USAGE>
+
+The usage of this device, for example C<filesystem> or C<raid>.
+
+=back");
+
]
let all_functions = non_daemon_functions @ daemon_functions
glob copy-out /home/* .");
+ ("delete_event", (RErr,[], []), -1, [], [],
+ "delete a previously registered event handler",
+ " delete-event name
+
+Delete the event handler which was previously registered as C<name>.
+If multiple event handlers were registered with the same name, they
+are all deleted.
+
+See also the guestfish commands C<event> and C<list-events>.");
+
+ ("display", (RErr,[], []), -1, [], [],
+ "display an image",
+ " display filename
+
+Use C<display> (a graphical display program) to display an image
+file. It downloads the file, and runs C<display> on it.
+
+To use an alternative program, set the C<GUESTFISH_DISPLAY_IMAGE>
+environment variable. For example to use the GNOME display program:
+
+ export GUESTFISH_DISPLAY_IMAGE=eog
+
+See also L<display(1)>.");
+
("echo", (RErr,[], []), -1, [], [],
"display a line of text",
" echo [params ...]
commands C<vi> or C<emacs> you will get those corresponding
editors.");
+ ("event", (RErr,[], []), -1, [], [],
+ "register a handler for an event or events",
+ " event name eventset \"shell script ...\"
+
+Register a shell script fragment which is executed when an
+event is raised. See L<guestfs(3)/guestfs_set_event_callback>
+for a discussion of the event API in libguestfs.
+
+The C<name> parameter is a name that you give to this event
+handler. It can be any string (even the empty string) and is
+simply there so you can delete the handler using the guestfish
+C<delete-event> command.
+
+The C<eventset> parameter is a comma-separated list of one
+or more events, for example C<close> or C<close,trace>. The
+special value C<*> means all events.
+
+The third and final parameter is the shell script fragment
+(or any external command) that is executed when any of the
+events in the eventset occurs. It is executed using
+C<$SHELL -c>, or if C<$SHELL> is not set then C</bin/sh -c>.
+
+The shell script fragment receives callback parameters as
+arguments C<$1>, C<$2> etc. The actual event that was
+called is available in the environment variable C<$EVENT>.
+
+ event \"\" close \"echo closed\"
+ event messages appliance,library,trace \"echo $@\"
+ event \"\" progress \"echo progress: $3/$4\"
+ event \"\" * \"echo $EVENT $@\"
+
+See also the guestfish commands C<delete-event> and C<list-events>.");
+
("glob", (RErr,[], []), -1, [], [],
"expand wildcards in command",
" glob command args...
Note that C<!cd> won't do what you might expect.");
+ ("list_events", (RErr,[], []), -1, [], [],
+ "list event handlers",
+ " list-events
+
+List the event handlers registered using the guestfish
+C<event> command.");
+
("man", (RErr,[], []), -1, [FishAlias "manual"], [],
"open the manual",
" man
this normally, because the handle is closed properly when guestfish
exits. However this is occasionally useful for testing.");
+ ("setenv", (RErr,[], []), -1, [], [],
+ "set an environment variable",
+ " setenv VAR value
+
+Set the environment variable C<VAR> to the string C<value>.
+
+To print the value of an environment variable use a shell command
+such as:
+
+ !echo $VAR");
+
("sparse", (RErr,[], []), -1, [], [],
"create a sparse disk image and add",
" sparse filename size
Run the command as usual, but print the elapsed time afterwards. This
can be useful for benchmarking operations.");
+ ("unsetenv", (RErr,[], []), -1, [], [],
+ "unset an environment variable",
+ " unsetenv VAR
+
+Remove C<VAR> from the environment.");
+
]