X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=generator%2Fgenerator_actions.ml;h=c684e3587093aa0b9f7456292c89a96310e657e0;hp=086584ca448e6785bf0640de4f7a3e94cfaa2ae1;hb=7739d7f471f9575828bd32489695d92dde005a9c;hpb=a51f56adb168ac7d4b65b98c7f0cdb07f266265f diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index 086584c..c684e35 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -1,5 +1,5 @@ (* 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 @@ -103,7 +103,7 @@ You probably don't want to call this function.")] *) let non_daemon_functions = test_functions @ [ - ("launch", (RErr, [], []), -1, [FishAlias "run"], + ("launch", (RErr, [], []), -1, [FishAlias "run"; Progress], [], "launch the qemu subprocess", "\ @@ -113,7 +113,7 @@ using L. 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)", "\ @@ -155,7 +155,7 @@ and specifying the format."); "\ 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: @@ -190,7 +190,7 @@ automatically."); "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. @@ -282,8 +282,8 @@ If C then no options are added."); "set autosync mode", "\ If C is true, this enables autosync. Libguestfs will make a -best effort attempt to run C followed by -C 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 @@ -300,10 +300,14 @@ Get the autosync flag."); [], "set verbose mode", "\ -If C is true, this turns on verbose messages (to C). +If C is true, this turns on verbose messages. Verbose messages are disabled unless the environment variable -C is defined and set to C<1>."); +C is defined and set to C<1>. + +Verbose messages are normally sent to C, unless you +register a callback to send them somewhere else (see +C)."); ("get_verbose", (RBool "verbose", [], []), -1, [], [], @@ -469,19 +473,19 @@ see L."); ["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 is defined and set to C<1>."); +C is defined and set to C<1>. + +Trace messages are normally sent to C, unless you +register a callback to send them somewhere else (see +C)."); ("get_trace", (RBool "trace", [], []), -1, [], [], @@ -722,9 +726,6 @@ See also C."); [], "get type of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the type of the inspected operating system. Currently defined types are: @@ -738,6 +739,10 @@ Any Linux-based operating system. Any Microsoft Windows operating system. +=item \"freebsd\" + +FreeBSD. + =item \"unknown\" The operating system type could not be determined. @@ -753,9 +758,6 @@ Please read L for more details."); [], "get architecture of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the architecture of the inspected operating system. The possible return values are listed under C. @@ -769,9 +771,6 @@ Please read L for more details."); [], "get distro of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the distro (distribution) of the inspected operating system. @@ -779,31 +778,71 @@ Currently defined distros are: =over 4 +=item \"archlinux\" + +Arch Linux. + +=item \"centos\" + +CentOS. + =item \"debian\" -Debian or a Debian-derived distro such as Ubuntu. +Debian. =item \"fedora\" Fedora. +=item \"gentoo\" + +Gentoo. + +=item \"linuxmint\" + +Linux Mint. + +=item \"mandriva\" + +Mandriva. + +=item \"meego\" + +MeeGo. + +=item \"pardus\" + +Pardus. + =item \"redhat-based\" Some Red Hat-derived distro. =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 \"ubuntu\" + +Ubuntu. =item \"unknown\" 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. @@ -815,9 +854,6 @@ Please read L for more details."); [], "get major version of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the major version number of the inspected operating system. @@ -836,9 +872,6 @@ Please read L for more details."); [], "get minor version of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the minor version number of the inspected operating system. @@ -851,9 +884,6 @@ See also C."); [], "get product name of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - 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 @@ -868,13 +898,14 @@ Please read L for more details."); [], "get mountpoints of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - 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. +I 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) and a value @@ -884,6 +915,12 @@ which is the filesystem that would be mounted there Non-mounted devices such as swap devices are I 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. + Please read L for more details. See also C."); @@ -891,9 +928,6 @@ See also C."); [], "get filesystems associated with inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - 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 @@ -1006,9 +1040,6 @@ deprecated C call (q.v.) [], "get Windows systemroot of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the Windows systemroot of the inspected guest. The systemroot is a directory path such as C. @@ -1018,6 +1049,502 @@ the case then an error is returned. Please read L 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, +but without redoing the whole inspection process. + +This returns an empty list if either no root devices were +found or the caller has not called C. + +Please read L for more details."); + + ("debug_cmdline", (RStringList "cmdline", [], []), -1, [NotInDocs], + [], + "debug the QEMU command line (internal use only)", + "\ +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."); + + ("add_domain", (RInt "nrdisks", [String "dom"], [String "libvirturi"; Bool "readonly"; String "iface"; Bool "live"; Bool "allowuuid"]), -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. It works by connecting to libvirt, requesting +the domain and domain XML from libvirt, parsing it for disks, +and calling C 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 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) +will fail unless those disks are accessible via the same device path +locally too. + +The optional C parameter sets the libvirt URI +(see L). 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 flag controls whether this call will try +to connect to a running virtual machine C process if +it sees a suitable EchannelE element in the libvirt +XML definition. The default (if the flag is omitted) is never +to try. See L for more +information. + +If the C flag is true (default is false) then a UUID +I be passed instead of the domain name. The C string is +treated as a UUID first and looked up, and if that lookup fails +then we treat C as a name as usual. + +The other optional parameters are passed directly through to +C."); + +(* +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"]), -1, [NotInFish], + [], + "add the disk(s) from a libvirt domain", + "\ +This function adds the disk(s) attached to the libvirt domain C. +It works by requesting the domain XML from libvirt, parsing it for +disks, and calling C on each one. + +In the C API we declare C, but really it has type +C. This is so we don't need Elibvirt.hE. + +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 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) +will fail unless those disks are accessible via the same device path +locally too. + +The optional C flag controls whether this call will try +to connect to a running virtual machine C process if +it sees a suitable EchannelE element in the libvirt +XML definition. The default (if the flag is omitted) is never +to try. See L for more +information. + +The other optional parameters are passed directly through to +C."); +*) + + ("inspect_get_package_format", (RString "packageformat", [Device "root"], []), -1, [], + [], + "get package format used by the operating system", + "\ +This function and C return +the package format and package management tool used by the +inspected operating system. For example for Fedora these +functions would return C (package format) and +C (package management). + +This returns the string C if we could not determine the +package format I if the operating system does not have +a real packaging system (eg. Windows). + +Possible strings include: C, C, C, C, C. +Future versions of libguestfs may return other strings. + +Please read L for more details."); + + ("inspect_get_package_management", (RString "packagemanagement", [Device "root"], []), -1, [], + [], + "get package management tool used by the operating system", + "\ +C 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 (package format) and +C (package management). + +This returns the string C if we could not determine the +package management tool I if the operating system does not have +a real packaging system (eg. Windows). + +Possible strings include: C, C, +C (for all Debian derivatives), +C, C, C, C. +Future versions of libguestfs may return other strings. + +Please read L 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 This call works differently from other parts of the +inspection API. You have to call C, then +C, 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 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 + +The name of the application. For Red Hat-derived and Debian-derived +Linux guests, this is the package name. + +=item C + +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 instead. + +=item C + +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 + +The version string of the application or package. If unavailable +this is returned as an empty string C<\"\">. + +=item C + +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 + +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 + +The install path translated into a libguestfs path. +If unavailable this is returned as an empty string C<\"\">. + +=item C + +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 + +The URL (eg. upstream URL) of the application. +If unavailable this is returned as an empty string C<\"\">. + +=item C + +For packaging systems which support this, the name of the source +package. If unavailable this is returned as an empty string C<\"\">. + +=item C + +A short (usually one line) description of the application or package. +If unavailable this is returned as an empty string C<\"\">. + +=item C + +A longer description of the application or package. +If unavailable this is returned as an empty string C<\"\">. + +=back + +Please read L 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 is returned. + +Please read L 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 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 for more details."); + + ("inspect_is_live", (RBool "live", [Device "root"], []), -1, [], + [], + "get live flag for install disk", + "\ +If C returns C (this +is an install disk), then this returns true if a live image +was detected on the disk. + +Please read L for more details."); + + ("inspect_is_netinst", (RBool "netinst", [Device "root"], []), -1, [], + [], + "get netinst (network installer) flag for install disk", + "\ +If C returns C (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 for more details."); + + ("inspect_is_multipart", (RBool "multipart", [Device "root"], []), -1, [], + [], + "get multipart flag for install disk", + "\ +If C returns C (this +is an install disk), then this returns true if the disk is +part of a set. + +Please read L 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 + +Launch an appliance and connect to it. This is the ordinary method +and the default. + +=item C> + +Connect to the Unix domain socket I. + +This method lets you connect to an existing daemon or (using +virtio-serial) to a live guest. For more information, see +L. + +=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."); + + ("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 +C which is usually a string such as +C or C (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 and the latter is C). + +For enterprise Linux guests, in future we intend this to return +the product variant such as C, C and so on. But +this is not implemented at present. + +If the product variant could not be determined, then the +string C is returned. + +Please read L for more details. +See also C, +C."); + + ("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. + +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 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, C

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 for more details. +See also C, +C."); + + ("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. + +Libguestfs will start by looking for a file called +C or C +and if it has the correct format, the contents of this file will +be returned. You can disable favicons by passing the +optional C 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 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 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 program from the C package, and +several programs (C, C, C) +from the C 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 is true, child processes are placed into +their own process group. + +The practical upshot of this is that signals like C (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."); + ] (* daemon_functions are any functions which cause some action @@ -1025,7 +1552,7 @@ Please read L for more details."); *) let daemon_functions = [ - ("mount", (RErr, [Device "device"; String "mountpoint"], []), 1, [], + ("mount", (RErr, [Device "device"; String "mountpoint"], []), 1, [DeprecatedBy "mount_options"], [InitEmpty, Always, TestOutput ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext2"; "/dev/sda1"]; @@ -1069,9 +1596,9 @@ You should always call this if you have modified a disk image, before closing the handle."); ("touch", (RErr, [Pathname "path"], []), 3, [], - [InitBasicFS, Always, TestOutputTrue ( - [["touch"; "/new"]; - ["exists"; "/new"]])], + [InitScratchFS, Always, TestOutputTrue ( + [["touch"; "/touch"]; + ["exists"; "/touch"]])], "update file timestamps or create a new file", "\ Touch acts like the L command. It can be used to @@ -1106,11 +1633,12 @@ This command is mostly useful for interactive sessions. It is I intended that you try to parse the output string."); ("ls", (RStringList "listing", [Pathname "directory"], []), 6, [], - [InitBasicFS, Always, TestOutputList ( - [["touch"; "/new"]; - ["touch"; "/newer"]; - ["touch"; "/newest"]; - ["ls"; "/"]], ["lost+found"; "new"; "newer"; "newest"])], + [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 (relative to the root directory, @@ -1133,10 +1661,13 @@ See also C."); ("list_partitions", (RStringList "partitions", [], []), 8, [], [InitBasicFS, Always, TestOutputListOfDevices ( - [["list_partitions"]], ["/dev/sda1"]); + [["list_partitions"]], ["/dev/sda1"; "/dev/sdb1"]); InitEmpty, Always, TestOutputListOfDevices ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; - ["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])], + [["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. @@ -1152,7 +1683,10 @@ See also C."); [InitBasicFSonLVM, Always, TestOutputListOfDevices ( [["pvs"]], ["/dev/sda1"]); InitEmpty, Always, TestOutputListOfDevices ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["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"]; @@ -1171,7 +1705,10 @@ See also C."); [InitBasicFSonLVM, Always, TestOutputList ( [["vgs"]], ["VG"]); InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["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"]; @@ -1192,7 +1729,10 @@ See also C."); [InitBasicFSonLVM, Always, TestOutputList ( [["lvs"]], ["/dev/VG/LV"]); InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["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"]; @@ -1281,7 +1821,12 @@ do not overwrite original. Overrides C. =item C = 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 +environment variable or call C. =item C = 8 @@ -1415,38 +1960,40 @@ This is just a shortcut for listing C C 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."); ("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."); ("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, recursively removing the @@ -1454,32 +2001,32 @@ contents if its a directory. This is like the C shell 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."); ("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, creating any parent directories @@ -1548,7 +2095,10 @@ See also C."); ("pvcreate", (RErr, [Device "device"], []), 39, [Optional "lvm2"], [InitEmpty, Always, TestOutputListOfDevices ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["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"]; @@ -1561,7 +2111,10 @@ as C."); ("vgcreate", (RErr, [String "volgroup"; DeviceList "physvols"], []), 40, [Optional "lvm2"], [InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["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"]; @@ -1575,7 +2128,10 @@ from the non-empty list of physical volumes C."); ("lvcreate", (RErr, [String "logvol"; String "volgroup"; Int "mbytes"], []), 41, [Optional "lvm2"], [InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["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"]; @@ -1609,7 +2165,7 @@ example C."); ("sfdisk", (RErr, [Device "device"; Int "cyls"; Int "heads"; Int "sectors"; - StringList "lines"], []), 43, [DangerWillRobinson], + StringList "lines"], []), 43, [DangerWillRobinson; DeprecatedBy "part_add"], [], "create partitions on a block device", "\ @@ -1638,8 +2194,8 @@ C"); ("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. The contents of the @@ -1672,8 +2228,8 @@ specified either by its mountpoint (path) or the device which 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 @@ -1684,12 +2240,15 @@ Some internal mounts are not shown. See also: C"); ("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: *) InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["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"]; ["mkfs"; "ext2"; "/dev/sda1"]; ["mkfs"; "ext2"; "/dev/sda2"]; ["mkfs"; "ext2"; "/dev/sda3"]; @@ -1735,67 +2294,76 @@ of compressed file. The exact command which runs is C. 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 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. +The output depends on the output of the underlying L +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 does not begin with C 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 etc."); +See also: L, C, C, +C, C (etc), C."); ("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 @@ -1829,50 +2397,61 @@ all filesystems that are needed are mounted at the right 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, but splits the @@ -2036,11 +2615,12 @@ Reread the partition table on C. This uses the L 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", "\ @@ -2052,12 +2632,13 @@ C can also be a named pipe. See also C."); ("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", "\ @@ -2136,9 +2717,10 @@ To get the checksum for a device, use C. To get the checksums for many files, use C."); ("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 (an @@ -2158,9 +2740,10 @@ To download a compressed tarball, use C or C."); ("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 (a @@ -2212,7 +2795,7 @@ This is the same as the C command, but it allows you to set both the mount options and the vfstype as for the L 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", "\ @@ -2364,10 +2947,10 @@ to return the existing UUID of a filesystem."); ("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 @@ -2412,10 +2995,9 @@ Checking or repairing NTFS volumes is not supported This command is entirely equivalent to running C."); ("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. @@ -2424,7 +3006,8 @@ How many blocks are zeroed isn't specified (but it's I enough to securely wipe the device). It should be sufficient to remove any partition tables, filesystem superblocks and so on. -See also: C, C."); +See also: C, C, +C"); ("grub_install", (RErr, [Pathname "root"; Device "device"], []), 86, [], (* See: @@ -2453,45 +3036,50 @@ a file containing: replacing C with the name of the installation device."); ("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 to C where C 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 to C recursively using the C 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 to C where C is @@ -2537,16 +3125,19 @@ daemon responds to the ping message, without affecting the daemon 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 and C and returns @@ -2570,9 +3161,9 @@ the list of printable strings found."); ("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 command, but allows you to @@ -2662,7 +3253,7 @@ volume to match the new size of the underlying device."); ("sfdisk_N", (RErr, [Device "device"; Int "partnum"; Int "cyls"; Int "heads"; Int "sectors"; - String "line"], []), 99, [DangerWillRobinson], + String "line"], []), 99, [DangerWillRobinson; DeprecatedBy "part_add"], [], "modify a single partition on a block device", "\ @@ -2674,7 +3265,7 @@ pass C<0> for the cyls/heads/sectors parameters. See also: C"); - ("sfdisk_l", (RString "partitions", [Device "device"], []), 100, [], + ("sfdisk_l", (RString "partitions", [Device "device"], []), 100, [DeprecatedBy "part_list"], [], "display the partition table", "\ @@ -2711,9 +3302,6 @@ be parsed."); "\ This command activates or (if C 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 devices. If deactivated, -then those devices disappear. This command is the same as running C"); @@ -2723,9 +3311,6 @@ This command is the same as running C"); "\ This command activates or (if C is false) deactivates all logical volumes in the listed volume groups C. -If activated, then they are made known to the -kernel, ie. they appear as C devices. If deactivated, -then those devices disappear. This command is the same as running C @@ -2781,10 +3366,10 @@ calling this function."); ["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, @@ -2819,8 +3404,8 @@ See also C."); "check an ext2/ext3 filesystem", "\ This runs C, ie. runs the ext2/ext3 -filesystem checker on C, noninteractively (C<-p>), -even if the filesystem appears to be clean (C<-f>). +filesystem checker on C, noninteractively (I<-p>), +even if the filesystem appears to be clean (I<-f>). This command is only needed because of C (q.v.). Normally you should use C."); @@ -2886,21 +3471,21 @@ See also: C"); * 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 @@ -2926,9 +3511,9 @@ It is an interface to the L program. See that 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 @@ -2953,9 +3538,9 @@ It is an interface to the L program. See that 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 @@ -3067,7 +3652,7 @@ This command runs the C command to report disk space used. This command is mostly useful for interactive sessions. It is I intended that you try to parse the output string. -Use C from programs."); +Use C from programs."); ("df_h", (RString "output", [], []), 126, [], [], (* XXX Tricky to test because it depends on the exact format @@ -3080,9 +3665,9 @@ in human-readable format. This command is mostly useful for interactive sessions. It is I intended that you try to parse the output string. -Use C from programs."); +Use C 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", @@ -3150,13 +3735,13 @@ a limitation of the kernel or swap tools."); Create a swap partition on C with UUID C."); ("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 @@ -3178,9 +3763,9 @@ in the appropriate constant for you. 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 with @@ -3190,9 +3775,9 @@ C. 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 with @@ -3202,9 +3787,9 @@ It is just a convenient wrapper around C. 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 with @@ -3293,7 +3878,7 @@ This function is primarily intended for use by programs. To get a simple list of names, use C. To get a printable directory for human consumption, use C."); - ("sfdiskM", (RErr, [Device "device"; StringList "lines"], []), 139, [DangerWillRobinson], + ("sfdiskM", (RErr, [Device "device"; StringList "lines"], []), 139, [DangerWillRobinson; DeprecatedBy "part_add"], [], "create partitions on a block device", "\ @@ -3430,7 +4015,7 @@ pathnames, as in the example code above. For more details see L Autosync [see C, this is set by default on -handles] means that C is called when the handle +handles] can cause C to be called when the handle is closed which can also trigger these issues."); ("rmmountpoint", (RErr, [String "exemptpath"], []), 149, [], @@ -3445,18 +4030,18 @@ for full details."); [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 as a @@ -3577,44 +4162,47 @@ Return the canonicalized absolute pathname of C. The 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 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 command. -The C<-f> option removes the link (C) if it exists already."); +The I<-f> option removes the link (C) 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 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 command, -The C<-f> option removes the link (C) if it exists already."); +The I<-f> option removes the link (C) if it exists already."); ("readlink", (RString "link", [Pathname "path"], []), 168, [], [] (* XXX tested above *), @@ -3623,9 +4211,9 @@ The C<-f> option removes the link (C) if it exists already."); 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 @@ -3664,11 +4252,12 @@ device or partition named C. See C."); ("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. @@ -3682,12 +4271,12 @@ This command disables the libguestfs appliance swap on 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. @@ -3703,7 +4292,7 @@ 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", @@ -3719,9 +4308,10 @@ This command disables the libguestfs appliance swap partition 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. @@ -3771,11 +4361,12 @@ via libguestfs. Note that there is one global inotify handle 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", "\ @@ -3845,7 +4436,7 @@ This gets the SELinux security context of the daemon. See the documentation about SELINUX in L, and C"); - ("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"]; @@ -3876,7 +4467,9 @@ the requested cluster size."); ("mke2journal", (RErr, [Int "blocksize"; Device "device"], []), 188, [], [InitEmpty, Always, TestOutput ( - [["sfdiskM"; "/dev/sda"; ",100 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "-64"]; ["mke2journal"; "4096"; "/dev/sda1"]; ["mke2fs_J"; "ext2"; "4096"; "/dev/sda2"; "/dev/sda1"]; ["mount_options"; ""; "/dev/sda2"; "/"]; @@ -3891,7 +4484,9 @@ to the command: ("mke2journal_L", (RErr, [Int "blocksize"; String "label"; Device "device"], []), 189, [], [InitEmpty, Always, TestOutput ( - [["sfdiskM"; "/dev/sda"; ",100 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "-64"]; ["mke2journal_L"; "4096"; "JOURNAL"; "/dev/sda1"]; ["mke2fs_JL"; "ext2"; "4096"; "/dev/sda2"; "JOURNAL"]; ["mount_options"; ""; "/dev/sda2"; "/"]; @@ -3904,7 +4499,9 @@ This creates an ext2 external journal on C with label C