X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=fa08688b38491608322b720882ee857e534df199;hp=b43b3bfa3d1e3c9fa0918d90cfe189c9a76102e4;hb=22cee80bc2f631703bf417a54ef4e0f0837e921a;hpb=08c27722647d14a30648dd02e221e1e803d1189e diff --git a/src/generator.ml b/src/generator.ml index b43b3bf..fa08688 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -139,6 +139,7 @@ and argt = | Dev_or_Path of string (* /dev device name or Pathname, cannot be NULL *) | OptString of string (* const char *name, may be NULL *) | StringList of string(* list of strings (each string cannot be NULL) *) + | DeviceList of string(* list of Device names (each cannot be NULL) *) | Bool of string (* boolean *) | Int of string (* int (smallish ints, signed, <= 31 bits) *) (* These are treated as filenames (simple string parameters) in @@ -177,13 +178,13 @@ type flags = * * Note that the test environment has 3 block devices, of size 500MB, * 50MB and 10MB (respectively /dev/sda, /dev/sdb, /dev/sdc), and - * a fourth squashfs block device with some known files on it (/dev/sdd). + * a fourth ISO block device with some known files on it (/dev/sdd). * * Note for partitioning purposes, the 500MB device has 1015 cylinders. * Number of cylinders was 63 for IDE emulated disks with precisely * the same size. How exactly this is calculated is a mystery. * - * The squashfs block device (/dev/sdd) comes from images/test.sqsh. + * The ISO block device (/dev/sdd) comes from images/test.iso. * * To be able to run the tests in a reasonable amount of time, * the virtual machine and block devices are reused between tests. @@ -325,10 +326,10 @@ and test_init = *) | InitBasicFSonLVM - (* /dev/sdd (the squashfs, see images/ directory in source) + (* /dev/sdd (the ISO, see images/ directory in source) * is mounted on / *) - | InitSquashFS + | InitISOFS (* Sequence of commands for testing. *) and seq = cmd list @@ -342,6 +343,19 @@ and cmd = string list * Apart from that, long descriptions are just perldoc paragraphs. *) +(* Generate a random UUID (used in tests). *) +let uuidgen () = + let chan = Unix.open_process_in "uuidgen" in + let uuid = input_line chan in + (match Unix.close_process_in chan with + | Unix.WEXITED 0 -> () + | Unix.WEXITED _ -> + failwith "uuidgen: process exited with non-zero status" + | Unix.WSIGNALED _ | Unix.WSTOPPED _ -> + failwith "uuidgen: process signalled or stopped by signal" + ); + uuid + (* These test functions are used in the language binding tests. *) let test_all_args = [ @@ -791,6 +805,32 @@ is passed to the appliance at boot time. See C. For more information on the architecture of libguestfs, see L."); + ("set_trace", (RErr, [Bool "trace"]), -1, [FishAlias "trace"], + [InitNone, Always, TestOutputTrue ( + [["set_trace"; "true"]; + ["get_trace"]])], + "enable or disable command traces", + "\ +If the command trace flag is set to 1, then commands are +printed on stdout 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 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>."); + + ("get_trace", (RBool "trace", []), -1, [], + [], + "get command trace enabled flag", + "\ +Return the command trace flag."); + ] (* daemon_functions are any functions which cause some action @@ -845,7 +885,7 @@ update the timestamps on a file, or, if the file does not exist, to create a new zero-length file."); ("cat", (RString "content", [Pathname "path"]), 4, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutput ( + [InitISOFS, Always, TestOutput ( [["cat"; "/known-2"]], "abcdef\n")], "list the contents of a file", "\ @@ -856,7 +896,7 @@ Note that this function cannot correctly handle binary files as end of string). For those you need to use the C or C functions which have a more complex interface."); - ("ll", (RString "listing", [String "directory"]), 5, [], + ("ll", (RString "listing", [Pathname "directory"]), 5, [], [], (* XXX Tricky to test because it depends on the exact format * of the 'ls -l' command, which changes between F10 and F11. *) @@ -868,7 +908,7 @@ there is no cwd) in the format of 'ls -la'. This command is mostly useful for interactive sessions. It is I intended that you try to parse the output string."); - ("ls", (RStringList "listing", [String "directory"]), 6, [], + ("ls", (RStringList "listing", [Pathname "directory"]), 6, [], [InitBasicFS, Always, TestOutputList ( [["touch"; "/new"]; ["touch"; "/newer"]; @@ -993,9 +1033,9 @@ List all the logical volumes detected. This is the equivalent of the L command. The \"full\" version includes all fields."); ("read_lines", (RStringList "lines", [Pathname "path"]), 15, [], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["read_lines"; "/known-4"]], ["abc"; "def"; "ghi"]); - InitSquashFS, Always, TestOutputList ( + InitISOFS, Always, TestOutputList ( [["read_lines"; "/empty"]], [])], "read file as lines", "\ @@ -1257,9 +1297,9 @@ names, you will need to locate and parse the password file yourself (Augeas support makes this relatively easy)."); ("exists", (RBool "existsflag", [Pathname "path"]), 36, [], - [InitSquashFS, Always, TestOutputTrue ( + [InitISOFS, Always, TestOutputTrue ( [["exists"; "/empty"]]); - InitSquashFS, Always, TestOutputTrue ( + InitISOFS, Always, TestOutputTrue ( [["exists"; "/directory"]])], "test if file or directory exists", "\ @@ -1269,9 +1309,9 @@ This returns C if and only if there is a file, directory See also C, C, C."); ("is_file", (RBool "fileflag", [Pathname "path"]), 37, [], - [InitSquashFS, Always, TestOutputTrue ( + [InitISOFS, Always, TestOutputTrue ( [["is_file"; "/known-1"]]); - InitSquashFS, Always, TestOutputFalse ( + InitISOFS, Always, TestOutputFalse ( [["is_file"; "/directory"]])], "test if file exists", "\ @@ -1282,9 +1322,9 @@ other objects like directories. See also C."); ("is_dir", (RBool "dirflag", [Pathname "path"]), 38, [], - [InitSquashFS, Always, TestOutputFalse ( + [InitISOFS, Always, TestOutputFalse ( [["is_dir"; "/known-3"]]); - InitSquashFS, Always, TestOutputTrue ( + InitISOFS, Always, TestOutputTrue ( [["is_dir"; "/directory"]])], "test if file exists", "\ @@ -1307,7 +1347,7 @@ This creates an LVM physical volume on the named C, where C should usually be a partition name such as C."); - ("vgcreate", (RErr, [String "volgroup"; StringList "physvols"]), 40, [], + ("vgcreate", (RErr, [String "volgroup"; DeviceList "physvols"]), 40, [], [InitEmpty, Always, TestOutputList ( [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; ["pvcreate"; "/dev/sda1"]; @@ -1479,11 +1519,11 @@ This command removes all LVM logical volumes, volume groups and physical volumes."); ("file", (RString "description", [Dev_or_Path "path"]), 49, [], - [InitSquashFS, Always, TestOutput ( + [InitISOFS, Always, TestOutput ( [["file"; "/empty"]], "empty"); - InitSquashFS, Always, TestOutput ( + InitISOFS, Always, TestOutput ( [["file"; "/known-1"]], "ASCII text"); - InitSquashFS, Always, TestLastFail ( + InitISOFS, Always, TestLastFail ( [["file"; "/notexists"]])], "determine file type", "\ @@ -1632,7 +1672,7 @@ result into a list of lines. See also: C"); ("stat", (RStruct ("statbuf", "stat"), [Pathname "path"]), 52, [], - [InitSquashFS, Always, TestOutputStruct ( + [InitISOFS, Always, TestOutputStruct ( [["stat"; "/empty"]], [CompareWithInt ("size", 0)])], "get file information", "\ @@ -1641,7 +1681,7 @@ Returns file information for the given C. This is the same as the C system call."); ("lstat", (RStruct ("statbuf", "stat"), [Pathname "path"]), 53, [], - [InitSquashFS, Always, TestOutputStruct ( + [InitISOFS, Always, TestOutputStruct ( [["lstat"; "/empty"]], [CompareWithInt ("size", 0)])], "get file information for a symbolic link", "\ @@ -1654,8 +1694,8 @@ refers to. This is the same as the C system call."); ("statvfs", (RStruct ("statbuf", "statvfs"), [Pathname "path"]), 54, [], - [InitSquashFS, Always, TestOutputStruct ( - [["statvfs"; "/"]], [CompareWithInt ("namemax", 256)])], + [InitISOFS, Always, TestOutputStruct ( + [["statvfs"; "/"]], [CompareWithInt ("namemax", 255)])], "get file system statistics", "\ Returns file system statistics for any mounted file system. @@ -1820,21 +1860,21 @@ C can also be a named pipe. See also C, C."); ("checksum", (RString "checksum", [String "csumtype"; Pathname "path"]), 68, [], - [InitSquashFS, Always, TestOutput ( + [InitISOFS, Always, TestOutput ( [["checksum"; "crc"; "/known-3"]], "2891671662"); - InitSquashFS, Always, TestLastFail ( + InitISOFS, Always, TestLastFail ( [["checksum"; "crc"; "/notexists"]]); - InitSquashFS, Always, TestOutput ( + InitISOFS, Always, TestOutput ( [["checksum"; "md5"; "/known-3"]], "46d6ca27ee07cdc6fa99c2e138cc522c"); - InitSquashFS, Always, TestOutput ( + InitISOFS, Always, TestOutput ( [["checksum"; "sha1"; "/known-3"]], "b7ebccc3ee418311091c3eda0a45b83c0a770f15"); - InitSquashFS, Always, TestOutput ( + InitISOFS, Always, TestOutput ( [["checksum"; "sha224"; "/known-3"]], "d2cd1774b28f3659c14116be0a6dc2bb5c4b350ce9cd5defac707741"); - InitSquashFS, Always, TestOutput ( + InitISOFS, Always, TestOutput ( [["checksum"; "sha256"; "/known-3"]], "75bb71b90cd20cb13f86d2bea8dad63ac7194e7517c3b52b8d06ff52d3487d30"); - InitSquashFS, Always, TestOutput ( + InitISOFS, Always, TestOutput ( [["checksum"; "sha384"; "/known-3"]], "5fa7883430f357b5d7b7271d3a1d2872b51d73cba72731de6863d3dea55f30646af2799bef44d5ea776a5ec7941ac640"); - InitSquashFS, Always, TestOutput ( + InitISOFS, Always, TestOutput ( [["checksum"; "sha512"; "/known-3"]], "2794062c328c6b216dca90443b7f7134c5f40e56bd0ed7853123275a09982a6f992e6ca682f9d2fba34a4c5e870d8fe077694ff831e3032a004ee077e00603f6")], "compute MD5, SHAx or CRC checksum of file", "\ @@ -1910,7 +1950,7 @@ I tar file) into C. To upload an uncompressed tarball, use C."); - ("tgz_out", (RErr, [String "directory"; FileOut "tarball"]), 72, [], + ("tgz_out", (RErr, [Pathname "directory"; FileOut "tarball"]), 72, [], [], "pack directory into compressed tarball", "\ @@ -2077,17 +2117,18 @@ This returns the ext2/3/4 filesystem label of the filesystem on C."); ("set_e2uuid", (RErr, [Device "device"; String "uuid"]), 82, [], - [InitBasicFS, Always, TestOutput ( - [["set_e2uuid"; "/dev/sda1"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"]; - ["get_e2uuid"; "/dev/sda1"]], "a3a61220-882b-4f61-89f4-cf24dcc7297d"); - InitBasicFS, Always, TestOutput ( - [["set_e2uuid"; "/dev/sda1"; "clear"]; - ["get_e2uuid"; "/dev/sda1"]], ""); - (* We can't predict what UUIDs will be, so just check the commands run. *) - InitBasicFS, Always, TestRun ( - [["set_e2uuid"; "/dev/sda1"; "random"]]); - InitBasicFS, Always, TestRun ( - [["set_e2uuid"; "/dev/sda1"; "time"]])], + (let uuid = uuidgen () in + [InitBasicFS, Always, TestOutput ( + [["set_e2uuid"; "/dev/sda1"; uuid]; + ["get_e2uuid"; "/dev/sda1"]], uuid); + InitBasicFS, Always, TestOutput ( + [["set_e2uuid"; "/dev/sda1"; "clear"]; + ["get_e2uuid"; "/dev/sda1"]], ""); + (* We can't predict what UUIDs will be, so just check the commands run. *) + InitBasicFS, Always, TestRun ( + [["set_e2uuid"; "/dev/sda1"; "random"]]); + InitBasicFS, Always, TestRun ( + [["set_e2uuid"; "/dev/sda1"; "time"]])]), "set the ext2/3/4 filesystem UUID", "\ This sets the ext2/3/4 filesystem UUID of the filesystem on @@ -2170,7 +2211,7 @@ See also: C."); This command installs GRUB (the Grand Unified Bootloader) on C, with the root directory being C."); - ("cp", (RErr, [String "src"; String "dest"]), 87, [], + ("cp", (RErr, [Pathname "src"; Pathname "dest"]), 87, [], [InitBasicFS, Always, TestOutput ( [["write_file"; "/old"; "file content"; "0"]; ["cp"; "/old"; "/new"]; @@ -2189,7 +2230,7 @@ C, with the root directory being C."); This copies a file from C to C where C is either a destination filename or destination directory."); - ("cp_a", (RErr, [String "src"; String "dest"]), 88, [], + ("cp_a", (RErr, [Pathname "src"; Pathname "dest"]), 88, [], [InitBasicFS, Always, TestOutput ( [["mkdir"; "/olddir"]; ["mkdir"; "/newdir"]; @@ -2201,7 +2242,7 @@ either a destination filename or destination directory."); This copies a file or directory from C to C recursively using the C command."); - ("mv", (RErr, [String "src"; String "dest"]), 89, [], + ("mv", (RErr, [Pathname "src"; Pathname "dest"]), 89, [], [InitBasicFS, Always, TestOutput ( [["write_file"; "/old"; "file content"; "0"]; ["mv"; "/old"; "/new"]; @@ -2273,9 +2314,9 @@ true if their content is exactly equal, or false otherwise. The external L program is used for the comparison."); ("strings", (RStringList "stringsout", [Pathname "path"]), 94, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["strings"; "/known-5"]], ["abcdefghi"; "jklmnopqr"]); - InitSquashFS, Always, TestOutputList ( + InitISOFS, Always, TestOutputList ( [["strings"; "/empty"]], [])], "print the printable strings in a file", "\ @@ -2283,7 +2324,7 @@ This runs the L command on a file and returns the list of printable strings found."); ("strings_e", (RStringList "stringsout", [String "encoding"; Pathname "path"]), 95, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [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"]; @@ -2301,12 +2342,12 @@ show strings inside Windows/x86 files. The returned strings are transcoded to UTF-8."); ("hexdump", (RString "dump", [Pathname "path"]), 96, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutput ( + [InitISOFS, Always, TestOutput ( [["hexdump"; "/known-4"]], "00000000 61 62 63 0a 64 65 66 0a 67 68 69 |abc.def.ghi|\n0000000b\n"); (* Test for RHBZ#501888c2 regression which caused large hexdump * commands to segfault. *) - InitSquashFS, Always, TestRun ( + InitISOFS, Always, TestRun ( [["hexdump"; "/100krandom"]])], "dump a file in hexadecimal", "\ @@ -2595,7 +2636,7 @@ more difficult. It is an interface to the L program. See that manual page for more details."); - ("scrub_file", (RErr, [String "file"]), 115, [], + ("scrub_file", (RErr, [Pathname "file"]), 115, [], [InitBasicFS, Always, TestRun ( [["write_file"; "/file"; "content"; "0"]; ["scrub_file"; "/file"]])], @@ -2609,7 +2650,7 @@ The file is I after scrubbing. It is an interface to the L program. See that manual page for more details."); - ("scrub_freespace", (RErr, [String "dir"]), 116, [], + ("scrub_freespace", (RErr, [Pathname "dir"]), 116, [], [], (* XXX needs testing *) "scrub (securely wipe) free space", "\ @@ -2648,7 +2689,7 @@ directory and its contents after use. See also: L"); ("wc_l", (RInt "lines", [Pathname "path"]), 118, [], - [InitSquashFS, Always, TestOutputInt ( + [InitISOFS, Always, TestOutputInt ( [["wc_l"; "/10klines"]], 10000)], "count lines in a file", "\ @@ -2656,7 +2697,7 @@ This command counts the lines in a file, using the C external command."); ("wc_w", (RInt "words", [Pathname "path"]), 119, [], - [InitSquashFS, Always, TestOutputInt ( + [InitISOFS, Always, TestOutputInt ( [["wc_w"; "/10klines"]], 10000)], "count words in a file", "\ @@ -2664,7 +2705,7 @@ This command counts the words in a file, using the C external command."); ("wc_c", (RInt "chars", [Pathname "path"]), 120, [], - [InitSquashFS, Always, TestOutputInt ( + [InitISOFS, Always, TestOutputInt ( [["wc_c"; "/100kallspaces"]], 102400)], "count characters in a file", "\ @@ -2672,7 +2713,7 @@ This command counts the characters in a file, using the C external command."); ("head", (RStringList "lines", [Pathname "path"]), 121, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["head"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz";"3abcdefghijklmnopqrstuvwxyz";"4abcdefghijklmnopqrstuvwxyz";"5abcdefghijklmnopqrstuvwxyz";"6abcdefghijklmnopqrstuvwxyz";"7abcdefghijklmnopqrstuvwxyz";"8abcdefghijklmnopqrstuvwxyz";"9abcdefghijklmnopqrstuvwxyz"])], "return first 10 lines of a file", "\ @@ -2680,11 +2721,11 @@ This command returns up to the first 10 lines of a file as a list of strings."); ("head_n", (RStringList "lines", [Int "nrlines"; Pathname "path"]), 122, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["head_n"; "3"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]); - InitSquashFS, Always, TestOutputList ( + InitISOFS, Always, TestOutputList ( [["head_n"; "-9997"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]); - InitSquashFS, Always, TestOutputList ( + InitISOFS, Always, TestOutputList ( [["head_n"; "0"; "/10klines"]], [])], "return first N lines of a file", "\ @@ -2697,7 +2738,7 @@ from the file C, excluding the last C lines. If the parameter C is zero, this returns an empty list."); ("tail", (RStringList "lines", [Pathname "path"]), 123, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["tail"; "/10klines"]], ["9990abcdefghijklmnopqrstuvwxyz";"9991abcdefghijklmnopqrstuvwxyz";"9992abcdefghijklmnopqrstuvwxyz";"9993abcdefghijklmnopqrstuvwxyz";"9994abcdefghijklmnopqrstuvwxyz";"9995abcdefghijklmnopqrstuvwxyz";"9996abcdefghijklmnopqrstuvwxyz";"9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"])], "return last 10 lines of a file", "\ @@ -2705,11 +2746,11 @@ This command returns up to the last 10 lines of a file as a list of strings."); ("tail_n", (RStringList "lines", [Int "nrlines"; Pathname "path"]), 124, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["tail_n"; "3"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]); - InitSquashFS, Always, TestOutputList ( + InitISOFS, Always, TestOutputList ( [["tail_n"; "-9998"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]); - InitSquashFS, Always, TestOutputList ( + InitISOFS, Always, TestOutputList ( [["tail_n"; "0"; "/10klines"]], [])], "return last N lines of a file", "\ @@ -2747,8 +2788,8 @@ is I intended that you try to parse the output string. Use C from programs."); ("du", (RInt64 "sizekb", [Pathname "path"]), 127, [], - [InitSquashFS, Always, TestOutputInt ( - [["du"; "/directory"]], 0 (* squashfs doesn't have blocks *))], + [InitISOFS, Always, TestOutputInt ( + [["du"; "/directory"]], 2 (* ISO fs blocksize is 2K *))], "estimate file space usage", "\ This command runs the C command to estimate file space @@ -2762,7 +2803,7 @@ The result is the estimated size in I (ie. units of 1024 bytes)."); ("initrd_list", (RStringList "filenames", [Pathname "path"]), 128, [], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["initrd_list"; "/initrd"]], ["empty";"known-1";"known-2";"known-3";"known-4"; "known-5"])], "list files in an initrd", "\ @@ -2776,7 +2817,7 @@ Old Linux kernels (2.4 and earlier) used a compressed ext2 filesystem as initrd. We I support the newer initramfs format (compressed cpio files)."); - ("mount_loop", (RErr, [String "file"; String "mountpoint"]), 129, [], + ("mount_loop", (RErr, [Pathname "file"; Pathname "mountpoint"]), 129, [], [], "mount a file using the loop device", "\ @@ -2805,9 +2846,10 @@ Note that you cannot attach a swap label to a block device a limitation of the kernel or swap tools."); ("mkswap_U", (RErr, [String "uuid"; Device "device"]), 132, [], - [InitEmpty, Always, TestRun ( - [["sfdiskM"; "/dev/sda"; ","]; - ["mkswap_U"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"; "/dev/sda1"]])], + (let uuid = uuidgen () in + [InitEmpty, Always, TestRun ( + [["sfdiskM"; "/dev/sda"; ","]; + ["mkswap_U"; uuid; "/dev/sda1"]])]), "create a swap partition with an explicit UUID", "\ Create a swap partition on C with UUID C."); @@ -2882,7 +2924,7 @@ See also L, C, C. This call returns the previous umask."); - ("readdir", (RStructList ("entries", "dirent"), [String "dir"]), 138, [], + ("readdir", (RStructList ("entries", "dirent"), [Pathname "dir"]), 138, [], [], "read directories entries", "\ @@ -2952,7 +2994,7 @@ were rarely if ever used anyway. See also C and the L manpage."); - ("zfile", (RString "description", [String "method"; Pathname "path"]), 140, [DeprecatedBy "file"], + ("zfile", (RString "description", [String "meth"; Pathname "path"]), 140, [DeprecatedBy "file"], [], "determine file type inside a compressed file", "\ @@ -3073,7 +3115,7 @@ with C. See C for full details."); ("read_file", (RBufferOut "content", [Pathname "path"]), 150, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputBuffer ( + [InitISOFS, Always, TestOutputBuffer ( [["read_file"; "/known-4"]], "abc\ndef\nghi")], "read a file", "\ @@ -3086,9 +3128,9 @@ However unlike C, this function is limited in the total size of file that can be handled."); ("grep", (RStringList "lines", [String "regex"; Pathname "path"]), 151, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["grep"; "abc"; "/test-grep.txt"]], ["abc"; "abc123"]); - InitSquashFS, Always, TestOutputList ( + InitISOFS, Always, TestOutputList ( [["grep"; "nomatch"; "/test-grep.txt"]], [])], "return lines matching a pattern", "\ @@ -3096,7 +3138,7 @@ This calls the external C program and returns the matching lines."); ("egrep", (RStringList "lines", [String "regex"; Pathname "path"]), 152, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["egrep"; "abc"; "/test-grep.txt"]], ["abc"; "abc123"])], "return lines matching a pattern", "\ @@ -3104,7 +3146,7 @@ This calls the external C program and returns the matching lines."); ("fgrep", (RStringList "lines", [String "pattern"; Pathname "path"]), 153, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["fgrep"; "abc"; "/test-grep.txt"]], ["abc"; "abc123"])], "return lines matching a pattern", "\ @@ -3112,7 +3154,7 @@ This calls the external C program and returns the matching lines."); ("grepi", (RStringList "lines", [String "regex"; Pathname "path"]), 154, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["grepi"; "abc"; "/test-grep.txt"]], ["abc"; "abc123"; "ABC"])], "return lines matching a pattern", "\ @@ -3120,7 +3162,7 @@ This calls the external C program and returns the matching lines."); ("egrepi", (RStringList "lines", [String "regex"; Pathname "path"]), 155, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["egrepi"; "abc"; "/test-grep.txt"]], ["abc"; "abc123"; "ABC"])], "return lines matching a pattern", "\ @@ -3128,7 +3170,7 @@ This calls the external C program and returns the matching lines."); ("fgrepi", (RStringList "lines", [String "pattern"; Pathname "path"]), 156, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["fgrepi"; "abc"; "/test-grep.txt"]], ["abc"; "abc123"; "ABC"])], "return lines matching a pattern", "\ @@ -3136,7 +3178,7 @@ This calls the external C program and returns the matching lines."); ("zgrep", (RStringList "lines", [String "regex"; Pathname "path"]), 157, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["zgrep"; "abc"; "/test-grep.txt.gz"]], ["abc"; "abc123"])], "return lines matching a pattern", "\ @@ -3144,7 +3186,7 @@ This calls the external C program and returns the matching lines."); ("zegrep", (RStringList "lines", [String "regex"; Pathname "path"]), 158, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["zegrep"; "abc"; "/test-grep.txt.gz"]], ["abc"; "abc123"])], "return lines matching a pattern", "\ @@ -3152,7 +3194,7 @@ This calls the external C program and returns the matching lines."); ("zfgrep", (RStringList "lines", [String "pattern"; Pathname "path"]), 159, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["zfgrep"; "abc"; "/test-grep.txt.gz"]], ["abc"; "abc123"])], "return lines matching a pattern", "\ @@ -3160,7 +3202,7 @@ This calls the external C program and returns the matching lines."); ("zgrepi", (RStringList "lines", [String "regex"; Pathname "path"]), 160, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["zgrepi"; "abc"; "/test-grep.txt.gz"]], ["abc"; "abc123"; "ABC"])], "return lines matching a pattern", "\ @@ -3168,7 +3210,7 @@ This calls the external C program and returns the matching lines."); ("zegrepi", (RStringList "lines", [String "regex"; Pathname "path"]), 161, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["zegrepi"; "abc"; "/test-grep.txt.gz"]], ["abc"; "abc123"; "ABC"])], "return lines matching a pattern", "\ @@ -3176,7 +3218,7 @@ This calls the external C program and returns the matching lines."); ("zfgrepi", (RStringList "lines", [String "pattern"; Pathname "path"]), 162, [ProtocolLimitWarning], - [InitSquashFS, Always, TestOutputList ( + [InitISOFS, Always, TestOutputList ( [["zfgrepi"; "abc"; "/test-grep.txt.gz"]], ["abc"; "abc123"; "ABC"])], "return lines matching a pattern", "\ @@ -3184,7 +3226,7 @@ This calls the external C program and returns the matching lines."); ("realpath", (RString "rpath", [Pathname "path"]), 163, [], - [InitSquashFS, Always, TestOutput ( + [InitISOFS, Always, TestOutput ( [["realpath"; "/../directory"]], "/directory")], "canonicalized absolute pathname", "\ @@ -3278,7 +3320,7 @@ This command disables the libguestfs appliance swap device or partition named C. See C."); - ("swapon_file", (RErr, [String "file"]), 172, [], + ("swapon_file", (RErr, [Pathname "file"]), 172, [], [InitBasicFS, Always, TestRun ( [["fallocate"; "/swap"; "8388608"]; ["mkswap_file"; "/swap"]; @@ -3289,7 +3331,7 @@ See C."); This command enables swap to a file. See C for other notes."); - ("swapoff_file", (RErr, [String "file"]), 173, [], + ("swapoff_file", (RErr, [Pathname "file"]), 173, [], [], (* XXX tested by swapon_file *) "disable swap on file", "\ @@ -3316,10 +3358,11 @@ This command disables the libguestfs appliance swap on labeled swap partition."); ("swapon_uuid", (RErr, [String "uuid"]), 176, [], - [InitEmpty, Always, TestRun ( - [["mkswap_U"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"; "/dev/sdb"]; - ["swapon_uuid"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"]; - ["swapoff_uuid"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"]])], + (let uuid = uuidgen () in + [InitEmpty, Always, TestRun ( + [["mkswap_U"; uuid; "/dev/sdb"]; + ["swapon_uuid"; uuid]; + ["swapoff_uuid"; uuid]])]), "enable swap on swap partition by UUID", "\ This command enables swap to a swap partition with the given UUID. @@ -3344,7 +3387,7 @@ This command just writes a swap file signature to an existing file. To create the file itself, use something like C."); ("inotify_init", (RErr, [Int "maxevents"]), 179, [], - [InitSquashFS, Always, TestRun ( + [InitISOFS, Always, TestRun ( [["inotify_init"; "0"]])], "create an inotify handle", "\ @@ -3459,6 +3502,112 @@ 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, [], + [InitEmpty, Always, TestOutput ( + [["sfdiskM"; "/dev/sda"; ","]; + ["mkfs_b"; "ext2"; "4096"; "/dev/sda1"]; + ["mount"; "/dev/sda1"; "/"]; + ["write_file"; "/new"; "new file contents"; "0"]; + ["cat"; "/new"]], "new file contents")], + "make a filesystem with block size", + "\ +This call is similar to C, but it allows you to +control the block size of the resulting filesystem. Supported +block sizes depend on the filesystem type, but typically they +are C<1024>, C<2048> or C<4096> only."); + + ("mke2journal", (RErr, [Int "blocksize"; Device "device"]), 188, [], + [InitEmpty, Always, TestOutput ( + [["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"]; + ["cat"; "/new"]], "new file contents")], + "make ext2/3/4 external journal", + "\ +This creates an ext2 external journal on C. It is equivalent +to the command: + + mke2fs -O journal_dev -b blocksize device"); + + ("mke2journal_L", (RErr, [Int "blocksize"; String "label"; Device "device"]), 189, [], + [InitEmpty, Always, TestOutput ( + [["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"]; + ["cat"; "/new"]], "new file contents")], + "make ext2/3/4 external journal with label", + "\ +This creates an ext2 external journal on C with label C