From: Jim Meyering <meyering(a)redhat.com>
* src/generator.ml: Emit NEED_ROOT and ABS_PATH into generated
stubs.c, rather than requiring they be added manually at the start
of each and every do_* function that operates on a "path" parameter.
Update grammar: Pathname is just a String, with the above exception.
---
src/generator.ml | 200 +++++++++++++++++++++++++++++------------------------
1 files changed, 109 insertions(+), 91 deletions(-)
diff --git a/src/generator.ml b/src/generator.ml
index 30fe41c..325d3cb 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -135,6 +135,7 @@ and args = argt list (* Function parameters, guestfs handle is
implicit. *)
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 *)
| OptString of string (* const char *name, may be NULL *)
| StringList of string(* list of strings (each string cannot be NULL) *)
| Bool of string (* boolean *)
@@ -532,7 +533,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 "path"]), -1, [FishAlias
"path"],
+ ("set_path", (RErr, [Pathname "path"]), -1, [FishAlias
"path"],
[],
"set the search path",
"\
@@ -805,7 +806,7 @@ underlying disk image.
You should always call this if you have modified a disk image, before
closing the handle.");
- ("touch", (RErr, [String "path"]), 3, [],
+ ("touch", (RErr, [Pathname "path"]), 3, [],
[InitBasicFS, Always, TestOutputTrue (
[["touch"; "/new"];
["exists"; "/new"]])],
@@ -815,7 +816,7 @@ Touch acts like the L<touch(1)> command. It can be used to
update the timestamps on a file, or, if the file does not exist,
to create a new zero-length file.");
- ("cat", (RString "content", [String "path"]), 4,
[ProtocolLimitWarning],
+ ("cat", (RString "content", [Pathname "path"]), 4,
[ProtocolLimitWarning],
[InitSquashFS, Always, TestOutput (
[["cat"; "/known-2"]], "abcdef\n")],
"list the contents of a file",
@@ -963,7 +964,7 @@ of the L<vgs(8)> command. The \"full\" version
includes all fields.");
List all the logical volumes detected. This is the equivalent
of the L<lvs(8)> command. The \"full\" version includes all
fields.");
- ("read_lines", (RStringList "lines", [String "path"]),
15, [],
+ ("read_lines", (RStringList "lines", [Pathname "path"]),
15, [],
[InitSquashFS, Always, TestOutputList (
[["read_lines"; "/known-4"]], ["abc";
"def"; "ghi"]);
InitSquashFS, Always, TestOutputList (
@@ -1066,20 +1067,20 @@ On success this returns a pair containing the
number of nodes in the nodeset, and a boolean flag
if a node was created.");
- ("aug_get", (RString "val", [String "path"]), 19, [],
+ ("aug_get", (RString "val", [Pathname "path"]), 19, [],
[], (* XXX Augeas code needs tests. *)
"look up the value of an Augeas path",
"\
Look up the value associated with C<path>. If C<path>
matches exactly one node, the C<value> is returned.");
- ("aug_set", (RErr, [String "path"; String "val"]), 20,
[],
+ ("aug_set", (RErr, [Pathname "path"; String "val"]), 20,
[],
[], (* XXX Augeas code needs tests. *)
"set Augeas path to value",
"\
Set the value associated with C<path> to C<value>.");
- ("aug_insert", (RErr, [String "path"; String "label";
Bool "before"]), 21, [],
+ ("aug_insert", (RErr, [Pathname "path"; String "label";
Bool "before"]), 21, [],
[], (* XXX Augeas code needs tests. *)
"insert a sibling Augeas node",
"\
@@ -1091,7 +1092,7 @@ C<path> must match exactly one existing node in the tree, and
C<label> must be a label, ie. not contain C</>, C<*> or end
with a bracketed index C<[N]>.");
- ("aug_rm", (RInt "nrnodes", [String "path"]), 22, [],
+ ("aug_rm", (RInt "nrnodes", [Pathname "path"]), 22, [],
[], (* XXX Augeas code needs tests. *)
"remove an Augeas path",
"\
@@ -1106,7 +1107,7 @@ On success this returns the number of entries which were
removed.");
Move the node C<src> to C<dest>. C<src> must match exactly
one node. C<dest> is overwritten if it exists.");
- ("aug_match", (RStringList "matches", [String "path"]),
24, [],
+ ("aug_match", (RStringList "matches", [Pathname "path"]),
24, [],
[], (* XXX Augeas code needs tests. *)
"return Augeas nodes which match path",
"\
@@ -1132,14 +1133,14 @@ Load files into the tree.
See C<aug_load> in the Augeas documentation for the full gory
details.");
- ("aug_ls", (RStringList "matches", [String "path"]), 28,
[],
+ ("aug_ls", (RStringList "matches", [Pathname "path"]),
28, [],
[], (* XXX Augeas code needs tests. *)
"list Augeas nodes under a path",
"\
This is just a shortcut for listing C<guestfs_aug_match>
C<path/*> and sorting the resulting nodes into alphabetical order.");
- ("rm", (RErr, [String "path"]), 29, [],
+ ("rm", (RErr, [Pathname "path"]), 29, [],
[InitBasicFS, Always, TestRun
[["touch"; "/new"];
["rm"; "/new"]];
@@ -1152,7 +1153,7 @@ C<path/*> and sorting the resulting nodes into alphabetical
order.");
"\
Remove the single file C<path>.");
- ("rmdir", (RErr, [String "path"]), 30, [],
+ ("rmdir", (RErr, [Pathname "path"]), 30, [],
[InitBasicFS, Always, TestRun
[["mkdir"; "/new"];
["rmdir"; "/new"]];
@@ -1165,7 +1166,7 @@ Remove the single file C<path>.");
"\
Remove the single directory C<path>.");
- ("rm_rf", (RErr, [String "path"]), 31, [],
+ ("rm_rf", (RErr, [Pathname "path"]), 31, [],
[InitBasicFS, Always, TestOutputFalse
[["mkdir"; "/new"];
["mkdir"; "/new/foo"];
@@ -1178,7 +1179,7 @@ Remove the file or directory C<path>, recursively removing
the
contents if its a directory. This is like the C<rm -rf> shell
command.");
- ("mkdir", (RErr, [String "path"]), 32, [],
+ ("mkdir", (RErr, [Pathname "path"]), 32, [],
[InitBasicFS, Always, TestOutputTrue
[["mkdir"; "/new"];
["is_dir"; "/new"]];
@@ -1188,7 +1189,7 @@ command.");
"\
Create a directory named C<path>.");
- ("mkdir_p", (RErr, [String "path"]), 33, [],
+ ("mkdir_p", (RErr, [Pathname "path"]), 33, [],
[InitBasicFS, Always, TestOutputTrue
[["mkdir_p"; "/new/foo/bar"];
["is_dir"; "/new/foo/bar"]];
@@ -1210,14 +1211,14 @@ Create a directory named C<path>.");
Create a directory named C<path>, creating any parent directories
as necessary. This is like the C<mkdir -p> shell command.");
- ("chmod", (RErr, [Int "mode"; String "path"]), 34, [],
+ ("chmod", (RErr, [Int "mode"; Pathname "path"]), 34, [],
[], (* XXX Need stat command to test *)
"change file mode",
"\
Change the mode (permissions) of C<path> to C<mode>. Only
numeric modes are supported.");
- ("chown", (RErr, [Int "owner"; Int "group"; String
"path"]), 35, [],
+ ("chown", (RErr, [Int "owner"; Int "group"; Pathname
"path"]), 35, [],
[], (* XXX Need stat command to test *)
"change file owner and group",
"\
@@ -1227,7 +1228,7 @@ Only numeric uid and gid are supported. If you want to use
names, you will need to locate and parse the password file
yourself (Augeas support makes this relatively easy).");
- ("exists", (RBool "existsflag", [String "path"]), 36,
[],
+ ("exists", (RBool "existsflag", [Pathname "path"]), 36,
[],
[InitSquashFS, Always, TestOutputTrue (
[["exists"; "/empty"]]);
InitSquashFS, Always, TestOutputTrue (
@@ -1239,7 +1240,7 @@ This returns C<true> if and only if there is a file,
directory
See also C<guestfs_is_file>, C<guestfs_is_dir>,
C<guestfs_stat>.");
- ("is_file", (RBool "fileflag", [String "path"]), 37, [],
+ ("is_file", (RBool "fileflag", [Pathname "path"]), 37,
[],
[InitSquashFS, Always, TestOutputTrue (
[["is_file"; "/known-1"]]);
InitSquashFS, Always, TestOutputFalse (
@@ -1252,7 +1253,7 @@ other objects like directories.
See also C<guestfs_stat>.");
- ("is_dir", (RBool "dirflag", [String "path"]), 38, [],
+ ("is_dir", (RBool "dirflag", [Pathname "path"]), 38, [],
[InitSquashFS, Always, TestOutputFalse (
[["is_dir"; "/known-3"]]);
InitSquashFS, Always, TestOutputTrue (
@@ -1354,7 +1355,7 @@ the string C<,> (comma).
See also: C<guestfs_sfdisk_l>, C<guestfs_sfdisk_N>");
- ("write_file", (RErr, [String "path"; String "content";
Int "size"]), 44, [ProtocolLimitWarning],
+ ("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");
@@ -1449,7 +1450,7 @@ Some internal mounts are not unmounted by this call.");
This command removes all LVM logical volumes, volume groups
and physical volumes.");
- ("file", (RString "description", [String "path"]), 49,
[],
+ ("file", (RString "description", [Pathname "path"]), 49,
[],
[InitSquashFS, Always, TestOutput (
[["file"; "/empty"]], "empty");
InitSquashFS, Always, TestOutput (
@@ -1602,7 +1603,7 @@ result into a list of lines.
See also: C<guestfs_sh_lines>");
- ("stat", (RStruct ("statbuf", "stat"), [String
"path"]), 52, [],
+ ("stat", (RStruct ("statbuf", "stat"), [Pathname
"path"]), 52, [],
[InitSquashFS, Always, TestOutputStruct (
[["stat"; "/empty"]], [CompareWithInt ("size",
0)])],
"get file information",
@@ -1611,7 +1612,7 @@ Returns file information for the given C<path>.
This is the same as the C<stat(2)> system call.");
- ("lstat", (RStruct ("statbuf", "stat"), [String
"path"]), 53, [],
+ ("lstat", (RStruct ("statbuf", "stat"), [Pathname
"path"]), 53, [],
[InitSquashFS, Always, TestOutputStruct (
[["lstat"; "/empty"]], [CompareWithInt ("size",
0)])],
"get file information for a symbolic link",
@@ -1624,7 +1625,7 @@ refers to.
This is the same as the C<lstat(2)> system call.");
- ("statvfs", (RStruct ("statbuf", "statvfs"), [String
"path"]), 54, [],
+ ("statvfs", (RStruct ("statbuf", "statvfs"), [Pathname
"path"]), 54, [],
[InitSquashFS, Always, TestOutputStruct (
[["statvfs"; "/"]], [CompareWithInt ("namemax",
256)])],
"get file system statistics",
@@ -1790,7 +1791,7 @@ C<filename> can also be a named pipe.
See also C<guestfs_upload>, C<guestfs_cat>.");
- ("checksum", (RString "checksum", [String "csumtype";
String "path"]), 68, [],
+ ("checksum", (RString "checksum", [String "csumtype";
Pathname "path"]), 68, [],
[InitSquashFS, Always, TestOutput (
[["checksum"; "crc"; "/known-3"]],
"2891671662");
InitSquashFS, Always, TestLastFail (
@@ -2243,7 +2244,7 @@ true if their content is exactly equal, or false otherwise.
The external L<cmp(1)> program is used for the comparison.");
- ("strings", (RStringList "stringsout", [String "path"]),
94, [ProtocolLimitWarning],
+ ("strings", (RStringList "stringsout", [Pathname
"path"]), 94, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["strings"; "/known-5"]], ["abcdefghi";
"jklmnopqr"]);
InitSquashFS, Always, TestOutputList (
@@ -2253,7 +2254,7 @@ The external L<cmp(1)> program is used for the
comparison.");
This runs the L<strings(1)> command on a file and returns
the list of printable strings found.");
- ("strings_e", (RStringList "stringsout", [String
"encoding"; String "path"]), 95, [ProtocolLimitWarning],
+ ("strings_e", (RStringList "stringsout", [String
"encoding"; Pathname "path"]), 95, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["strings_e"; "b"; "/known-5"]], []);
InitBasicFS, Disabled, TestOutputList (
@@ -2271,7 +2272,7 @@ show strings inside Windows/x86 files.
The returned strings are transcoded to UTF-8.");
- ("hexdump", (RString "dump", [String "path"]), 96,
[ProtocolLimitWarning],
+ ("hexdump", (RString "dump", [Pathname "path"]), 96,
[ProtocolLimitWarning],
[InitSquashFS, 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
@@ -2589,7 +2590,7 @@ containing C<dir>.
It is an interface to the L<scrub(1)> program. See that
manual page for more details.");
- ("mkdtemp", (RString "dir", [String "template"]), 117,
[],
+ ("mkdtemp", (RString "dir", [Pathname "template"]), 117,
[],
[InitBasicFS, Always, TestRun (
[["mkdir"; "/tmp"];
["mkdtemp"; "/tmp/tmpXXXXXX"]])],
@@ -2614,7 +2615,7 @@ directory and its contents after use.
See also: L<mkdtemp(3)>");
- ("wc_l", (RInt "lines", [String "path"]), 118, [],
+ ("wc_l", (RInt "lines", [Pathname "path"]), 118, [],
[InitSquashFS, Always, TestOutputInt (
[["wc_l"; "/10klines"]], 10000)],
"count lines in a file",
@@ -2622,7 +2623,7 @@ See also: L<mkdtemp(3)>");
This command counts the lines in a file, using the
C<wc -l> external command.");
- ("wc_w", (RInt "words", [String "path"]), 119, [],
+ ("wc_w", (RInt "words", [Pathname "path"]), 119, [],
[InitSquashFS, Always, TestOutputInt (
[["wc_w"; "/10klines"]], 10000)],
"count words in a file",
@@ -2630,7 +2631,7 @@ C<wc -l> external command.");
This command counts the words in a file, using the
C<wc -w> external command.");
- ("wc_c", (RInt "chars", [String "path"]), 120, [],
+ ("wc_c", (RInt "chars", [Pathname "path"]), 120, [],
[InitSquashFS, Always, TestOutputInt (
[["wc_c"; "/100kallspaces"]], 102400)],
"count characters in a file",
@@ -2638,7 +2639,7 @@ C<wc -w> external command.");
This command counts the characters in a file, using the
C<wc -c> external command.");
- ("head", (RStringList "lines", [String "path"]), 121,
[ProtocolLimitWarning],
+ ("head", (RStringList "lines", [Pathname "path"]), 121,
[ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["head"; "/10klines"]],
["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz";"3abcdefghijklmnopqrstuvwxyz";"4abcdefghijklmnopqrstuvwxyz";"5abcdefghijklmnopqrstuvwxyz";"6abcdefghijklmnopqrstuvwxyz";"7abcdefghijklmnopqrstuvwxyz";"8abcdefghijklmnopqrstuvwxyz";"9abcdefghijklmnopqrstuvwxyz"])],
"return first 10 lines of a file",
@@ -2646,7 +2647,7 @@ C<wc -c> external command.");
This command returns up to the first 10 lines of a file as
a list of strings.");
- ("head_n", (RStringList "lines", [Int "nrlines"; String
"path"]), 122, [ProtocolLimitWarning],
+ ("head_n", (RStringList "lines", [Int "nrlines"; Pathname
"path"]), 122, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["head_n"; "3"; "/10klines"]],
["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]);
InitSquashFS, Always, TestOutputList (
@@ -2663,7 +2664,7 @@ from the file C<path>, excluding the last C<nrlines>
lines.
If the parameter C<nrlines> is zero, this returns an empty list.");
- ("tail", (RStringList "lines", [String "path"]), 123,
[ProtocolLimitWarning],
+ ("tail", (RStringList "lines", [Pathname "path"]), 123,
[ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["tail"; "/10klines"]],
["9990abcdefghijklmnopqrstuvwxyz";"9991abcdefghijklmnopqrstuvwxyz";"9992abcdefghijklmnopqrstuvwxyz";"9993abcdefghijklmnopqrstuvwxyz";"9994abcdefghijklmnopqrstuvwxyz";"9995abcdefghijklmnopqrstuvwxyz";"9996abcdefghijklmnopqrstuvwxyz";"9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"])],
"return last 10 lines of a file",
@@ -2671,7 +2672,7 @@ If the parameter C<nrlines> is zero, this returns an empty
list.");
This command returns up to the last 10 lines of a file as
a list of strings.");
- ("tail_n", (RStringList "lines", [Int "nrlines"; String
"path"]), 124, [ProtocolLimitWarning],
+ ("tail_n", (RStringList "lines", [Int "nrlines"; Pathname
"path"]), 124, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["tail_n"; "3"; "/10klines"]],
["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]);
InitSquashFS, Always, TestOutputList (
@@ -2713,7 +2714,7 @@ This command is mostly useful for interactive sessions. It
is I<not> intended that you try to parse the output string.
Use C<statvfs> from programs.");
- ("du", (RInt64 "sizekb", [String "path"]), 127, [],
+ ("du", (RInt64 "sizekb", [Pathname "path"]), 127, [],
[InitSquashFS, Always, TestOutputInt (
[["du"; "/directory"]], 0 (* squashfs doesn't have blocks
*))],
"estimate file space usage",
@@ -2728,7 +2729,7 @@ subdirectories (recursively).
The result is the estimated size in I<kilobytes>
(ie. units of 1024 bytes).");
- ("initrd_list", (RStringList "filenames", [String
"path"]), 128, [],
+ ("initrd_list", (RStringList "filenames", [Pathname
"path"]), 128, [],
[InitSquashFS, Always, TestOutputList (
[["initrd_list"; "/initrd"]],
["empty";"known-1";"known-2";"known-3";"known-4";
"known-5"])],
"list files in an initrd",
@@ -2779,7 +2780,7 @@ a limitation of the kernel or swap tools.");
"\
Create a swap partition on C<device> with UUID C<uuid>.");
- ("mknod", (RErr, [Int "mode"; Int "devmajor"; Int
"devminor"; String "path"]), 133, [],
+ ("mknod", (RErr, [Int "mode"; Int "devmajor"; Int
"devminor"; Pathname "path"]), 133, [],
[InitBasicFS, Always, TestOutputStruct (
[["mknod"; "0o10777"; "0"; "0";
"/node"];
(* NB: default umask 022 means 0777 -> 0755 in these tests *)
@@ -2797,7 +2798,7 @@ constants. C<devmajor> and C<devminor> are the
device major and minor numbers, only used when creating block
and character special devices.");
- ("mkfifo", (RErr, [Int "mode"; String "path"]), 134, [],
+ ("mkfifo", (RErr, [Int "mode"; Pathname "path"]), 134,
[],
[InitBasicFS, Always, TestOutputStruct (
[["mkfifo"; "0o777"; "/node"];
["stat"; "/node"]], [CompareWithInt ("mode",
0o10755)])],
@@ -2807,7 +2808,7 @@ This call creates a FIFO (named pipe) called C<path> with
mode C<mode>. It is just a convenient wrapper around
C<guestfs_mknod>.");
- ("mknod_b", (RErr, [Int "mode"; Int "devmajor"; Int
"devminor"; String "path"]), 135, [],
+ ("mknod_b", (RErr, [Int "mode"; Int "devmajor"; Int
"devminor"; Pathname "path"]), 135, [],
[InitBasicFS, Always, TestOutputStruct (
[["mknod_b"; "0o777"; "99"; "66";
"/node"];
["stat"; "/node"]], [CompareWithInt ("mode",
0o60755)])],
@@ -2817,7 +2818,7 @@ This call creates a block device node called C<path> with
mode C<mode> and device major/minor C<devmajor> and C<devminor>.
It is just a convenient wrapper around C<guestfs_mknod>.");
- ("mknod_c", (RErr, [Int "mode"; Int "devmajor"; Int
"devminor"; String "path"]), 136, [],
+ ("mknod_c", (RErr, [Int "mode"; Int "devmajor"; Int
"devminor"; Pathname "path"]), 136, [],
[InitBasicFS, Always, TestOutputStruct (
[["mknod_c"; "0o777"; "99"; "66";
"/node"];
["stat"; "/node"]], [CompareWithInt ("mode",
0o20755)])],
@@ -2919,7 +2920,7 @@ were rarely if ever used anyway.
See also C<guestfs_sfdisk> and the L<sfdisk(8)> manpage.");
- ("zfile", (RString "description", [String "method";
String "path"]), 140, [DeprecatedBy "file"],
+ ("zfile", (RString "description", [String "method";
Pathname "path"]), 140, [DeprecatedBy "file"],
[],
"determine file type inside a compressed file",
"\
@@ -2931,7 +2932,7 @@ C<method> must be one of C<gzip>, C<compress> or
C<bzip2>.
Since 1.0.63, use C<guestfs_file> instead which can now
process compressed files.");
- ("getxattrs", (RStructList ("xattrs", "xattr"), [String
"path"]), 141, [],
+ ("getxattrs", (RStructList ("xattrs", "xattr"), [Pathname
"path"]), 141, [],
[],
"list extended attributes of a file or directory",
"\
@@ -2943,7 +2944,7 @@ L<listxattr(2)> and L<getxattr(2)> calls.
See also: C<guestfs_lgetxattrs>, L<attr(5)>.");
- ("lgetxattrs", (RStructList ("xattrs", "xattr"), [String
"path"]), 142, [],
+ ("lgetxattrs", (RStructList ("xattrs", "xattr"),
[Pathname "path"]), 142, [],
[],
"list extended attributes of a file or directory",
"\
@@ -2953,7 +2954,7 @@ of the link itself.");
("setxattr", (RErr, [String "xattr";
String "val"; Int "vallen"; (* will be
BufferIn *)
- String "path"]), 143, [],
+ Pathname "path"]), 143, [],
[],
"set extended attribute of a file or directory",
"\
@@ -2965,7 +2966,7 @@ See also: C<guestfs_lsetxattr>, L<attr(5)>.");
("lsetxattr", (RErr, [String "xattr";
String "val"; Int "vallen"; (* will be
BufferIn *)
- String "path"]), 144, [],
+ Pathname "path"]), 144, [],
[],
"set extended attribute of a file or directory",
"\
@@ -2973,7 +2974,7 @@ This is the same as C<guestfs_setxattr>, but if C<path>
is a symbolic link, then it sets an extended attribute
of the link itself.");
- ("removexattr", (RErr, [String "xattr"; String "path"]),
145, [],
+ ("removexattr", (RErr, [String "xattr"; Pathname
"path"]), 145, [],
[],
"remove extended attribute of a file or directory",
"\
@@ -2982,7 +2983,7 @@ of the file C<path>.
See also: C<guestfs_lremovexattr>, L<attr(5)>.");
- ("lremovexattr", (RErr, [String "xattr"; String "path"]),
146, [],
+ ("lremovexattr", (RErr, [String "xattr"; Pathname
"path"]), 146, [],
[],
"remove extended attribute of a file or directory",
"\
@@ -2998,7 +2999,7 @@ This call is similar to C<guestfs_mounts>. 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, [String "path"]), 148, [],
+ ("mkmountpoint", (RErr, [Pathname "path"]), 148, [],
[],
"create a mountpoint",
"\
@@ -3026,7 +3027,7 @@ in guestfish:
The inner filesystem is now unpacked under the /ext3 mountpoint.");
- ("rmmountpoint", (RErr, [String "path"]), 149, [],
+ ("rmmountpoint", (RErr, [Pathname "path"]), 149, [],
[],
"remove a mountpoint",
"\
@@ -3034,7 +3035,7 @@ This calls removes a mountpoint that was previously created
with C<guestfs_mkmountpoint>. See C<guestfs_mkmountpoint>
for full details.");
- ("read_file", (RBufferOut "content", [String "path"]),
150, [ProtocolLimitWarning],
+ ("read_file", (RBufferOut "content", [Pathname "path"]),
150, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputBuffer (
[["read_file"; "/known-4"]], "abc\ndef\nghi")],
"read a file",
@@ -3047,7 +3048,7 @@ handle files that contain embedded ASCII NUL characters.
However unlike C<guestfs_download>, this function is limited
in the total size of file that can be handled.");
- ("grep", (RStringList "lines", [String "regex"; String
"path"]), 151, [ProtocolLimitWarning],
+ ("grep", (RStringList "lines", [String "regex"; Pathname
"path"]), 151, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["grep"; "abc"; "/test-grep.txt"]],
["abc"; "abc123"]);
InitSquashFS, Always, TestOutputList (
@@ -3057,7 +3058,7 @@ in the total size of file that can be handled.");
This calls the external C<grep> program and returns the
matching lines.");
- ("egrep", (RStringList "lines", [String "regex"; String
"path"]), 152, [ProtocolLimitWarning],
+ ("egrep", (RStringList "lines", [String "regex"; Pathname
"path"]), 152, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["egrep"; "abc"; "/test-grep.txt"]],
["abc"; "abc123"])],
"return lines matching a pattern",
@@ -3065,7 +3066,7 @@ matching lines.");
This calls the external C<egrep> program and returns the
matching lines.");
- ("fgrep", (RStringList "lines", [String "pattern"; String
"path"]), 153, [ProtocolLimitWarning],
+ ("fgrep", (RStringList "lines", [String "pattern";
Pathname "path"]), 153, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["fgrep"; "abc"; "/test-grep.txt"]],
["abc"; "abc123"])],
"return lines matching a pattern",
@@ -3073,7 +3074,7 @@ matching lines.");
This calls the external C<fgrep> program and returns the
matching lines.");
- ("grepi", (RStringList "lines", [String "regex"; String
"path"]), 154, [ProtocolLimitWarning],
+ ("grepi", (RStringList "lines", [String "regex"; Pathname
"path"]), 154, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["grepi"; "abc"; "/test-grep.txt"]],
["abc"; "abc123"; "ABC"])],
"return lines matching a pattern",
@@ -3081,7 +3082,7 @@ matching lines.");
This calls the external C<grep -i> program and returns the
matching lines.");
- ("egrepi", (RStringList "lines", [String "regex"; String
"path"]), 155, [ProtocolLimitWarning],
+ ("egrepi", (RStringList "lines", [String "regex";
Pathname "path"]), 155, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["egrepi"; "abc"; "/test-grep.txt"]],
["abc"; "abc123"; "ABC"])],
"return lines matching a pattern",
@@ -3089,7 +3090,7 @@ matching lines.");
This calls the external C<egrep -i> program and returns the
matching lines.");
- ("fgrepi", (RStringList "lines", [String "pattern";
String "path"]), 156, [ProtocolLimitWarning],
+ ("fgrepi", (RStringList "lines", [String "pattern";
Pathname "path"]), 156, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["fgrepi"; "abc"; "/test-grep.txt"]],
["abc"; "abc123"; "ABC"])],
"return lines matching a pattern",
@@ -3097,7 +3098,7 @@ matching lines.");
This calls the external C<fgrep -i> program and returns the
matching lines.");
- ("zgrep", (RStringList "lines", [String "regex"; String
"path"]), 157, [ProtocolLimitWarning],
+ ("zgrep", (RStringList "lines", [String "regex"; Pathname
"path"]), 157, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["zgrep"; "abc"; "/test-grep.txt.gz"]],
["abc"; "abc123"])],
"return lines matching a pattern",
@@ -3105,7 +3106,7 @@ matching lines.");
This calls the external C<zgrep> program and returns the
matching lines.");
- ("zegrep", (RStringList "lines", [String "regex"; String
"path"]), 158, [ProtocolLimitWarning],
+ ("zegrep", (RStringList "lines", [String "regex";
Pathname "path"]), 158, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["zegrep"; "abc"; "/test-grep.txt.gz"]],
["abc"; "abc123"])],
"return lines matching a pattern",
@@ -3113,7 +3114,7 @@ matching lines.");
This calls the external C<zegrep> program and returns the
matching lines.");
- ("zfgrep", (RStringList "lines", [String "pattern";
String "path"]), 159, [ProtocolLimitWarning],
+ ("zfgrep", (RStringList "lines", [String "pattern";
Pathname "path"]), 159, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["zfgrep"; "abc"; "/test-grep.txt.gz"]],
["abc"; "abc123"])],
"return lines matching a pattern",
@@ -3121,7 +3122,7 @@ matching lines.");
This calls the external C<zfgrep> program and returns the
matching lines.");
- ("zgrepi", (RStringList "lines", [String "regex"; String
"path"]), 160, [ProtocolLimitWarning],
+ ("zgrepi", (RStringList "lines", [String "regex";
Pathname "path"]), 160, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["zgrepi"; "abc"; "/test-grep.txt.gz"]],
["abc"; "abc123"; "ABC"])],
"return lines matching a pattern",
@@ -3129,7 +3130,7 @@ matching lines.");
This calls the external C<zgrep -i> program and returns the
matching lines.");
- ("zegrepi", (RStringList "lines", [String "regex"; String
"path"]), 161, [ProtocolLimitWarning],
+ ("zegrepi", (RStringList "lines", [String "regex";
Pathname "path"]), 161, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["zegrepi"; "abc"; "/test-grep.txt.gz"]],
["abc"; "abc123"; "ABC"])],
"return lines matching a pattern",
@@ -3137,7 +3138,7 @@ matching lines.");
This calls the external C<zegrep -i> program and returns the
matching lines.");
- ("zfgrepi", (RStringList "lines", [String "pattern";
String "path"]), 162, [ProtocolLimitWarning],
+ ("zfgrepi", (RStringList "lines", [String "pattern";
Pathname "path"]), 162, [ProtocolLimitWarning],
[InitSquashFS, Always, TestOutputList (
[["zfgrepi"; "abc"; "/test-grep.txt.gz"]],
["abc"; "abc123"; "ABC"])],
"return lines matching a pattern",
@@ -3145,7 +3146,7 @@ matching lines.");
This calls the external C<zfgrep -i> program and returns the
matching lines.");
- ("realpath", (RString "rpath", [String "path"]), 163,
[],
+ ("realpath", (RString "rpath", [Pathname "path"]), 163,
[],
[InitSquashFS, Always, TestOutput (
[["realpath"; "/../directory"]], "/directory")],
"canonicalized absolute pathname",
@@ -3193,13 +3194,13 @@ This command creates a symbolic link using the C<ln -s>
command.");
This command creates a symbolic link using the C<ln -sf> command,
The C<-f> option removes the link (C<linkname>) if it exists
already.");
- ("readlink", (RString "link", [String "path"]), 168, [],
+ ("readlink", (RString "link", [Pathname "path"]), 168,
[],
[] (* XXX tested above *),
"read the target of a symbolic link",
"\
This command reads the target of a symbolic link.");
- ("fallocate", (RErr, [String "path"; Int "len"]), 169,
[],
+ ("fallocate", (RErr, [Pathname "path"; Int "len"]), 169,
[],
[InitBasicFS, Always, TestOutputStruct (
[["fallocate"; "/a"; "1000000"];
["stat"; "/a"]], [CompareWithInt ("size",
1_000_000)])],
@@ -3294,7 +3295,7 @@ See C<guestfs_swapon_device> for other notes.");
This command disables the libguestfs appliance swap partition
with the given UUID.");
- ("mkswap_file", (RErr, [String "path"]), 178, [],
+ ("mkswap_file", (RErr, [Pathname "path"]), 178, [],
[InitBasicFS, Always, TestRun (
[["fallocate"; "/swap"; "8388608"];
["mkswap_file"; "/swap"]])],
@@ -3346,7 +3347,7 @@ as exposed by the Linux kernel, which is roughly what we expose
via libguestfs. Note that there is one global inotify handle
per libguestfs instance.");
- ("inotify_add_watch", (RInt64 "wd", [String "path"; Int
"mask"]), 180, [],
+ ("inotify_add_watch", (RInt64 "wd", [Pathname "path"; Int
"mask"]), 180, [],
[InitBasicFS, Always, TestOutputList (
[["inotify_init"; "0"];
["inotify_add_watch"; "/"; "1073741823"];
@@ -3727,7 +3728,7 @@ let mapi f xs =
loop 0 xs
let name_of_argt = function
- | Device n | String n | OptString n | StringList n | Bool n | Int n
+ | Pathname n | Device n | String n | OptString n | StringList n | Bool n | Int n
| FileIn n | FileOut n -> n
let java_name_of_struct typ =
@@ -4114,7 +4115,7 @@ and generate_xdr () =
pr "struct %s_args {\n" name;
List.iter (
function
- | Device n | String n -> pr " string %s<>;\n" n
+ | Pathname n | Device n | String n -> pr " string
%s<>;\n" n
| OptString n -> pr " str *%s;\n" n
| StringList n -> pr " str %s<>;\n" n
| Bool n -> pr " bool %s;\n" n
@@ -4475,7 +4476,7 @@ check_state (guestfs_h *g, const char *caller)
| args ->
List.iter (
function
- | Device n | String n ->
+ | Pathname n | Device n | String n ->
pr " args.%s = (char *) %s;\n" n n
| OptString n ->
pr " args.%s = %s ? (char **) &%s : NULL;\n" n n n
@@ -4681,7 +4682,7 @@ and generate_daemon_actions () =
List.iter (
function
(* FIXME: eventually, make String "const", too *)
- | Device n -> pr " const char *%s;\n" n
+ | Pathname n | Device n -> pr " const char *%s;\n" n
| String n
| OptString n -> pr " char *%s;\n" n
| StringList n -> pr " char **%s;\n" n
@@ -4703,7 +4704,10 @@ and generate_daemon_actions () =
pr " }\n";
List.iter (
function
- | Device n ->
+ | Pathname n ->
+ pr " NEED_ROOT (goto done);\n";
+ pr " ABS_PATH (%s, goto done);\n" n;
+ | Device n ->
pr " %s = args.%s;\n" n n;
pr " RESOLVE_DEVICE (%s, goto done);" n;
| String n -> pr " %s = args.%s;\n" n n
@@ -5610,6 +5614,7 @@ and generate_test_command_call ?(expect_error = false) ?test
test_name cmd =
List.iter (
function
| OptString n, "NULL" -> ()
+ | Pathname n, arg
| Device n, arg
| String n, arg
| OptString n, arg ->
@@ -5658,6 +5663,7 @@ and generate_test_command_call ?(expect_error = false) ?test
test_name cmd =
List.iter (
function
| OptString _, "NULL" -> pr ", NULL"
+ | Pathname n, _
| Device n, _
| String n, _
| OptString n, _ ->
@@ -5907,6 +5913,7 @@ and generate_fish_cmds () =
);
List.iter (
function
+ | Pathname n
| Device n
| String n
| OptString n
@@ -5928,6 +5935,7 @@ and generate_fish_cmds () =
iteri (
fun i ->
function
+ | Pathname name
| Device name | String name -> pr " %s = argv[%d];\n" name i
| OptString name ->
pr " %s = strcmp (argv[%d], \"\") != 0 ? argv[%d] :
NULL;\n"
@@ -6161,7 +6169,7 @@ and generate_fish_actions_pod () =
pr " %s" name;
List.iter (
function
- | Device n | String n -> pr " %s" n
+ | Pathname n | Device n | String n -> pr " %s" n
| OptString n -> pr " %s" n
| StringList n -> pr " '%s ...'" n
| Bool _ -> pr " true|false"
@@ -6227,6 +6235,7 @@ and generate_prototype ?(extern = true) ?(static = false)
?(semicolon = true)
in
List.iter (
function
+ | Pathname n
| Device n
| String n
| OptString n ->
@@ -6489,6 +6498,7 @@ copy_table (char * const * argv)
List.iter (
function
+ | Pathname n
| Device n
| String n
| FileIn n
@@ -6542,7 +6552,7 @@ copy_table (char * const * argv)
function
| StringList n ->
pr " ocaml_guestfs_free_strings (%s);\n" n;
- | Device _ | String _ | OptString _ | Bool _ | Int _
+ | Pathname _ | Device _ | String _ | OptString _ | Bool _ | Int _
| FileIn _ | FileOut _ -> ()
) (snd style);
@@ -6626,7 +6636,7 @@ and generate_ocaml_prototype ?(is_external = false) name style =
pr "%s : t -> " name;
List.iter (
function
- | Device _ | String _ | FileIn _ | FileOut _ -> pr "string -> "
+ | Pathname _ | Device _ | String _ | FileIn _ | FileOut _ -> pr "string ->
"
| OptString _ -> pr "string option -> "
| StringList _ -> pr "string array -> "
| Bool _ -> pr "bool -> "
@@ -6772,7 +6782,8 @@ DESTROY (g)
fun i ->
function
(* FIXME: ? *)
- | Device n | String n | FileIn n | FileOut n -> pr " char
*%s;\n" n
+ | Pathname n | Device n | String n | FileIn n | FileOut n ->
+ pr " char *%s;\n" n
| OptString n ->
(*
http://www.perlmonks.org/?node_id=554277
* Note that the implicit handle argument means we have
@@ -6787,7 +6798,7 @@ DESTROY (g)
let do_cleanups () =
List.iter (
function
- | Device _ | String _ | OptString _ | Bool _ | Int _
+ | Pathname _ | Device _ | String _ | OptString _ | Bool _ | Int _
| FileIn _ | FileOut _ -> ()
| StringList n -> pr " free (%s);\n" n
) (snd style)
@@ -7159,7 +7170,7 @@ and generate_perl_prototype name style =
if !comma then pr ", ";
comma := true;
match arg with
- | Device n | String n
+ | Pathname n | Device n | String n
| OptString n | Bool n | Int n | FileIn n | FileOut n ->
pr "$%s" n
| StringList n ->
@@ -7407,7 +7418,8 @@ py_guestfs_close (PyObject *self, PyObject *args)
List.iter (
function
- | Device n | String n | FileIn n | FileOut n -> pr " const char
*%s;\n" n
+ | Pathname n | Device n | String n | FileIn n | FileOut n ->
+ pr " const char *%s;\n" n
| OptString n -> pr " const char *%s;\n" n
| StringList n ->
pr " PyObject *py_%s;\n" n;
@@ -7422,7 +7434,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " if (!PyArg_ParseTuple (args, (char *) \"O";
List.iter (
function
- | Device _ | String _ | FileIn _ | FileOut _ -> pr "s"
+ | Pathname _ | Device _ | String _ | FileIn _ | FileOut _ -> pr "s"
| OptString _ -> pr "z"
| StringList _ -> pr "O"
| Bool _ -> pr "i" (* XXX Python has booleans? *)
@@ -7432,7 +7444,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " &py_g";
List.iter (
function
- | Device n | String n | FileIn n | FileOut n -> pr ", &%s" n
+ | Pathname n | Device n | String n | FileIn n | FileOut n -> pr ",
&%s" n
| OptString n -> pr ", &%s" n
| StringList n -> pr ", &py_%s" n
| Bool n -> pr ", &%s" n
@@ -7445,7 +7457,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " g = get_handle (py_g);\n";
List.iter (
function
- | Device _ | String _
+ | Pathname _ | Device _ | String _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " %s = get_string_list (py_%s);\n" n n;
@@ -7460,7 +7472,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
List.iter (
function
- | Device _ | String _
+ | Pathname _ | Device _ | String _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " free (%s);\n" n
@@ -7769,7 +7781,7 @@ static VALUE ruby_guestfs_close (VALUE gv)
List.iter (
function
- | Device n | String n | FileIn n | FileOut n ->
+ | Pathname n | Device n | String n | FileIn n | FileOut n ->
pr " Check_Type (%sv, T_STRING);\n" n;
pr " const char *%s = StringValueCStr (%sv);\n" n n;
pr " if (!%s)\n" n;
@@ -7821,7 +7833,7 @@ static VALUE ruby_guestfs_close (VALUE gv)
List.iter (
function
- | Device _ | String _
+ | Pathname _ | Device _ | String _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " free (%s);\n" n
@@ -8132,6 +8144,7 @@ and generate_java_prototype ?(public=false) ?(privat=false)
?(native=false)
needs_comma := true;
match arg with
+ | Pathname n
| Device n
| String n
| OptString n
@@ -8250,6 +8263,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
pr " (JNIEnv *env, jobject obj, jlong jg";
List.iter (
function
+ | Pathname n
| Device n
| String n
| OptString n
@@ -8302,6 +8316,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
"NULL", "NULL" in
List.iter (
function
+ | Pathname n
| Device n
| String n
| OptString n
@@ -8331,6 +8346,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
(* Get the parameters. *)
List.iter (
function
+ | Pathname n
| Device n
| String n
| FileIn n
@@ -8363,6 +8379,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
(* Release the parameters. *)
List.iter (
function
+ | Pathname n
| Device n
| String n
| FileIn n
@@ -8638,7 +8655,7 @@ last_error h = do
function
| FileIn n
| FileOut n
- | Device n | String n -> pr "withCString %s $ \\%s -> " n n
+ | Pathname n | Device n | String n -> pr "withCString %s $ \\%s ->
" n n
| OptString n -> pr "maybeWith withCString %s $ \\%s -> " n n
| StringList n -> pr "withMany withCString %s $ \\%s -> withArray0
nullPtr %s $ \\%s -> " n n n n
| Bool _ | Int _ -> ()
@@ -8650,7 +8667,7 @@ last_error h = do
| Bool n -> sprintf "(fromBool %s)" n
| Int n -> sprintf "(fromIntegral %s)" n
| FileIn n | FileOut n
- | Device n | String n | OptString n | StringList n -> n
+ | Pathname n | Device n | String n | OptString n | StringList n -> n
) (snd style) in
pr "withForeignPtr h (\\p -> c_%s %s)\n" name
(String.concat " " ("p" :: args));
@@ -8700,7 +8717,7 @@ and generate_haskell_prototype ~handle ?(hs = false) style =
List.iter (
fun arg ->
(match arg with
- | Device _ | String _ -> pr "%s" string
+ | Pathname _ | Device _ | String _ -> pr "%s" string
| OptString _ -> if hs then pr "Maybe String" else pr
"CString"
| StringList _ -> if hs then pr "[String]" else pr "Ptr
CString"
| Bool _ -> pr "%s" bool
@@ -8775,6 +8792,7 @@ print_strings (char * const* const argv)
pr "{\n";
List.iter (
function
+ | Pathname n
| Device n
| String n
| FileIn n
--
1.6.4.337.g5420e