X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=6f77e4ba77e564dd0bc83bd04f5eb6e348a02c74;hp=940d1a7305c7f23c31856820b1ca71dbf04d9622;hb=dc0c80b3884c5fa2735b55b205e7406599bd77b0;hpb=79b5084f70cb67c37dd7cbe60821a78981fd8d59 diff --git a/src/generator.ml b/src/generator.ml index 940d1a7..6f77e4b 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -136,8 +136,10 @@ and argt = | String of string (* const char *name, cannot be NULL *) | Device of string (* /dev device name, cannot be NULL *) | Pathname of string (* file name, cannot be NULL *) + | 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 @@ -176,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. @@ -324,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 @@ -341,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 = [ @@ -425,13 +440,18 @@ You should call this after configuring the handle ("wait_ready", (RErr, []), -1, [NotInFish], [], - "wait until the qemu subprocess launches", + "wait until the qemu subprocess launches (no op)", "\ -Internally libguestfs is implemented by running a virtual machine -using L. +This function is a no op. + +In versions of the API E 1.0.71 you had to call this function +just after calling C to wait for the launch +to complete. However this is no longer necessary because +C now does the waiting. -You should call this after C to wait for the launch -to complete."); +If you see any calls to this function in code then you can just +remove them, unless you want to retain compatibility with older +versions of the API."); ("kill_subprocess", (RErr, []), -1, [], [], @@ -665,34 +685,6 @@ only useful for printing debug and internal error messages. For more information on states, see L."); - ("set_busy", (RErr, []), -1, [NotInFish], - [], - "set state to busy", - "\ -This sets the state to C. This is only used when implementing -actions using the low-level API. - -For more information on states, see L."); - - ("set_ready", (RErr, []), -1, [NotInFish], - [], - "set state to ready", - "\ -This sets the state to C. This is only used when implementing -actions using the low-level API. - -For more information on states, see L."); - - ("end_busy", (RErr, []), -1, [NotInFish], - [], - "leave the busy state", - "\ -This sets the state to C, or if in C then it leaves the -state as is. This is only used when implementing -actions using the low-level API. - -For more information on states, see L."); - ("set_memsize", (RErr, [Int "memsize"]), -1, [FishAlias "memsize"], [InitNone, Always, TestOutputInt ( [["set_memsize"; "500"]; @@ -790,6 +782,57 @@ 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, TestOutputFalse ( + [["set_trace"; "false"]; + ["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."); + + ("set_direct", (RErr, [Bool "direct"]), -1, [FishAlias "direct"], + [InitNone, Always, TestOutputFalse ( + [["set_direct"; "false"]; + ["get_direct"]])], + "enable or disable direct appliance mode", + "\ +If the direct appliance mode flag is enabled, then stdin and +stdout are passed directly through to the appliance once it +is launched. + +One consequence of this is that log messages aren't caught +by the library and handled by C, +but go straight to stdout. + +You probably don't want to use this unless you know what you +are doing. + +The default is disabled."); + + ("get_direct", (RBool "direct", []), -1, [], + [], + "get direct appliance mode flag", + "\ +Return the direct appliance mode flag."); + ] (* daemon_functions are any functions which cause some action @@ -844,7 +887,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", "\ @@ -855,7 +898,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. *) @@ -867,7 +910,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"]; @@ -992,9 +1035,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", "\ @@ -1008,7 +1051,7 @@ Note that this function cannot correctly handle binary files as end of line). For those you need to use the C function which has a more complex interface."); - ("aug_init", (RErr, [String "root"; Int "flags"]), 16, [], + ("aug_init", (RErr, [Pathname "root"; Int "flags"]), 16, [], [], (* XXX Augeas code needs tests. *) "create a new Augeas handle", "\ @@ -1256,9 +1299,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", "\ @@ -1268,9 +1311,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", "\ @@ -1281,9 +1324,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", "\ @@ -1306,7 +1349,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"]; @@ -1477,12 +1520,12 @@ Some internal mounts are not unmounted by this call."); This command removes all LVM logical volumes, volume groups and physical volumes."); - ("file", (RString "description", [Pathname "path"]), 49, [], - [InitSquashFS, Always, TestOutput ( + ("file", (RString "description", [Dev_or_Path "path"]), 49, [], + [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", "\ @@ -1631,7 +1674,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", "\ @@ -1640,7 +1683,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", "\ @@ -1653,8 +1696,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. @@ -1801,7 +1844,7 @@ C can also be a named pipe. See also C."); - ("download", (RErr, [String "remotefilename"; FileOut "filename"]), 67, [], + ("download", (RErr, [Dev_or_Path "remotefilename"; FileOut "filename"]), 67, [], [InitBasicFS, Always, TestOutput ( (* Pick a file from cwd which isn't likely to change. *) [["upload"; "../COPYING.LIB"; "/COPYING.LIB"]; @@ -1819,21 +1862,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", "\ @@ -1909,7 +1952,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", "\ @@ -2076,17 +2119,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 @@ -2157,7 +2201,7 @@ any partition tables, filesystem superblocks and so on. See also: C."); - ("grub_install", (RErr, [String "root"; Device "device"]), 86, [], + ("grub_install", (RErr, [Pathname "root"; Device "device"]), 86, [], (* Test disabled because grub-install incompatible with virtio-blk driver. * See also: https://bugzilla.redhat.com/show_bug.cgi?id=479760 *) @@ -2169,7 +2213,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"]; @@ -2188,7 +2232,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"]; @@ -2200,7 +2244,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"]; @@ -2253,7 +2297,7 @@ the qemu subprocess. Calling this function checks that the daemon responds to the ping message, without affecting the daemon or attached block device(s) in any other way."); - ("equal", (RBool "equality", [String "file1"; String "file2"]), 93, [], + ("equal", (RBool "equality", [Pathname "file1"; Pathname "file2"]), 93, [], [InitBasicFS, Always, TestOutputTrue ( [["write_file"; "/file1"; "contents of a file"; "0"]; ["cp"; "/file1"; "/file2"]; @@ -2272,9 +2316,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", "\ @@ -2282,7 +2326,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"]; @@ -2300,12 +2344,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", "\ @@ -2444,7 +2488,7 @@ C sometimes gives an error about this and sometimes not. In any case, it is always safe to call C before calling this function."); - ("find", (RStringList "names", [String "directory"]), 107, [], + ("find", (RStringList "names", [Pathname "directory"]), 107, [], [InitBasicFS, Always, TestOutputList ( [["find"; "/"]], ["lost+found"]); InitBasicFS, Always, TestOutputList ( @@ -2550,7 +2594,11 @@ into a list of lines. See also: C"); - ("glob_expand", (RStringList "paths", [String "pattern"]), 113, [], + ("glob_expand", (RStringList "paths", [Pathname "pattern"]), 113, [], + (* Use Pathname here, and hence ABS_PATH (pattern,... in generated + * 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"]; @@ -2590,7 +2638,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"]])], @@ -2604,7 +2652,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", "\ @@ -2643,7 +2691,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", "\ @@ -2651,7 +2699,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", "\ @@ -2659,7 +2707,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", "\ @@ -2667,7 +2715,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", "\ @@ -2675,11 +2723,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", "\ @@ -2692,7 +2740,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", "\ @@ -2700,11 +2748,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", "\ @@ -2742,8 +2790,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 @@ -2757,7 +2805,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", "\ @@ -2771,7 +2819,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", "\ @@ -2800,9 +2848,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."); @@ -2877,7 +2926,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", "\ @@ -2947,7 +2996,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", "\ @@ -3026,7 +3075,12 @@ This call is similar to C. That call returns a list of devices. This one returns a hash table (map) of device name to directory where the device is mounted."); - ("mkmountpoint", (RErr, [Pathname "path"]), 148, [], + ("mkmountpoint", (RErr, [String "exemptpath"]), 148, [], + (* This is a special case: while you would expect a parameter + * of type "Pathname", that doesn't work, because it implies + * NEED_ROOT in the generated calling code in stubs.c, and + * this function cannot use NEED_ROOT. + *) [], "create a mountpoint", "\ @@ -3063,7 +3117,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", "\ @@ -3076,9 +3130,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", "\ @@ -3086,7 +3140,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", "\ @@ -3094,7 +3148,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", "\ @@ -3102,7 +3156,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", "\ @@ -3110,7 +3164,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", "\ @@ -3118,7 +3172,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", "\ @@ -3126,7 +3180,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", "\ @@ -3134,7 +3188,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", "\ @@ -3142,7 +3196,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", "\ @@ -3150,7 +3204,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", "\ @@ -3158,7 +3212,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", "\ @@ -3166,7 +3220,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", "\ @@ -3174,14 +3228,14 @@ 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", "\ Return the canonicalized absolute pathname of C. The returned path has no C<.>, C<..> or symbolic link path elements."); - ("ln", (RErr, [String "target"; String "linkname"]), 164, [], + ("ln", (RErr, [String "target"; Pathname "linkname"]), 164, [], [InitBasicFS, Always, TestOutputStruct ( [["touch"; "/a"]; ["ln"; "/a"; "/b"]; @@ -3190,7 +3244,7 @@ returned path has no C<.>, C<..> or symbolic link path elements."); "\ This command creates a hard link using the C command."); - ("ln_f", (RErr, [String "target"; String "linkname"]), 165, [], + ("ln_f", (RErr, [String "target"; Pathname "linkname"]), 165, [], [InitBasicFS, Always, TestOutputStruct ( [["touch"; "/a"]; ["touch"; "/b"]; @@ -3201,7 +3255,7 @@ This command creates a hard link using the C command."); This command creates a hard link using the C command. The C<-f> option removes the link (C) if it exists already."); - ("ln_s", (RErr, [String "target"; String "linkname"]), 166, [], + ("ln_s", (RErr, [String "target"; Pathname "linkname"]), 166, [], [InitBasicFS, Always, TestOutputStruct ( [["touch"; "/a"]; ["ln_s"; "a"; "/b"]; @@ -3210,7 +3264,7 @@ The C<-f> option removes the link (C) if it exists already."); "\ This command creates a symbolic link using the C command."); - ("ln_sf", (RErr, [String "target"; String "linkname"]), 167, [], + ("ln_sf", (RErr, [String "target"; Pathname "linkname"]), 167, [], [InitBasicFS, Always, TestOutput ( [["mkdir_p"; "/a/b"]; ["touch"; "/a/b/c"]; @@ -3268,7 +3322,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"]; @@ -3279,7 +3333,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", "\ @@ -3306,10 +3360,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. @@ -3334,7 +3389,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", "\ @@ -3449,6 +3504,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