X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=96a58478d6c0041790103887ba1cde11748586cd;hp=2243609b604b521dc553bc4011cedd97a72f8ce9;hb=6b500f1b8e1ac8d28c485a5591c2833b18cc86e2;hpb=9ff1c97f04e8c0e513262893df71da0d31b34637 diff --git a/src/generator.ml b/src/generator.ml index 2243609..96a5847 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -1,6 +1,6 @@ #!/usr/bin/env ocaml (* libguestfs - * Copyright (C) 2009 Red Hat Inc. + * Copyright (C) 2009-2010 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 @@ -19,17 +19,17 @@ (* This script generates a large amount of code and documentation for * all the daemon actions. - * + * * To add a new action there are only two files you need to change, * this one to describe the interface (see the big table of * 'daemon_functions' below), and daemon/.c to write the * implementation. - * + * * After editing this file, run it (./src/generator.ml) to regenerate * all the output files. 'make' will rerun this automatically when * necessary. Note that if you are using a separate build directory * you must run generator.ml from the _source_ directory. - * + * * IMPORTANT: This script should NOT print any warnings. If it prints * warnings, you should treat them as errors. * @@ -41,6 +41,9 @@ #load "unix.cma";; #load "str.cma";; +#directory "+xml-light";; +#directory "+../pkg-lib/xml-light";; (* for GODI users *) +#load "xml-light.cma";; open Unix open Printf @@ -161,9 +164,8 @@ and argt = *) | FileIn of string | FileOut of string -(* Not implemented: (* Opaque buffer which can contain arbitrary 8 bit data. - * In the C API, this is expressed as pair. + * In the C API, this is expressed as pair. * Most other languages have a string type which can contain * ASCII NUL. We use whatever type is appropriate for each * language. @@ -172,18 +174,21 @@ and argt = * To return an arbitrary buffer, use RBufferOut. *) | BufferIn of string -*) type flags = | ProtocolLimitWarning (* display warning about protocol size limits *) | DangerWillRobinson (* flags particularly dangerous commands *) | FishAlias of string (* provide an alias for this cmd in guestfish *) - | FishAction of string (* call this function in guestfish *) + | FishOutput of fish_output_t (* how to display output in guestfish *) | NotInFish (* do not export via guestfish *) | NotInDocs (* do not add this function to documentation *) | DeprecatedBy of string (* function is deprecated, use .. instead *) | Optional of string (* function is part of an optional group *) +and fish_output_t = + | FishOutputOctal (* for int return, print in octal *) + | FishOutputHexadecimal (* for int return, print in hex *) + (* You can supply zero or as many tests as you want per API call. * * Note that the test environment has 3 block devices, of size 500MB, @@ -377,6 +382,7 @@ let test_all_args = [ Int64 "integer64"; FileIn "filein"; FileOut "fileout"; + BufferIn "bufferin"; ] let test_all_rets = [ @@ -439,7 +445,7 @@ You probably don't want to call this function.")] *) let non_daemon_functions = test_functions @ [ - ("launch", (RErr, []), -1, [FishAlias "run"; FishAction "launch"], + ("launch", (RErr, []), -1, [FishAlias "run"], [], "launch the qemu subprocess", "\ @@ -487,9 +493,15 @@ image). This is equivalent to the qemu parameter C<-drive file=filename,cache=off,if=...>. + C is omitted in cases where it is not supported by the underlying filesystem. +C is set at compile time by the configuration option +C<./configure --with-drive-if=...>. In the rare case where you +might need to change this at run time, use C +or C. + Note that this call checks for the existence of C. This stops you from specifying other types of drive which are supported by qemu such as C and C URLs. To specify those, use @@ -503,10 +515,24 @@ This function adds a virtual CD-ROM disk image to the guest. This is equivalent to the qemu parameter C<-cdrom filename>. -Note that this call checks for the existence of C. This +Notes: + +=over 4 + +=item * + +This call checks for the existence of C. This stops you from specifying other types of drive which are supported by qemu such as C and C URLs. To specify those, use -the general C call instead."); +the general C call instead. + +=item * + +If you just want to add an ISO file (often you use this as an +efficient way to transfer large files into the guest), then you +should probably use C instead. + +=back"); ("add_drive_ro", (RErr, [String "filename"]), -1, [FishAlias "add-ro"], [], @@ -522,7 +548,14 @@ handle is closed. We don't currently have any method to enable changes to be committed, although qemu can support this. This is equivalent to the qemu parameter -C<-drive file=filename,snapshot=on,if=...>. +C<-drive file=filename,snapshot=on,readonly=on,if=...>. + +C is set at compile time by the configuration option +C<./configure --with-drive-if=...>. In the rare case where you +might need to change this at run time, use C +or C. + +C is only added where qemu supports this option. Note that this call checks for the existence of C. This stops you from specifying other types of drive which are supported @@ -542,7 +575,7 @@ The first character of C string must be a C<-> (dash). C can be NULL."); - ("set_qemu", (RErr, [String "qemu"]), -1, [FishAlias "qemu"], + ("set_qemu", (RErr, [OptString "qemu"]), -1, [FishAlias "qemu"], [], "set the qemu binary", "\ @@ -554,7 +587,15 @@ configure script. You can also override this by setting the C environment variable. -Setting C to C restores the default qemu binary."); +Setting C to C restores the default qemu binary. + +Note that you should call this function as early as possible +after creating the handle. This is because some pre-launch +operations depend on testing qemu features (by running C). +If the qemu binary changes, we don't retest features, and +so you might see inconsistent results. Using the environment +variable C is safest of all since that picks +the qemu binary at the same time as the handle is created."); ("get_qemu", (RConstString "qemu", []), -1, [], [InitNone, Always, TestRun ( @@ -566,7 +607,7 @@ Return the current qemu binary. This is always non-NULL. If it wasn't set already, then this will return the default qemu binary name."); - ("set_path", (RErr, [String "searchpath"]), -1, [FishAlias "path"], + ("set_path", (RErr, [OptString "searchpath"]), -1, [FishAlias "path"], [], "set the search path", "\ @@ -753,8 +794,9 @@ against a completely different C library. This call was added in version C<1.0.58>. In previous versions of libguestfs there was no way to get the version -number. From C code you can use ELF weak linking tricks to find out if -this symbol exists (if it doesn't, then it's an earlier version). +number. From C code you can use dynamic linker functions +to find out if this symbol exists (if it doesn't, then +it's an earlier version). The call returns a structure with four elements. The first three (C, C and C) are numbers and @@ -871,6 +913,20 @@ qemu, which is not very helpful."); "\ Return the recovery process enabled flag."); + ("add_drive_with_if", (RErr, [String "filename"; String "iface"]), -1, [], + [], + "add a drive specifying the QEMU block emulation to use", + "\ +This is the same as C but it allows you +to specify the QEMU interface emulation to use at run time."); + + ("add_drive_ro_with_if", (RErr, [String "filename"; String "iface"]), -1, [], + [], + "add a drive read-only specifying the QEMU block emulation to use", + "\ +This is the same as C but it allows you +to specify the QEMU interface emulation to use at run time."); + ] (* daemon_functions are any functions which cause some action @@ -883,7 +939,7 @@ let daemon_functions = [ [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext2"; "/dev/sda1"]; ["mount"; "/dev/sda1"; "/"]; - ["write_file"; "/new"; "new file contents"; "0"]; + ["write"; "/new"; "new file contents"]; ["cat"; "/new"]], "new file contents")], "mount a guest disk at a position in the filesystem", "\ @@ -901,8 +957,15 @@ exist. The mounted filesystem is writable, if we have sufficient permissions on the underlying device. -The filesystem options C and C are set with this -call, in order to improve reliability."); +B +When you use this call, the filesystem options C and C +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 in any code that needs performance, and instead +use C (use an empty string for the first +parameter if you don't want any options)."); ("sync", (RErr, []), 2, [], [ InitEmpty, Always, TestRun [["sync"]]], @@ -1186,7 +1249,12 @@ matches exactly one node, the C is returned."); [], (* XXX Augeas code needs tests. *) "set Augeas path to value", "\ -Set the value associated with C to C."); +Set the value associated with C to C. + +In the Augeas API, it is possible to clear a node by setting +the value to NULL. Due to an oversight in the libguestfs API +you cannot do that with this call. Instead you must use the +C call."); ("aug_insert", (RErr, [String "augpath"; String "label"; Bool "before"]), 21, [Optional "augeas"], [], (* XXX Augeas code needs tests. *) @@ -1324,7 +1392,13 @@ as necessary. This is like the C shell command."); "change file mode", "\ Change the mode (permissions) of C to C. Only -numeric modes are supported."); +numeric modes are supported. + +I: When using this command from guestfish, C +by default would be decimal, unless you prefix it with +C<0> to get octal, ie. use C<0700> not C<700>. + +The mode actually set is affected by the umask."); ("chown", (RErr, [Int "owner"; Int "group"; Pathname "path"]), 35, [], [], (* XXX Need stat command to test *) @@ -1417,17 +1491,17 @@ from the non-empty list of physical volumes C."); ["lvs"]], ["/dev/VG1/LV1"; "/dev/VG1/LV2"; "/dev/VG2/LV3"; "/dev/VG2/LV4"; "/dev/VG2/LV5"])], - "create an LVM volume group", + "create an LVM logical volume", "\ -This creates an LVM volume group called C +This creates an LVM logical volume called C on the volume group C, with C megabytes."); ("mkfs", (RErr, [String "fstype"; Device "device"]), 42, [], [InitEmpty, Always, TestOutput ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext2"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; - ["write_file"; "/new"; "new file contents"; "0"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; + ["write"; "/new"; "new file contents"]; ["cat"; "/new"]], "new file contents")], "make a filesystem", "\ @@ -1464,25 +1538,8 @@ the string C<,> (comma). See also: C, C, C"); - ("write_file", (RErr, [Pathname "path"; String "content"; Int "size"]), 44, [ProtocolLimitWarning], - [InitBasicFS, Always, TestOutput ( - [["write_file"; "/new"; "new file contents"; "0"]; - ["cat"; "/new"]], "new file contents"); - InitBasicFS, Always, TestOutput ( - [["write_file"; "/new"; "\nnew file contents\n"; "0"]; - ["cat"; "/new"]], "\nnew file contents\n"); - InitBasicFS, Always, TestOutput ( - [["write_file"; "/new"; "\n\n"; "0"]; - ["cat"; "/new"]], "\n\n"); - InitBasicFS, Always, TestOutput ( - [["write_file"; "/new"; ""; "0"]; - ["cat"; "/new"]], ""); - InitBasicFS, Always, TestOutput ( - [["write_file"; "/new"; "\n\n\n"; "0"]; - ["cat"; "/new"]], "\n\n\n"); - InitBasicFS, Always, TestOutput ( - [["write_file"; "/new"; "\n"; "0"]; - ["cat"; "/new"]], "\n")], + ("write_file", (RErr, [Pathname "path"; String "content"; Int "size"]), 44, [ProtocolLimitWarning; DeprecatedBy "write"], + [], "create a file", "\ This call creates a file called C. The contents of the @@ -1494,20 +1551,18 @@ then the length is calculated using C (so in this case the content cannot contain embedded ASCII NULs). I Owing to a bug, writing content containing ASCII NUL -characters does I work, even if the length is specified. -We hope to resolve this bug in a future version. In the meantime -use C."); +characters does I work, even if the length is specified."); ("umount", (RErr, [String "pathordevice"]), 45, [FishAlias "unmount"], [InitEmpty, Always, TestOutputListOfDevices ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext2"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["mounts"]], ["/dev/sda1"]); InitEmpty, Always, TestOutputList ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext2"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["umount"; "/"]; ["mounts"]], [])], "unmount a filesystem", @@ -1538,11 +1593,11 @@ See also: C"); ["mkfs"; "ext2"; "/dev/sda1"]; ["mkfs"; "ext2"; "/dev/sda2"]; ["mkfs"; "ext2"; "/dev/sda3"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["mkdir"; "/mp1"]; - ["mount"; "/dev/sda2"; "/mp1"]; + ["mount_options"; ""; "/dev/sda2"; "/mp1"]; ["mkdir"; "/mp1/mp2"]; - ["mount"; "/dev/sda3"; "/mp1/mp2"]; + ["mount_options"; ""; "/dev/sda3"; "/mp1/mp2"]; ["mkdir"; "/mp1/mp2/mp3"]; ["umount_all"]; ["mounts"]], [])], @@ -1916,7 +1971,10 @@ See also C, C."); InitISOFS, Always, TestOutput ( [["checksum"; "sha384"; "/known-3"]], "5fa7883430f357b5d7b7271d3a1d2872b51d73cba72731de6863d3dea55f30646af2799bef44d5ea776a5ec7941ac640"); InitISOFS, Always, TestOutput ( - [["checksum"; "sha512"; "/known-3"]], "2794062c328c6b216dca90443b7f7134c5f40e56bd0ed7853123275a09982a6f992e6ca682f9d2fba34a4c5e870d8fe077694ff831e3032a004ee077e00603f6")], + [["checksum"; "sha512"; "/known-3"]], "2794062c328c6b216dca90443b7f7134c5f40e56bd0ed7853123275a09982a6f992e6ca682f9d2fba34a4c5e870d8fe077694ff831e3032a004ee077e00603f6"); + (* Test for RHBZ#579608, absolute symbolic links. *) + InitISOFS, Always, TestOutput ( + [["checksum"; "sha512"; "/abssymlink"]], "5f57d0639bc95081c53afc63a449403883818edc64da48930ad6b1a4fb49be90404686877743fbcd7c99811f3def7df7bc22635c885c6a8cf79c806b43451c1a")], "compute MD5, SHAx or CRC checksum of file", "\ This call computes the MD5, SHAx or CRC checksum of the @@ -1958,9 +2016,13 @@ Compute the SHA512 hash (using the C program). =back -The checksum is returned as a printable string."); +The checksum is returned as a printable string. + +To get the checksum for a device, use C. - ("tar_in", (RErr, [FileIn "tarfile"; String "directory"]), 69, [], +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")], @@ -1969,7 +2031,8 @@ The checksum is returned as a printable string."); This command uploads and unpacks local file C (an I tar file) into C. -To upload a compressed tarball, use C."); +To upload a compressed tarball, use C +or C."); ("tar_out", (RErr, [String "directory"; FileOut "tarfile"]), 70, [], [], @@ -1978,9 +2041,10 @@ To upload a compressed tarball, use C."); This command packs the contents of C and downloads it to local file C. -To download a compressed tarball, use C."); +To download a compressed tarball, use C +or C."); - ("tgz_in", (RErr, [FileIn "tarball"; String "directory"]), 71, [], + ("tgz_in", (RErr, [FileIn "tarball"; Pathname "directory"]), 71, [], [InitBasicFS, Always, TestOutput ( [["tgz_in"; "../images/helloworld.tar.gz"; "/"]; ["cat"; "/hello"]], "hello\n")], @@ -2006,7 +2070,7 @@ To download an uncompressed tarball, use C."); ["mount_ro"; "/dev/sda1"; "/"]; ["touch"; "/new"]]); InitBasicFS, Always, TestOutput ( - [["write_file"; "/new"; "data"; "0"]; + [["write"; "/new"; "data"]; ["umount"; "/"]; ["mount_ro"; "/dev/sda1"; "/"]; ["cat"; "/new"]], "data")], @@ -2021,7 +2085,11 @@ mounts the filesystem with the read-only (I<-o ro>) flag."); "\ This is the same as the C command, but it allows you to set the mount options as for the -L I<-o> flag."); +L I<-o> flag. + +If the C parameter is an empty string, then +no options are passed (all options default to whatever +the filesystem uses)."); ("mount_vfs", (RErr, [String "options"; String "vfstype"; Device "device"; String "mountpoint"]), 75, [], [], @@ -2187,7 +2255,7 @@ to return the existing UUID of a filesystem."); This returns the ext2/3/4 filesystem UUID of the filesystem on C."); - ("fsck", (RInt "status", [String "fstype"; Device "device"]), 84, [], + ("fsck", (RInt "status", [String "fstype"; Device "device"]), 84, [FishOutput FishOutputHexadecimal], [InitBasicFS, Always, TestOutputInt ( [["umount"; "/dev/sda1"]; ["fsck"; "ext2"; "/dev/sda1"]], 0); @@ -2238,7 +2306,7 @@ 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."); +See also: C, C."); ("grub_install", (RErr, [Pathname "root"; Device "device"]), 86, [], (* Test disabled because grub-install incompatible with virtio-blk driver. @@ -2254,15 +2322,15 @@ C, with the root directory being C."); ("cp", (RErr, [Pathname "src"; Pathname "dest"]), 87, [], [InitBasicFS, Always, TestOutput ( - [["write_file"; "/old"; "file content"; "0"]; + [["write"; "/old"; "file content"]; ["cp"; "/old"; "/new"]; ["cat"; "/new"]], "file content"); InitBasicFS, Always, TestOutputTrue ( - [["write_file"; "/old"; "file content"; "0"]; + [["write"; "/old"; "file content"]; ["cp"; "/old"; "/new"]; ["is_file"; "/old"]]); InitBasicFS, Always, TestOutput ( - [["write_file"; "/old"; "file content"; "0"]; + [["write"; "/old"; "file content"]; ["mkdir"; "/dir"]; ["cp"; "/old"; "/dir/new"]; ["cat"; "/dir/new"]], "file content")], @@ -2275,7 +2343,7 @@ either a destination filename or destination directory."); [InitBasicFS, Always, TestOutput ( [["mkdir"; "/olddir"]; ["mkdir"; "/newdir"]; - ["write_file"; "/olddir/file"; "file content"; "0"]; + ["write"; "/olddir/file"; "file content"]; ["cp_a"; "/olddir"; "/newdir"]; ["cat"; "/newdir/olddir/file"]], "file content")], "copy a file or directory recursively", @@ -2285,11 +2353,11 @@ recursively using the C command."); ("mv", (RErr, [Pathname "src"; Pathname "dest"]), 89, [], [InitBasicFS, Always, TestOutput ( - [["write_file"; "/old"; "file content"; "0"]; + [["write"; "/old"; "file content"]; ["mv"; "/old"; "/new"]; ["cat"; "/new"]], "file content"); InitBasicFS, Always, TestOutputFalse ( - [["write_file"; "/old"; "file content"; "0"]; + [["write"; "/old"; "file content"]; ["mv"; "/old"; "/new"]; ["is_file"; "/old"]])], "move a file", @@ -2338,12 +2406,12 @@ or attached block device(s) in any other way."); ("equal", (RBool "equality", [Pathname "file1"; Pathname "file2"]), 93, [], [InitBasicFS, Always, TestOutputTrue ( - [["write_file"; "/file1"; "contents of a file"; "0"]; + [["write"; "/file1"; "contents of a file"]; ["cp"; "/file1"; "/file2"]; ["equal"; "/file1"; "/file2"]]); InitBasicFS, Always, TestOutputFalse ( - [["write_file"; "/file1"; "contents of a file"; "0"]; - ["write_file"; "/file2"; "contents of another file"; "0"]; + [["write"; "/file1"; "contents of a file"]; + ["write"; "/file2"; "contents of another file"]; ["equal"; "/file1"; "/file2"]]); InitBasicFS, Always, TestLastFail ( [["equal"; "/file1"; "/file2"]])], @@ -2358,7 +2426,10 @@ The external L program is used for the comparison."); [InitISOFS, Always, TestOutputList ( [["strings"; "/known-5"]], ["abcdefghi"; "jklmnopqr"]); InitISOFS, Always, TestOutputList ( - [["strings"; "/empty"]], [])], + [["strings"; "/empty"]], []); + (* Test for RHBZ#579608, absolute symbolic links. *) + InitISOFS, Always, TestRun ( + [["strings"; "/abssymlink"]])], "print the printable strings in a file", "\ This runs the L command on a file and returns @@ -2367,18 +2438,47 @@ 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, Disabled, TestOutputList ( - [["write_file"; "/new"; "\000h\000e\000l\000l\000o\000\n\000w\000o\000r\000l\000d\000\n"; "24"]; + 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"])], "print the printable strings in a file", "\ This is like the C command, but allows you to -specify the encoding. +specify the encoding of strings that are looked for in +the source file C. + +Allowed encodings are: + +=over 4 + +=item s + +Single 7-bit-byte characters like ASCII and the ASCII-compatible +parts of ISO-8859-X (this is what C uses). + +=item S + +Single 8-bit-byte characters. -See the L manpage for the full list of encodings. +=item b -Commonly useful encodings are C (lower case L) which will -show strings inside Windows/x86 files. +16-bit big endian strings such as those encoded in +UTF-16BE or UCS-2BE. + +=item l (lower case letter L) + +16-bit little endian such as UTF-16LE and UCS-2LE. +This is useful for examining binaries in Windows guests. + +=item B + +32-bit big endian such as UCS-4BE. + +=item L + +32-bit little endian such as UCS-4LE. + +=back The returned strings are transcoded to UTF-8."); @@ -2389,7 +2489,10 @@ The returned strings are transcoded to UTF-8."); * commands to segfault. *) InitISOFS, Always, TestRun ( - [["hexdump"; "/100krandom"]])], + [["hexdump"; "/100krandom"]]); + (* Test for RHBZ#579608, absolute symbolic links. *) + InitISOFS, Always, TestRun ( + [["hexdump"; "/abssymlink"]])], "dump a file in hexadecimal", "\ This runs C on the given C. The result is @@ -2399,11 +2502,11 @@ the human-readable, canonical hex dump of the file."); [InitNone, Always, TestOutput ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext3"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; - ["write_file"; "/new"; "test file"; "0"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; + ["write"; "/new"; "test file"]; ["umount"; "/dev/sda1"]; ["zerofree"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["cat"; "/new"]], "test file")], "zero unused inodes and disk blocks on ext2/3 filesystem", "\ @@ -2504,14 +2607,21 @@ are activated or deactivated."); ["vgcreate"; "VG"; "/dev/sda1"]; ["lvcreate"; "LV"; "VG"; "10"]; ["mkfs"; "ext2"; "/dev/VG/LV"]; - ["mount"; "/dev/VG/LV"; "/"]; - ["write_file"; "/new"; "test content"; "0"]; + ["mount_options"; ""; "/dev/VG/LV"; "/"]; + ["write"; "/new"; "test content"]; ["umount"; "/"]; ["lvresize"; "/dev/VG/LV"; "20"]; ["e2fsck_f"; "/dev/VG/LV"]; ["resize2fs"; "/dev/VG/LV"]; - ["mount"; "/dev/VG/LV"; "/"]; - ["cat"; "/new"]], "test content")], + ["mount_options"; ""; "/dev/VG/LV"; "/"]; + ["cat"; "/new"]], "test content"); + InitNone, Always, TestRun ( + (* Make an LV smaller to test RHBZ#587484. *) + [["part_disk"; "/dev/sda"; "mbr"]; + ["pvcreate"; "/dev/sda1"]; + ["vgcreate"; "VG"; "/dev/sda1"]; + ["lvcreate"; "LV"; "VG"; "20"]; + ["lvresize"; "/dev/VG/LV"; "10"]])], "resize an LVM logical volume", "\ This resizes (expands or shrinks) an existing LVM logical @@ -2685,7 +2795,7 @@ manual page for more details."); ("scrub_file", (RErr, [Pathname "file"]), 115, [Optional "scrub"], [InitBasicFS, Always, TestRun ( - [["write_file"; "/file"; "content"; "0"]; + [["write"; "/file"; "content"]; ["scrub_file"; "/file"]])], "scrub (securely wipe) a file", "\ @@ -2737,7 +2847,10 @@ See also: L"); ("wc_l", (RInt "lines", [Pathname "path"]), 118, [], [InitISOFS, Always, TestOutputInt ( - [["wc_l"; "/10klines"]], 10000)], + [["wc_l"; "/10klines"]], 10000); + (* Test for RHBZ#579608, absolute symbolic links. *) + InitISOFS, Always, TestOutputInt ( + [["wc_l"; "/abssymlink"]], 10000)], "count lines in a file", "\ This command counts the lines in a file, using the @@ -2761,7 +2874,10 @@ C external command."); ("head", (RStringList "lines", [Pathname "path"]), 121, [ProtocolLimitWarning], [InitISOFS, Always, TestOutputList ( - [["head"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz";"3abcdefghijklmnopqrstuvwxyz";"4abcdefghijklmnopqrstuvwxyz";"5abcdefghijklmnopqrstuvwxyz";"6abcdefghijklmnopqrstuvwxyz";"7abcdefghijklmnopqrstuvwxyz";"8abcdefghijklmnopqrstuvwxyz";"9abcdefghijklmnopqrstuvwxyz"])], + [["head"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz";"3abcdefghijklmnopqrstuvwxyz";"4abcdefghijklmnopqrstuvwxyz";"5abcdefghijklmnopqrstuvwxyz";"6abcdefghijklmnopqrstuvwxyz";"7abcdefghijklmnopqrstuvwxyz";"8abcdefghijklmnopqrstuvwxyz";"9abcdefghijklmnopqrstuvwxyz"]); + (* Test for RHBZ#579608, absolute symbolic links. *) + InitISOFS, Always, TestOutputList ( + [["head"; "/abssymlink"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz";"3abcdefghijklmnopqrstuvwxyz";"4abcdefghijklmnopqrstuvwxyz";"5abcdefghijklmnopqrstuvwxyz";"6abcdefghijklmnopqrstuvwxyz";"7abcdefghijklmnopqrstuvwxyz";"8abcdefghijklmnopqrstuvwxyz";"9abcdefghijklmnopqrstuvwxyz"])], "return first 10 lines of a file", "\ This command returns up to the first 10 lines of a file as @@ -2917,7 +3033,17 @@ named pipes (FIFOs). The C parameter should be the mode, using the standard constants. C and C are the device major and minor numbers, only used when creating block -and character special devices."); +and character special devices. + +Note that, just like L, the mode must be bitwise +OR'd with S_IFBLK, S_IFCHR, S_IFIFO or S_IFSOCK (otherwise this call +just creates a regular file). These constants are +available in the standard Linux header files, or you can use +C, C or C +which are wrappers around this command which bitwise OR +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 ( @@ -2927,7 +3053,9 @@ and character special devices."); "\ This call creates a FIFO (named pipe) called C with mode C. It is just a convenient wrapper around -C."); +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 ( @@ -2937,7 +3065,9 @@ C."); "\ This call creates a block device node called C with mode C and device major/minor C and C. -It is just a convenient wrapper around C."); +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 ( @@ -2947,12 +3077,13 @@ It is just a convenient wrapper around C."); "\ This call creates a char device node called C with mode C and device major/minor C and C. -It is just a convenient wrapper around C."); +It is just a convenient wrapper around C. - ("umask", (RInt "oldmask", [Int "mask"]), 137, [], - [], (* XXX umask is one of those stateful things that we should - * reset between each test. - *) +The mode actually set is affected by the umask."); + + ("umask", (RInt "oldmask", [Int "mask"]), 137, [FishOutput FishOutputOctal], + [InitEmpty, Always, TestOutputInt ( + [["umask"; "0o22"]], 0o22)], "set file mode creation mask (umask)", "\ This function sets the mask used for creating new files and @@ -2967,7 +3098,8 @@ The default umask is C<022>. This is important because it means that directories and device nodes will be created with C<0644> or C<0755> mode even if you specify C<0777>. -See also L, C, C. +See also C, +L, C, C. This call returns the previous umask."); @@ -3164,7 +3296,20 @@ for full details."); ("read_file", (RBufferOut "content", [Pathname "path"]), 150, [ProtocolLimitWarning], [InitISOFS, Always, TestOutputBuffer ( - [["read_file"; "/known-4"]], "abc\ndef\nghi")], + [["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"]])], "read a file", "\ This calls returns the contents of the file C as a @@ -3179,7 +3324,10 @@ in the total size of file that can be handled."); [InitISOFS, Always, TestOutputList ( [["grep"; "abc"; "/test-grep.txt"]], ["abc"; "abc123"]); InitISOFS, Always, TestOutputList ( - [["grep"; "nomatch"; "/test-grep.txt"]], [])], + [["grep"; "nomatch"; "/test-grep.txt"]], []); + (* Test for RHBZ#579608, absolute symbolic links. *) + InitISOFS, Always, TestOutputList ( + [["grep"; "nomatch"; "/abssymlink"]], [])], "return lines matching a pattern", "\ This calls the external C program and returns the @@ -3327,7 +3475,7 @@ 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, [], + ("fallocate", (RErr, [Pathname "path"; Int "len"]), 169, [DeprecatedBy "fallocate64"], [InitBasicFS, Always, TestOutputStruct ( [["fallocate"; "/a"; "1000000"]; ["stat"; "/a"]], [CompareWithInt ("size", 1_000_000)])], @@ -3554,8 +3702,8 @@ and C"); [InitEmpty, Always, TestOutput ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs_b"; "ext2"; "4096"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; - ["write_file"; "/new"; "new file contents"; "0"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; + ["write"; "/new"; "new file contents"]; ["cat"; "/new"]], "new file contents")], "make a filesystem with block size", "\ @@ -3569,8 +3717,8 @@ are C<1024>, C<2048> or C<4096> only."); [["sfdiskM"; "/dev/sda"; ",100 ,"]; ["mke2journal"; "4096"; "/dev/sda1"]; ["mke2fs_J"; "ext2"; "4096"; "/dev/sda2"; "/dev/sda1"]; - ["mount"; "/dev/sda2"; "/"]; - ["write_file"; "/new"; "new file contents"; "0"]; + ["mount_options"; ""; "/dev/sda2"; "/"]; + ["write"; "/new"; "new file contents"]; ["cat"; "/new"]], "new file contents")], "make ext2/3/4 external journal", "\ @@ -3584,8 +3732,8 @@ to the command: [["sfdiskM"; "/dev/sda"; ",100 ,"]; ["mke2journal_L"; "4096"; "JOURNAL"; "/dev/sda1"]; ["mke2fs_JL"; "ext2"; "4096"; "/dev/sda2"; "JOURNAL"]; - ["mount"; "/dev/sda2"; "/"]; - ["write_file"; "/new"; "new file contents"; "0"]; + ["mount_options"; ""; "/dev/sda2"; "/"]; + ["write"; "/new"; "new file contents"]; ["cat"; "/new"]], "new file contents")], "make ext2/3/4 external journal with label", "\ @@ -3597,8 +3745,8 @@ This creates an ext2 external journal on C with label C