summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/MAX_PROC_NR1
-rw-r--r--src/Makefile.am73
-rwxr-xr-xsrc/generator.ml1153
-rw-r--r--src/guestfs-actions.c10076
-rw-r--r--src/guestfs-actions.h183
-rw-r--r--src/guestfs-bindtests.c309
-rw-r--r--src/guestfs-structs.h129
-rw-r--r--src/guestfs.c354
-rw-r--r--src/guestfs.h1
-rw-r--r--src/guestfs_protocol.c1943
-rw-r--r--src/guestfs_protocol.h1433
-rw-r--r--src/guestfs_protocol.x893
12 files changed, 1397 insertions, 15151 deletions
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
new file mode 100644
index 00000000..897bdc82
--- /dev/null
+++ b/src/MAX_PROC_NR
@@ -0,0 +1 @@
+139
diff --git a/src/Makefile.am b/src/Makefile.am
index c310c9c4..1c0fa0ac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,17 +15,82 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-EXTRA_DIST = guestfs_protocol.x \
+EXTRA_DIST = \
+ guestfs_protocol.x \
guestfs_protocol.c \
- guestfs_protocol.h
+ guestfs_protocol.h \
+ MAX_PROC_NR \
+ stamp-generator \
+ generator.ml
+
+# Rerun the generator if it has changed.
+# Git removes empty directories, so in cases where the
+# generator is creating the sole file in a directory, we
+# have to create the directory first.
+noinst_DATA = stamp-generator
-EXTRA_DIST += generator.ml
+stamp-generator: generator.ml
+ mkdir -p $(top_srcdir)/perl/lib/Sys
+ cd .. && ocaml -warn-error A $(srcdir)/src/$<
+
+guestfs_protocol.x: stamp-generator
include_HEADERS = guestfs.h guestfs-actions.h guestfs-structs.h
lib_LTLIBRARIES = libguestfs.la
-libguestfs_la_LDFLAGS = -version-info 0:0:0
+# From the libtool info file, with comments:
+#
+# | 1. Start with version information of `0:0:0' for each libtool library.
+# |
+# | 2. Update the version information only immediately before a public
+# | release of your software. More frequent updates are unnecessary,
+# | and only guarantee that the current interface number gets larger
+# | faster.
+# |
+# | 3. If the library source code has changed at all since the last
+# | update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
+#
+# [So it seems like we should always update the middle 'R' field
+# for any release.]
+#
+# | 4. If any interfaces have been added, removed, or changed since the
+# | last update, increment CURRENT, and set REVISION to 0.
+# |
+# | 5. If any interfaces have been added since the last public release,
+# | then increment AGE.
+#
+# [These two rules seem to mean that if any change is made to the
+# generator, we should increment C and A, and set R to 0, so:
+# C+1:0:A+1.]
+#
+# | 6. If any interfaces have been removed since the last public release,
+# | then set AGE to 0.
+#
+# [Our ABI guarantee means we won't remove interfaces except in
+# very exceptional circumstances.]
+#
+# The maximum proc number (see guestfs_protocol.x:guestfs_procedure) is
+# a mostly accurate stand-in for C & A in rules 5 & 6, so we use that. It
+# is always incremented when we add a new appliance interface, and easy to
+# calculate.
+#
+# The middle number is hard to increment-and-reset as described in rules
+# 4 & 5, so for the moment it is always set to 0.
+#
+# Note that this scheme means the real library version will always be
+# 'libguestfs.so.0.$(MAX_PROC_NR).0'.
+
+BUILT_SOURCES = \
+ guestfs_protocol.x \
+ guestfs-structs.h \
+ guestfs-actions.h \
+ guestfs-actions.c \
+ guestfs-bindtests.c
+
+$(BUILT_SOURCES): stamp-generator
+
+libguestfs_la_LDFLAGS = -version-info $(MAX_PROC_NR):0:$(MAX_PROC_NR)
libguestfs_la_SOURCES = \
guestfs.c \
guestfs.h \
diff --git a/src/generator.ml b/src/generator.ml
index b3f27cd7..ed5810bf 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -83,6 +83,8 @@ and ret =
* inefficient. Keys should be unique. NULLs are not permitted.
*)
| RHashtable of string
+ (* List of directory entries (the result of readdir(3)). *)
+ | RDirentList of string
and args = argt list (* Function parameters, guestfs handle is implicit. *)
@@ -133,7 +135,9 @@ can easily destroy all your data>."
* 50MB and 10MB (respectively /dev/sda, /dev/sdb, /dev/sdc), and
* a fourth squashfs block device with some known files on it (/dev/sdd).
*
- * Note for partitioning purposes, the 500MB device has 63 cylinders.
+ * 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.
*
@@ -373,7 +377,8 @@ for whatever operations you want to perform (ie. read access if you
just want to read the image or write access if you want to modify the
image).
-This is equivalent to the qemu parameter C<-drive file=filename>.
+This is equivalent to the qemu parameter
+C<-drive file=filename,cache=off,if=...>.
Note that this call checks for the existence of C<filename>. This
stops you from specifying other types of drive which are supported
@@ -407,7 +412,7 @@ handle is closed. We don't currently have any method to enable
changes to be committed, although qemu can support this.
This is equivalent to the qemu parameter
-C<-drive file=filename,snapshot=on>.
+C<-drive file=filename,snapshot=on,if=...>.
Note that this call checks for the existence of C<filename>. This
stops you from specifying other types of drive which are supported
@@ -598,6 +603,35 @@ actions using the low-level API.
For more information on states, see L<guestfs(3)>.");
+ ("set_memsize", (RErr, [Int "memsize"]), -1, [FishAlias "memsize"],
+ [],
+ "set memory allocated to the qemu subprocess",
+ "\
+This sets the memory size in megabytes allocated to the
+qemu subprocess. This only has any effect if called before
+C<guestfs_launch>.
+
+You can also change this by setting the environment
+variable C<LIBGUESTFS_MEMSIZE> before the handle is
+created.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.");
+
+ ("get_memsize", (RInt "memsize", []), -1, [],
+ [],
+ "get memory allocated to the qemu subprocess",
+ "\
+This gets the memory size in megabytes allocated to the
+qemu subprocess.
+
+If C<guestfs_set_memsize> was not called
+on this handle, and if C<LIBGUESTFS_MEMSIZE> was not set,
+then this returns the compiled-in default value for memsize.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.");
+
]
(* daemon_functions are any functions which cause some action
@@ -607,7 +641,7 @@ For more information on states, see L<guestfs(3)>.");
let daemon_functions = [
("mount", (RErr, [String "device"; String "mountpoint"]), 1, [],
[InitEmpty, Always, TestOutput (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["mkfs"; "ext2"; "/dev/sda1"];
["mount"; "/dev/sda1"; "/"];
["write_file"; "/new"; "new file contents"; "0"];
@@ -704,7 +738,7 @@ The full block device names are returned, eg. C</dev/sda>");
[InitBasicFS, Always, TestOutputListOfDevices (
[["list_partitions"]], ["/dev/sda1"]);
InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"];
["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])],
"list the partitions",
"\
@@ -719,7 +753,7 @@ call C<guestfs_lvs>.");
[InitBasicFSonLVM, Always, TestOutputListOfDevices (
[["pvs"]], ["/dev/sda1"]);
InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
@@ -738,7 +772,7 @@ See also C<guestfs_pvs_full>.");
[InitBasicFSonLVM, Always, TestOutputList (
[["vgs"]], ["VG"]);
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
@@ -759,7 +793,7 @@ See also C<guestfs_vgs_full>.");
[InitBasicFSonLVM, Always, TestOutputList (
[["lvs"]], ["/dev/VG/LV"]);
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
@@ -1112,7 +1146,7 @@ See also C<guestfs_stat>.");
("pvcreate", (RErr, [String "device"]), 39, [],
[InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
@@ -1125,7 +1159,7 @@ as C</dev/sda1>.");
("vgcreate", (RErr, [String "volgroup"; StringList "physvols"]), 40, [],
[InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
@@ -1139,7 +1173,7 @@ from the non-empty list of physical volumes C<physvols>.");
("lvcreate", (RErr, [String "logvol"; String "volgroup"; Int "mbytes"]), 41, [],
[InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
@@ -1160,7 +1194,7 @@ on the volume group C<volgroup>, with C<size> megabytes.");
("mkfs", (RErr, [String "fstype"; String "device"]), 42, [],
[InitEmpty, Always, TestOutput (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["mkfs"; "ext2"; "/dev/sda1"];
["mount"; "/dev/sda1"; "/"];
["write_file"; "/new"; "new file contents"; "0"];
@@ -1235,12 +1269,12 @@ use C<guestfs_upload>.");
("umount", (RErr, [String "pathordevice"]), 45, [FishAlias "unmount"],
[InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["mkfs"; "ext2"; "/dev/sda1"];
["mount"; "/dev/sda1"; "/"];
["mounts"]], ["/dev/sda1"]);
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["mkfs"; "ext2"; "/dev/sda1"];
["mount"; "/dev/sda1"; "/"];
["umount"; "/"];
@@ -1267,7 +1301,7 @@ Some internal mounts are not shown.");
["mounts"]], []);
(* check that umount_all can unmount nested mounts correctly: *)
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"];
["mkfs"; "ext2"; "/dev/sda1"];
["mkfs"; "ext2"; "/dev/sda2"];
["mkfs"; "ext2"; "/dev/sda3"];
@@ -1314,51 +1348,51 @@ particular that the filename is not prepended to the output
("command", (RString "output", [StringList "arguments"]), 50, [ProtocolLimitWarning],
[InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 1"]], "Result1");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 2"]], "Result2\n");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 3"]], "\nResult3");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 4"]], "\nResult4\n");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 5"]], "\nResult5\n\n");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 6"]], "\n\nResult6\n\n");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 7"]], "");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 8"]], "\n");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 9"]], "\n\n");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 10"]], "Result10-1\nResult10-2\n");
InitBasicFS, Always, TestOutput (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command 11"]], "Result11-1\nResult11-2");
InitBasicFS, Always, TestLastFail (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command"; "/test-command"]])],
"run a command from the guest filesystem",
"\
@@ -1370,7 +1404,9 @@ or compatible processor architecture).
The single parameter is an argv-style list of arguments.
The first element is the name of the program to run.
Subsequent elements are parameters. The list must be
-non-empty (ie. must contain a program name).
+non-empty (ie. must contain a program name). Note that
+the command runs directly, and is I<not> invoked via
+the shell (see C<guestfs_sh>).
The return value is anything printed to I<stdout> by
the command.
@@ -1393,52 +1429,54 @@ locations.");
("command_lines", (RStringList "lines", [StringList "arguments"]), 51, [ProtocolLimitWarning],
[InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 1"]], ["Result1"]);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 2"]], ["Result2"]);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 3"]], ["";"Result3"]);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 4"]], ["";"Result4"]);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 5"]], ["";"Result5";""]);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 6"]], ["";"";"Result6";""]);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 7"]], []);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 8"]], [""]);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 9"]], ["";""]);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 10"]], ["Result10-1";"Result10-2"]);
InitBasicFS, Always, TestOutputList (
[["upload"; "test-command"; "/test-command"];
- ["chmod"; "493"; "/test-command"];
+ ["chmod"; "0o755"; "/test-command"];
["command_lines"; "/test-command 11"]], ["Result11-1";"Result11-2"])],
"run a command, returning lines",
"\
This is the same as C<guestfs_command>, but splits the
-result into a list of lines.");
+result into a list of lines.
+
+See also: C<guestfs_sh_lines>");
("stat", (RStat "statbuf", [String "path"]), 52, [],
[InitBasicFS, Always, TestOutputStruct (
@@ -1466,8 +1504,7 @@ This is the same as the C<lstat(2)> system call.");
("statvfs", (RStatVFS "statbuf", [String "path"]), 54, [],
[InitBasicFS, Always, TestOutputStruct (
- [["statvfs"; "/"]], [CompareWithInt ("bfree", 487702);
- CompareWithInt ("blocks", 490020);
+ [["statvfs"; "/"]], [CompareWithInt ("namemax", 255);
CompareWithInt ("bsize", 1024)])],
"get file system statistics",
"\
@@ -1788,7 +1825,7 @@ to find out what you can do.");
("lvremove", (RErr, [String "device"]), 77, [],
[InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV1"; "VG"; "50"];
@@ -1796,7 +1833,7 @@ to find out what you can do.");
["lvremove"; "/dev/VG/LV1"];
["lvs"]], ["/dev/VG/LV2"]);
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV1"; "VG"; "50"];
@@ -1804,7 +1841,7 @@ to find out what you can do.");
["lvremove"; "/dev/VG"];
["lvs"]], []);
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV1"; "VG"; "50"];
@@ -1821,7 +1858,7 @@ the VG name, C</dev/VG>.");
("vgremove", (RErr, [String "vgname"]), 78, [],
[InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV1"; "VG"; "50"];
@@ -1829,7 +1866,7 @@ the VG name, C</dev/VG>.");
["vgremove"; "VG"];
["lvs"]], []);
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV1"; "VG"; "50"];
@@ -1845,7 +1882,7 @@ group (if any).");
("pvremove", (RErr, [String "device"]), 79, [],
[InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV1"; "VG"; "50"];
@@ -1854,7 +1891,7 @@ group (if any).");
["pvremove"; "/dev/sda1"];
["lvs"]], []);
InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV1"; "VG"; "50"];
@@ -1863,7 +1900,7 @@ group (if any).");
["pvremove"; "/dev/sda1"];
["vgs"]], []);
InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV1"; "VG"; "50"];
@@ -1978,10 +2015,15 @@ This command writes zeroes over the first few blocks of C<device>.
How many blocks are zeroed isn't specified (but it's I<not> enough
to securely wipe the device). It should be sufficient to remove
-any partition tables, filesystem superblocks and so on.");
+any partition tables, filesystem superblocks and so on.
+
+See also: C<guestfs_scrub_device>.");
("grub_install", (RErr, [String "root"; String "device"]), 86, [],
- [InitBasicFS, Always, TestOutputTrue (
+ (* Test disabled because grub-install incompatible with virtio-blk driver.
+ * See also: https://bugzilla.redhat.com/show_bug.cgi?id=479760
+ *)
+ [InitBasicFS, Disabled, TestOutputTrue (
[["grub_install"; "/"; "/dev/sda1"];
["is_dir"; "/boot"]])],
"install GRUB",
@@ -2125,7 +2167,13 @@ The returned strings are transcoded to UTF-8.");
("hexdump", (RString "dump", [String "path"]), 96, [ProtocolLimitWarning],
[InitBasicFS, Always, TestOutput (
[["write_file"; "/new"; "hello\nworld\n"; "12"];
- ["hexdump"; "/new"]], "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n")],
+ ["hexdump"; "/new"]], "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n");
+ (* Test for RHBZ#501888c2 regression which caused large hexdump
+ * commands to segfault.
+ *)
+ InitBasicFS, Always, TestRun (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["hexdump"; "/100krandom"]])],
"dump a file in hexadecimal",
"\
This runs C<hexdump -C> on the given C<path>. The result is
@@ -2133,7 +2181,7 @@ the human-readable, canonical hex dump of the file.");
("zerofree", (RErr, [String "device"]), 97, [],
[InitNone, Always, TestOutput (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["mkfs"; "ext3"; "/dev/sda1"];
["mount"; "/dev/sda1"; "/"];
["write_file"; "/new"; "test file"; "0"];
@@ -2161,7 +2209,7 @@ or data on the filesystem.");
This resizes (expands or shrinks) an existing LVM physical
volume to match the new size of the underlying device.");
- ("sfdisk_N", (RErr, [String "device"; Int "n";
+ ("sfdisk_N", (RErr, [String "device"; Int "partnum";
Int "cyls"; Int "heads"; Int "sectors";
String "line"]), 99, [DangerWillRobinson],
[],
@@ -2231,7 +2279,7 @@ are activated or deactivated.");
("lvresize", (RErr, [String "device"; Int "mbytes"]), 105, [],
[InitNone, Always, TestOutput (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV"; "VG"; "10"];
@@ -2322,11 +2370,11 @@ Sleep for C<secs> seconds.");
("ntfs_3g_probe", (RInt "status", [Bool "rw"; String "device"]), 110, [],
[InitNone, Always, TestOutputInt (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["mkfs"; "ntfs"; "/dev/sda1"];
["ntfs_3g_probe"; "true"; "/dev/sda1"]], 0);
InitNone, Always, TestOutputInt (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ [["sfdiskM"; "/dev/sda"; ","];
["mkfs"; "ext2"; "/dev/sda1"];
["ntfs_3g_probe"; "true"; "/dev/sda1"]], 12)],
"probe NTFS volume",
@@ -2343,6 +2391,394 @@ The return value is an integer which C<0> if the operation
would succeed, or some non-zero value documented in the
L<ntfs-3g.probe(8)> manual page.");
+ ("sh", (RString "output", [String "command"]), 111, [],
+ [], (* XXX needs tests *)
+ "run a command via the shell",
+ "\
+This call runs a command from the guest filesystem via the
+guest's C</bin/sh>.
+
+This is like C<guestfs_command>, but passes the command to:
+
+ /bin/sh -c \"command\"
+
+Depending on the guest's shell, this usually results in
+wildcards being expanded, shell expressions being interpolated
+and so on.
+
+All the provisos about C<guestfs_command> apply to this call.");
+
+ ("sh_lines", (RStringList "lines", [String "command"]), 112, [],
+ [], (* XXX needs tests *)
+ "run a command via the shell returning lines",
+ "\
+This is the same as C<guestfs_sh>, but splits the result
+into a list of lines.
+
+See also: C<guestfs_command_lines>");
+
+ ("glob_expand", (RStringList "paths", [String "pattern"]), 113, [],
+ [InitBasicFS, Always, TestOutputList (
+ [["mkdir_p"; "/a/b/c"];
+ ["touch"; "/a/b/c/d"];
+ ["touch"; "/a/b/c/e"];
+ ["glob_expand"; "/a/b/c/*"]], ["/a/b/c/d"; "/a/b/c/e"]);
+ InitBasicFS, Always, TestOutputList (
+ [["mkdir_p"; "/a/b/c"];
+ ["touch"; "/a/b/c/d"];
+ ["touch"; "/a/b/c/e"];
+ ["glob_expand"; "/a/*/c/*"]], ["/a/b/c/d"; "/a/b/c/e"]);
+ InitBasicFS, Always, TestOutputList (
+ [["mkdir_p"; "/a/b/c"];
+ ["touch"; "/a/b/c/d"];
+ ["touch"; "/a/b/c/e"];
+ ["glob_expand"; "/a/*/x/*"]], [])],
+ "expand a wildcard path",
+ "\
+This command searches for all the pathnames matching
+C<pattern> according to the wildcard expansion rules
+used by the shell.
+
+If no paths match, then this returns an empty list
+(note: not an error).
+
+It is just a wrapper around the C L<glob(3)> function
+with flags C<GLOB_MARK|GLOB_BRACE>.
+See that manual page for more details.");
+
+ ("scrub_device", (RErr, [String "device"]), 114, [DangerWillRobinson],
+ [InitNone, Always, TestRun ( (* use /dev/sdc because it's smaller *)
+ [["scrub_device"; "/dev/sdc"]])],
+ "scrub (securely wipe) a device",
+ "\
+This command writes patterns over C<device> to make data retrieval
+more difficult.
+
+It is an interface to the L<scrub(1)> program. See that
+manual page for more details.");
+
+ ("scrub_file", (RErr, [String "file"]), 115, [],
+ [InitBasicFS, Always, TestRun (
+ [["write_file"; "/file"; "content"; "0"];
+ ["scrub_file"; "/file"]])],
+ "scrub (securely wipe) a file",
+ "\
+This command writes patterns over a file to make data retrieval
+more difficult.
+
+The file is I<removed> after scrubbing.
+
+It is an interface to the L<scrub(1)> program. See that
+manual page for more details.");
+
+ ("scrub_freespace", (RErr, [String "dir"]), 116, [],
+ [], (* XXX needs testing *)
+ "scrub (securely wipe) free space",
+ "\
+This command creates the directory C<dir> and then fills it
+with files until the filesystem is full, and scrubs the files
+as for C<guestfs_scrub_file>, and deletes them.
+The intention is to scrub any free space on the partition
+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, [],
+ [InitBasicFS, Always, TestRun (
+ [["mkdir"; "/tmp"];
+ ["mkdtemp"; "/tmp/tmpXXXXXX"]])],
+ "create a temporary directory",
+ "\
+This command creates a temporary directory. The
+C<template> parameter should be a full pathname for the
+temporary directory name with the final six characters being
+\"XXXXXX\".
+
+For example: \"/tmp/myprogXXXXXX\" or \"/Temp/myprogXXXXXX\",
+the second one being suitable for Windows filesystems.
+
+The name of the temporary directory that was created
+is returned.
+
+The temporary directory is created with mode 0700
+and is owned by root.
+
+The caller is responsible for deleting the temporary
+directory and its contents after use.
+
+See also: L<mkdtemp(3)>");
+
+ ("wc_l", (RInt "lines", [String "path"]), 118, [],
+ [InitBasicFS, Always, TestOutputInt (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["wc_l"; "/10klines"]], 10000)],
+ "count lines in a file",
+ "\
+This command counts the lines in a file, using the
+C<wc -l> external command.");
+
+ ("wc_w", (RInt "words", [String "path"]), 119, [],
+ [InitBasicFS, Always, TestOutputInt (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["wc_w"; "/10klines"]], 10000)],
+ "count words in a file",
+ "\
+This command counts the words in a file, using the
+C<wc -w> external command.");
+
+ ("wc_c", (RInt "chars", [String "path"]), 120, [],
+ [InitBasicFS, Always, TestOutputInt (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["wc_c"; "/100kallspaces"]], 102400)],
+ "count characters in a file",
+ "\
+This command counts the characters in a file, using the
+C<wc -c> external command.");
+
+ ("head", (RStringList "lines", [String "path"]), 121, [ProtocolLimitWarning],
+ [InitBasicFS, Always, TestOutputList (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["head"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz";"3abcdefghijklmnopqrstuvwxyz";"4abcdefghijklmnopqrstuvwxyz";"5abcdefghijklmnopqrstuvwxyz";"6abcdefghijklmnopqrstuvwxyz";"7abcdefghijklmnopqrstuvwxyz";"8abcdefghijklmnopqrstuvwxyz";"9abcdefghijklmnopqrstuvwxyz"])],
+ "return first 10 lines of a file",
+ "\
+This command returns up to the first 10 lines of a file as
+a list of strings.");
+
+ ("head_n", (RStringList "lines", [Int "nrlines"; String "path"]), 122, [ProtocolLimitWarning],
+ [InitBasicFS, Always, TestOutputList (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["head_n"; "3"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]);
+ InitBasicFS, Always, TestOutputList (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["head_n"; "-9997"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]);
+ InitBasicFS, Always, TestOutputList (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["head_n"; "0"; "/10klines"]], [])],
+ "return first N lines of a file",
+ "\
+If the parameter C<nrlines> is a positive number, this returns the first
+C<nrlines> lines of the file C<path>.
+
+If the parameter C<nrlines> is a negative number, this returns lines
+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],
+ [InitBasicFS, Always, TestOutputList (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["tail"; "/10klines"]], ["9990abcdefghijklmnopqrstuvwxyz";"9991abcdefghijklmnopqrstuvwxyz";"9992abcdefghijklmnopqrstuvwxyz";"9993abcdefghijklmnopqrstuvwxyz";"9994abcdefghijklmnopqrstuvwxyz";"9995abcdefghijklmnopqrstuvwxyz";"9996abcdefghijklmnopqrstuvwxyz";"9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"])],
+ "return last 10 lines of a file",
+ "\
+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],
+ [InitBasicFS, Always, TestOutputList (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["tail_n"; "3"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]);
+ InitBasicFS, Always, TestOutputList (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["tail_n"; "-9998"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]);
+ InitBasicFS, Always, TestOutputList (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["tail_n"; "0"; "/10klines"]], [])],
+ "return last N lines of a file",
+ "\
+If the parameter C<nrlines> is a positive number, this returns the last
+C<nrlines> lines of the file C<path>.
+
+If the parameter C<nrlines> is a negative number, this returns lines
+from the file C<path>, starting with the C<-nrlines>th line.
+
+If the parameter C<nrlines> is zero, this returns an empty list.");
+
+ ("df", (RString "output", []), 125, [],
+ [], (* XXX Tricky to test because it depends on the exact format
+ * of the 'df' command and other imponderables.
+ *)
+ "report file system disk space usage",
+ "\
+This command runs the C<df> command to report disk space used.
+
+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.");
+
+ ("df_h", (RString "output", []), 126, [],
+ [], (* XXX Tricky to test because it depends on the exact format
+ * of the 'df' command and other imponderables.
+ *)
+ "report file system disk space usage (human readable)",
+ "\
+This command runs the C<df -h> command to report disk space used
+in human-readable format.
+
+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, [],
+ [InitBasicFS, Always, TestOutputInt (
+ [["mkdir"; "/p"];
+ ["du"; "/p"]], 1 (* ie. 1 block, so depends on ext3 blocksize *))],
+ "estimate file space usage",
+ "\
+This command runs the C<du -s> command to estimate file space
+usage for C<path>.
+
+C<path> can be a file or a directory. If C<path> is a directory
+then the estimate includes the contents of the directory and all
+subdirectories (recursively).
+
+The result is the estimated size in I<kilobytes>
+(ie. units of 1024 bytes).");
+
+ ("initrd_list", (RStringList "filenames", [String "path"]), 128, [],
+ [InitBasicFS, Always, TestOutputList (
+ [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"];
+ ["initrd_list"; "/initrd"]], ["empty";"known-1";"known-2";"known-3"])],
+ "list files in an initrd",
+ "\
+This command lists out files contained in an initrd.
+
+The files are listed without any initial C</> character. The
+files are listed in the order they appear (not necessarily
+alphabetical). Directory names are listed as separate items.
+
+Old Linux kernels (2.4 and earlier) used a compressed ext2
+filesystem as initrd. We I<only> support the newer initramfs
+format (compressed cpio files).");
+
+ ("mount_loop", (RErr, [String "file"; String "mountpoint"]), 129, [],
+ [],
+ "mount a file using the loop device",
+ "\
+This command lets you mount C<file> (a filesystem image
+in a file) on a mount point. It is entirely equivalent to
+the command C<mount -o loop file mountpoint>.");
+
+ ("mkswap", (RErr, [String "device"]), 130, [],
+ [InitEmpty, Always, TestRun (
+ [["sfdiskM"; "/dev/sda"; ","];
+ ["mkswap"; "/dev/sda1"]])],
+ "create a swap partition",
+ "\
+Create a swap partition on C<device>.");
+
+ ("mkswap_L", (RErr, [String "label"; String "device"]), 131, [],
+ [InitEmpty, Always, TestRun (
+ [["sfdiskM"; "/dev/sda"; ","];
+ ["mkswap_L"; "hello"; "/dev/sda1"]])],
+ "create a swap partition with a label",
+ "\
+Create a swap partition on C<device> with label C<label>.");
+
+ ("mkswap_U", (RErr, [String "uuid"; String "device"]), 132, [],
+ [InitEmpty, Always, TestRun (
+ [["sfdiskM"; "/dev/sda"; ","];
+ ["mkswap_U"; "a3a61220-882b-4f61-89f4-cf24dcc7297d"; "/dev/sda1"]])],
+ "create a swap partition with an explicit UUID",
+ "\
+Create a swap partition on C<device> with UUID C<uuid>.");
+
+ ("mknod", (RErr, [Int "mode"; Int "devmajor"; Int "devminor"; String "path"]), 133, [],
+ [InitBasicFS, Always, TestOutputStruct (
+ [["mknod"; "0o10777"; "0"; "0"; "/node"];
+ (* NB: default umask 022 means 0777 -> 0755 in these tests *)
+ ["stat"; "/node"]], [CompareWithInt ("mode", 0o10755)]);
+ InitBasicFS, Always, TestOutputStruct (
+ [["mknod"; "0o60777"; "66"; "99"; "/node"];
+ ["stat"; "/node"]], [CompareWithInt ("mode", 0o60755)])],
+ "make block, character or FIFO devices",
+ "\
+This call creates block or character special devices, or
+named pipes (FIFOs).
+
+The C<mode> parameter should be the mode, using the standard
+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, [],
+ [InitBasicFS, Always, TestOutputStruct (
+ [["mkfifo"; "0o777"; "/node"];
+ ["stat"; "/node"]], [CompareWithInt ("mode", 0o10755)])],
+ "make FIFO (named pipe)",
+ "\
+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, [],
+ [InitBasicFS, Always, TestOutputStruct (
+ [["mknod_b"; "0o777"; "99"; "66"; "/node"];
+ ["stat"; "/node"]], [CompareWithInt ("mode", 0o60755)])],
+ "make block device node",
+ "\
+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, [],
+ [InitBasicFS, Always, TestOutputStruct (
+ [["mknod_c"; "0o777"; "99"; "66"; "/node"];
+ ["stat"; "/node"]], [CompareWithInt ("mode", 0o20755)])],
+ "make char device node",
+ "\
+This call creates a char 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>.");
+
+ ("umask", (RInt "oldmask", [Int "mask"]), 137, [],
+ [], (* XXX umask is one of those stateful things that we should
+ * reset between each test.
+ *)
+ "set file mode creation mask (umask)",
+ "\
+This function sets the mask used for creating new files and
+device nodes to C<mask & 0777>.
+
+Typical umask values would be C<022> which creates new files
+with permissions like \"-rw-r--r--\" or \"-rwxr-xr-x\", and
+C<002> which creates new files with permissions like
+\"-rw-rw-r--\" or \"-rwxrwxr-x\".
+
+The default umask is C<022>. This is important because it
+means that directories and device nodes will be created with
+C<0644> or C<0755> mode even if you specify C<0777>.
+
+See also L<umask(2)>, C<guestfs_mknod>, C<guestfs_mkdir>.
+
+This call returns the previous umask.");
+
+ ("readdir", (RDirentList "entries", [String "dir"]), 138, [],
+ [],
+ "read directories entries",
+ "\
+This returns the list of directory entries in directory C<dir>.
+
+All entries in the directory are returned, including C<.> and
+C<..>. The entries are I<not> sorted, but returned in the same
+order as the underlying filesystem.
+
+This function is primarily intended for use by programs. To
+get a simple list of names, use C<guestfs_ls>. To get a printable
+directory for human consumption, use C<guestfs_ll>.");
+
+ ("sfdiskM", (RErr, [String "device"; StringList "lines"]), 139, [DangerWillRobinson],
+ [],
+ "create partitions on a block device",
+ "\
+This is a simplified interface to the C<guestfs_sfdisk>
+command, where partition sizes are specified in megabytes
+only (rounded to the nearest cylinder) and you don't need
+to specify the cyls, heads and sectors parameters which
+were rarely if ever used anyway.
+
+See also C<guestfs_sfdisk> and the L<sfdisk(8)> manpage.");
+
]
let all_functions = non_daemon_functions @ daemon_functions
@@ -2450,6 +2886,13 @@ let statvfs_cols = [
"namemax", `Int;
]
+(* Column names in dirent structure. *)
+let dirent_cols = [
+ "ino", `Int;
+ "ftyp", `Char; (* 'b' 'c' 'd' 'f' (FIFO) 'l' 'r' (regular file) 's' 'u' '?' *)
+ "name", `String;
+]
+
(* Used for testing language bindings. *)
type callt =
| CallString of string
@@ -2458,6 +2901,17 @@ type callt =
| CallInt of int
| CallBool of bool
+(* Used to memoize the result of pod2text. *)
+let pod2text_memo_filename = "src/.pod2text.data"
+let pod2text_memo : ((int * string * string), string list) Hashtbl.t =
+ try
+ let chan = open_in pod2text_memo_filename in
+ let v = input_value chan in
+ close_in chan;
+ v
+ with
+ _ -> Hashtbl.create 13
+
(* Useful functions.
* Note we don't want to use any external OCaml libraries which
* makes this a bit harder than it should be.
@@ -2623,8 +3077,8 @@ let check_functions () =
failwithf "%s has a param/ret called 'value', which causes conflicts in the OCaml bindings, use something like 'val' or a more descriptive name" name;
if n = "int" || n = "char" || n = "short" || n = "long" then
failwithf "%s has a param/ret which conflicts with a C type (eg. 'int', 'char' etc.)" name;
- if n = "i" then
- failwithf "%s has a param/ret called 'i', which will cause some conflicts in the generated code" name;
+ if n = "i" || n = "n" then
+ failwithf "%s has a param/ret called 'i' or 'n', which will cause some conflicts in the generated code" name;
if n = "argv" || n = "args" then
failwithf "%s has a param/ret called 'argv' or 'args', which will cause some conflicts in the generated code" name
in
@@ -2634,7 +3088,8 @@ let check_functions () =
| RInt n | RInt64 n | RBool n | RConstString n | RString n
| RStringList n | RPVList n | RVGList n | RLVList n
| RStat n | RStatVFS n
- | RHashtable n ->
+ | RHashtable n
+ | RDirentList n ->
check_arg_ret_name n
| RIntBool (n,m) ->
check_arg_ret_name n;
@@ -2839,6 +3294,11 @@ strings, or NULL if there was an error.
The array of strings will always have length C<2n+1>, where
C<n> keys and values alternate, followed by the trailing NULL entry.
I<The caller must free the strings and the array after use>.\n\n"
+ | RDirentList _ ->
+ pr "This function returns a C<struct guestfs_dirent_list *>
+(see E<lt>guestfs-structs.hE<gt>),
+or NULL if there was an error.
+I<The caller must call C<guestfs_free_dirent_list> after use>.\n\n"
);
if List.mem ProtocolLimitWarning flags then
pr "%s\n\n" protocol_limit_warning;
@@ -2875,7 +3335,41 @@ and generate_structs_pod () =
pr " void guestfs_free_lvm_%s_list (struct guestfs_free_lvm_%s_list *);\n"
typ typ;
pr "\n"
- ) ["pv", pv_cols; "vg", vg_cols; "lv", lv_cols]
+ ) ["pv", pv_cols; "vg", vg_cols; "lv", lv_cols];
+
+ (* Stat *)
+ List.iter (
+ fun (typ, cols) ->
+ pr "=head2 guestfs_%s\n" typ;
+ pr "\n";
+ pr " struct guestfs_%s {\n" typ;
+ List.iter (
+ function
+ | name, `Int -> pr " int64_t %s;\n" name
+ ) cols;
+ pr " };\n";
+ pr "\n";
+ ) [ "stat", stat_cols; "statvfs", statvfs_cols ];
+
+ (* DirentList *)
+ pr "=head2 guestfs_dirent\n";
+ pr "\n";
+ pr " struct guestfs_dirent {\n";
+ List.iter (
+ function
+ | name, `String -> pr " char *%s;\n" name
+ | name, `Int -> pr " int64_t %s;\n" name
+ | name, `Char -> pr " char %s;\n" name
+ ) dirent_cols;
+ pr " };\n";
+ pr "\n";
+ pr " struct guestfs_dirent_list {\n";
+ pr " uint32_t len; /* Number of elements in list. */\n";
+ pr " struct guestfs_dirent *val; /* Elements. */\n";
+ pr " };\n";
+ pr " \n";
+ pr " void guestfs_free_dirent_list (struct guestfs_free_dirent_list *);\n";
+ pr "\n"
(* Generate the protocol (XDR) file, 'guestfs_protocol.x' and
* indirectly 'guestfs_protocol.h' and 'guestfs_protocol.c'.
@@ -2922,6 +3416,18 @@ and generate_xdr () =
pr "\n";
) ["stat", stat_cols; "statvfs", statvfs_cols];
+ (* Dirent structures. *)
+ pr "struct guestfs_int_dirent {\n";
+ List.iter (function
+ | name, `Int -> pr " hyper %s;\n" name
+ | name, `Char -> pr " char %s;\n" name
+ | name, `String -> pr " string %s<>;\n" name
+ ) dirent_cols;
+ pr "};\n";
+ pr "\n";
+ pr "typedef struct guestfs_int_dirent guestfs_int_dirent_list<>;\n";
+ pr "\n";
+
List.iter (
fun (shortname, style, _, _, _, _, _) ->
let name = "guestfs_" ^ shortname in
@@ -2994,6 +3500,10 @@ and generate_xdr () =
pr "struct %s_ret {\n" name;
pr " str %s<>;\n" n;
pr "};\n\n"
+ | RDirentList n ->
+ pr "struct %s_ret {\n" name;
+ pr " guestfs_int_dirent_list %s;\n" n;
+ pr "};\n\n"
);
) daemon_functions;
@@ -3121,7 +3631,23 @@ and generate_structs_h () =
) cols;
pr "};\n";
pr "\n"
- ) ["stat", stat_cols; "statvfs", statvfs_cols]
+ ) ["stat", stat_cols; "statvfs", statvfs_cols];
+
+ (* Dirent structures. *)
+ pr "struct guestfs_dirent {\n";
+ List.iter (
+ function
+ | name, `Int -> pr " int64_t %s;\n" name
+ | name, `Char -> pr " char %s;\n" name
+ | name, `String -> pr " char *%s;\n" name
+ ) dirent_cols;
+ pr "};\n";
+ pr "\n";
+ pr "struct guestfs_dirent_list {\n";
+ pr " uint32_t len;\n";
+ pr " struct guestfs_dirent *val;\n";
+ pr "};\n";
+ pr "\n"
(* Generate the guestfs-actions.h file. *)
and generate_actions_h () =
@@ -3229,7 +3755,8 @@ check_state (guestfs_h *g, const char *caller)
| RIntBool _
| RPVList _ | RVGList _ | RLVList _
| RStat _ | RStatVFS _
- | RHashtable _ ->
+ | RHashtable _
+ | RDirentList _ ->
pr " struct %s_ret ret;\n" name
);
pr "};\n";
@@ -3272,7 +3799,8 @@ check_state (guestfs_h *g, const char *caller)
| RIntBool _
| RPVList _ | RVGList _ | RLVList _
| RStat _ | RStatVFS _
- | RHashtable _ ->
+ | RHashtable _
+ | RDirentList _ ->
pr " if (!xdr_%s_ret (xdr, &ctx->ret)) {\n" name;
pr " error (g, \"%%s: failed to parse reply\", \"%s\");\n" name;
pr " return;\n";
@@ -3295,7 +3823,8 @@ check_state (guestfs_h *g, const char *caller)
| RString _ | RStringList _ | RIntBool _
| RPVList _ | RVGList _ | RLVList _
| RStat _ | RStatVFS _
- | RHashtable _ ->
+ | RHashtable _
+ | RDirentList _ ->
"NULL" in
pr "{\n";
@@ -3431,7 +3960,8 @@ check_state (guestfs_h *g, const char *caller)
pr " /* caller with free this */\n";
pr " return safe_memdup (g, &ctx.ret, sizeof (ctx.ret));\n"
| RPVList n | RVGList n | RLVList n
- | RStat n | RStatVFS n ->
+ | RStat n | RStatVFS n
+ | RDirentList n ->
pr " /* caller will free this */\n";
pr " return safe_memdup (g, &ctx.ret.%s, sizeof (ctx.ret.%s));\n" n n
);
@@ -3491,7 +4021,8 @@ and generate_daemon_actions () =
| RVGList _ -> pr " guestfs_lvm_int_vg_list *r;\n"; "NULL"
| RLVList _ -> pr " guestfs_lvm_int_lv_list *r;\n"; "NULL"
| RStat _ -> pr " guestfs_int_stat *r;\n"; "NULL"
- | RStatVFS _ -> pr " guestfs_int_statvfs *r;\n"; "NULL" in
+ | RStatVFS _ -> pr " guestfs_int_statvfs *r;\n"; "NULL"
+ | RDirentList _ -> pr " guestfs_int_dirent_list *r;\n"; "NULL" in
(match snd style with
| [] -> ()
@@ -3592,7 +4123,8 @@ and generate_daemon_actions () =
name;
pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_ret, (char *) r);\n" name
| RPVList n | RVGList n | RLVList n
- | RStat n | RStatVFS n ->
+ | RStat n | RStatVFS n
+ | RDirentList n ->
pr " struct guestfs_%s_ret ret;\n" name;
pr " ret.%s = *r;\n" n;
pr " reply ((xdrproc_t) xdr_guestfs_%s_ret, (char *) &ret);\n"
@@ -3627,7 +4159,7 @@ and generate_daemon_actions () =
) daemon_functions;
pr " default:\n";
- pr " reply_with_error (\"dispatch_incoming_message: unknown procedure number %%d\", proc_nr);\n";
+ pr " reply_with_error (\"dispatch_incoming_message: unknown procedure number %%d, set LIBGUESTFS_PATH to point to the matching libguestfs appliance directory\", proc_nr);\n";
pr " }\n";
pr "}\n";
pr "\n";
@@ -3798,6 +4330,22 @@ and generate_daemon_actions () =
) ["pv", pv_cols; "vg", vg_cols; "lv", lv_cols]
+(* Generate a list of function names, for debugging in the daemon.. *)
+and generate_daemon_names () =
+ generate_header CStyle GPLv2;
+
+ pr "#include <config.h>\n";
+ pr "\n";
+ pr "#include \"daemon.h\"\n";
+ pr "\n";
+
+ pr "/* This array is indexed by proc_nr. See guestfs_protocol.x. */\n";
+ pr "const char *function_names[] = {\n";
+ List.iter (
+ fun (name, _, proc_nr, _, _, _, _) -> pr " [%d] = \"%s\",\n" proc_nr name
+ ) daemon_functions;
+ pr "};\n";
+
(* Generate the tests. *)
and generate_tests () =
generate_header CStyle GPLv2;
@@ -3875,6 +4423,8 @@ int main (int argc, char *argv[])
int fd;
int nr_tests, test_num = 0;
+ setbuf (stdout, NULL);
+
no_test_warnings ();
g = guestfs_create ();
@@ -3980,11 +4530,18 @@ int main (int argc, char *argv[])
printf (\"guestfs_launch FAILED\\n\");
exit (1);
}
+
+ /* Set a timeout in case qemu hangs during launch (RHBZ#505329). */
+ alarm (600);
+
if (guestfs_wait_ready (g) == -1) {
printf (\"guestfs_wait_ready FAILED\\n\");
exit (1);
}
+ /* Cancel previous alarm. */
+ alarm (0);
+
nr_tests = %d;
" (500 * 1024 * 1024) (50 * 1024 * 1024) (10 * 1024 * 1024) nr_tests;
@@ -4023,6 +4580,9 @@ static int %s_skip (void)
{
const char *str;
+ str = getenv (\"TEST_ONLY\");
+ if (str)
+ return strstr (str, \"%s\") == NULL;
str = getenv (\"SKIP_%s\");
if (str && strcmp (str, \"1\") == 0) return 1;
str = getenv (\"SKIP_TEST_%s\");
@@ -4030,7 +4590,7 @@ static int %s_skip (void)
return 0;
}
-" test_name (String.uppercase test_name) (String.uppercase name);
+" test_name name (String.uppercase test_name) (String.uppercase name);
(match prereq with
| Disabled | Always -> ()
@@ -4046,7 +4606,7 @@ static int %s_skip (void)
static int %s (void)
{
if (%s_skip ()) {
- printf (\"%%s skipped (reason: SKIP_TEST_* variable set)\\n\", \"%s\");
+ printf (\" %%s skipped (reason: environment variable set)\\n\", \"%s\");
return 0;
}
@@ -4054,17 +4614,17 @@ static int %s (void)
(match prereq with
| Disabled ->
- pr " printf (\"%%s skipped (reason: test disabled in generator)\\n\", \"%s\");\n" test_name
+ pr " printf (\" %%s skipped (reason: test disabled in generator)\\n\", \"%s\");\n" test_name
| If _ ->
pr " if (! %s_prereq ()) {\n" test_name;
- pr " printf (\"%%s skipped (reason: test prerequisite)\\n\", \"%s\");\n" test_name;
+ pr " printf (\" %%s skipped (reason: test prerequisite)\\n\", \"%s\");\n" test_name;
pr " return 0;\n";
pr " }\n";
pr "\n";
generate_one_test_body name i test_name init test;
| Unless _ ->
pr " if (%s_prereq ()) {\n" test_name;
- pr " printf (\"%%s skipped (reason: test prerequisite)\\n\", \"%s\");\n" test_name;
+ pr " printf (\" %%s skipped (reason: test prerequisite)\\n\", \"%s\");\n" test_name;
pr " return 0;\n";
pr " }\n";
pr "\n";
@@ -4093,7 +4653,7 @@ and generate_one_test_body name i test_name init test =
[["blockdev_setrw"; "/dev/sda"];
["umount_all"];
["lvm_remove_all"];
- ["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ ["sfdiskM"; "/dev/sda"; ","];
["mkfs"; "ext2"; "/dev/sda1"];
["mount"; "/dev/sda1"; "/"]]
| InitBasicFSonLVM ->
@@ -4103,7 +4663,7 @@ and generate_one_test_body name i test_name init test =
[["blockdev_setrw"; "/dev/sda"];
["umount_all"];
["lvm_remove_all"];
- ["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
+ ["sfdiskM"; "/dev/sda"; ","];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["lvcreate"; "LV"; "VG"; "8"];
@@ -4361,7 +4921,9 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd =
| RStat _ ->
pr " struct guestfs_stat *r;\n"; "NULL"
| RStatVFS _ ->
- pr " struct guestfs_statvfs *r;\n"; "NULL" in
+ pr " struct guestfs_statvfs *r;\n"; "NULL"
+ | RDirentList _ ->
+ pr " struct guestfs_dirent_list *r;\n"; "NULL" in
pr " suppress_error = %d;\n" (if expect_error then 1 else 0);
pr " r = guestfs_%s (g" name;
@@ -4417,6 +4979,8 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd =
pr " guestfs_free_lvm_lv_list (r);\n"
| RStat _ | RStatVFS _ ->
pr " free (r);\n"
+ | RDirentList _ ->
+ pr " guestfs_free_dirent_list (r);\n"
);
pr " }\n"
@@ -4572,6 +5136,29 @@ and generate_fish_cmds () =
pr "\n";
) ["stat", stat_cols; "statvfs", statvfs_cols];
+ (* print_dirent_list function *)
+ pr "static void print_dirent (struct guestfs_dirent *dirent)\n";
+ pr "{\n";
+ List.iter (
+ function
+ | name, `String ->
+ pr " printf (\"%s: %%s\\n\", dirent->%s);\n" name name
+ | name, `Int ->
+ pr " printf (\"%s: %%\" PRIi64 \"\\n\", dirent->%s);\n" name name
+ | name, `Char ->
+ pr " printf (\"%s: %%c\\n\", dirent->%s);\n" name name
+ ) dirent_cols;
+ pr "}\n";
+ pr "\n";
+ pr "static void print_dirent_list (struct guestfs_dirent_list *dirents)\n";
+ pr "{\n";
+ pr " int i;\n";
+ pr "\n";
+ pr " for (i = 0; i < dirents->len; ++i)\n";
+ pr " print_dirent (&dirents->val[i]);\n";
+ pr "}\n";
+ pr "\n";
+
(* run_<action> actions *)
List.iter (
fun (name, style, _, flags, _, _, _) ->
@@ -4591,6 +5178,7 @@ and generate_fish_cmds () =
| RLVList _ -> pr " struct guestfs_lvm_lv_list *r;\n"
| RStat _ -> pr " struct guestfs_stat *r;\n"
| RStatVFS _ -> pr " struct guestfs_statvfs *r;\n"
+ | RDirentList _ -> pr " struct guestfs_dirent_list *r;\n"
);
List.iter (
function
@@ -4705,6 +5293,11 @@ and generate_fish_cmds () =
pr " print_table (r);\n";
pr " free_strings (r);\n";
pr " return 0;\n"
+ | RDirentList _ ->
+ pr " if (r == NULL) return -1;\n";
+ pr " print_dirent_list (r);\n";
+ pr " guestfs_free_dirent_list (r);\n";
+ pr " return 0;\n"
);
pr "}\n";
pr "\n"
@@ -4796,6 +5389,8 @@ generator (const char *text, int state)
len = strlen (text);
}
+ rl_attempted_completion_over = 1;
+
while ((name = commands[index]) != NULL) {
index++;
if (strncasecmp (name, text, len) == 0)
@@ -4812,8 +5407,12 @@ char **do_completion (const char *text, int start, int end)
char **matches = NULL;
#ifdef HAVE_LIBREADLINE
+ rl_completion_append_character = ' ';
+
if (start == 0)
matches = rl_completion_matches (text, generator);
+ else if (complete_dest_paths)
+ matches = rl_completion_matches (text, complete_dest_paths_generator);
#endif
return matches;
@@ -4909,6 +5508,9 @@ and generate_prototype ?(extern = true) ?(static = false) ?(semicolon = true)
| RStatVFS _ ->
if not in_daemon then pr "struct guestfs_statvfs *"
else pr "guestfs_int_statvfs *"
+ | RDirentList _ ->
+ if not in_daemon then pr "struct guestfs_dirent_list *"
+ else pr "guestfs_int_dirent_list *"
);
pr "%s%s (" prefix name;
if handle = None && List.length (snd style) = 0 then
@@ -4990,6 +5592,8 @@ val close : t -> unit
generate_ocaml_stat_structure_decls ();
+ generate_ocaml_dirent_structure_decls ();
+
(* The actions. *)
List.iter (
fun (name, style, _, _, _, shortdesc, _) ->
@@ -5017,6 +5621,8 @@ let () =
generate_ocaml_stat_structure_decls ();
+ generate_ocaml_dirent_structure_decls ();
+
(* The actions. *)
List.iter (
fun (name, style, _, _, _, shortdesc, _) ->
@@ -5159,6 +5765,50 @@ copy_table (char * const * argv)
pr "\n";
) ["stat", stat_cols; "statvfs", statvfs_cols];
+ (* Dirent copy functions. *)
+ pr "static CAMLprim value\n";
+ pr "copy_dirent (const struct guestfs_dirent *dirent)\n";
+ pr "{\n";
+ pr " CAMLparam0 ();\n";
+ pr " CAMLlocal2 (rv, v);\n";
+ pr "\n";
+ pr " rv = caml_alloc (%d, 0);\n" (List.length dirent_cols);
+ iteri (
+ fun i col ->
+ (match col with
+ | name, `String ->
+ pr " v = caml_copy_string (dirent->%s);\n" name
+ | name, `Int ->
+ pr " v = caml_copy_int64 (dirent->%s);\n" name
+ | name, `Char ->
+ pr " v = Val_int (dirent->%s);\n" name
+ );
+ pr " Store_field (rv, %d, v);\n" i
+ ) dirent_cols;
+ pr " CAMLreturn (rv);\n";
+ pr "}\n";
+ pr "\n";
+
+ pr "static CAMLprim value\n";
+ pr "copy_dirent_list (const struct guestfs_dirent_list *dirents)\n";
+ pr "{\n";
+ pr " CAMLparam0 ();\n";
+ pr " CAMLlocal2 (rv, v);\n";
+ pr " int i;\n";
+ pr "\n";
+ pr " if (dirents->len == 0)\n";
+ pr " CAMLreturn (Atom (0));\n";
+ pr " else {\n";
+ pr " rv = caml_alloc (dirents->len, 0);\n";
+ pr " for (i = 0; i < dirents->len; ++i) {\n";
+ pr " v = copy_dirent (&dirents->val[i]);\n";
+ pr " caml_modify (&Field (rv, i), v);\n";
+ pr " }\n";
+ pr " CAMLreturn (rv);\n";
+ pr " }\n";
+ pr "}\n";
+ pr "\n";
+
(* The wrappers. *)
List.iter (
fun (name, style, _, _, _, _, _) ->
@@ -5233,7 +5883,9 @@ copy_table (char * const * argv)
| RHashtable _ ->
pr " int i;\n";
pr " char **r;\n";
- "NULL" in
+ "NULL"
+ | RDirentList _ ->
+ pr " struct guestfs_dirent_list *r;\n"; "NULL" in
pr "\n";
pr " caml_enter_blocking_section ();\n";
@@ -5291,6 +5943,9 @@ copy_table (char * const * argv)
pr " rv = copy_table (r);\n";
pr " for (i = 0; r[i] != NULL; ++i) free (r[i]);\n";
pr " free (r);\n";
+ | RDirentList _ ->
+ pr " rv = copy_dirent_list (r);\n";
+ pr " guestfs_free_dirent_list (r);\n";
);
pr " CAMLreturn (rv);\n";
@@ -5337,6 +5992,17 @@ and generate_ocaml_stat_structure_decls () =
pr "\n"
) ["stat", stat_cols; "statvfs", statvfs_cols]
+and generate_ocaml_dirent_structure_decls () =
+ pr "type dirent = {\n";
+ List.iter (
+ function
+ | name, `Int -> pr " %s : int64;\n" name
+ | name, `Char -> pr " %s : char;\n" name
+ | name, `String -> pr " %s : string;\n" name
+ ) dirent_cols;
+ pr "}\n";
+ pr "\n"
+
and generate_ocaml_prototype ?(is_external = false) name style =
if is_external then pr "external " else pr "val ";
pr "%s : t -> " name;
@@ -5363,6 +6029,7 @@ and generate_ocaml_prototype ?(is_external = false) name style =
| RStat _ -> pr "stat"
| RStatVFS _ -> pr "statvfs"
| RHashtable _ -> pr "(string * string) list"
+ | RDirentList _ -> pr "dirent array"
);
if is_external then (
pr " = ";
@@ -5479,7 +6146,8 @@ DESTROY (g)
| RIntBool _
| RPVList _ | RVGList _ | RLVList _
| RStat _ | RStatVFS _
- | RHashtable _ ->
+ | RHashtable _
+ | RDirentList _ ->
pr "void\n" (* all lists returned implictly on the stack *)
);
(* Call and arguments. *)
@@ -5620,6 +6288,9 @@ DESTROY (g)
| RStatVFS n ->
generate_perl_stat_code
"statvfs" statvfs_cols name style n do_cleanups
+ | RDirentList n ->
+ generate_perl_dirent_code
+ "dirent" dirent_cols name style n do_cleanups
);
pr "\n"
@@ -5658,7 +6329,7 @@ and generate_perl_lvm_code typ cols name style n do_cleanups =
pr " (void) hv_store (hv, \"%s\", %d, newSVnv (%s->val[i].%s), 0);\n"
name (String.length name) n name
) cols;
- pr " PUSHs (sv_2mortal ((SV *) hv));\n";
+ pr " PUSHs (sv_2mortal (newRV ((SV *) hv)));\n";
pr " }\n";
pr " guestfs_free_lvm_%s_list (%s);\n" typ n
@@ -5680,6 +6351,37 @@ and generate_perl_stat_code typ cols name style n do_cleanups =
) cols;
pr " free (%s);\n" n
+and generate_perl_dirent_code typ cols name style n do_cleanups =
+ pr "PREINIT:\n";
+ pr " struct guestfs_%s_list *%s;\n" typ n;
+ pr " int i;\n";
+ pr " HV *hv;\n";
+ pr " PPCODE:\n";
+ pr " %s = guestfs_%s " n name;
+ generate_call_args ~handle:"g" (snd style);
+ pr ";\n";
+ do_cleanups ();
+ pr " if (%s == NULL)\n" n;
+ pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name;
+ pr " EXTEND (SP, %s->len);\n" n;
+ pr " for (i = 0; i < %s->len; ++i) {\n" n;
+ pr " hv = newHV ();\n";
+ List.iter (
+ function
+ | name, `String ->
+ pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s, 0), 0);\n"
+ name (String.length name) n name
+ | name, `Int ->
+ pr " (void) hv_store (hv, \"%s\", %d, my_newSVull (%s->val[i].%s), 0);\n"
+ name (String.length name) n name
+ | name, `Char ->
+ pr " (void) hv_store (hv, \"%s\", %d, newSVpv (&%s->val[i].%s, 1), 0);\n"
+ name (String.length name) n name
+ ) cols;
+ pr " PUSHs (newRV (sv_2mortal ((SV *) hv)));\n";
+ pr " }\n";
+ pr " guestfs_free_%s_list (%s);\n" typ n
+
(* Generate Sys/Guestfs.pm. *)
and generate_perl_pm () =
generate_header HashStyle LGPLv2;
@@ -5813,7 +6515,8 @@ and generate_perl_prototype name style =
| RStringList n
| RPVList n
| RVGList n
- | RLVList n -> pr "@%s = " n
+ | RLVList n
+ | RDirentList n -> pr "@%s = " n
| RStat n
| RStatVFS n
| RHashtable n -> pr "%%%s = " n
@@ -6049,6 +6752,42 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr "\n";
) ["stat", stat_cols; "statvfs", statvfs_cols];
+ (* Dirent structures, turned into Python dictionaries. *)
+ pr "static PyObject *\n";
+ pr "put_dirent (struct guestfs_dirent *dirent)\n";
+ pr "{\n";
+ pr " PyObject *dict;\n";
+ pr "\n";
+ pr " dict = PyDict_New ();\n";
+ List.iter (
+ function
+ | name, `Int ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyLong_FromLongLong (dirent->%s));\n" name
+ | name, `Char ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyString_FromStringAndSize (&dirent->%s, 1));\n" name
+ | name, `String ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyString_FromString (dirent->%s));\n" name
+ ) dirent_cols;
+ pr " return dict;\n";
+ pr "};\n";
+ pr "\n";
+
+ pr "static PyObject *\n";
+ pr "put_dirent_list (struct guestfs_dirent_list *dirents)\n";
+ pr "{\n";
+ pr " PyObject *list;\n";
+ pr " int i;\n";
+ pr "\n";
+ pr " list = PyList_New (dirents->len);\n";
+ pr " for (i = 0; i < dirents->len; ++i)\n";
+ pr " PyList_SetItem (list, i, put_dirent (&dirents->val[i]));\n";
+ pr " return list;\n";
+ pr "};\n";
+ pr "\n";
+
(* Python wrapper functions. *)
List.iter (
fun (name, style, _, _, _, _, _) ->
@@ -6072,7 +6811,8 @@ py_guestfs_close (PyObject *self, PyObject *args)
| RVGList n -> pr " struct guestfs_lvm_vg_list *r;\n"; "NULL"
| RLVList n -> pr " struct guestfs_lvm_lv_list *r;\n"; "NULL"
| RStat n -> pr " struct guestfs_stat *r;\n"; "NULL"
- | RStatVFS n -> pr " struct guestfs_statvfs *r;\n"; "NULL" in
+ | RStatVFS n -> pr " struct guestfs_statvfs *r;\n"; "NULL"
+ | RDirentList n -> pr " struct guestfs_dirent_list *r;\n"; "NULL" in
List.iter (
function
@@ -6176,6 +6916,9 @@ py_guestfs_close (PyObject *self, PyObject *args)
| RHashtable n ->
pr " py_r = put_table (r);\n";
pr " free_strings (r);\n"
+ | RDirentList n ->
+ pr " py_r = put_dirent_list (r);\n";
+ pr " guestfs_free_dirent_list (r);\n"
);
pr " return py_r;\n";
@@ -6303,7 +7046,9 @@ class GuestFS:
| RStatVFS _ ->
doc ^ "\n\nThis function returns a dictionary, with keys matching the various fields in the statvfs structure."
| RHashtable _ ->
- doc ^ "\n\nThis function returns a dictionary." in
+ doc ^ "\n\nThis function returns a dictionary."
+ | RDirentList _ ->
+ doc ^ "\n\nThis function returns a list of directory entries. Each directory entry is represented as a dictionary." in
let doc =
if List.mem ProtocolLimitWarning flags then
doc ^ "\n\n" ^ protocol_limit_warning
@@ -6326,32 +7071,42 @@ class GuestFS:
(* Useful if you need the longdesc POD text as plain text. Returns a
* list of lines.
*
- * This is the slowest thing about autogeneration.
+ * Because this is very slow (the slowest part of autogeneration),
+ * we memoize the results.
*)
and pod2text ~width name longdesc =
- let filename, chan = Filename.open_temp_file "gen" ".tmp" in
- fprintf chan "=head1 %s\n\n%s\n" name longdesc;
- close_out chan;
- let cmd = sprintf "pod2text -w %d %s" width (Filename.quote filename) in
- let chan = Unix.open_process_in cmd in
- let lines = ref [] in
- let rec loop i =
- let line = input_line chan in
- if i = 1 then (* discard the first line of output *)
- loop (i+1)
- else (
- let line = triml line in
- lines := line :: !lines;
- loop (i+1)
- ) in
- let lines = try loop 1 with End_of_file -> List.rev !lines in
- Unix.unlink filename;
- match Unix.close_process_in chan with
- | Unix.WEXITED 0 -> lines
- | Unix.WEXITED i ->
- failwithf "pod2text: process exited with non-zero status (%d)" i
- | Unix.WSIGNALED i | Unix.WSTOPPED i ->
- failwithf "pod2text: process signalled or stopped by signal %d" i
+ let key = width, name, longdesc in
+ try Hashtbl.find pod2text_memo key
+ with Not_found ->
+ let filename, chan = Filename.open_temp_file "gen" ".tmp" in
+ fprintf chan "=head1 %s\n\n%s\n" name longdesc;
+ close_out chan;
+ let cmd = sprintf "pod2text -w %d %s" width (Filename.quote filename) in
+ let chan = Unix.open_process_in cmd in
+ let lines = ref [] in
+ let rec loop i =
+ let line = input_line chan in
+ if i = 1 then (* discard the first line of output *)
+ loop (i+1)
+ else (
+ let line = triml line in
+ lines := line :: !lines;
+ loop (i+1)
+ ) in
+ let lines = try loop 1 with End_of_file -> List.rev !lines in
+ Unix.unlink filename;
+ (match Unix.close_process_in chan with
+ | Unix.WEXITED 0 -> ()
+ | Unix.WEXITED i ->
+ failwithf "pod2text: process exited with non-zero status (%d)" i
+ | Unix.WSIGNALED i | Unix.WSTOPPED i ->
+ failwithf "pod2text: process signalled or stopped by signal %d" i
+ );
+ Hashtbl.add pod2text_memo key lines;
+ let chan = open_out pod2text_memo_filename in
+ output_value chan pod2text_memo;
+ close_out chan;
+ lines
(* Generate ruby bindings. *)
and generate_ruby_c () =
@@ -6428,6 +7183,7 @@ static VALUE ruby_guestfs_close (VALUE gv)
List.iter (
function
| 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;
pr " rb_raise (rb_eTypeError, \"expected string for parameter %%s of %%s\",\n";
@@ -6435,7 +7191,8 @@ static VALUE ruby_guestfs_close (VALUE gv)
| OptString n ->
pr " const char *%s = !NIL_P (%sv) ? StringValueCStr (%sv) : NULL;\n" n n n
| StringList n ->
- pr " char **%s;" n;
+ pr " char **%s;\n" n;
+ pr " Check_Type (%sv, T_ARRAY);\n" n;
pr " {\n";
pr " int i, len;\n";
pr " len = RARRAY_LEN (%sv);\n" n;
@@ -6466,7 +7223,8 @@ static VALUE ruby_guestfs_close (VALUE gv)
| RVGList n -> pr " struct guestfs_lvm_vg_list *r;\n"; "NULL"
| RLVList n -> pr " struct guestfs_lvm_lv_list *r;\n"; "NULL"
| RStat n -> pr " struct guestfs_stat *r;\n"; "NULL"
- | RStatVFS n -> pr " struct guestfs_statvfs *r;\n"; "NULL" in
+ | RStatVFS n -> pr " struct guestfs_statvfs *r;\n"; "NULL"
+ | RDirentList n -> pr " struct guestfs_dirent_list *r;\n"; "NULL" in
pr "\n";
pr " r = guestfs_%s " name;
@@ -6547,6 +7305,8 @@ static VALUE ruby_guestfs_close (VALUE gv)
pr " }\n";
pr " free (r);\n";
pr " return rv;\n"
+ | RDirentList n ->
+ generate_ruby_dirent_code "dirent" dirent_cols
);
pr "}\n";
@@ -6597,6 +7357,24 @@ and generate_ruby_lvm_code typ cols =
pr " guestfs_free_lvm_%s_list (r);\n" typ;
pr " return rv;\n"
+(* Ruby code to return a dirent struct list. *)
+and generate_ruby_dirent_code typ cols =
+ pr " VALUE rv = rb_ary_new2 (r->len);\n";
+ pr " int i;\n";
+ pr " for (i = 0; i < r->len; ++i) {\n";
+ pr " VALUE hv = rb_hash_new ();\n";
+ List.iter (
+ function
+ | name, `String ->
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), rb_str_new2 (r->val[i].%s));\n" name name
+ | name, (`Char|`Int) ->
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), ULL2NUM (r->val[i].%s));\n" name name
+ ) cols;
+ pr " rb_ary_push (rv, hv);\n";
+ pr " }\n";
+ pr " guestfs_free_%s_list (r);\n" typ;
+ pr " return rv;\n"
+
(* Generate Java bindings GuestFS.java file. *)
and generate_java_java () =
generate_header CStyle LGPLv2;
@@ -6612,6 +7390,7 @@ import com.redhat.et.libguestfs.LV;
import com.redhat.et.libguestfs.Stat;
import com.redhat.et.libguestfs.StatVFS;
import com.redhat.et.libguestfs.IntBool;
+import com.redhat.et.libguestfs.Dirent;
/**
* The GuestFS object is a libguestfs handle.
@@ -6735,6 +7514,7 @@ and generate_java_prototype ?(public=false) ?(privat=false) ?(native=false)
| RStat _ -> pr "Stat ";
| RStatVFS _ -> pr "StatVFS ";
| RHashtable _ -> pr "HashMap<String,String> ";
+ | RDirentList _ -> pr "Dirent[] ";
);
if native then pr "_%s " name else pr "%s " name;
@@ -6790,6 +7570,7 @@ public class %s {
| name, `UUID -> pr " public String %s;\n" name
| name, `Bytes
| name, `Int -> pr " public long %s;\n" name
+ | name, `Char -> pr " public char %s;\n" name
| name, `OptPercent ->
pr " /* The next field is [0..100] or -1 meaning 'not present': */\n";
pr " public float %s;\n" name
@@ -6856,7 +7637,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
| RConstString _ | RString _ -> pr "jstring ";
| RIntBool _ | RStat _ | RStatVFS _ | RHashtable _ ->
pr "jobject ";
- | RStringList _ | RPVList _ | RVGList _ | RLVList _ ->
+ | RStringList _ | RPVList _ | RVGList _ | RLVList _ | RDirentList _ ->
pr "jobjectArray ";
);
pr "JNICALL\n";
@@ -6930,7 +7711,13 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
pr " jfieldID fl;\n";
pr " jobject jfl;\n";
pr " struct guestfs_lvm_lv_list *r;\n"; "NULL", "NULL"
- | RHashtable _ -> pr " char **r;\n"; "NULL", "NULL" in
+ | RHashtable _ -> pr " char **r;\n"; "NULL", "NULL"
+ | RDirentList _ ->
+ pr " jobjectArray jr;\n";
+ pr " jclass cl;\n";
+ pr " jfieldID fl;\n";
+ pr " jobject jfl;\n";
+ pr " struct guestfs_dirent_list *r;\n"; "NULL", "NULL" in
List.iter (
function
| String n
@@ -6948,7 +7735,8 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
let needs_i =
(match fst style with
- | RStringList _ | RPVList _ | RVGList _ | RLVList _ -> true
+ | RStringList _ | RPVList _ | RVGList _ | RLVList _
+ | RDirentList _ -> true
| RErr | RBool _ | RInt _ | RInt64 _ | RConstString _
| RString _ | RIntBool _ | RStat _ | RStatVFS _
| RHashtable _ -> false) ||
@@ -7082,6 +7870,8 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
(* XXX *)
pr " throw_exception (env, \"%s: internal error: please let us know how to make a Java HashMap from JNI bindings!\");\n" name;
pr " return NULL;\n"
+ | RDirentList _ ->
+ generate_java_dirent_return "dirent" "Dirent" dirent_cols
);
pr "}\n";
@@ -7118,6 +7908,25 @@ and generate_java_lvm_return typ jtyp cols =
pr " guestfs_free_lvm_%s_list (r);\n" typ;
pr " return jr;\n"
+and generate_java_dirent_return typ jtyp cols =
+ pr " cl = (*env)->FindClass (env, \"com/redhat/et/libguestfs/%s\");\n" jtyp;
+ pr " jr = (*env)->NewObjectArray (env, r->len, cl, NULL);\n";
+ pr " for (i = 0; i < r->len; ++i) {\n";
+ pr " jfl = (*env)->AllocObject (env, cl);\n";
+ List.iter (
+ function
+ | name, `String ->
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\", \"Ljava/lang/String;\");\n" name;
+ pr " (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].%s));\n" name;
+ | name, (`Char|`Int) ->
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\", \"J\");\n" name;
+ pr " (*env)->SetLongField (env, jfl, fl, r->val[i].%s);\n" name;
+ ) cols;
+ pr " (*env)->SetObjectArrayElement (env, jfl, i, jfl);\n";
+ pr " }\n";
+ pr " guestfs_free_%s_list (r);\n" typ;
+ pr " return jr;\n"
+
and generate_haskell_hs () =
generate_header HaskellStyle LGPLv2;
@@ -7125,14 +7934,11 @@ and generate_haskell_hs () =
* at the moment. Please help out!
*)
let can_generate style =
- let check_no_bad_args =
- List.for_all (function Bool _ | Int _ -> false | _ -> true)
- in
match style with
- | RErr, args -> check_no_bad_args args
- | RBool _, _
+ | RErr, _
| RInt _, _
- | RInt64 _, _
+ | RInt64 _, _ -> true
+ | RBool _, _
| RConstString _, _
| RString _, _
| RStringList _, _
@@ -7142,7 +7948,8 @@ and generate_haskell_hs () =
| RLVList _, _
| RStat _, _
| RStatVFS _, _
- | RHashtable _, _ -> false in
+ | RHashtable _, _
+ | RDirentList _, _ -> false in
pr "\
{-# INCLUDE <guestfs.h> #-}
@@ -7161,6 +7968,7 @@ module Guestfs (
) where
import Foreign
import Foreign.C
+import Foreign.C.Types
import IO
import Control.Exception
import Data.Typeable
@@ -7224,6 +8032,7 @@ last_error h = do
pr "%s %s = do\n" name
(String.concat " " ("h" :: List.map name_of_argt (snd style)));
pr " r <- ";
+ (* Convert pointer arguments using with* functions. *)
List.iter (
function
| FileIn n
@@ -7231,17 +8040,18 @@ last_error h = do
| 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 n ->
- (* XXX this doesn't work *)
- pr " let\n";
- pr " %s = case %s of\n" n n;
- pr " False -> 0\n";
- pr " True -> 1\n";
- pr " in fromIntegral %s $ \\%s ->\n" n n
- | Int n -> pr "fromIntegral %s $ \\%s -> " n n
+ | Bool _ | Int _ -> ()
) (snd style);
+ (* Convert integer arguments. *)
+ let args =
+ List.map (
+ function
+ | Bool n -> sprintf "(fromBool %s)" n
+ | Int n -> sprintf "(fromIntegral %s)" n
+ | FileIn n | FileOut n | String n | OptString n | StringList n -> n
+ ) (snd style) in
pr "withForeignPtr h (\\p -> c_%s %s)\n" name
- (String.concat " " ("p" :: List.map name_of_argt (snd style)));
+ (String.concat " " ("p" :: args));
(match fst style with
| RErr | RInt _ | RInt64 _ | RBool _ ->
pr " if (r == -1)\n";
@@ -7250,7 +8060,7 @@ last_error h = do
pr " fail err\n";
| RConstString _ | RString _ | RStringList _ | RIntBool _
| RPVList _ | RVGList _ | RLVList _ | RStat _ | RStatVFS _
- | RHashtable _ ->
+ | RHashtable _ | RDirentList _ ->
pr " if (r == nullPtr)\n";
pr " then do\n";
pr " err <- last_error h\n";
@@ -7274,7 +8084,8 @@ last_error h = do
| RLVList _
| RStat _
| RStatVFS _
- | RHashtable _ ->
+ | RHashtable _
+ | RDirentList _ ->
pr " else return ()\n" (* XXXXXXXXXXXXXXXXXXXX *)
);
pr "\n";
@@ -7316,6 +8127,7 @@ and generate_haskell_prototype ~handle ?(hs = false) style =
| RStat _ -> pr "Stat"
| RStatVFS _ -> pr "StatVFS"
| RHashtable _ -> pr "Hashtable"
+ | RDirentList _ -> pr "[Dirent]"
);
pr ")"
@@ -7476,6 +8288,15 @@ print_strings (char * const* const argv)
pr " }\n";
pr " strs[n*2] = NULL;\n";
pr " return strs;\n"
+ | RDirentList _ ->
+ pr " struct guestfs_dirent_list *r;\n";
+ pr " int i;\n";
+ pr " r = malloc (sizeof (struct guestfs_dirent_list));\n";
+ pr " sscanf (val, \"%%d\", &r->len);\n";
+ pr " r->val = calloc (r->len, sizeof (struct guestfs_dirent));\n";
+ pr " for (i = 0; i < r->len; ++i)\n";
+ pr " r->val[i].ino = i;\n";
+ pr " return r;\n"
);
pr "}\n";
pr "\n"
@@ -7491,7 +8312,8 @@ print_strings (char * const* const argv)
| RConstString _
| RString _ | RStringList _ | RIntBool _
| RPVList _ | RVGList _ | RLVList _ | RStat _ | RStatVFS _
- | RHashtable _ ->
+ | RHashtable _
+ | RDirentList _ ->
pr " return NULL;\n"
);
pr "}\n";
@@ -7667,7 +8489,38 @@ public class Bindtests {
"
and generate_haskell_bindtests () =
- () (* XXX Haskell bindings need to be fleshed out. *)
+ generate_header HaskellStyle GPLv2;
+
+ pr "\
+module Bindtests where
+import qualified Guestfs
+
+main = do
+ g <- Guestfs.create
+";
+
+ let mkargs args =
+ String.concat " " (
+ List.map (
+ function
+ | CallString s -> "\"" ^ s ^ "\""
+ | CallOptString None -> "Nothing"
+ | CallOptString (Some s) -> sprintf "(Just \"%s\")" s
+ | CallStringList xs ->
+ "[" ^ String.concat "," (List.map (sprintf "\"%s\"") xs) ^ "]"
+ | CallInt i when i < 0 -> "(" ^ string_of_int i ^ ")"
+ | CallInt i -> string_of_int i
+ | CallBool true -> "True"
+ | CallBool false -> "False"
+ ) args
+ )
+ in
+
+ generate_lang_bindtests (
+ fun f args -> pr " Guestfs.%s g %s\n" f (mkargs args)
+ );
+
+ pr " putStrLn \"EOF\"\n"
(* Language-independent bindings tests - we do it this way to
* ensure there is parity in testing bindings across all languages.
@@ -7715,6 +8568,19 @@ and generate_lang_bindtests call =
(* XXX Add here tests of the return and error functions. *)
+(* This is used to generate the src/MAX_PROC_NR file which
+ * contains the maximum procedure number, a surrogate for the
+ * ABI version number. See src/Makefile.am for the details.
+ *)
+and generate_max_proc_nr () =
+ let proc_nrs = List.map (
+ fun (_, _, proc_nr, _, _, _, _) -> proc_nr
+ ) daemon_functions in
+
+ let max_proc_nr = List.fold_left max 0 proc_nrs in
+
+ pr "%d\n" max_proc_nr
+
let output_to filename =
let filename_new = filename ^ ".new" in
chan := open_out filename_new;
@@ -7772,6 +8638,10 @@ Run it from the top source directory using the command
generate_daemon_actions ();
close ();
+ let close = output_to "daemon/names.c" in
+ generate_daemon_names ();
+ close ();
+
let close = output_to "capitests/tests.c" in
generate_tests ();
close ();
@@ -7872,6 +8742,10 @@ Run it from the top source directory using the command
generate_java_struct "StatVFS" statvfs_cols;
close ();
+ let close = output_to "java/com/redhat/et/libguestfs/Dirent.java" in
+ generate_java_struct "Dirent" dirent_cols;
+ close ();
+
let close = output_to "java/com_redhat_et_libguestfs_GuestFS.c" in
generate_java_c ();
close ();
@@ -7884,6 +8758,17 @@ Run it from the top source directory using the command
generate_haskell_hs ();
close ();
- let close = output_to "haskell/bindtests.hs" in
+ let close = output_to "haskell/Bindtests.hs" in
generate_haskell_bindtests ();
close ();
+
+ let close = output_to "src/MAX_PROC_NR" in
+ generate_max_proc_nr ();
+ close ();
+
+ (* Always generate this file last, and unconditionally. It's used
+ * by the Makefile to know when we must re-run the generator.
+ *)
+ let chan = open_out "src/stamp-generator" in
+ fprintf chan "1\n";
+ close_out chan
diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c
deleted file mode 100644
index ecaa5662..00000000
--- a/src/guestfs-actions.c
+++ /dev/null
@@ -1,10076 +0,0 @@
-/* libguestfs generated file
- * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
- * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "guestfs.h"
-#include "guestfs_protocol.h"
-
-#define error guestfs_error
-#define perrorf guestfs_perrorf
-#define safe_malloc guestfs_safe_malloc
-#define safe_realloc guestfs_safe_realloc
-#define safe_strdup guestfs_safe_strdup
-#define safe_memdup guestfs_safe_memdup
-
-/* Check the return message from a call for validity. */
-static int
-check_reply_header (guestfs_h *g,
- const struct guestfs_message_header *hdr,
- int proc_nr, int serial)
-{
- if (hdr->prog != GUESTFS_PROGRAM) {
- error (g, "wrong program (%d/%d)", hdr->prog, GUESTFS_PROGRAM);
- return -1;
- }
- if (hdr->vers != GUESTFS_PROTOCOL_VERSION) {
- error (g, "wrong protocol version (%d/%d)",
- hdr->vers, GUESTFS_PROTOCOL_VERSION);
- return -1;
- }
- if (hdr->direction != GUESTFS_DIRECTION_REPLY) {
- error (g, "unexpected message direction (%d/%d)",
- hdr->direction, GUESTFS_DIRECTION_REPLY);
- return -1;
- }
- if (hdr->proc != proc_nr) {
- error (g, "unexpected procedure number (%d/%d)", hdr->proc, proc_nr);
- return -1;
- }
- if (hdr->serial != serial) {
- error (g, "unexpected serial (%d/%d)", hdr->serial, serial);
- return -1;
- }
-
- return 0;
-}
-
-/* Check we are in the right state to run a high-level action. */
-static int
-check_state (guestfs_h *g, const char *caller)
-{
- if (!guestfs_is_ready (g)) {
- if (guestfs_is_config (g))
- error (g, "%s: call launch() before using this function",
- caller);
- else if (guestfs_is_launching (g))
- error (g, "%s: call wait_ready() before using this function",
- caller);
- else
- error (g, "%s called from the wrong state, %d != READY",
- caller, guestfs_get_state (g));
- return -1;
- }
- return 0;
-}
-
-struct mount_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void mount_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mount_ctx *ctx = (struct mount_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_mount");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mount");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_mount");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mount (guestfs_h *g,
- const char *device,
- const char *mountpoint)
-{
- struct guestfs_mount_args args;
- struct mount_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mount") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- args.mountpoint = (char *) mountpoint;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNT,
- (xdrproc_t) xdr_guestfs_mount_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, mount_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_mount");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNT, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct sync_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void sync_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct sync_ctx *ctx = (struct sync_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_sync");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_sync");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_sync");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_sync (guestfs_h *g)
-{
- struct sync_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_sync") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_SYNC, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, sync_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_sync");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SYNC, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct touch_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void touch_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct touch_ctx *ctx = (struct touch_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_touch");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_touch");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_touch");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_touch (guestfs_h *g,
- const char *path)
-{
- struct guestfs_touch_args args;
- struct touch_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_touch") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_TOUCH,
- (xdrproc_t) xdr_guestfs_touch_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, touch_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_touch");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TOUCH, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct cat_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_cat_ret ret;
-};
-
-static void cat_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct cat_ctx *ctx = (struct cat_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_cat");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_cat");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_cat");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_cat_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_cat");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_cat (guestfs_h *g,
- const char *path)
-{
- struct guestfs_cat_args args;
- struct cat_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_cat") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_CAT,
- (xdrproc_t) xdr_guestfs_cat_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, cat_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_cat");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CAT, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.content; /* caller will free */
-}
-
-struct ll_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_ll_ret ret;
-};
-
-static void ll_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct ll_ctx *ctx = (struct ll_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_ll");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_ll");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_ll");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_ll_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_ll");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_ll (guestfs_h *g,
- const char *directory)
-{
- struct guestfs_ll_args args;
- struct ll_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_ll") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.directory = (char *) directory;
- serial = guestfs__send_sync (g, GUESTFS_PROC_LL,
- (xdrproc_t) xdr_guestfs_ll_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, ll_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_ll");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LL, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.listing; /* caller will free */
-}
-
-struct ls_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_ls_ret ret;
-};
-
-static void ls_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct ls_ctx *ctx = (struct ls_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_ls");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_ls");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_ls");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_ls_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_ls");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_ls (guestfs_h *g,
- const char *directory)
-{
- struct guestfs_ls_args args;
- struct ls_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_ls") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.directory = (char *) directory;
- serial = guestfs__send_sync (g, GUESTFS_PROC_LS,
- (xdrproc_t) xdr_guestfs_ls_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, ls_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_ls");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LS, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.listing.listing_val =
- safe_realloc (g, ctx.ret.listing.listing_val,
- sizeof (char *) * (ctx.ret.listing.listing_len + 1));
- ctx.ret.listing.listing_val[ctx.ret.listing.listing_len] = NULL;
- return ctx.ret.listing.listing_val;
-}
-
-struct list_devices_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_list_devices_ret ret;
-};
-
-static void list_devices_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct list_devices_ctx *ctx = (struct list_devices_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_list_devices");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_list_devices");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_list_devices");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_list_devices_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_list_devices");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_list_devices (guestfs_h *g)
-{
- struct list_devices_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_list_devices") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_LIST_DEVICES, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, list_devices_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_list_devices");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LIST_DEVICES, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.devices.devices_val =
- safe_realloc (g, ctx.ret.devices.devices_val,
- sizeof (char *) * (ctx.ret.devices.devices_len + 1));
- ctx.ret.devices.devices_val[ctx.ret.devices.devices_len] = NULL;
- return ctx.ret.devices.devices_val;
-}
-
-struct list_partitions_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_list_partitions_ret ret;
-};
-
-static void list_partitions_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct list_partitions_ctx *ctx = (struct list_partitions_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_list_partitions");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_list_partitions");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_list_partitions");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_list_partitions_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_list_partitions");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_list_partitions (guestfs_h *g)
-{
- struct list_partitions_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_list_partitions") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_LIST_PARTITIONS, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, list_partitions_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_list_partitions");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LIST_PARTITIONS, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.partitions.partitions_val =
- safe_realloc (g, ctx.ret.partitions.partitions_val,
- sizeof (char *) * (ctx.ret.partitions.partitions_len + 1));
- ctx.ret.partitions.partitions_val[ctx.ret.partitions.partitions_len] = NULL;
- return ctx.ret.partitions.partitions_val;
-}
-
-struct pvs_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_pvs_ret ret;
-};
-
-static void pvs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct pvs_ctx *ctx = (struct pvs_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_pvs");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_pvs");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_pvs");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_pvs_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_pvs");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_pvs (guestfs_h *g)
-{
- struct pvs_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_pvs") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_PVS, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, pvs_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_pvs");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PVS, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.physvols.physvols_val =
- safe_realloc (g, ctx.ret.physvols.physvols_val,
- sizeof (char *) * (ctx.ret.physvols.physvols_len + 1));
- ctx.ret.physvols.physvols_val[ctx.ret.physvols.physvols_len] = NULL;
- return ctx.ret.physvols.physvols_val;
-}
-
-struct vgs_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_vgs_ret ret;
-};
-
-static void vgs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct vgs_ctx *ctx = (struct vgs_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_vgs");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_vgs");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_vgs");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_vgs_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_vgs");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_vgs (guestfs_h *g)
-{
- struct vgs_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_vgs") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_VGS, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, vgs_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_vgs");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VGS, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.volgroups.volgroups_val =
- safe_realloc (g, ctx.ret.volgroups.volgroups_val,
- sizeof (char *) * (ctx.ret.volgroups.volgroups_len + 1));
- ctx.ret.volgroups.volgroups_val[ctx.ret.volgroups.volgroups_len] = NULL;
- return ctx.ret.volgroups.volgroups_val;
-}
-
-struct lvs_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_lvs_ret ret;
-};
-
-static void lvs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct lvs_ctx *ctx = (struct lvs_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_lvs");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_lvs");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_lvs");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_lvs_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_lvs");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_lvs (guestfs_h *g)
-{
- struct lvs_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_lvs") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_LVS, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, lvs_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_lvs");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVS, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.logvols.logvols_val =
- safe_realloc (g, ctx.ret.logvols.logvols_val,
- sizeof (char *) * (ctx.ret.logvols.logvols_len + 1));
- ctx.ret.logvols.logvols_val[ctx.ret.logvols.logvols_len] = NULL;
- return ctx.ret.logvols.logvols_val;
-}
-
-struct pvs_full_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_pvs_full_ret ret;
-};
-
-static void pvs_full_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct pvs_full_ctx *ctx = (struct pvs_full_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_pvs_full");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_pvs_full");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_pvs_full");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_pvs_full_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_pvs_full");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *g)
-{
- struct pvs_full_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_pvs_full") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_PVS_FULL, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, pvs_full_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_pvs_full");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PVS_FULL, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this */
- return safe_memdup (g, &ctx.ret.physvols, sizeof (ctx.ret.physvols));
-}
-
-struct vgs_full_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_vgs_full_ret ret;
-};
-
-static void vgs_full_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct vgs_full_ctx *ctx = (struct vgs_full_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_vgs_full");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_vgs_full");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_vgs_full");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_vgs_full_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_vgs_full");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-struct guestfs_lvm_vg_list *guestfs_vgs_full (guestfs_h *g)
-{
- struct vgs_full_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_vgs_full") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_VGS_FULL, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, vgs_full_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_vgs_full");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VGS_FULL, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this */
- return safe_memdup (g, &ctx.ret.volgroups, sizeof (ctx.ret.volgroups));
-}
-
-struct lvs_full_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_lvs_full_ret ret;
-};
-
-static void lvs_full_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct lvs_full_ctx *ctx = (struct lvs_full_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_lvs_full");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_lvs_full");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_lvs_full");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_lvs_full_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_lvs_full");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *g)
-{
- struct lvs_full_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_lvs_full") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_LVS_FULL, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, lvs_full_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_lvs_full");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVS_FULL, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this */
- return safe_memdup (g, &ctx.ret.logvols, sizeof (ctx.ret.logvols));
-}
-
-struct read_lines_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_read_lines_ret ret;
-};
-
-static void read_lines_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct read_lines_ctx *ctx = (struct read_lines_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_read_lines");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_read_lines");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_read_lines");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_read_lines_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_read_lines");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_read_lines (guestfs_h *g,
- const char *path)
-{
- struct guestfs_read_lines_args args;
- struct read_lines_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_read_lines") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_READ_LINES,
- (xdrproc_t) xdr_guestfs_read_lines_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, read_lines_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_read_lines");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_READ_LINES, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.lines.lines_val =
- safe_realloc (g, ctx.ret.lines.lines_val,
- sizeof (char *) * (ctx.ret.lines.lines_len + 1));
- ctx.ret.lines.lines_val[ctx.ret.lines.lines_len] = NULL;
- return ctx.ret.lines.lines_val;
-}
-
-struct aug_init_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void aug_init_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_init_ctx *ctx = (struct aug_init_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_init");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_init");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_init");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_aug_init (guestfs_h *g,
- const char *root,
- int flags)
-{
- struct guestfs_aug_init_args args;
- struct aug_init_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_init") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.root = (char *) root;
- args.flags = flags;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_INIT,
- (xdrproc_t) xdr_guestfs_aug_init_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_init_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_init");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_INIT, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct aug_close_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void aug_close_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_close_ctx *ctx = (struct aug_close_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_close");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_close");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_close");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_aug_close (guestfs_h *g)
-{
- struct aug_close_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_close") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_CLOSE, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_close_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_close");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_CLOSE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct aug_defvar_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_aug_defvar_ret ret;
-};
-
-static void aug_defvar_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_defvar_ctx *ctx = (struct aug_defvar_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_defvar");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_defvar");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_defvar");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_aug_defvar_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_aug_defvar");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_aug_defvar (guestfs_h *g,
- const char *name,
- const char *expr)
-{
- struct guestfs_aug_defvar_args args;
- struct aug_defvar_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_defvar") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.name = (char *) name;
- args.expr = expr ? (char **) &expr : NULL;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_DEFVAR,
- (xdrproc_t) xdr_guestfs_aug_defvar_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_defvar_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_defvar");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_DEFVAR, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.nrnodes;
-}
-
-struct aug_defnode_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_aug_defnode_ret ret;
-};
-
-static void aug_defnode_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_defnode_ctx *ctx = (struct aug_defnode_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_defnode");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_defnode");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_defnode");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_aug_defnode_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_aug_defnode");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-struct guestfs_int_bool *guestfs_aug_defnode (guestfs_h *g,
- const char *name,
- const char *expr,
- const char *val)
-{
- struct guestfs_aug_defnode_args args;
- struct aug_defnode_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_defnode") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.name = (char *) name;
- args.expr = (char *) expr;
- args.val = (char *) val;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_DEFNODE,
- (xdrproc_t) xdr_guestfs_aug_defnode_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_defnode_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_defnode");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_DEFNODE, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller with free this */
- return safe_memdup (g, &ctx.ret, sizeof (ctx.ret));
-}
-
-struct aug_get_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_aug_get_ret ret;
-};
-
-static void aug_get_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_get_ctx *ctx = (struct aug_get_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_get");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_get");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_get");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_aug_get_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_aug_get");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_aug_get (guestfs_h *g,
- const char *path)
-{
- struct guestfs_aug_get_args args;
- struct aug_get_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_get") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_GET,
- (xdrproc_t) xdr_guestfs_aug_get_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_get_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_get");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_GET, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.val; /* caller will free */
-}
-
-struct aug_set_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void aug_set_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_set_ctx *ctx = (struct aug_set_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_set");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_set");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_set");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_aug_set (guestfs_h *g,
- const char *path,
- const char *val)
-{
- struct guestfs_aug_set_args args;
- struct aug_set_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_set") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- args.val = (char *) val;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_SET,
- (xdrproc_t) xdr_guestfs_aug_set_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_set_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_set");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_SET, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct aug_insert_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void aug_insert_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_insert_ctx *ctx = (struct aug_insert_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_insert");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_insert");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_insert");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_aug_insert (guestfs_h *g,
- const char *path,
- const char *label,
- int before)
-{
- struct guestfs_aug_insert_args args;
- struct aug_insert_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_insert") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- args.label = (char *) label;
- args.before = before;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_INSERT,
- (xdrproc_t) xdr_guestfs_aug_insert_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_insert_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_insert");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_INSERT, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct aug_rm_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_aug_rm_ret ret;
-};
-
-static void aug_rm_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_rm_ctx *ctx = (struct aug_rm_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_rm");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_rm");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_rm");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_aug_rm_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_aug_rm");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_aug_rm (guestfs_h *g,
- const char *path)
-{
- struct guestfs_aug_rm_args args;
- struct aug_rm_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_rm") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_RM,
- (xdrproc_t) xdr_guestfs_aug_rm_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_rm_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_rm");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_RM, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.nrnodes;
-}
-
-struct aug_mv_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void aug_mv_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_mv_ctx *ctx = (struct aug_mv_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_mv");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_mv");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_mv");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_aug_mv (guestfs_h *g,
- const char *src,
- const char *dest)
-{
- struct guestfs_aug_mv_args args;
- struct aug_mv_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_mv") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.src = (char *) src;
- args.dest = (char *) dest;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_MV,
- (xdrproc_t) xdr_guestfs_aug_mv_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_mv_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_mv");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_MV, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct aug_match_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_aug_match_ret ret;
-};
-
-static void aug_match_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_match_ctx *ctx = (struct aug_match_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_match");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_match");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_match");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_aug_match_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_aug_match");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_aug_match (guestfs_h *g,
- const char *path)
-{
- struct guestfs_aug_match_args args;
- struct aug_match_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_match") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_MATCH,
- (xdrproc_t) xdr_guestfs_aug_match_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_match_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_match");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_MATCH, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.matches.matches_val =
- safe_realloc (g, ctx.ret.matches.matches_val,
- sizeof (char *) * (ctx.ret.matches.matches_len + 1));
- ctx.ret.matches.matches_val[ctx.ret.matches.matches_len] = NULL;
- return ctx.ret.matches.matches_val;
-}
-
-struct aug_save_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void aug_save_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_save_ctx *ctx = (struct aug_save_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_save");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_save");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_save");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_aug_save (guestfs_h *g)
-{
- struct aug_save_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_save") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_SAVE, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_save_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_save");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_SAVE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct aug_load_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void aug_load_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_load_ctx *ctx = (struct aug_load_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_load");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_load");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_load");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_aug_load (guestfs_h *g)
-{
- struct aug_load_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_load") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_LOAD, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_load_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_load");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_LOAD, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct aug_ls_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_aug_ls_ret ret;
-};
-
-static void aug_ls_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct aug_ls_ctx *ctx = (struct aug_ls_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_aug_ls");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_aug_ls");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_aug_ls");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_aug_ls_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_aug_ls");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_aug_ls (guestfs_h *g,
- const char *path)
-{
- struct guestfs_aug_ls_args args;
- struct aug_ls_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_aug_ls") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_LS,
- (xdrproc_t) xdr_guestfs_aug_ls_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, aug_ls_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_aug_ls");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_LS, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.matches.matches_val =
- safe_realloc (g, ctx.ret.matches.matches_val,
- sizeof (char *) * (ctx.ret.matches.matches_len + 1));
- ctx.ret.matches.matches_val[ctx.ret.matches.matches_len] = NULL;
- return ctx.ret.matches.matches_val;
-}
-
-struct rm_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void rm_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct rm_ctx *ctx = (struct rm_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_rm");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_rm");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_rm");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_rm (guestfs_h *g,
- const char *path)
-{
- struct guestfs_rm_args args;
- struct rm_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_rm") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_RM,
- (xdrproc_t) xdr_guestfs_rm_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, rm_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_rm");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_RM, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct rmdir_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void rmdir_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct rmdir_ctx *ctx = (struct rmdir_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_rmdir");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_rmdir");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_rmdir");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_rmdir (guestfs_h *g,
- const char *path)
-{
- struct guestfs_rmdir_args args;
- struct rmdir_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_rmdir") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_RMDIR,
- (xdrproc_t) xdr_guestfs_rmdir_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, rmdir_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_rmdir");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_RMDIR, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct rm_rf_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void rm_rf_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct rm_rf_ctx *ctx = (struct rm_rf_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_rm_rf");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_rm_rf");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_rm_rf");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_rm_rf (guestfs_h *g,
- const char *path)
-{
- struct guestfs_rm_rf_args args;
- struct rm_rf_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_rm_rf") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_RM_RF,
- (xdrproc_t) xdr_guestfs_rm_rf_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, rm_rf_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_rm_rf");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_RM_RF, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct mkdir_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void mkdir_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mkdir_ctx *ctx = (struct mkdir_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_mkdir");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mkdir");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_mkdir");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mkdir (guestfs_h *g,
- const char *path)
-{
- struct guestfs_mkdir_args args;
- struct mkdir_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mkdir") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKDIR,
- (xdrproc_t) xdr_guestfs_mkdir_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, mkdir_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_mkdir");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKDIR, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct mkdir_p_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void mkdir_p_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mkdir_p_ctx *ctx = (struct mkdir_p_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_mkdir_p");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mkdir_p");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_mkdir_p");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mkdir_p (guestfs_h *g,
- const char *path)
-{
- struct guestfs_mkdir_p_args args;
- struct mkdir_p_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mkdir_p") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKDIR_P,
- (xdrproc_t) xdr_guestfs_mkdir_p_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, mkdir_p_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_mkdir_p");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKDIR_P, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct chmod_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void chmod_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct chmod_ctx *ctx = (struct chmod_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_chmod");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_chmod");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_chmod");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_chmod (guestfs_h *g,
- int mode,
- const char *path)
-{
- struct guestfs_chmod_args args;
- struct chmod_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_chmod") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.mode = mode;
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_CHMOD,
- (xdrproc_t) xdr_guestfs_chmod_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, chmod_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_chmod");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CHMOD, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct chown_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void chown_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct chown_ctx *ctx = (struct chown_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_chown");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_chown");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_chown");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_chown (guestfs_h *g,
- int owner,
- int group,
- const char *path)
-{
- struct guestfs_chown_args args;
- struct chown_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_chown") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.owner = owner;
- args.group = group;
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_CHOWN,
- (xdrproc_t) xdr_guestfs_chown_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, chown_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_chown");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CHOWN, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct exists_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_exists_ret ret;
-};
-
-static void exists_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct exists_ctx *ctx = (struct exists_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_exists");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_exists");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_exists");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_exists_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_exists");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_exists (guestfs_h *g,
- const char *path)
-{
- struct guestfs_exists_args args;
- struct exists_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_exists") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_EXISTS,
- (xdrproc_t) xdr_guestfs_exists_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, exists_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_exists");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_EXISTS, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.existsflag;
-}
-
-struct is_file_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_is_file_ret ret;
-};
-
-static void is_file_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct is_file_ctx *ctx = (struct is_file_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_is_file");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_is_file");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_is_file");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_is_file_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_is_file");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_is_file (guestfs_h *g,
- const char *path)
-{
- struct guestfs_is_file_args args;
- struct is_file_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_is_file") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_IS_FILE,
- (xdrproc_t) xdr_guestfs_is_file_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, is_file_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_is_file");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_IS_FILE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.fileflag;
-}
-
-struct is_dir_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_is_dir_ret ret;
-};
-
-static void is_dir_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct is_dir_ctx *ctx = (struct is_dir_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_is_dir");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_is_dir");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_is_dir");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_is_dir_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_is_dir");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_is_dir (guestfs_h *g,
- const char *path)
-{
- struct guestfs_is_dir_args args;
- struct is_dir_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_is_dir") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_IS_DIR,
- (xdrproc_t) xdr_guestfs_is_dir_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, is_dir_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_is_dir");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_IS_DIR, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.dirflag;
-}
-
-struct pvcreate_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void pvcreate_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct pvcreate_ctx *ctx = (struct pvcreate_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_pvcreate");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_pvcreate");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_pvcreate");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_pvcreate (guestfs_h *g,
- const char *device)
-{
- struct guestfs_pvcreate_args args;
- struct pvcreate_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_pvcreate") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_PVCREATE,
- (xdrproc_t) xdr_guestfs_pvcreate_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, pvcreate_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_pvcreate");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PVCREATE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct vgcreate_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void vgcreate_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct vgcreate_ctx *ctx = (struct vgcreate_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_vgcreate");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_vgcreate");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_vgcreate");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_vgcreate (guestfs_h *g,
- const char *volgroup,
- char * const* const physvols)
-{
- struct guestfs_vgcreate_args args;
- struct vgcreate_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_vgcreate") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.volgroup = (char *) volgroup;
- args.physvols.physvols_val = (char **) physvols;
- for (args.physvols.physvols_len = 0; physvols[args.physvols.physvols_len]; args.physvols.physvols_len++) ;
- serial = guestfs__send_sync (g, GUESTFS_PROC_VGCREATE,
- (xdrproc_t) xdr_guestfs_vgcreate_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, vgcreate_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_vgcreate");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VGCREATE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct lvcreate_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void lvcreate_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct lvcreate_ctx *ctx = (struct lvcreate_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_lvcreate");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_lvcreate");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_lvcreate");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_lvcreate (guestfs_h *g,
- const char *logvol,
- const char *volgroup,
- int mbytes)
-{
- struct guestfs_lvcreate_args args;
- struct lvcreate_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_lvcreate") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.logvol = (char *) logvol;
- args.volgroup = (char *) volgroup;
- args.mbytes = mbytes;
- serial = guestfs__send_sync (g, GUESTFS_PROC_LVCREATE,
- (xdrproc_t) xdr_guestfs_lvcreate_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, lvcreate_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_lvcreate");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVCREATE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct mkfs_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void mkfs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mkfs_ctx *ctx = (struct mkfs_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_mkfs");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mkfs");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_mkfs");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mkfs (guestfs_h *g,
- const char *fstype,
- const char *device)
-{
- struct guestfs_mkfs_args args;
- struct mkfs_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mkfs") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.fstype = (char *) fstype;
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKFS,
- (xdrproc_t) xdr_guestfs_mkfs_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, mkfs_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_mkfs");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKFS, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct sfdisk_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void sfdisk_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct sfdisk_ctx *ctx = (struct sfdisk_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_sfdisk");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_sfdisk");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_sfdisk");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_sfdisk (guestfs_h *g,
- const char *device,
- int cyls,
- int heads,
- int sectors,
- char * const* const lines)
-{
- struct guestfs_sfdisk_args args;
- struct sfdisk_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_sfdisk") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- args.cyls = cyls;
- args.heads = heads;
- args.sectors = sectors;
- args.lines.lines_val = (char **) lines;
- for (args.lines.lines_len = 0; lines[args.lines.lines_len]; args.lines.lines_len++) ;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SFDISK,
- (xdrproc_t) xdr_guestfs_sfdisk_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, sfdisk_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_sfdisk");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SFDISK, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct write_file_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void write_file_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct write_file_ctx *ctx = (struct write_file_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_write_file");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_write_file");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_write_file");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_write_file (guestfs_h *g,
- const char *path,
- const char *content,
- int size)
-{
- struct guestfs_write_file_args args;
- struct write_file_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_write_file") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- args.content = (char *) content;
- args.size = size;
- serial = guestfs__send_sync (g, GUESTFS_PROC_WRITE_FILE,
- (xdrproc_t) xdr_guestfs_write_file_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, write_file_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_write_file");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_WRITE_FILE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct umount_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void umount_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct umount_ctx *ctx = (struct umount_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_umount");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_umount");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_umount");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_umount (guestfs_h *g,
- const char *pathordevice)
-{
- struct guestfs_umount_args args;
- struct umount_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_umount") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.pathordevice = (char *) pathordevice;
- serial = guestfs__send_sync (g, GUESTFS_PROC_UMOUNT,
- (xdrproc_t) xdr_guestfs_umount_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, umount_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_umount");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_UMOUNT, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct mounts_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_mounts_ret ret;
-};
-
-static void mounts_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mounts_ctx *ctx = (struct mounts_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_mounts");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mounts");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_mounts");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_mounts_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_mounts");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_mounts (guestfs_h *g)
-{
- struct mounts_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mounts") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNTS, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, mounts_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_mounts");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNTS, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.devices.devices_val =
- safe_realloc (g, ctx.ret.devices.devices_val,
- sizeof (char *) * (ctx.ret.devices.devices_len + 1));
- ctx.ret.devices.devices_val[ctx.ret.devices.devices_len] = NULL;
- return ctx.ret.devices.devices_val;
-}
-
-struct umount_all_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void umount_all_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct umount_all_ctx *ctx = (struct umount_all_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_umount_all");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_umount_all");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_umount_all");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_umount_all (guestfs_h *g)
-{
- struct umount_all_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_umount_all") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_UMOUNT_ALL, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, umount_all_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_umount_all");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_UMOUNT_ALL, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct lvm_remove_all_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void lvm_remove_all_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct lvm_remove_all_ctx *ctx = (struct lvm_remove_all_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_lvm_remove_all");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_lvm_remove_all");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_lvm_remove_all");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_lvm_remove_all (guestfs_h *g)
-{
- struct lvm_remove_all_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_lvm_remove_all") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_LVM_REMOVE_ALL, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, lvm_remove_all_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_lvm_remove_all");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVM_REMOVE_ALL, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct file_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_file_ret ret;
-};
-
-static void file_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct file_ctx *ctx = (struct file_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_file");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_file");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_file");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_file_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_file");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_file (guestfs_h *g,
- const char *path)
-{
- struct guestfs_file_args args;
- struct file_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_file") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_FILE,
- (xdrproc_t) xdr_guestfs_file_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, file_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_file");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_FILE, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.description; /* caller will free */
-}
-
-struct command_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_command_ret ret;
-};
-
-static void command_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct command_ctx *ctx = (struct command_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_command");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_command");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_command");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_command_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_command");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_command (guestfs_h *g,
- char * const* const arguments)
-{
- struct guestfs_command_args args;
- struct command_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_command") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.arguments.arguments_val = (char **) arguments;
- for (args.arguments.arguments_len = 0; arguments[args.arguments.arguments_len]; args.arguments.arguments_len++) ;
- serial = guestfs__send_sync (g, GUESTFS_PROC_COMMAND,
- (xdrproc_t) xdr_guestfs_command_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, command_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_command");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_COMMAND, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.output; /* caller will free */
-}
-
-struct command_lines_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_command_lines_ret ret;
-};
-
-static void command_lines_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct command_lines_ctx *ctx = (struct command_lines_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_command_lines");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_command_lines");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_command_lines");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_command_lines_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_command_lines");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_command_lines (guestfs_h *g,
- char * const* const arguments)
-{
- struct guestfs_command_lines_args args;
- struct command_lines_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_command_lines") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.arguments.arguments_val = (char **) arguments;
- for (args.arguments.arguments_len = 0; arguments[args.arguments.arguments_len]; args.arguments.arguments_len++) ;
- serial = guestfs__send_sync (g, GUESTFS_PROC_COMMAND_LINES,
- (xdrproc_t) xdr_guestfs_command_lines_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, command_lines_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_command_lines");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_COMMAND_LINES, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.lines.lines_val =
- safe_realloc (g, ctx.ret.lines.lines_val,
- sizeof (char *) * (ctx.ret.lines.lines_len + 1));
- ctx.ret.lines.lines_val[ctx.ret.lines.lines_len] = NULL;
- return ctx.ret.lines.lines_val;
-}
-
-struct stat_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_stat_ret ret;
-};
-
-static void stat_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct stat_ctx *ctx = (struct stat_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_stat");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_stat");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_stat");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_stat_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_stat");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-struct guestfs_stat *guestfs_stat (guestfs_h *g,
- const char *path)
-{
- struct guestfs_stat_args args;
- struct stat_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_stat") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_STAT,
- (xdrproc_t) xdr_guestfs_stat_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, stat_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_stat");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_STAT, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this */
- return safe_memdup (g, &ctx.ret.statbuf, sizeof (ctx.ret.statbuf));
-}
-
-struct lstat_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_lstat_ret ret;
-};
-
-static void lstat_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct lstat_ctx *ctx = (struct lstat_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_lstat");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_lstat");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_lstat");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_lstat_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_lstat");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-struct guestfs_stat *guestfs_lstat (guestfs_h *g,
- const char *path)
-{
- struct guestfs_lstat_args args;
- struct lstat_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_lstat") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_LSTAT,
- (xdrproc_t) xdr_guestfs_lstat_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, lstat_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_lstat");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LSTAT, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this */
- return safe_memdup (g, &ctx.ret.statbuf, sizeof (ctx.ret.statbuf));
-}
-
-struct statvfs_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_statvfs_ret ret;
-};
-
-static void statvfs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct statvfs_ctx *ctx = (struct statvfs_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_statvfs");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_statvfs");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_statvfs");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_statvfs_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_statvfs");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-struct guestfs_statvfs *guestfs_statvfs (guestfs_h *g,
- const char *path)
-{
- struct guestfs_statvfs_args args;
- struct statvfs_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_statvfs") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_STATVFS,
- (xdrproc_t) xdr_guestfs_statvfs_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, statvfs_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_statvfs");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_STATVFS, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this */
- return safe_memdup (g, &ctx.ret.statbuf, sizeof (ctx.ret.statbuf));
-}
-
-struct tune2fs_l_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_tune2fs_l_ret ret;
-};
-
-static void tune2fs_l_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct tune2fs_l_ctx *ctx = (struct tune2fs_l_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_tune2fs_l");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_tune2fs_l");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_tune2fs_l");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_tune2fs_l_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_tune2fs_l");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_tune2fs_l (guestfs_h *g,
- const char *device)
-{
- struct guestfs_tune2fs_l_args args;
- struct tune2fs_l_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_tune2fs_l") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_TUNE2FS_L,
- (xdrproc_t) xdr_guestfs_tune2fs_l_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, tune2fs_l_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_tune2fs_l");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TUNE2FS_L, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.superblock.superblock_val =
- safe_realloc (g, ctx.ret.superblock.superblock_val,
- sizeof (char *) * (ctx.ret.superblock.superblock_len + 1));
- ctx.ret.superblock.superblock_val[ctx.ret.superblock.superblock_len] = NULL;
- return ctx.ret.superblock.superblock_val;
-}
-
-struct blockdev_setro_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void blockdev_setro_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_setro_ctx *ctx = (struct blockdev_setro_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_setro");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_setro");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_setro");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_blockdev_setro (guestfs_h *g,
- const char *device)
-{
- struct guestfs_blockdev_setro_args args;
- struct blockdev_setro_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_setro") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_SETRO,
- (xdrproc_t) xdr_guestfs_blockdev_setro_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_setro_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_setro");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_SETRO, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct blockdev_setrw_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void blockdev_setrw_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_setrw_ctx *ctx = (struct blockdev_setrw_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_setrw");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_setrw");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_setrw");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_blockdev_setrw (guestfs_h *g,
- const char *device)
-{
- struct guestfs_blockdev_setrw_args args;
- struct blockdev_setrw_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_setrw") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_SETRW,
- (xdrproc_t) xdr_guestfs_blockdev_setrw_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_setrw_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_setrw");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_SETRW, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct blockdev_getro_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_blockdev_getro_ret ret;
-};
-
-static void blockdev_getro_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_getro_ctx *ctx = (struct blockdev_getro_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getro");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_getro");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_getro");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_blockdev_getro_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_blockdev_getro");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_blockdev_getro (guestfs_h *g,
- const char *device)
-{
- struct guestfs_blockdev_getro_args args;
- struct blockdev_getro_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_getro") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETRO,
- (xdrproc_t) xdr_guestfs_blockdev_getro_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_getro_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getro");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETRO, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.ro;
-}
-
-struct blockdev_getss_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_blockdev_getss_ret ret;
-};
-
-static void blockdev_getss_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_getss_ctx *ctx = (struct blockdev_getss_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getss");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_getss");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_getss");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_blockdev_getss_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_blockdev_getss");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_blockdev_getss (guestfs_h *g,
- const char *device)
-{
- struct guestfs_blockdev_getss_args args;
- struct blockdev_getss_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_getss") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETSS,
- (xdrproc_t) xdr_guestfs_blockdev_getss_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_getss_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getss");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETSS, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.sectorsize;
-}
-
-struct blockdev_getbsz_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_blockdev_getbsz_ret ret;
-};
-
-static void blockdev_getbsz_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_getbsz_ctx *ctx = (struct blockdev_getbsz_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getbsz");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_getbsz");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_getbsz");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_blockdev_getbsz_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_blockdev_getbsz");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_blockdev_getbsz (guestfs_h *g,
- const char *device)
-{
- struct guestfs_blockdev_getbsz_args args;
- struct blockdev_getbsz_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_getbsz") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETBSZ,
- (xdrproc_t) xdr_guestfs_blockdev_getbsz_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_getbsz_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getbsz");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETBSZ, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.blocksize;
-}
-
-struct blockdev_setbsz_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void blockdev_setbsz_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_setbsz_ctx *ctx = (struct blockdev_setbsz_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_setbsz");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_setbsz");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_setbsz");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_blockdev_setbsz (guestfs_h *g,
- const char *device,
- int blocksize)
-{
- struct guestfs_blockdev_setbsz_args args;
- struct blockdev_setbsz_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_setbsz") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- args.blocksize = blocksize;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_SETBSZ,
- (xdrproc_t) xdr_guestfs_blockdev_setbsz_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_setbsz_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_setbsz");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_SETBSZ, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct blockdev_getsz_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_blockdev_getsz_ret ret;
-};
-
-static void blockdev_getsz_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_getsz_ctx *ctx = (struct blockdev_getsz_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getsz");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_getsz");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_getsz");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_blockdev_getsz_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_blockdev_getsz");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int64_t guestfs_blockdev_getsz (guestfs_h *g,
- const char *device)
-{
- struct guestfs_blockdev_getsz_args args;
- struct blockdev_getsz_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_getsz") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETSZ,
- (xdrproc_t) xdr_guestfs_blockdev_getsz_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_getsz_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getsz");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETSZ, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.sizeinsectors;
-}
-
-struct blockdev_getsize64_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_blockdev_getsize64_ret ret;
-};
-
-static void blockdev_getsize64_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_getsize64_ctx *ctx = (struct blockdev_getsize64_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getsize64");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_getsize64");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_getsize64");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_blockdev_getsize64_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_blockdev_getsize64");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int64_t guestfs_blockdev_getsize64 (guestfs_h *g,
- const char *device)
-{
- struct guestfs_blockdev_getsize64_args args;
- struct blockdev_getsize64_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_getsize64") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETSIZE64,
- (xdrproc_t) xdr_guestfs_blockdev_getsize64_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_getsize64_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getsize64");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETSIZE64, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.sizeinbytes;
-}
-
-struct blockdev_flushbufs_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void blockdev_flushbufs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_flushbufs_ctx *ctx = (struct blockdev_flushbufs_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_flushbufs");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_flushbufs");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_flushbufs");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_blockdev_flushbufs (guestfs_h *g,
- const char *device)
-{
- struct guestfs_blockdev_flushbufs_args args;
- struct blockdev_flushbufs_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_flushbufs") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_FLUSHBUFS,
- (xdrproc_t) xdr_guestfs_blockdev_flushbufs_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_flushbufs_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_flushbufs");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_FLUSHBUFS, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct blockdev_rereadpt_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void blockdev_rereadpt_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct blockdev_rereadpt_ctx *ctx = (struct blockdev_rereadpt_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_rereadpt");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_blockdev_rereadpt");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_blockdev_rereadpt");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_blockdev_rereadpt (guestfs_h *g,
- const char *device)
-{
- struct guestfs_blockdev_rereadpt_args args;
- struct blockdev_rereadpt_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_blockdev_rereadpt") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_REREADPT,
- (xdrproc_t) xdr_guestfs_blockdev_rereadpt_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, blockdev_rereadpt_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_rereadpt");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_REREADPT, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct upload_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void upload_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct upload_ctx *ctx = (struct upload_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_upload");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_upload");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_upload");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_upload (guestfs_h *g,
- const char *filename,
- const char *remotefilename)
-{
- struct guestfs_upload_args args;
- struct upload_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_upload") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.remotefilename = (char *) remotefilename;
- serial = guestfs__send_sync (g, GUESTFS_PROC_UPLOAD,
- (xdrproc_t) xdr_guestfs_upload_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- {
- int r;
-
- r = guestfs__send_file_sync (g, filename);
- if (r == -1) {
- guestfs_end_busy (g);
- return -1;
- }
- if (r == -2) /* daemon cancelled */
- goto read_reply;
- }
-
- read_reply:
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, upload_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_upload");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_UPLOAD, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct download_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void download_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct download_ctx *ctx = (struct download_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_download");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_download");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_download");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_download (guestfs_h *g,
- const char *remotefilename,
- const char *filename)
-{
- struct guestfs_download_args args;
- struct download_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_download") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.remotefilename = (char *) remotefilename;
- serial = guestfs__send_sync (g, GUESTFS_PROC_DOWNLOAD,
- (xdrproc_t) xdr_guestfs_download_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, download_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_download");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DOWNLOAD, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- if (guestfs__receive_file_sync (g, filename) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct checksum_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_checksum_ret ret;
-};
-
-static void checksum_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct checksum_ctx *ctx = (struct checksum_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_checksum");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_checksum");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_checksum");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_checksum_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_checksum");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_checksum (guestfs_h *g,
- const char *csumtype,
- const char *path)
-{
- struct guestfs_checksum_args args;
- struct checksum_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_checksum") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.csumtype = (char *) csumtype;
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_CHECKSUM,
- (xdrproc_t) xdr_guestfs_checksum_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, checksum_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_checksum");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CHECKSUM, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.checksum; /* caller will free */
-}
-
-struct tar_in_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void tar_in_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct tar_in_ctx *ctx = (struct tar_in_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_tar_in");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_tar_in");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_tar_in");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_tar_in (guestfs_h *g,
- const char *tarfile,
- const char *directory)
-{
- struct guestfs_tar_in_args args;
- struct tar_in_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_tar_in") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.directory = (char *) directory;
- serial = guestfs__send_sync (g, GUESTFS_PROC_TAR_IN,
- (xdrproc_t) xdr_guestfs_tar_in_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- {
- int r;
-
- r = guestfs__send_file_sync (g, tarfile);
- if (r == -1) {
- guestfs_end_busy (g);
- return -1;
- }
- if (r == -2) /* daemon cancelled */
- goto read_reply;
- }
-
- read_reply:
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, tar_in_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_tar_in");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TAR_IN, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct tar_out_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void tar_out_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct tar_out_ctx *ctx = (struct tar_out_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_tar_out");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_tar_out");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_tar_out");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_tar_out (guestfs_h *g,
- const char *directory,
- const char *tarfile)
-{
- struct guestfs_tar_out_args args;
- struct tar_out_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_tar_out") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.directory = (char *) directory;
- serial = guestfs__send_sync (g, GUESTFS_PROC_TAR_OUT,
- (xdrproc_t) xdr_guestfs_tar_out_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, tar_out_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_tar_out");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TAR_OUT, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- if (guestfs__receive_file_sync (g, tarfile) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct tgz_in_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void tgz_in_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct tgz_in_ctx *ctx = (struct tgz_in_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_tgz_in");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_tgz_in");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_tgz_in");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_tgz_in (guestfs_h *g,
- const char *tarball,
- const char *directory)
-{
- struct guestfs_tgz_in_args args;
- struct tgz_in_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_tgz_in") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.directory = (char *) directory;
- serial = guestfs__send_sync (g, GUESTFS_PROC_TGZ_IN,
- (xdrproc_t) xdr_guestfs_tgz_in_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- {
- int r;
-
- r = guestfs__send_file_sync (g, tarball);
- if (r == -1) {
- guestfs_end_busy (g);
- return -1;
- }
- if (r == -2) /* daemon cancelled */
- goto read_reply;
- }
-
- read_reply:
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, tgz_in_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_tgz_in");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TGZ_IN, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct tgz_out_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void tgz_out_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct tgz_out_ctx *ctx = (struct tgz_out_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_tgz_out");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_tgz_out");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_tgz_out");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_tgz_out (guestfs_h *g,
- const char *directory,
- const char *tarball)
-{
- struct guestfs_tgz_out_args args;
- struct tgz_out_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_tgz_out") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.directory = (char *) directory;
- serial = guestfs__send_sync (g, GUESTFS_PROC_TGZ_OUT,
- (xdrproc_t) xdr_guestfs_tgz_out_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, tgz_out_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_tgz_out");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TGZ_OUT, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- if (guestfs__receive_file_sync (g, tarball) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct mount_ro_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void mount_ro_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mount_ro_ctx *ctx = (struct mount_ro_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_mount_ro");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mount_ro");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_mount_ro");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mount_ro (guestfs_h *g,
- const char *device,
- const char *mountpoint)
-{
- struct guestfs_mount_ro_args args;
- struct mount_ro_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mount_ro") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- args.mountpoint = (char *) mountpoint;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNT_RO,
- (xdrproc_t) xdr_guestfs_mount_ro_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, mount_ro_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_mount_ro");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNT_RO, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct mount_options_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void mount_options_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mount_options_ctx *ctx = (struct mount_options_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_mount_options");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mount_options");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_mount_options");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mount_options (guestfs_h *g,
- const char *options,
- const char *device,
- const char *mountpoint)
-{
- struct guestfs_mount_options_args args;
- struct mount_options_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mount_options") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.options = (char *) options;
- args.device = (char *) device;
- args.mountpoint = (char *) mountpoint;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNT_OPTIONS,
- (xdrproc_t) xdr_guestfs_mount_options_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, mount_options_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_mount_options");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNT_OPTIONS, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct mount_vfs_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void mount_vfs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mount_vfs_ctx *ctx = (struct mount_vfs_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_mount_vfs");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mount_vfs");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_mount_vfs");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mount_vfs (guestfs_h *g,
- const char *options,
- const char *vfstype,
- const char *device,
- const char *mountpoint)
-{
- struct guestfs_mount_vfs_args args;
- struct mount_vfs_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mount_vfs") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.options = (char *) options;
- args.vfstype = (char *) vfstype;
- args.device = (char *) device;
- args.mountpoint = (char *) mountpoint;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNT_VFS,
- (xdrproc_t) xdr_guestfs_mount_vfs_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, mount_vfs_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_mount_vfs");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNT_VFS, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct debug_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_debug_ret ret;
-};
-
-static void debug_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct debug_ctx *ctx = (struct debug_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_debug");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_debug");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_debug");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_debug_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_debug");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_debug (guestfs_h *g,
- const char *subcmd,
- char * const* const extraargs)
-{
- struct guestfs_debug_args args;
- struct debug_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_debug") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.subcmd = (char *) subcmd;
- args.extraargs.extraargs_val = (char **) extraargs;
- for (args.extraargs.extraargs_len = 0; extraargs[args.extraargs.extraargs_len]; args.extraargs.extraargs_len++) ;
- serial = guestfs__send_sync (g, GUESTFS_PROC_DEBUG,
- (xdrproc_t) xdr_guestfs_debug_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, debug_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_debug");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DEBUG, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.result; /* caller will free */
-}
-
-struct lvremove_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void lvremove_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct lvremove_ctx *ctx = (struct lvremove_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_lvremove");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_lvremove");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_lvremove");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_lvremove (guestfs_h *g,
- const char *device)
-{
- struct guestfs_lvremove_args args;
- struct lvremove_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_lvremove") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_LVREMOVE,
- (xdrproc_t) xdr_guestfs_lvremove_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, lvremove_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_lvremove");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVREMOVE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct vgremove_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void vgremove_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct vgremove_ctx *ctx = (struct vgremove_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_vgremove");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_vgremove");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_vgremove");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_vgremove (guestfs_h *g,
- const char *vgname)
-{
- struct guestfs_vgremove_args args;
- struct vgremove_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_vgremove") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.vgname = (char *) vgname;
- serial = guestfs__send_sync (g, GUESTFS_PROC_VGREMOVE,
- (xdrproc_t) xdr_guestfs_vgremove_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, vgremove_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_vgremove");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VGREMOVE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct pvremove_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void pvremove_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct pvremove_ctx *ctx = (struct pvremove_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_pvremove");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_pvremove");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_pvremove");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_pvremove (guestfs_h *g,
- const char *device)
-{
- struct guestfs_pvremove_args args;
- struct pvremove_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_pvremove") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_PVREMOVE,
- (xdrproc_t) xdr_guestfs_pvremove_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, pvremove_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_pvremove");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PVREMOVE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct set_e2label_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void set_e2label_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct set_e2label_ctx *ctx = (struct set_e2label_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_set_e2label");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_set_e2label");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_set_e2label");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_set_e2label (guestfs_h *g,
- const char *device,
- const char *label)
-{
- struct guestfs_set_e2label_args args;
- struct set_e2label_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_set_e2label") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- args.label = (char *) label;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SET_E2LABEL,
- (xdrproc_t) xdr_guestfs_set_e2label_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, set_e2label_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_set_e2label");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SET_E2LABEL, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct get_e2label_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_get_e2label_ret ret;
-};
-
-static void get_e2label_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct get_e2label_ctx *ctx = (struct get_e2label_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_get_e2label");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_get_e2label");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_get_e2label");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_get_e2label_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_get_e2label");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_get_e2label (guestfs_h *g,
- const char *device)
-{
- struct guestfs_get_e2label_args args;
- struct get_e2label_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_get_e2label") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_GET_E2LABEL,
- (xdrproc_t) xdr_guestfs_get_e2label_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, get_e2label_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_get_e2label");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_GET_E2LABEL, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.label; /* caller will free */
-}
-
-struct set_e2uuid_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void set_e2uuid_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct set_e2uuid_ctx *ctx = (struct set_e2uuid_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_set_e2uuid");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_set_e2uuid");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_set_e2uuid");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_set_e2uuid (guestfs_h *g,
- const char *device,
- const char *uuid)
-{
- struct guestfs_set_e2uuid_args args;
- struct set_e2uuid_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_set_e2uuid") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- args.uuid = (char *) uuid;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SET_E2UUID,
- (xdrproc_t) xdr_guestfs_set_e2uuid_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, set_e2uuid_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_set_e2uuid");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SET_E2UUID, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct get_e2uuid_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_get_e2uuid_ret ret;
-};
-
-static void get_e2uuid_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct get_e2uuid_ctx *ctx = (struct get_e2uuid_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_get_e2uuid");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_get_e2uuid");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_get_e2uuid");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_get_e2uuid_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_get_e2uuid");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_get_e2uuid (guestfs_h *g,
- const char *device)
-{
- struct guestfs_get_e2uuid_args args;
- struct get_e2uuid_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_get_e2uuid") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_GET_E2UUID,
- (xdrproc_t) xdr_guestfs_get_e2uuid_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, get_e2uuid_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_get_e2uuid");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_GET_E2UUID, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.uuid; /* caller will free */
-}
-
-struct fsck_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_fsck_ret ret;
-};
-
-static void fsck_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct fsck_ctx *ctx = (struct fsck_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_fsck");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_fsck");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_fsck");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_fsck_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_fsck");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_fsck (guestfs_h *g,
- const char *fstype,
- const char *device)
-{
- struct guestfs_fsck_args args;
- struct fsck_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_fsck") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.fstype = (char *) fstype;
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_FSCK,
- (xdrproc_t) xdr_guestfs_fsck_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, fsck_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_fsck");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_FSCK, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.status;
-}
-
-struct zero_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void zero_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct zero_ctx *ctx = (struct zero_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_zero");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_zero");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_zero");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_zero (guestfs_h *g,
- const char *device)
-{
- struct guestfs_zero_args args;
- struct zero_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_zero") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_ZERO,
- (xdrproc_t) xdr_guestfs_zero_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, zero_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_zero");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_ZERO, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct grub_install_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void grub_install_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct grub_install_ctx *ctx = (struct grub_install_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_grub_install");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_grub_install");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_grub_install");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_grub_install (guestfs_h *g,
- const char *root,
- const char *device)
-{
- struct guestfs_grub_install_args args;
- struct grub_install_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_grub_install") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.root = (char *) root;
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_GRUB_INSTALL,
- (xdrproc_t) xdr_guestfs_grub_install_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, grub_install_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_grub_install");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_GRUB_INSTALL, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct cp_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void cp_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct cp_ctx *ctx = (struct cp_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_cp");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_cp");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_cp");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_cp (guestfs_h *g,
- const char *src,
- const char *dest)
-{
- struct guestfs_cp_args args;
- struct cp_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_cp") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.src = (char *) src;
- args.dest = (char *) dest;
- serial = guestfs__send_sync (g, GUESTFS_PROC_CP,
- (xdrproc_t) xdr_guestfs_cp_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, cp_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_cp");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CP, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct cp_a_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void cp_a_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct cp_a_ctx *ctx = (struct cp_a_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_cp_a");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_cp_a");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_cp_a");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_cp_a (guestfs_h *g,
- const char *src,
- const char *dest)
-{
- struct guestfs_cp_a_args args;
- struct cp_a_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_cp_a") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.src = (char *) src;
- args.dest = (char *) dest;
- serial = guestfs__send_sync (g, GUESTFS_PROC_CP_A,
- (xdrproc_t) xdr_guestfs_cp_a_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, cp_a_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_cp_a");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CP_A, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct mv_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void mv_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mv_ctx *ctx = (struct mv_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_mv");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mv");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_mv");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mv (guestfs_h *g,
- const char *src,
- const char *dest)
-{
- struct guestfs_mv_args args;
- struct mv_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mv") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.src = (char *) src;
- args.dest = (char *) dest;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MV,
- (xdrproc_t) xdr_guestfs_mv_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, mv_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_mv");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MV, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct drop_caches_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void drop_caches_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct drop_caches_ctx *ctx = (struct drop_caches_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_drop_caches");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_drop_caches");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_drop_caches");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_drop_caches (guestfs_h *g,
- int whattodrop)
-{
- struct guestfs_drop_caches_args args;
- struct drop_caches_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_drop_caches") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.whattodrop = whattodrop;
- serial = guestfs__send_sync (g, GUESTFS_PROC_DROP_CACHES,
- (xdrproc_t) xdr_guestfs_drop_caches_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, drop_caches_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_drop_caches");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DROP_CACHES, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct dmesg_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_dmesg_ret ret;
-};
-
-static void dmesg_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct dmesg_ctx *ctx = (struct dmesg_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_dmesg");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_dmesg");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_dmesg");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_dmesg_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_dmesg");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_dmesg (guestfs_h *g)
-{
- struct dmesg_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_dmesg") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_DMESG, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, dmesg_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_dmesg");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DMESG, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.kmsgs; /* caller will free */
-}
-
-struct ping_daemon_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void ping_daemon_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct ping_daemon_ctx *ctx = (struct ping_daemon_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_ping_daemon");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_ping_daemon");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_ping_daemon");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_ping_daemon (guestfs_h *g)
-{
- struct ping_daemon_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_ping_daemon") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_PING_DAEMON, NULL, NULL);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, ping_daemon_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_ping_daemon");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PING_DAEMON, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct equal_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_equal_ret ret;
-};
-
-static void equal_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct equal_ctx *ctx = (struct equal_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_equal");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_equal");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_equal");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_equal_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_equal");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_equal (guestfs_h *g,
- const char *file1,
- const char *file2)
-{
- struct guestfs_equal_args args;
- struct equal_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_equal") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.file1 = (char *) file1;
- args.file2 = (char *) file2;
- serial = guestfs__send_sync (g, GUESTFS_PROC_EQUAL,
- (xdrproc_t) xdr_guestfs_equal_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, equal_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_equal");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_EQUAL, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.equality;
-}
-
-struct strings_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_strings_ret ret;
-};
-
-static void strings_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct strings_ctx *ctx = (struct strings_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_strings");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_strings");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_strings");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_strings_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_strings");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_strings (guestfs_h *g,
- const char *path)
-{
- struct guestfs_strings_args args;
- struct strings_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_strings") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_STRINGS,
- (xdrproc_t) xdr_guestfs_strings_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, strings_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_strings");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_STRINGS, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.stringsout.stringsout_val =
- safe_realloc (g, ctx.ret.stringsout.stringsout_val,
- sizeof (char *) * (ctx.ret.stringsout.stringsout_len + 1));
- ctx.ret.stringsout.stringsout_val[ctx.ret.stringsout.stringsout_len] = NULL;
- return ctx.ret.stringsout.stringsout_val;
-}
-
-struct strings_e_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_strings_e_ret ret;
-};
-
-static void strings_e_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct strings_e_ctx *ctx = (struct strings_e_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_strings_e");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_strings_e");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_strings_e");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_strings_e_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_strings_e");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_strings_e (guestfs_h *g,
- const char *encoding,
- const char *path)
-{
- struct guestfs_strings_e_args args;
- struct strings_e_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_strings_e") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.encoding = (char *) encoding;
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_STRINGS_E,
- (xdrproc_t) xdr_guestfs_strings_e_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, strings_e_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_strings_e");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_STRINGS_E, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.stringsout.stringsout_val =
- safe_realloc (g, ctx.ret.stringsout.stringsout_val,
- sizeof (char *) * (ctx.ret.stringsout.stringsout_len + 1));
- ctx.ret.stringsout.stringsout_val[ctx.ret.stringsout.stringsout_len] = NULL;
- return ctx.ret.stringsout.stringsout_val;
-}
-
-struct hexdump_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_hexdump_ret ret;
-};
-
-static void hexdump_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct hexdump_ctx *ctx = (struct hexdump_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_hexdump");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_hexdump");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_hexdump");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_hexdump_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_hexdump");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_hexdump (guestfs_h *g,
- const char *path)
-{
- struct guestfs_hexdump_args args;
- struct hexdump_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_hexdump") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_HEXDUMP,
- (xdrproc_t) xdr_guestfs_hexdump_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, hexdump_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_hexdump");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_HEXDUMP, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.dump; /* caller will free */
-}
-
-struct zerofree_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void zerofree_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct zerofree_ctx *ctx = (struct zerofree_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_zerofree");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_zerofree");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_zerofree");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_zerofree (guestfs_h *g,
- const char *device)
-{
- struct guestfs_zerofree_args args;
- struct zerofree_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_zerofree") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_ZEROFREE,
- (xdrproc_t) xdr_guestfs_zerofree_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, zerofree_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_zerofree");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_ZEROFREE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct pvresize_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void pvresize_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct pvresize_ctx *ctx = (struct pvresize_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_pvresize");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_pvresize");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_pvresize");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_pvresize (guestfs_h *g,
- const char *device)
-{
- struct guestfs_pvresize_args args;
- struct pvresize_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_pvresize") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_PVRESIZE,
- (xdrproc_t) xdr_guestfs_pvresize_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, pvresize_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_pvresize");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PVRESIZE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct sfdisk_N_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void sfdisk_N_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct sfdisk_N_ctx *ctx = (struct sfdisk_N_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_sfdisk_N");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_sfdisk_N");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_sfdisk_N");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_sfdisk_N (guestfs_h *g,
- const char *device,
- int n,
- int cyls,
- int heads,
- int sectors,
- const char *line)
-{
- struct guestfs_sfdisk_N_args args;
- struct sfdisk_N_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_sfdisk_N") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- args.n = n;
- args.cyls = cyls;
- args.heads = heads;
- args.sectors = sectors;
- args.line = (char *) line;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SFDISK_N,
- (xdrproc_t) xdr_guestfs_sfdisk_N_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, sfdisk_N_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_sfdisk_N");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SFDISK_N, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct sfdisk_l_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_sfdisk_l_ret ret;
-};
-
-static void sfdisk_l_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct sfdisk_l_ctx *ctx = (struct sfdisk_l_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_sfdisk_l");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_sfdisk_l");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_sfdisk_l");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_sfdisk_l_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_sfdisk_l");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_sfdisk_l (guestfs_h *g,
- const char *device)
-{
- struct guestfs_sfdisk_l_args args;
- struct sfdisk_l_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_sfdisk_l") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SFDISK_L,
- (xdrproc_t) xdr_guestfs_sfdisk_l_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, sfdisk_l_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_sfdisk_l");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SFDISK_L, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.partitions; /* caller will free */
-}
-
-struct sfdisk_kernel_geometry_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_sfdisk_kernel_geometry_ret ret;
-};
-
-static void sfdisk_kernel_geometry_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct sfdisk_kernel_geometry_ctx *ctx = (struct sfdisk_kernel_geometry_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_sfdisk_kernel_geometry");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_sfdisk_kernel_geometry");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_sfdisk_kernel_geometry");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_sfdisk_kernel_geometry_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_sfdisk_kernel_geometry");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_sfdisk_kernel_geometry (guestfs_h *g,
- const char *device)
-{
- struct guestfs_sfdisk_kernel_geometry_args args;
- struct sfdisk_kernel_geometry_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_sfdisk_kernel_geometry") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SFDISK_KERNEL_GEOMETRY,
- (xdrproc_t) xdr_guestfs_sfdisk_kernel_geometry_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, sfdisk_kernel_geometry_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_sfdisk_kernel_geometry");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SFDISK_KERNEL_GEOMETRY, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.partitions; /* caller will free */
-}
-
-struct sfdisk_disk_geometry_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_sfdisk_disk_geometry_ret ret;
-};
-
-static void sfdisk_disk_geometry_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct sfdisk_disk_geometry_ctx *ctx = (struct sfdisk_disk_geometry_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_sfdisk_disk_geometry");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_sfdisk_disk_geometry");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_sfdisk_disk_geometry");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_sfdisk_disk_geometry_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_sfdisk_disk_geometry");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_sfdisk_disk_geometry (guestfs_h *g,
- const char *device)
-{
- struct guestfs_sfdisk_disk_geometry_args args;
- struct sfdisk_disk_geometry_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_sfdisk_disk_geometry") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SFDISK_DISK_GEOMETRY,
- (xdrproc_t) xdr_guestfs_sfdisk_disk_geometry_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, sfdisk_disk_geometry_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_sfdisk_disk_geometry");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SFDISK_DISK_GEOMETRY, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.partitions; /* caller will free */
-}
-
-struct vg_activate_all_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void vg_activate_all_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct vg_activate_all_ctx *ctx = (struct vg_activate_all_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_vg_activate_all");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_vg_activate_all");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_vg_activate_all");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_vg_activate_all (guestfs_h *g,
- int activate)
-{
- struct guestfs_vg_activate_all_args args;
- struct vg_activate_all_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_vg_activate_all") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.activate = activate;
- serial = guestfs__send_sync (g, GUESTFS_PROC_VG_ACTIVATE_ALL,
- (xdrproc_t) xdr_guestfs_vg_activate_all_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, vg_activate_all_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_vg_activate_all");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VG_ACTIVATE_ALL, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct vg_activate_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void vg_activate_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct vg_activate_ctx *ctx = (struct vg_activate_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_vg_activate");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_vg_activate");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_vg_activate");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_vg_activate (guestfs_h *g,
- int activate,
- char * const* const volgroups)
-{
- struct guestfs_vg_activate_args args;
- struct vg_activate_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_vg_activate") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.activate = activate;
- args.volgroups.volgroups_val = (char **) volgroups;
- for (args.volgroups.volgroups_len = 0; volgroups[args.volgroups.volgroups_len]; args.volgroups.volgroups_len++) ;
- serial = guestfs__send_sync (g, GUESTFS_PROC_VG_ACTIVATE,
- (xdrproc_t) xdr_guestfs_vg_activate_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, vg_activate_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_vg_activate");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VG_ACTIVATE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct lvresize_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void lvresize_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct lvresize_ctx *ctx = (struct lvresize_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_lvresize");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_lvresize");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_lvresize");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_lvresize (guestfs_h *g,
- const char *device,
- int mbytes)
-{
- struct guestfs_lvresize_args args;
- struct lvresize_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_lvresize") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- args.mbytes = mbytes;
- serial = guestfs__send_sync (g, GUESTFS_PROC_LVRESIZE,
- (xdrproc_t) xdr_guestfs_lvresize_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, lvresize_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_lvresize");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVRESIZE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct resize2fs_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void resize2fs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct resize2fs_ctx *ctx = (struct resize2fs_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_resize2fs");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_resize2fs");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_resize2fs");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_resize2fs (guestfs_h *g,
- const char *device)
-{
- struct guestfs_resize2fs_args args;
- struct resize2fs_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_resize2fs") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_RESIZE2FS,
- (xdrproc_t) xdr_guestfs_resize2fs_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, resize2fs_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_resize2fs");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_RESIZE2FS, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct find_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_find_ret ret;
-};
-
-static void find_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct find_ctx *ctx = (struct find_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_find");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_find");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_find");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_find_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_find");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_find (guestfs_h *g,
- const char *directory)
-{
- struct guestfs_find_args args;
- struct find_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_find") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.directory = (char *) directory;
- serial = guestfs__send_sync (g, GUESTFS_PROC_FIND,
- (xdrproc_t) xdr_guestfs_find_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, find_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_find");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_FIND, serial) == -1) {
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return NULL;
- }
-
- guestfs_end_busy (g);
- /* caller will free this, but we need to add a NULL entry */
- ctx.ret.names.names_val =
- safe_realloc (g, ctx.ret.names.names_val,
- sizeof (char *) * (ctx.ret.names.names_len + 1));
- ctx.ret.names.names_val[ctx.ret.names.names_len] = NULL;
- return ctx.ret.names.names_val;
-}
-
-struct e2fsck_f_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void e2fsck_f_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct e2fsck_f_ctx *ctx = (struct e2fsck_f_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_e2fsck_f");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_e2fsck_f");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_e2fsck_f");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_e2fsck_f (guestfs_h *g,
- const char *device)
-{
- struct guestfs_e2fsck_f_args args;
- struct e2fsck_f_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_e2fsck_f") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_E2FSCK_F,
- (xdrproc_t) xdr_guestfs_e2fsck_f_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, e2fsck_f_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_e2fsck_f");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_E2FSCK_F, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct sleep_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
-};
-
-static void sleep_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct sleep_ctx *ctx = (struct sleep_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_sleep");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_sleep");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_sleep");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_sleep (guestfs_h *g,
- int secs)
-{
- struct guestfs_sleep_args args;
- struct sleep_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_sleep") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.secs = secs;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SLEEP,
- (xdrproc_t) xdr_guestfs_sleep_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, sleep_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_sleep");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SLEEP, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return 0;
-}
-
-struct ntfs_3g_probe_ctx {
- /* This flag is set by the callbacks, so we know we've done
- * the callbacks as expected, and in the right sequence.
- * 0 = not called, 1 = reply_cb called.
- */
- int cb_sequence;
- struct guestfs_message_header hdr;
- struct guestfs_message_error err;
- struct guestfs_ntfs_3g_probe_ret ret;
-};
-
-static void ntfs_3g_probe_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct ntfs_3g_probe_ctx *ctx = (struct ntfs_3g_probe_ctx *) data;
-
- /* This should definitely not happen. */
- if (ctx->cb_sequence != 0) {
- ctx->cb_sequence = 9999;
- error (g, "%s: internal error: reply callback called twice", "guestfs_ntfs_3g_probe");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_ntfs_3g_probe");
- return;
- }
- if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
- if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
- error (g, "%s: failed to parse reply error", "guestfs_ntfs_3g_probe");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_ntfs_3g_probe_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_ntfs_3g_probe");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_ntfs_3g_probe (guestfs_h *g,
- int rw,
- const char *device)
-{
- struct guestfs_ntfs_3g_probe_args args;
- struct ntfs_3g_probe_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_ntfs_3g_probe") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.rw = rw;
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_NTFS_3G_PROBE,
- (xdrproc_t) xdr_guestfs_ntfs_3g_probe_args, (char *) &args);
- if (serial == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs__switch_to_receiving (g);
- ctx.cb_sequence = 0;
- guestfs_set_reply_callback (g, ntfs_3g_probe_reply_cb, &ctx);
- (void) ml->main_loop_run (ml, g);
- guestfs_set_reply_callback (g, NULL, NULL);
- if (ctx.cb_sequence != 1) {
- error (g, "%s reply failed, see earlier error messages", "guestfs_ntfs_3g_probe");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_NTFS_3G_PROBE, serial) == -1) {
- guestfs_end_busy (g);
- return -1;
- }
-
- if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
- error (g, "%s", ctx.err.error_message);
- free (ctx.err.error_message);
- guestfs_end_busy (g);
- return -1;
- }
-
- guestfs_end_busy (g);
- return ctx.ret.status;
-}
-
diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h
deleted file mode 100644
index 7f8f0deb..00000000
--- a/src/guestfs-actions.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* libguestfs generated file
- * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
- * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-extern int guestfs_test0 (guestfs_h *handle, const char *str, const char *optstr, char * const* const strlist, int b, int integer, const char *filein, const char *fileout);
-extern int guestfs_test0rint (guestfs_h *handle, const char *val);
-extern int guestfs_test0rinterr (guestfs_h *handle);
-extern int64_t guestfs_test0rint64 (guestfs_h *handle, const char *val);
-extern int64_t guestfs_test0rint64err (guestfs_h *handle);
-extern int guestfs_test0rbool (guestfs_h *handle, const char *val);
-extern int guestfs_test0rboolerr (guestfs_h *handle);
-extern const char *guestfs_test0rconststring (guestfs_h *handle, const char *val);
-extern const char *guestfs_test0rconststringerr (guestfs_h *handle);
-extern char *guestfs_test0rstring (guestfs_h *handle, const char *val);
-extern char *guestfs_test0rstringerr (guestfs_h *handle);
-extern char **guestfs_test0rstringlist (guestfs_h *handle, const char *val);
-extern char **guestfs_test0rstringlisterr (guestfs_h *handle);
-extern struct guestfs_int_bool *guestfs_test0rintbool (guestfs_h *handle, const char *val);
-extern struct guestfs_int_bool *guestfs_test0rintboolerr (guestfs_h *handle);
-extern struct guestfs_lvm_pv_list *guestfs_test0rpvlist (guestfs_h *handle, const char *val);
-extern struct guestfs_lvm_pv_list *guestfs_test0rpvlisterr (guestfs_h *handle);
-extern struct guestfs_lvm_vg_list *guestfs_test0rvglist (guestfs_h *handle, const char *val);
-extern struct guestfs_lvm_vg_list *guestfs_test0rvglisterr (guestfs_h *handle);
-extern struct guestfs_lvm_lv_list *guestfs_test0rlvlist (guestfs_h *handle, const char *val);
-extern struct guestfs_lvm_lv_list *guestfs_test0rlvlisterr (guestfs_h *handle);
-extern struct guestfs_stat *guestfs_test0rstat (guestfs_h *handle, const char *val);
-extern struct guestfs_stat *guestfs_test0rstaterr (guestfs_h *handle);
-extern struct guestfs_statvfs *guestfs_test0rstatvfs (guestfs_h *handle, const char *val);
-extern struct guestfs_statvfs *guestfs_test0rstatvfserr (guestfs_h *handle);
-extern char **guestfs_test0rhashtable (guestfs_h *handle, const char *val);
-extern char **guestfs_test0rhashtableerr (guestfs_h *handle);
-extern int guestfs_launch (guestfs_h *handle);
-extern int guestfs_wait_ready (guestfs_h *handle);
-extern int guestfs_kill_subprocess (guestfs_h *handle);
-extern int guestfs_add_drive (guestfs_h *handle, const char *filename);
-extern int guestfs_add_cdrom (guestfs_h *handle, const char *filename);
-extern int guestfs_add_drive_ro (guestfs_h *handle, const char *filename);
-extern int guestfs_config (guestfs_h *handle, const char *qemuparam, const char *qemuvalue);
-extern int guestfs_set_qemu (guestfs_h *handle, const char *qemu);
-extern const char *guestfs_get_qemu (guestfs_h *handle);
-extern int guestfs_set_path (guestfs_h *handle, const char *path);
-extern const char *guestfs_get_path (guestfs_h *handle);
-extern int guestfs_set_append (guestfs_h *handle, const char *append);
-extern const char *guestfs_get_append (guestfs_h *handle);
-extern int guestfs_set_autosync (guestfs_h *handle, int autosync);
-extern int guestfs_get_autosync (guestfs_h *handle);
-extern int guestfs_set_verbose (guestfs_h *handle, int verbose);
-extern int guestfs_get_verbose (guestfs_h *handle);
-extern int guestfs_is_ready (guestfs_h *handle);
-extern int guestfs_is_config (guestfs_h *handle);
-extern int guestfs_is_launching (guestfs_h *handle);
-extern int guestfs_is_busy (guestfs_h *handle);
-extern int guestfs_get_state (guestfs_h *handle);
-extern int guestfs_set_busy (guestfs_h *handle);
-extern int guestfs_set_ready (guestfs_h *handle);
-extern int guestfs_end_busy (guestfs_h *handle);
-extern int guestfs_mount (guestfs_h *handle, const char *device, const char *mountpoint);
-extern int guestfs_sync (guestfs_h *handle);
-extern int guestfs_touch (guestfs_h *handle, const char *path);
-extern char *guestfs_cat (guestfs_h *handle, const char *path);
-extern char *guestfs_ll (guestfs_h *handle, const char *directory);
-extern char **guestfs_ls (guestfs_h *handle, const char *directory);
-extern char **guestfs_list_devices (guestfs_h *handle);
-extern char **guestfs_list_partitions (guestfs_h *handle);
-extern char **guestfs_pvs (guestfs_h *handle);
-extern char **guestfs_vgs (guestfs_h *handle);
-extern char **guestfs_lvs (guestfs_h *handle);
-extern struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *handle);
-extern struct guestfs_lvm_vg_list *guestfs_vgs_full (guestfs_h *handle);
-extern struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *handle);
-extern char **guestfs_read_lines (guestfs_h *handle, const char *path);
-extern int guestfs_aug_init (guestfs_h *handle, const char *root, int flags);
-extern int guestfs_aug_close (guestfs_h *handle);
-extern int guestfs_aug_defvar (guestfs_h *handle, const char *name, const char *expr);
-extern struct guestfs_int_bool *guestfs_aug_defnode (guestfs_h *handle, const char *name, const char *expr, const char *val);
-extern char *guestfs_aug_get (guestfs_h *handle, const char *path);
-extern int guestfs_aug_set (guestfs_h *handle, const char *path, const char *val);
-extern int guestfs_aug_insert (guestfs_h *handle, const char *path, const char *label, int before);
-extern int guestfs_aug_rm (guestfs_h *handle, const char *path);
-extern int guestfs_aug_mv (guestfs_h *handle, const char *src, const char *dest);
-extern char **guestfs_aug_match (guestfs_h *handle, const char *path);
-extern int guestfs_aug_save (guestfs_h *handle);
-extern int guestfs_aug_load (guestfs_h *handle);
-extern char **guestfs_aug_ls (guestfs_h *handle, const char *path);
-extern int guestfs_rm (guestfs_h *handle, const char *path);
-extern int guestfs_rmdir (guestfs_h *handle, const char *path);
-extern int guestfs_rm_rf (guestfs_h *handle, const char *path);
-extern int guestfs_mkdir (guestfs_h *handle, const char *path);
-extern int guestfs_mkdir_p (guestfs_h *handle, const char *path);
-extern int guestfs_chmod (guestfs_h *handle, int mode, const char *path);
-extern int guestfs_chown (guestfs_h *handle, int owner, int group, const char *path);
-extern int guestfs_exists (guestfs_h *handle, const char *path);
-extern int guestfs_is_file (guestfs_h *handle, const char *path);
-extern int guestfs_is_dir (guestfs_h *handle, const char *path);
-extern int guestfs_pvcreate (guestfs_h *handle, const char *device);
-extern int guestfs_vgcreate (guestfs_h *handle, const char *volgroup, char * const* const physvols);
-extern int guestfs_lvcreate (guestfs_h *handle, const char *logvol, const char *volgroup, int mbytes);
-extern int guestfs_mkfs (guestfs_h *handle, const char *fstype, const char *device);
-extern int guestfs_sfdisk (guestfs_h *handle, const char *device, int cyls, int heads, int sectors, char * const* const lines);
-extern int guestfs_write_file (guestfs_h *handle, const char *path, const char *content, int size);
-extern int guestfs_umount (guestfs_h *handle, const char *pathordevice);
-extern char **guestfs_mounts (guestfs_h *handle);
-extern int guestfs_umount_all (guestfs_h *handle);
-extern int guestfs_lvm_remove_all (guestfs_h *handle);
-extern char *guestfs_file (guestfs_h *handle, const char *path);
-extern char *guestfs_command (guestfs_h *handle, char * const* const arguments);
-extern char **guestfs_command_lines (guestfs_h *handle, char * const* const arguments);
-extern struct guestfs_stat *guestfs_stat (guestfs_h *handle, const char *path);
-extern struct guestfs_stat *guestfs_lstat (guestfs_h *handle, const char *path);
-extern struct guestfs_statvfs *guestfs_statvfs (guestfs_h *handle, const char *path);
-extern char **guestfs_tune2fs_l (guestfs_h *handle, const char *device);
-extern int guestfs_blockdev_setro (guestfs_h *handle, const char *device);
-extern int guestfs_blockdev_setrw (guestfs_h *handle, const char *device);
-extern int guestfs_blockdev_getro (guestfs_h *handle, const char *device);
-extern int guestfs_blockdev_getss (guestfs_h *handle, const char *device);
-extern int guestfs_blockdev_getbsz (guestfs_h *handle, const char *device);
-extern int guestfs_blockdev_setbsz (guestfs_h *handle, const char *device, int blocksize);
-extern int64_t guestfs_blockdev_getsz (guestfs_h *handle, const char *device);
-extern int64_t guestfs_blockdev_getsize64 (guestfs_h *handle, const char *device);
-extern int guestfs_blockdev_flushbufs (guestfs_h *handle, const char *device);
-extern int guestfs_blockdev_rereadpt (guestfs_h *handle, const char *device);
-extern int guestfs_upload (guestfs_h *handle, const char *filename, const char *remotefilename);
-extern int guestfs_download (guestfs_h *handle, const char *remotefilename, const char *filename);
-extern char *guestfs_checksum (guestfs_h *handle, const char *csumtype, const char *path);
-extern int guestfs_tar_in (guestfs_h *handle, const char *tarfile, const char *directory);
-extern int guestfs_tar_out (guestfs_h *handle, const char *directory, const char *tarfile);
-extern int guestfs_tgz_in (guestfs_h *handle, const char *tarball, const char *directory);
-extern int guestfs_tgz_out (guestfs_h *handle, const char *directory, const char *tarball);
-extern int guestfs_mount_ro (guestfs_h *handle, const char *device, const char *mountpoint);
-extern int guestfs_mount_options (guestfs_h *handle, const char *options, const char *device, const char *mountpoint);
-extern int guestfs_mount_vfs (guestfs_h *handle, const char *options, const char *vfstype, const char *device, const char *mountpoint);
-extern char *guestfs_debug (guestfs_h *handle, const char *subcmd, char * const* const extraargs);
-extern int guestfs_lvremove (guestfs_h *handle, const char *device);
-extern int guestfs_vgremove (guestfs_h *handle, const char *vgname);
-extern int guestfs_pvremove (guestfs_h *handle, const char *device);
-extern int guestfs_set_e2label (guestfs_h *handle, const char *device, const char *label);
-extern char *guestfs_get_e2label (guestfs_h *handle, const char *device);
-extern int guestfs_set_e2uuid (guestfs_h *handle, const char *device, const char *uuid);
-extern char *guestfs_get_e2uuid (guestfs_h *handle, const char *device);
-extern int guestfs_fsck (guestfs_h *handle, const char *fstype, const char *device);
-extern int guestfs_zero (guestfs_h *handle, const char *device);
-extern int guestfs_grub_install (guestfs_h *handle, const char *root, const char *device);
-extern int guestfs_cp (guestfs_h *handle, const char *src, const char *dest);
-extern int guestfs_cp_a (guestfs_h *handle, const char *src, const char *dest);
-extern int guestfs_mv (guestfs_h *handle, const char *src, const char *dest);
-extern int guestfs_drop_caches (guestfs_h *handle, int whattodrop);
-extern char *guestfs_dmesg (guestfs_h *handle);
-extern int guestfs_ping_daemon (guestfs_h *handle);
-extern int guestfs_equal (guestfs_h *handle, const char *file1, const char *file2);
-extern char **guestfs_strings (guestfs_h *handle, const char *path);
-extern char **guestfs_strings_e (guestfs_h *handle, const char *encoding, const char *path);
-extern char *guestfs_hexdump (guestfs_h *handle, const char *path);
-extern int guestfs_zerofree (guestfs_h *handle, const char *device);
-extern int guestfs_pvresize (guestfs_h *handle, const char *device);
-extern int guestfs_sfdisk_N (guestfs_h *handle, const char *device, int n, int cyls, int heads, int sectors, const char *line);
-extern char *guestfs_sfdisk_l (guestfs_h *handle, const char *device);
-extern char *guestfs_sfdisk_kernel_geometry (guestfs_h *handle, const char *device);
-extern char *guestfs_sfdisk_disk_geometry (guestfs_h *handle, const char *device);
-extern int guestfs_vg_activate_all (guestfs_h *handle, int activate);
-extern int guestfs_vg_activate (guestfs_h *handle, int activate, char * const* const volgroups);
-extern int guestfs_lvresize (guestfs_h *handle, const char *device, int mbytes);
-extern int guestfs_resize2fs (guestfs_h *handle, const char *device);
-extern char **guestfs_find (guestfs_h *handle, const char *directory);
-extern int guestfs_e2fsck_f (guestfs_h *handle, const char *device);
-extern int guestfs_sleep (guestfs_h *handle, int secs);
-extern int guestfs_ntfs_3g_probe (guestfs_h *handle, int rw, const char *device);
diff --git a/src/guestfs-bindtests.c b/src/guestfs-bindtests.c
deleted file mode 100644
index a472bca6..00000000
--- a/src/guestfs-bindtests.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/* libguestfs generated file
- * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
- * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <string.h>
-
-#include "guestfs.h"
-#include "guestfs_protocol.h"
-
-#define error guestfs_error
-
-static void
-print_strings (char * const* const argv)
-{
- int argc;
-
- printf ("[");
- for (argc = 0; argv[argc] != NULL; ++argc) {
- if (argc > 0) printf (", ");
- printf ("\"%s\"", argv[argc]);
- }
- printf ("]\n");
-}
-
-/* The test0 function prints its parameters to stdout. */
-int guestfs_test0 (guestfs_h *g,
- const char *str,
- const char *optstr,
- char * const* const strlist,
- int b,
- int integer,
- const char *filein,
- const char *fileout)
-{
- printf ("%s\n", str);
- printf ("%s\n", optstr ? optstr : "null");
- print_strings (strlist);
- printf ("%s\n", b ? "true" : "false");
- printf ("%d\n", integer);
- printf ("%s\n", filein);
- printf ("%s\n", fileout);
- /* Java changes stdout line buffering so we need this: */
- fflush (stdout);
- return 0;
-}
-
-/* Test normal return. */
-int guestfs_test0rint (guestfs_h *g,
- const char *val)
-{
- int r;
- sscanf (val, "%d", &r);
- return r;
-}
-
-/* Test error return. */
-int guestfs_test0rinterr (guestfs_h *g)
-{
- error (g, "error");
- return -1;
-}
-
-/* Test normal return. */
-int64_t guestfs_test0rint64 (guestfs_h *g,
- const char *val)
-{
- int64_t r;
- sscanf (val, "%" SCNi64, &r);
- return r;
-}
-
-/* Test error return. */
-int64_t guestfs_test0rint64err (guestfs_h *g)
-{
- error (g, "error");
- return -1;
-}
-
-/* Test normal return. */
-int guestfs_test0rbool (guestfs_h *g,
- const char *val)
-{
- return strcmp (val, "true") == 0;
-}
-
-/* Test error return. */
-int guestfs_test0rboolerr (guestfs_h *g)
-{
- error (g, "error");
- return -1;
-}
-
-/* Test normal return. */
-const char *guestfs_test0rconststring (guestfs_h *g,
- const char *val)
-{
- return "static string";
-}
-
-/* Test error return. */
-const char *guestfs_test0rconststringerr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
-/* Test normal return. */
-char *guestfs_test0rstring (guestfs_h *g,
- const char *val)
-{
- return strdup (val);
-}
-
-/* Test error return. */
-char *guestfs_test0rstringerr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
-/* Test normal return. */
-char **guestfs_test0rstringlist (guestfs_h *g,
- const char *val)
-{
- char **strs;
- int n, i;
- sscanf (val, "%d", &n);
- strs = malloc ((n+1) * sizeof (char *));
- for (i = 0; i < n; ++i) {
- strs[i] = malloc (16);
- snprintf (strs[i], 16, "%d", i);
- }
- strs[n] = NULL;
- return strs;
-}
-
-/* Test error return. */
-char **guestfs_test0rstringlisterr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
-/* Test normal return. */
-struct guestfs_int_bool *guestfs_test0rintbool (guestfs_h *g,
- const char *val)
-{
- struct guestfs_int_bool *r;
- r = malloc (sizeof (struct guestfs_int_bool));
- sscanf (val, "%" SCNi32, &r->i);
- r->b = 0;
- return r;
-}
-
-/* Test error return. */
-struct guestfs_int_bool *guestfs_test0rintboolerr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
-/* Test normal return. */
-struct guestfs_lvm_pv_list *guestfs_test0rpvlist (guestfs_h *g,
- const char *val)
-{
- struct guestfs_lvm_pv_list *r;
- int i;
- r = malloc (sizeof (struct guestfs_lvm_pv_list));
- sscanf (val, "%d", &r->len);
- r->val = calloc (r->len, sizeof (struct guestfs_lvm_pv));
- for (i = 0; i < r->len; ++i) {
- r->val[i].pv_name = malloc (16);
- snprintf (r->val[i].pv_name, 16, "%d", i);
- }
- return r;
-}
-
-/* Test error return. */
-struct guestfs_lvm_pv_list *guestfs_test0rpvlisterr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
-/* Test normal return. */
-struct guestfs_lvm_vg_list *guestfs_test0rvglist (guestfs_h *g,
- const char *val)
-{
- struct guestfs_lvm_vg_list *r;
- int i;
- r = malloc (sizeof (struct guestfs_lvm_vg_list));
- sscanf (val, "%d", &r->len);
- r->val = calloc (r->len, sizeof (struct guestfs_lvm_vg));
- for (i = 0; i < r->len; ++i) {
- r->val[i].vg_name = malloc (16);
- snprintf (r->val[i].vg_name, 16, "%d", i);
- }
- return r;
-}
-
-/* Test error return. */
-struct guestfs_lvm_vg_list *guestfs_test0rvglisterr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
-/* Test normal return. */
-struct guestfs_lvm_lv_list *guestfs_test0rlvlist (guestfs_h *g,
- const char *val)
-{
- struct guestfs_lvm_lv_list *r;
- int i;
- r = malloc (sizeof (struct guestfs_lvm_lv_list));
- sscanf (val, "%d", &r->len);
- r->val = calloc (r->len, sizeof (struct guestfs_lvm_lv));
- for (i = 0; i < r->len; ++i) {
- r->val[i].lv_name = malloc (16);
- snprintf (r->val[i].lv_name, 16, "%d", i);
- }
- return r;
-}
-
-/* Test error return. */
-struct guestfs_lvm_lv_list *guestfs_test0rlvlisterr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
-/* Test normal return. */
-struct guestfs_stat *guestfs_test0rstat (guestfs_h *g,
- const char *val)
-{
- struct guestfs_stat *r;
- r = calloc (1, sizeof (*r));
- sscanf (val, "%" SCNi64, &r->dev);
- return r;
-}
-
-/* Test error return. */
-struct guestfs_stat *guestfs_test0rstaterr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
-/* Test normal return. */
-struct guestfs_statvfs *guestfs_test0rstatvfs (guestfs_h *g,
- const char *val)
-{
- struct guestfs_statvfs *r;
- r = calloc (1, sizeof (*r));
- sscanf (val, "%" SCNi64, &r->bsize);
- return r;
-}
-
-/* Test error return. */
-struct guestfs_statvfs *guestfs_test0rstatvfserr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
-/* Test normal return. */
-char **guestfs_test0rhashtable (guestfs_h *g,
- const char *val)
-{
- char **strs;
- int n, i;
- sscanf (val, "%d", &n);
- strs = malloc ((n*2+1) * sizeof (char *));
- for (i = 0; i < n; ++i) {
- strs[i*2] = malloc (16);
- strs[i*2+1] = malloc (16);
- snprintf (strs[i*2], 16, "%d", i);
- snprintf (strs[i*2+1], 16, "%d", i);
- }
- strs[n*2] = NULL;
- return strs;
-}
-
-/* Test error return. */
-char **guestfs_test0rhashtableerr (guestfs_h *g)
-{
- error (g, "error");
- return NULL;
-}
-
diff --git a/src/guestfs-structs.h b/src/guestfs-structs.h
deleted file mode 100644
index 76ac8199..00000000
--- a/src/guestfs-structs.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* libguestfs generated file
- * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
- * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-struct guestfs_int_bool {
- int32_t i;
- int32_t b;
-};
-
-struct guestfs_lvm_pv {
- char *pv_name;
- char pv_uuid[32]; /* this is NOT nul-terminated, be careful when printing */
- char *pv_fmt;
- uint64_t pv_size;
- uint64_t dev_size;
- uint64_t pv_free;
- uint64_t pv_used;
- char *pv_attr;
- int64_t pv_pe_count;
- int64_t pv_pe_alloc_count;
- char *pv_tags;
- uint64_t pe_start;
- int64_t pv_mda_count;
- uint64_t pv_mda_free;
-};
-
-struct guestfs_lvm_pv_list {
- uint32_t len;
- struct guestfs_lvm_pv *val;
-};
-
-struct guestfs_lvm_vg {
- char *vg_name;
- char vg_uuid[32]; /* this is NOT nul-terminated, be careful when printing */
- char *vg_fmt;
- char *vg_attr;
- uint64_t vg_size;
- uint64_t vg_free;
- char *vg_sysid;
- uint64_t vg_extent_size;
- int64_t vg_extent_count;
- int64_t vg_free_count;
- int64_t max_lv;
- int64_t max_pv;
- int64_t pv_count;
- int64_t lv_count;
- int64_t snap_count;
- int64_t vg_seqno;
- char *vg_tags;
- int64_t vg_mda_count;
- uint64_t vg_mda_free;
-};
-
-struct guestfs_lvm_vg_list {
- uint32_t len;
- struct guestfs_lvm_vg *val;
-};
-
-struct guestfs_lvm_lv {
- char *lv_name;
- char lv_uuid[32]; /* this is NOT nul-terminated, be careful when printing */
- char *lv_attr;
- int64_t lv_major;
- int64_t lv_minor;
- int64_t lv_kernel_major;
- int64_t lv_kernel_minor;
- uint64_t lv_size;
- int64_t seg_count;
- char *origin;
- float snap_percent; /* [0..100] or -1 */
- float copy_percent; /* [0..100] or -1 */
- char *move_pv;
- char *lv_tags;
- char *mirror_log;
- char *modules;
-};
-
-struct guestfs_lvm_lv_list {
- uint32_t len;
- struct guestfs_lvm_lv *val;
-};
-
-struct guestfs_stat {
- int64_t dev;
- int64_t ino;
- int64_t mode;
- int64_t nlink;
- int64_t uid;
- int64_t gid;
- int64_t rdev;
- int64_t size;
- int64_t blksize;
- int64_t blocks;
- int64_t atime;
- int64_t mtime;
- int64_t ctime;
-};
-
-struct guestfs_statvfs {
- int64_t bsize;
- int64_t frsize;
- int64_t blocks;
- int64_t bfree;
- int64_t bavail;
- int64_t files;
- int64_t ffree;
- int64_t favail;
- int64_t fsid;
- int64_t flag;
- int64_t namemax;
-};
-
diff --git a/src/guestfs.c b/src/guestfs.c
index fea8107d..c3bce0b8 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -31,6 +31,7 @@
#include <time.h>
#include <sys/stat.h>
#include <sys/select.h>
+#include <dirent.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
@@ -161,6 +162,8 @@ struct guestfs_h
char *tmpdir; /* Temporary directory containing socket. */
+ char *qemu_help, *qemu_version; /* Output of qemu -help, qemu -version. */
+
char **cmdline; /* Qemu command line. */
int cmdline_size;
@@ -171,6 +174,8 @@ struct guestfs_h
char *qemu; /* Qemu binary. */
char *append; /* Append to kernel command line. */
+ int memsize; /* Size of RAM (megabytes). */
+
char *last_error;
/* Callbacks. */
@@ -243,6 +248,22 @@ guestfs_create (void)
if (!g->append) goto error;
}
+ /* Choose a suitable memory size. Previously we tried to choose
+ * a minimal memory size, but this isn't really necessary since
+ * recent QEMU and KVM don't do anything nasty like locking
+ * memory into core any more. Thus we can safely choose a
+ * large, generous amount of memory, and it'll just get swapped
+ * on smaller systems.
+ */
+ str = getenv ("LIBGUESTFS_MEMSIZE");
+ if (str) {
+ if (sscanf (str, "%d", &g->memsize) != 1 || g->memsize <= 256) {
+ fprintf (stderr, "libguestfs: non-numeric or too small value for LIBGUESTFS_MEMSIZE\n");
+ goto error;
+ }
+ } else
+ g->memsize = 500;
+
g->main_loop = guestfs_get_default_main_loop ();
/* Start with large serial numbers so they are easy to spot
@@ -309,6 +330,12 @@ guestfs_close (guestfs_h *g)
snprintf (filename, sizeof filename, "%s/sock", g->tmpdir);
unlink (filename);
+ snprintf (filename, sizeof filename, "%s/initrd", g->tmpdir);
+ unlink (filename);
+
+ snprintf (filename, sizeof filename, "%s/kernel", g->tmpdir);
+ unlink (filename);
+
rmdir (g->tmpdir);
free (g->tmpdir);
@@ -339,6 +366,8 @@ guestfs_close (guestfs_h *g)
free (g->path);
free (g->qemu);
free (g->append);
+ free (g->qemu_help);
+ free (g->qemu_version);
free (g);
}
@@ -375,9 +404,11 @@ guestfs_error (guestfs_h *g, const char *fs, ...)
char *msg;
va_start (args, fs);
- vasprintf (&msg, fs, args);
+ int err = vasprintf (&msg, fs, args);
va_end (args);
+ if (err < 0) return;
+
if (g->error_cb) g->error_cb (g, g->error_cb_data, msg);
set_last_error (g, msg);
@@ -586,6 +617,19 @@ guestfs_get_append (guestfs_h *g)
return g->append;
}
+int
+guestfs_set_memsize (guestfs_h *g, int memsize)
+{
+ g->memsize = memsize;
+ return 0;
+}
+
+int
+guestfs_get_memsize (guestfs_h *g)
+{
+ return g->memsize;
+}
+
/* Add a string to the current command line. */
static void
incr_cmdline_size (guestfs_h *g)
@@ -631,7 +675,6 @@ guestfs_config (guestfs_h *g,
strcmp (qemu_param, "-initrd") == 0 ||
strcmp (qemu_param, "-nographic") == 0 ||
strcmp (qemu_param, "-serial") == 0 ||
- strcmp (qemu_param, "-vnc") == 0 ||
strcmp (qemu_param, "-full-screen") == 0 ||
strcmp (qemu_param, "-std-vga") == 0 ||
strcmp (qemu_param, "-vnc") == 0) {
@@ -664,7 +707,8 @@ guestfs_add_drive (guestfs_h *g, const char *filename)
return -1;
}
- snprintf (buf, len, "file=%s", filename);
+ /* cache=off improves reliability in the event of a host crash. */
+ snprintf (buf, len, "file=%s,cache=off,if=%s", filename, DRIVE_IF);
return guestfs_config (g, "-drive", buf);
}
@@ -685,7 +729,7 @@ guestfs_add_drive_ro (guestfs_h *g, const char *filename)
return -1;
}
- snprintf (buf, len, "file=%s,snapshot=on", filename);
+ snprintf (buf, len, "file=%s,snapshot=on,if=%s", filename, DRIVE_IF);
return guestfs_config (g, "-drive", buf);
}
@@ -706,16 +750,56 @@ guestfs_add_cdrom (guestfs_h *g, const char *filename)
return guestfs_config (g, "-cdrom", filename);
}
+/* Returns true iff file is contained in dir. */
+static int
+dir_contains_file (const char *dir, const char *file)
+{
+ int dirlen = strlen (dir);
+ int filelen = strlen (file);
+ int len = dirlen+filelen+2;
+ char path[len];
+
+ snprintf (path, len, "%s/%s", dir, file);
+ return access (path, F_OK) == 0;
+}
+
+/* Returns true iff every listed file is contained in 'dir'. */
+static int
+dir_contains_files (const char *dir, ...)
+{
+ va_list args;
+ const char *file;
+
+ va_start (args, dir);
+ while ((file = va_arg (args, const char *)) != NULL) {
+ if (!dir_contains_file (dir, file)) {
+ va_end (args);
+ return 0;
+ }
+ }
+ va_end (args);
+ return 1;
+}
+
+static int build_supermin_appliance (guestfs_h *g, const char *path, char **kernel, char **initrd);
+static int test_qemu (guestfs_h *g);
+static int qemu_supports (guestfs_h *g, const char *option);
+
+static const char *kernel_name = "vmlinuz." REPO "." host_cpu;
+static const char *initrd_name = "initramfs." REPO "." host_cpu ".img";
+static const char *supermin_name =
+ "initramfs." REPO "." host_cpu ".supermin.img";
+static const char *supermin_hostfiles_name =
+ "initramfs." REPO "." host_cpu ".supermin.hostfiles";
+
int
guestfs_launch (guestfs_h *g)
{
static const char *dir_template = "/tmp/libguestfsXXXXXX";
- int r, i, pmore, memsize;
+ int r, i, pmore;
size_t len;
int wfd[2], rfd[2];
int tries;
- const char *kernel_name = "vmlinuz." REPO "." host_cpu;
- const char *initrd_name = "initramfs." REPO "." host_cpu ".img";
char *path, *pelem, *pend;
char *kernel = NULL, *initrd = NULL;
char unixsock[256];
@@ -732,7 +816,20 @@ guestfs_launch (guestfs_h *g)
return -1;
}
- /* Search g->path for the kernel and initrd. */
+ /* Make the temporary directory. */
+ if (!g->tmpdir) {
+ g->tmpdir = safe_strdup (g, dir_template);
+ if (mkdtemp (g->tmpdir) == NULL) {
+ perrorf (g, _("%s: cannot create temporary directory"), dir_template);
+ goto cleanup0;
+ }
+ }
+
+ /* First search g->path for the supermin appliance, and try to
+ * synthesize a kernel and initrd from that. If it fails, we
+ * try the path search again looking for a backup ordinary
+ * appliance.
+ */
pelem = path = safe_strdup (g, g->path);
do {
pend = strchrnul (pelem, ':');
@@ -740,32 +837,31 @@ guestfs_launch (guestfs_h *g)
*pend = '\0';
len = pend - pelem;
- /* Empty element or "." means cwd. */
+ /* Empty element of "." means cwd. */
if (len == 0 || (len == 1 && *pelem == '.')) {
if (g->verbose)
fprintf (stderr,
- "looking for kernel and initrd in current directory\n");
- if (access (kernel_name, F_OK) == 0 && access (initrd_name, F_OK) == 0) {
- kernel = safe_strdup (g, kernel_name);
- initrd = safe_strdup (g, initrd_name);
+ "looking for supermin appliance in current directory\n");
+ if (dir_contains_files (".",
+ supermin_name, supermin_hostfiles_name,
+ "kmod.whitelist", NULL)) {
+ if (build_supermin_appliance (g, ".", &kernel, &initrd) == -1)
+ return -1;
break;
}
}
- /* Look at <path>/kernel etc. */
+ /* Look at <path>/supermin* etc. */
else {
- kernel = safe_malloc (g, len + strlen (kernel_name) + 2);
- initrd = safe_malloc (g, len + strlen (initrd_name) + 2);
- sprintf (kernel, "%s/%s", pelem, kernel_name);
- sprintf (initrd, "%s/%s", pelem, initrd_name);
-
if (g->verbose)
- fprintf (stderr, "looking for %s and %s\n", kernel, initrd);
+ fprintf (stderr, "looking for supermin appliance in %s\n", pelem);
- if (access (kernel, F_OK) == 0 && access (initrd, F_OK) == 0)
+ if (dir_contains_files (pelem,
+ supermin_name, supermin_hostfiles_name,
+ "kmod.whitelist", NULL)) {
+ if (build_supermin_appliance (g, pelem, &kernel, &initrd) == -1)
+ return -1;
break;
- free (kernel);
- free (initrd);
- kernel = initrd = NULL;
+ }
}
pelem = pend + 1;
@@ -774,29 +870,56 @@ guestfs_launch (guestfs_h *g)
free (path);
if (kernel == NULL || initrd == NULL) {
+ /* Search g->path for the kernel and initrd. */
+ pelem = path = safe_strdup (g, g->path);
+ do {
+ pend = strchrnul (pelem, ':');
+ pmore = *pend == ':';
+ *pend = '\0';
+ len = pend - pelem;
+
+ /* Empty element or "." means cwd. */
+ if (len == 0 || (len == 1 && *pelem == '.')) {
+ if (g->verbose)
+ fprintf (stderr,
+ "looking for appliance in current directory\n");
+ if (dir_contains_files (".", kernel_name, initrd_name, NULL)) {
+ kernel = safe_strdup (g, kernel_name);
+ initrd = safe_strdup (g, initrd_name);
+ break;
+ }
+ }
+ /* Look at <path>/kernel etc. */
+ else {
+ if (g->verbose)
+ fprintf (stderr, "looking for appliance in %s\n", pelem);
+
+ if (dir_contains_files (pelem, kernel_name, initrd_name, NULL)) {
+ kernel = safe_malloc (g, len + strlen (kernel_name) + 2);
+ initrd = safe_malloc (g, len + strlen (initrd_name) + 2);
+ sprintf (kernel, "%s/%s", pelem, kernel_name);
+ sprintf (initrd, "%s/%s", pelem, initrd_name);
+ break;
+ }
+ }
+
+ pelem = pend + 1;
+ } while (pmore);
+
+ free (path);
+ }
+
+ if (kernel == NULL || initrd == NULL) {
error (g, _("cannot find %s or %s on LIBGUESTFS_PATH (current path = %s)"),
kernel_name, initrd_name, g->path);
goto cleanup0;
}
- /* Choose a suitable memory size. Previously we tried to choose
- * a minimal memory size, but this isn't really necessary since
- * recent QEMU and KVM don't do anything nasty like locking
- * memory into core any more. This we can safely choose a
- * large, generous amount of memory, and it'll just get swapped
- * on smaller systems.
- */
- memsize = 384;
-
- /* Make the temporary directory containing the socket. */
- if (!g->tmpdir) {
- g->tmpdir = safe_strdup (g, dir_template);
- if (mkdtemp (g->tmpdir) == NULL) {
- perrorf (g, _("%s: cannot create temporary directory"), dir_template);
- goto cleanup0;
- }
- }
+ /* Get qemu help text and version. */
+ if (test_qemu (g) == -1)
+ goto cleanup0;
+ /* Make the vmchannel socket. */
snprintf (unixsock, sizeof unixsock, "%s/sock", g->tmpdir);
unlink (unixsock);
@@ -837,13 +960,10 @@ guestfs_launch (guestfs_h *g)
g->verbose ? " guestfs_verbose=1" : "",
g->append ? " " : "", g->append ? g->append : "");
- snprintf (memsize_str, sizeof memsize_str, "%d", memsize);
+ snprintf (memsize_str, sizeof memsize_str, "%d", g->memsize);
add_cmdline (g, "-m");
add_cmdline (g, memsize_str);
-#if 0
- add_cmdline (g, "-no-kqemu"); /* Avoids a warning. */
-#endif
add_cmdline (g, "-no-reboot"); /* Force exit instead of reboot on panic */
add_cmdline (g, "-kernel");
add_cmdline (g, (char *) kernel);
@@ -860,6 +980,15 @@ guestfs_launch (guestfs_h *g)
add_cmdline (g, "user,vlan=0");
add_cmdline (g, "-net");
add_cmdline (g, "nic,model=virtio,vlan=0");
+
+ /* These options recommended by KVM developers to improve reliability. */
+ if (qemu_supports (g, "-no-hpet"))
+ add_cmdline (g, "-no-hpet");
+
+ if (qemu_supports (g, "-rtc-td-hack"))
+ add_cmdline (g, "-rtc-td-hack");
+
+ /* Finish off the command line. */
incr_cmdline_size (g);
g->cmdline[g->cmdline_size-1] = NULL;
@@ -1048,6 +1177,127 @@ guestfs_launch (guestfs_h *g)
return -1;
}
+/* This function does the hard work of building the supermin appliance
+ * on the fly. 'path' is the directory containing the control files.
+ * 'kernel' and 'initrd' are where we will return the names of the
+ * kernel and initrd (only initrd is built). The work is done by
+ * an external script. We just tell it where to put the result.
+ */
+static int
+build_supermin_appliance (guestfs_h *g, const char *path,
+ char **kernel, char **initrd)
+{
+ char cmd[4096];
+ int r, len;
+
+ len = strlen (g->tmpdir);
+ *kernel = safe_malloc (g, len + 8);
+ snprintf (*kernel, len+8, "%s/kernel", g->tmpdir);
+ *initrd = safe_malloc (g, len + 8);
+ snprintf (*initrd, len+8, "%s/initrd", g->tmpdir);
+
+ snprintf (cmd, sizeof cmd,
+ "PATH='%s':$PATH "
+ "libguestfs-supermin-helper '%s' %s %s",
+ path,
+ path, *kernel, *initrd);
+
+ r = system (cmd);
+ if (r == -1 || WEXITSTATUS(r) != 0) {
+ error (g, _("external command failed: %s"), cmd);
+ free (*kernel);
+ free (*initrd);
+ *kernel = *initrd = NULL;
+ return -1;
+ }
+
+ return 0;
+}
+
+static int read_all (guestfs_h *g, FILE *fp, char **ret);
+
+/* Test qemu binary (or wrapper) runs, and do 'qemu -help' and
+ * 'qemu -version' so we know what options this qemu supports and
+ * the version.
+ */
+static int
+test_qemu (guestfs_h *g)
+{
+ char cmd[1024];
+ FILE *fp;
+
+ free (g->qemu_help);
+ free (g->qemu_version);
+ g->qemu_help = NULL;
+ g->qemu_version = NULL;
+
+ snprintf (cmd, sizeof cmd, "'%s' -help", g->qemu);
+
+ fp = popen (cmd, "r");
+ /* qemu -help should always work (qemu -version OTOH wasn't
+ * supported by qemu 0.9). If this command doesn't work then it
+ * probably indicates that the qemu binary is missing.
+ */
+ if (!fp) {
+ /* XXX This error is never printed, even if the qemu binary
+ * doesn't exist. Why?
+ */
+ error:
+ perrorf (g, _("%s: command failed: If qemu is located on a non-standard path, try setting the LIBGUESTFS_QEMU environment variable."), cmd);
+ return -1;
+ }
+
+ if (read_all (g, fp, &g->qemu_help) == -1)
+ goto error;
+
+ if (pclose (fp) == -1)
+ goto error;
+
+ snprintf (cmd, sizeof cmd, "'%s' -version 2>/dev/null", g->qemu);
+
+ fp = popen (cmd, "r");
+ if (fp) {
+ /* Intentionally ignore errors. */
+ read_all (g, fp, &g->qemu_version);
+ pclose (fp);
+ }
+
+ return 0;
+}
+
+static int
+read_all (guestfs_h *g, FILE *fp, char **ret)
+{
+ int r, n = 0;
+ char *p;
+
+ again:
+ if (feof (fp)) {
+ *ret = safe_realloc (g, *ret, n + 1);
+ (*ret)[n] = '\0';
+ return n;
+ }
+
+ *ret = safe_realloc (g, *ret, n + BUFSIZ);
+ p = &(*ret)[n];
+ r = fread (p, 1, BUFSIZ, fp);
+ if (ferror (fp)) {
+ perrorf (g, "read");
+ return -1;
+ }
+ n += r;
+ goto again;
+}
+
+/* Test if option is supported by qemu command line (just by grepping
+ * the help text).
+ */
+static int
+qemu_supports (guestfs_h *g, const char *option)
+{
+ return g->qemu_help && strstr (g->qemu_help, option) != NULL;
+}
+
static void
finish_wait_ready (guestfs_h *g, void *vp)
{
@@ -1223,6 +1473,13 @@ guestfs_free_lvm_lv_list (struct guestfs_lvm_lv_list *x)
free (x);
}
+void
+guestfs_free_dirent_list (struct guestfs_dirent_list *x)
+{
+ xdr_free ((xdrproc_t) xdr_guestfs_int_dirent_list, (char *) x);
+ free (x);
+}
+
/* We don't know if stdout_event or sock_read_event will be the
* first to receive EOF if the qemu process dies. This function
* has the common cleanup code for both.
@@ -1451,7 +1708,7 @@ static void
sock_write_event (struct guestfs_main_loop *ml, guestfs_h *g, void *data,
int watch, int fd, int events)
{
- int n;
+ int n, err;
if (g->verbose)
fprintf (stderr,
@@ -1475,8 +1732,11 @@ sock_write_event (struct guestfs_main_loop *ml, guestfs_h *g, void *data,
n = write (g->sock, g->msg_out + g->msg_out_pos,
g->msg_out_size - g->msg_out_pos);
if (n == -1) {
- if (errno != EAGAIN)
+ err = errno;
+ if (err != EAGAIN)
perrorf (g, "write");
+ if (err == EPIPE) /* Disconnected from guest (RHBZ#508713). */
+ child_cleanup (g);
return;
}
diff --git a/src/guestfs.h b/src/guestfs.h
index b5ed0f78..201d60ca 100644
--- a/src/guestfs.h
+++ b/src/guestfs.h
@@ -57,6 +57,7 @@ extern void guestfs_free_int_bool (struct guestfs_int_bool *);
extern void guestfs_free_lvm_pv_list (struct guestfs_lvm_pv_list *);
extern void guestfs_free_lvm_vg_list (struct guestfs_lvm_vg_list *);
extern void guestfs_free_lvm_lv_list (struct guestfs_lvm_lv_list *);
+extern void guestfs_free_dirent_list (struct guestfs_dirent_list *);
/* Low-level event API. */
typedef void (*guestfs_send_cb) (guestfs_h *g, void *data);
diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c
deleted file mode 100644
index fc88d05f..00000000
--- a/src/guestfs_protocol.c
+++ /dev/null
@@ -1,1943 +0,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#include "guestfs_protocol.h"
-
-bool_t
-xdr_str (XDR *xdrs, str *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, objp, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvm_int_pv (XDR *xdrs, guestfs_lvm_int_pv *objp)
-{
- register int32_t *buf;
-
- int i;
- if (!xdr_string (xdrs, &objp->pv_name, ~0))
- return FALSE;
- if (!xdr_opaque (xdrs, objp->pv_uuid, 32))
- return FALSE;
- if (!xdr_string (xdrs, &objp->pv_fmt, ~0))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->pv_size))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->dev_size))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->pv_free))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->pv_used))
- return FALSE;
- if (!xdr_string (xdrs, &objp->pv_attr, ~0))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->pv_pe_count))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->pv_pe_alloc_count))
- return FALSE;
- if (!xdr_string (xdrs, &objp->pv_tags, ~0))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->pe_start))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->pv_mda_count))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->pv_mda_free))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvm_int_pv_list (XDR *xdrs, guestfs_lvm_int_pv_list *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->guestfs_lvm_int_pv_list_val, (u_int *) &objp->guestfs_lvm_int_pv_list_len, ~0,
- sizeof (guestfs_lvm_int_pv), (xdrproc_t) xdr_guestfs_lvm_int_pv))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvm_int_vg (XDR *xdrs, guestfs_lvm_int_vg *objp)
-{
- register int32_t *buf;
-
- int i;
- if (!xdr_string (xdrs, &objp->vg_name, ~0))
- return FALSE;
- if (!xdr_opaque (xdrs, objp->vg_uuid, 32))
- return FALSE;
- if (!xdr_string (xdrs, &objp->vg_fmt, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->vg_attr, ~0))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->vg_size))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->vg_free))
- return FALSE;
- if (!xdr_string (xdrs, &objp->vg_sysid, ~0))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->vg_extent_size))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->vg_extent_count))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->vg_free_count))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->max_lv))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->max_pv))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->pv_count))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->lv_count))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->snap_count))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->vg_seqno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->vg_tags, ~0))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->vg_mda_count))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->vg_mda_free))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvm_int_vg_list (XDR *xdrs, guestfs_lvm_int_vg_list *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->guestfs_lvm_int_vg_list_val, (u_int *) &objp->guestfs_lvm_int_vg_list_len, ~0,
- sizeof (guestfs_lvm_int_vg), (xdrproc_t) xdr_guestfs_lvm_int_vg))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvm_int_lv (XDR *xdrs, guestfs_lvm_int_lv *objp)
-{
- register int32_t *buf;
-
- int i;
- if (!xdr_string (xdrs, &objp->lv_name, ~0))
- return FALSE;
- if (!xdr_opaque (xdrs, objp->lv_uuid, 32))
- return FALSE;
- if (!xdr_string (xdrs, &objp->lv_attr, ~0))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->lv_major))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->lv_minor))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->lv_kernel_major))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->lv_kernel_minor))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->lv_size))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->seg_count))
- return FALSE;
- if (!xdr_string (xdrs, &objp->origin, ~0))
- return FALSE;
- if (!xdr_float (xdrs, &objp->snap_percent))
- return FALSE;
- if (!xdr_float (xdrs, &objp->copy_percent))
- return FALSE;
- if (!xdr_string (xdrs, &objp->move_pv, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->lv_tags, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->mirror_log, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->modules, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvm_int_lv_list (XDR *xdrs, guestfs_lvm_int_lv_list *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->guestfs_lvm_int_lv_list_val, (u_int *) &objp->guestfs_lvm_int_lv_list_len, ~0,
- sizeof (guestfs_lvm_int_lv), (xdrproc_t) xdr_guestfs_lvm_int_lv))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_int_stat (XDR *xdrs, guestfs_int_stat *objp)
-{
- register int32_t *buf;
-
- if (!xdr_quad_t (xdrs, &objp->dev))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->ino))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->mode))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->nlink))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->uid))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->gid))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->rdev))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->size))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->blksize))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->blocks))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->atime))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->mtime))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->ctime))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_int_statvfs (XDR *xdrs, guestfs_int_statvfs *objp)
-{
- register int32_t *buf;
-
- if (!xdr_quad_t (xdrs, &objp->bsize))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->frsize))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->blocks))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->bfree))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->bavail))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->files))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->ffree))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->favail))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->fsid))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->flag))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->namemax))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_mount_args (XDR *xdrs, guestfs_mount_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->mountpoint, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_touch_args (XDR *xdrs, guestfs_touch_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_cat_args (XDR *xdrs, guestfs_cat_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_cat_ret (XDR *xdrs, guestfs_cat_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->content, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_ll_args (XDR *xdrs, guestfs_ll_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->directory, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_ll_ret (XDR *xdrs, guestfs_ll_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->listing, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_ls_args (XDR *xdrs, guestfs_ls_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->directory, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_ls_ret (XDR *xdrs, guestfs_ls_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->listing.listing_val, (u_int *) &objp->listing.listing_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_list_devices_ret (XDR *xdrs, guestfs_list_devices_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->devices.devices_val, (u_int *) &objp->devices.devices_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_list_partitions_ret (XDR *xdrs, guestfs_list_partitions_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->partitions.partitions_val, (u_int *) &objp->partitions.partitions_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_pvs_ret (XDR *xdrs, guestfs_pvs_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->physvols.physvols_val, (u_int *) &objp->physvols.physvols_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_vgs_ret (XDR *xdrs, guestfs_vgs_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->volgroups.volgroups_val, (u_int *) &objp->volgroups.volgroups_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvs_ret (XDR *xdrs, guestfs_lvs_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->logvols.logvols_val, (u_int *) &objp->logvols.logvols_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_pvs_full_ret (XDR *xdrs, guestfs_pvs_full_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_guestfs_lvm_int_pv_list (xdrs, &objp->physvols))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_vgs_full_ret (XDR *xdrs, guestfs_vgs_full_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_guestfs_lvm_int_vg_list (xdrs, &objp->volgroups))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvs_full_ret (XDR *xdrs, guestfs_lvs_full_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_guestfs_lvm_int_lv_list (xdrs, &objp->logvols))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_read_lines_args (XDR *xdrs, guestfs_read_lines_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_read_lines_ret (XDR *xdrs, guestfs_read_lines_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->lines.lines_val, (u_int *) &objp->lines.lines_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_init_args (XDR *xdrs, guestfs_aug_init_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->root, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->flags))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_defvar_args (XDR *xdrs, guestfs_aug_defvar_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->name, ~0))
- return FALSE;
- if (!xdr_pointer (xdrs, (char **)&objp->expr, sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_defvar_ret (XDR *xdrs, guestfs_aug_defvar_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->nrnodes))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_defnode_args (XDR *xdrs, guestfs_aug_defnode_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->name, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->expr, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->val, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_defnode_ret (XDR *xdrs, guestfs_aug_defnode_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->nrnodes))
- return FALSE;
- if (!xdr_bool (xdrs, &objp->created))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_get_args (XDR *xdrs, guestfs_aug_get_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_get_ret (XDR *xdrs, guestfs_aug_get_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->val, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_set_args (XDR *xdrs, guestfs_aug_set_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->val, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_insert_args (XDR *xdrs, guestfs_aug_insert_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->label, ~0))
- return FALSE;
- if (!xdr_bool (xdrs, &objp->before))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_rm_args (XDR *xdrs, guestfs_aug_rm_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_rm_ret (XDR *xdrs, guestfs_aug_rm_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->nrnodes))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_mv_args (XDR *xdrs, guestfs_aug_mv_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->src, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->dest, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_match_args (XDR *xdrs, guestfs_aug_match_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_match_ret (XDR *xdrs, guestfs_aug_match_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->matches.matches_val, (u_int *) &objp->matches.matches_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_ls_args (XDR *xdrs, guestfs_aug_ls_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_aug_ls_ret (XDR *xdrs, guestfs_aug_ls_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->matches.matches_val, (u_int *) &objp->matches.matches_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_rm_args (XDR *xdrs, guestfs_rm_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_rmdir_args (XDR *xdrs, guestfs_rmdir_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_rm_rf_args (XDR *xdrs, guestfs_rm_rf_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_mkdir_args (XDR *xdrs, guestfs_mkdir_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_mkdir_p_args (XDR *xdrs, guestfs_mkdir_p_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_chmod_args (XDR *xdrs, guestfs_chmod_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->mode))
- return FALSE;
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_chown_args (XDR *xdrs, guestfs_chown_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->owner))
- return FALSE;
- if (!xdr_int (xdrs, &objp->group))
- return FALSE;
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_exists_args (XDR *xdrs, guestfs_exists_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_exists_ret (XDR *xdrs, guestfs_exists_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_bool (xdrs, &objp->existsflag))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_is_file_args (XDR *xdrs, guestfs_is_file_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_is_file_ret (XDR *xdrs, guestfs_is_file_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_bool (xdrs, &objp->fileflag))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_is_dir_args (XDR *xdrs, guestfs_is_dir_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_is_dir_ret (XDR *xdrs, guestfs_is_dir_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_bool (xdrs, &objp->dirflag))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_pvcreate_args (XDR *xdrs, guestfs_pvcreate_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_vgcreate_args (XDR *xdrs, guestfs_vgcreate_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->volgroup, ~0))
- return FALSE;
- if (!xdr_array (xdrs, (char **)&objp->physvols.physvols_val, (u_int *) &objp->physvols.physvols_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvcreate_args (XDR *xdrs, guestfs_lvcreate_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->logvol, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volgroup, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->mbytes))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_mkfs_args (XDR *xdrs, guestfs_mkfs_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->fstype, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_sfdisk_args (XDR *xdrs, guestfs_sfdisk_args *objp)
-{
- register int32_t *buf;
-
-
- if (xdrs->x_op == XDR_ENCODE) {
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
- if (buf == NULL) {
- if (!xdr_int (xdrs, &objp->cyls))
- return FALSE;
- if (!xdr_int (xdrs, &objp->heads))
- return FALSE;
- if (!xdr_int (xdrs, &objp->sectors))
- return FALSE;
-
- } else {
- IXDR_PUT_LONG(buf, objp->cyls);
- IXDR_PUT_LONG(buf, objp->heads);
- IXDR_PUT_LONG(buf, objp->sectors);
- }
- if (!xdr_array (xdrs, (char **)&objp->lines.lines_val, (u_int *) &objp->lines.lines_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
- } else if (xdrs->x_op == XDR_DECODE) {
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
- if (buf == NULL) {
- if (!xdr_int (xdrs, &objp->cyls))
- return FALSE;
- if (!xdr_int (xdrs, &objp->heads))
- return FALSE;
- if (!xdr_int (xdrs, &objp->sectors))
- return FALSE;
-
- } else {
- objp->cyls = IXDR_GET_LONG(buf);
- objp->heads = IXDR_GET_LONG(buf);
- objp->sectors = IXDR_GET_LONG(buf);
- }
- if (!xdr_array (xdrs, (char **)&objp->lines.lines_val, (u_int *) &objp->lines.lines_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
- }
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->cyls))
- return FALSE;
- if (!xdr_int (xdrs, &objp->heads))
- return FALSE;
- if (!xdr_int (xdrs, &objp->sectors))
- return FALSE;
- if (!xdr_array (xdrs, (char **)&objp->lines.lines_val, (u_int *) &objp->lines.lines_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_write_file_args (XDR *xdrs, guestfs_write_file_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->content, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->size))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_umount_args (XDR *xdrs, guestfs_umount_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->pathordevice, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_mounts_ret (XDR *xdrs, guestfs_mounts_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->devices.devices_val, (u_int *) &objp->devices.devices_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_file_args (XDR *xdrs, guestfs_file_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_file_ret (XDR *xdrs, guestfs_file_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->description, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_command_args (XDR *xdrs, guestfs_command_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->arguments.arguments_val, (u_int *) &objp->arguments.arguments_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_command_ret (XDR *xdrs, guestfs_command_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->output, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_command_lines_args (XDR *xdrs, guestfs_command_lines_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->arguments.arguments_val, (u_int *) &objp->arguments.arguments_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_command_lines_ret (XDR *xdrs, guestfs_command_lines_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->lines.lines_val, (u_int *) &objp->lines.lines_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_stat_args (XDR *xdrs, guestfs_stat_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_stat_ret (XDR *xdrs, guestfs_stat_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_guestfs_int_stat (xdrs, &objp->statbuf))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lstat_args (XDR *xdrs, guestfs_lstat_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lstat_ret (XDR *xdrs, guestfs_lstat_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_guestfs_int_stat (xdrs, &objp->statbuf))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_statvfs_args (XDR *xdrs, guestfs_statvfs_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_statvfs_ret (XDR *xdrs, guestfs_statvfs_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_guestfs_int_statvfs (xdrs, &objp->statbuf))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_tune2fs_l_args (XDR *xdrs, guestfs_tune2fs_l_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_tune2fs_l_ret (XDR *xdrs, guestfs_tune2fs_l_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->superblock.superblock_val, (u_int *) &objp->superblock.superblock_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_setro_args (XDR *xdrs, guestfs_blockdev_setro_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_setrw_args (XDR *xdrs, guestfs_blockdev_setrw_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getro_args (XDR *xdrs, guestfs_blockdev_getro_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getro_ret (XDR *xdrs, guestfs_blockdev_getro_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_bool (xdrs, &objp->ro))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getss_args (XDR *xdrs, guestfs_blockdev_getss_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getss_ret (XDR *xdrs, guestfs_blockdev_getss_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->sectorsize))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getbsz_args (XDR *xdrs, guestfs_blockdev_getbsz_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getbsz_ret (XDR *xdrs, guestfs_blockdev_getbsz_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->blocksize))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_setbsz_args (XDR *xdrs, guestfs_blockdev_setbsz_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->blocksize))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getsz_args (XDR *xdrs, guestfs_blockdev_getsz_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getsz_ret (XDR *xdrs, guestfs_blockdev_getsz_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_quad_t (xdrs, &objp->sizeinsectors))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getsize64_args (XDR *xdrs, guestfs_blockdev_getsize64_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_getsize64_ret (XDR *xdrs, guestfs_blockdev_getsize64_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_quad_t (xdrs, &objp->sizeinbytes))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_flushbufs_args (XDR *xdrs, guestfs_blockdev_flushbufs_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_blockdev_rereadpt_args (XDR *xdrs, guestfs_blockdev_rereadpt_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_upload_args (XDR *xdrs, guestfs_upload_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->remotefilename, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_download_args (XDR *xdrs, guestfs_download_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->remotefilename, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_checksum_args (XDR *xdrs, guestfs_checksum_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->csumtype, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_checksum_ret (XDR *xdrs, guestfs_checksum_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->checksum, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_tar_in_args (XDR *xdrs, guestfs_tar_in_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->directory, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_tar_out_args (XDR *xdrs, guestfs_tar_out_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->directory, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_tgz_in_args (XDR *xdrs, guestfs_tgz_in_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->directory, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_tgz_out_args (XDR *xdrs, guestfs_tgz_out_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->directory, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_mount_ro_args (XDR *xdrs, guestfs_mount_ro_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->mountpoint, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_mount_options_args (XDR *xdrs, guestfs_mount_options_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->options, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->mountpoint, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_mount_vfs_args (XDR *xdrs, guestfs_mount_vfs_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->options, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->vfstype, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->mountpoint, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_debug_args (XDR *xdrs, guestfs_debug_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->subcmd, ~0))
- return FALSE;
- if (!xdr_array (xdrs, (char **)&objp->extraargs.extraargs_val, (u_int *) &objp->extraargs.extraargs_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_debug_ret (XDR *xdrs, guestfs_debug_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->result, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvremove_args (XDR *xdrs, guestfs_lvremove_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_vgremove_args (XDR *xdrs, guestfs_vgremove_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->vgname, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_pvremove_args (XDR *xdrs, guestfs_pvremove_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_set_e2label_args (XDR *xdrs, guestfs_set_e2label_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->label, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_get_e2label_args (XDR *xdrs, guestfs_get_e2label_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_get_e2label_ret (XDR *xdrs, guestfs_get_e2label_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->label, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_set_e2uuid_args (XDR *xdrs, guestfs_set_e2uuid_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->uuid, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_get_e2uuid_args (XDR *xdrs, guestfs_get_e2uuid_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_get_e2uuid_ret (XDR *xdrs, guestfs_get_e2uuid_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->uuid, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_fsck_args (XDR *xdrs, guestfs_fsck_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->fstype, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_fsck_ret (XDR *xdrs, guestfs_fsck_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->status))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_zero_args (XDR *xdrs, guestfs_zero_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_grub_install_args (XDR *xdrs, guestfs_grub_install_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->root, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_cp_args (XDR *xdrs, guestfs_cp_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->src, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->dest, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_cp_a_args (XDR *xdrs, guestfs_cp_a_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->src, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->dest, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_mv_args (XDR *xdrs, guestfs_mv_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->src, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->dest, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_drop_caches_args (XDR *xdrs, guestfs_drop_caches_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->whattodrop))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_dmesg_ret (XDR *xdrs, guestfs_dmesg_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->kmsgs, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_equal_args (XDR *xdrs, guestfs_equal_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->file1, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->file2, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_equal_ret (XDR *xdrs, guestfs_equal_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_bool (xdrs, &objp->equality))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_strings_args (XDR *xdrs, guestfs_strings_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_strings_ret (XDR *xdrs, guestfs_strings_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->stringsout.stringsout_val, (u_int *) &objp->stringsout.stringsout_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_strings_e_args (XDR *xdrs, guestfs_strings_e_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->encoding, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_strings_e_ret (XDR *xdrs, guestfs_strings_e_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->stringsout.stringsout_val, (u_int *) &objp->stringsout.stringsout_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_hexdump_args (XDR *xdrs, guestfs_hexdump_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_hexdump_ret (XDR *xdrs, guestfs_hexdump_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->dump, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_zerofree_args (XDR *xdrs, guestfs_zerofree_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_pvresize_args (XDR *xdrs, guestfs_pvresize_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_sfdisk_N_args (XDR *xdrs, guestfs_sfdisk_N_args *objp)
-{
- register int32_t *buf;
-
-
- if (xdrs->x_op == XDR_ENCODE) {
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
- if (buf == NULL) {
- if (!xdr_int (xdrs, &objp->n))
- return FALSE;
- if (!xdr_int (xdrs, &objp->cyls))
- return FALSE;
- if (!xdr_int (xdrs, &objp->heads))
- return FALSE;
- if (!xdr_int (xdrs, &objp->sectors))
- return FALSE;
-
- } else {
- IXDR_PUT_LONG(buf, objp->n);
- IXDR_PUT_LONG(buf, objp->cyls);
- IXDR_PUT_LONG(buf, objp->heads);
- IXDR_PUT_LONG(buf, objp->sectors);
- }
- if (!xdr_string (xdrs, &objp->line, ~0))
- return FALSE;
- return TRUE;
- } else if (xdrs->x_op == XDR_DECODE) {
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
- if (buf == NULL) {
- if (!xdr_int (xdrs, &objp->n))
- return FALSE;
- if (!xdr_int (xdrs, &objp->cyls))
- return FALSE;
- if (!xdr_int (xdrs, &objp->heads))
- return FALSE;
- if (!xdr_int (xdrs, &objp->sectors))
- return FALSE;
-
- } else {
- objp->n = IXDR_GET_LONG(buf);
- objp->cyls = IXDR_GET_LONG(buf);
- objp->heads = IXDR_GET_LONG(buf);
- objp->sectors = IXDR_GET_LONG(buf);
- }
- if (!xdr_string (xdrs, &objp->line, ~0))
- return FALSE;
- return TRUE;
- }
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->n))
- return FALSE;
- if (!xdr_int (xdrs, &objp->cyls))
- return FALSE;
- if (!xdr_int (xdrs, &objp->heads))
- return FALSE;
- if (!xdr_int (xdrs, &objp->sectors))
- return FALSE;
- if (!xdr_string (xdrs, &objp->line, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_sfdisk_l_args (XDR *xdrs, guestfs_sfdisk_l_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_sfdisk_l_ret (XDR *xdrs, guestfs_sfdisk_l_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->partitions, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_sfdisk_kernel_geometry_args (XDR *xdrs, guestfs_sfdisk_kernel_geometry_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_sfdisk_kernel_geometry_ret (XDR *xdrs, guestfs_sfdisk_kernel_geometry_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->partitions, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_sfdisk_disk_geometry_args (XDR *xdrs, guestfs_sfdisk_disk_geometry_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_sfdisk_disk_geometry_ret (XDR *xdrs, guestfs_sfdisk_disk_geometry_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->partitions, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_vg_activate_all_args (XDR *xdrs, guestfs_vg_activate_all_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_bool (xdrs, &objp->activate))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_vg_activate_args (XDR *xdrs, guestfs_vg_activate_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_bool (xdrs, &objp->activate))
- return FALSE;
- if (!xdr_array (xdrs, (char **)&objp->volgroups.volgroups_val, (u_int *) &objp->volgroups.volgroups_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_lvresize_args (XDR *xdrs, guestfs_lvresize_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->mbytes))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_resize2fs_args (XDR *xdrs, guestfs_resize2fs_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_find_args (XDR *xdrs, guestfs_find_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->directory, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_find_ret (XDR *xdrs, guestfs_find_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_array (xdrs, (char **)&objp->names.names_val, (u_int *) &objp->names.names_len, ~0,
- sizeof (str), (xdrproc_t) xdr_str))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_e2fsck_f_args (XDR *xdrs, guestfs_e2fsck_f_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_sleep_args (XDR *xdrs, guestfs_sleep_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->secs))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_ntfs_3g_probe_args (XDR *xdrs, guestfs_ntfs_3g_probe_args *objp)
-{
- register int32_t *buf;
-
- if (!xdr_bool (xdrs, &objp->rw))
- return FALSE;
- if (!xdr_string (xdrs, &objp->device, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_ntfs_3g_probe_ret (XDR *xdrs, guestfs_ntfs_3g_probe_ret *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->status))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp)
-{
- register int32_t *buf;
-
- if (!xdr_enum (xdrs, (enum_t *) objp))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_message_direction (XDR *xdrs, guestfs_message_direction *objp)
-{
- register int32_t *buf;
-
- if (!xdr_enum (xdrs, (enum_t *) objp))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_message_status (XDR *xdrs, guestfs_message_status *objp)
-{
- register int32_t *buf;
-
- if (!xdr_enum (xdrs, (enum_t *) objp))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_message_error (XDR *xdrs, guestfs_message_error *objp)
-{
- register int32_t *buf;
-
- if (!xdr_string (xdrs, &objp->error_message, GUESTFS_ERROR_LEN))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_message_header (XDR *xdrs, guestfs_message_header *objp)
-{
- register int32_t *buf;
-
- if (!xdr_u_int (xdrs, &objp->prog))
- return FALSE;
- if (!xdr_u_int (xdrs, &objp->vers))
- return FALSE;
- if (!xdr_guestfs_procedure (xdrs, &objp->proc))
- return FALSE;
- if (!xdr_guestfs_message_direction (xdrs, &objp->direction))
- return FALSE;
- if (!xdr_u_int (xdrs, &objp->serial))
- return FALSE;
- if (!xdr_guestfs_message_status (xdrs, &objp->status))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_guestfs_chunk (XDR *xdrs, guestfs_chunk *objp)
-{
- register int32_t *buf;
-
- if (!xdr_int (xdrs, &objp->cancel))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, GUESTFS_MAX_CHUNK_SIZE))
- return FALSE;
- return TRUE;
-}
diff --git a/src/guestfs_protocol.h b/src/guestfs_protocol.h
deleted file mode 100644
index 9f3bd8d0..00000000
--- a/src/guestfs_protocol.h
+++ /dev/null
@@ -1,1433 +0,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#ifndef _GUESTFS_PROTOCOL_H_RPCGEN
-#define _GUESTFS_PROTOCOL_H_RPCGEN
-
-#include <rpc/rpc.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-typedef char *str;
-
-struct guestfs_lvm_int_pv {
- char *pv_name;
- char pv_uuid[32];
- char *pv_fmt;
- quad_t pv_size;
- quad_t dev_size;
- quad_t pv_free;
- quad_t pv_used;
- char *pv_attr;
- quad_t pv_pe_count;
- quad_t pv_pe_alloc_count;
- char *pv_tags;
- quad_t pe_start;
- quad_t pv_mda_count;
- quad_t pv_mda_free;
-};
-typedef struct guestfs_lvm_int_pv guestfs_lvm_int_pv;
-
-typedef struct {
- u_int guestfs_lvm_int_pv_list_len;
- guestfs_lvm_int_pv *guestfs_lvm_int_pv_list_val;
-} guestfs_lvm_int_pv_list;
-
-struct guestfs_lvm_int_vg {
- char *vg_name;
- char vg_uuid[32];
- char *vg_fmt;
- char *vg_attr;
- quad_t vg_size;
- quad_t vg_free;
- char *vg_sysid;
- quad_t vg_extent_size;
- quad_t vg_extent_count;
- quad_t vg_free_count;
- quad_t max_lv;
- quad_t max_pv;
- quad_t pv_count;
- quad_t lv_count;
- quad_t snap_count;
- quad_t vg_seqno;
- char *vg_tags;
- quad_t vg_mda_count;
- quad_t vg_mda_free;
-};
-typedef struct guestfs_lvm_int_vg guestfs_lvm_int_vg;
-
-typedef struct {
- u_int guestfs_lvm_int_vg_list_len;
- guestfs_lvm_int_vg *guestfs_lvm_int_vg_list_val;
-} guestfs_lvm_int_vg_list;
-
-struct guestfs_lvm_int_lv {
- char *lv_name;
- char lv_uuid[32];
- char *lv_attr;
- quad_t lv_major;
- quad_t lv_minor;
- quad_t lv_kernel_major;
- quad_t lv_kernel_minor;
- quad_t lv_size;
- quad_t seg_count;
- char *origin;
- float snap_percent;
- float copy_percent;
- char *move_pv;
- char *lv_tags;
- char *mirror_log;
- char *modules;
-};
-typedef struct guestfs_lvm_int_lv guestfs_lvm_int_lv;
-
-typedef struct {
- u_int guestfs_lvm_int_lv_list_len;
- guestfs_lvm_int_lv *guestfs_lvm_int_lv_list_val;
-} guestfs_lvm_int_lv_list;
-
-struct guestfs_int_stat {
- quad_t dev;
- quad_t ino;
- quad_t mode;
- quad_t nlink;
- quad_t uid;
- quad_t gid;
- quad_t rdev;
- quad_t size;
- quad_t blksize;
- quad_t blocks;
- quad_t atime;
- quad_t mtime;
- quad_t ctime;
-};
-typedef struct guestfs_int_stat guestfs_int_stat;
-
-struct guestfs_int_statvfs {
- quad_t bsize;
- quad_t frsize;
- quad_t blocks;
- quad_t bfree;
- quad_t bavail;
- quad_t files;
- quad_t ffree;
- quad_t favail;
- quad_t fsid;
- quad_t flag;
- quad_t namemax;
-};
-typedef struct guestfs_int_statvfs guestfs_int_statvfs;
-
-struct guestfs_mount_args {
- char *device;
- char *mountpoint;
-};
-typedef struct guestfs_mount_args guestfs_mount_args;
-
-struct guestfs_touch_args {
- char *path;
-};
-typedef struct guestfs_touch_args guestfs_touch_args;
-
-struct guestfs_cat_args {
- char *path;
-};
-typedef struct guestfs_cat_args guestfs_cat_args;
-
-struct guestfs_cat_ret {
- char *content;
-};
-typedef struct guestfs_cat_ret guestfs_cat_ret;
-
-struct guestfs_ll_args {
- char *directory;
-};
-typedef struct guestfs_ll_args guestfs_ll_args;
-
-struct guestfs_ll_ret {
- char *listing;
-};
-typedef struct guestfs_ll_ret guestfs_ll_ret;
-
-struct guestfs_ls_args {
- char *directory;
-};
-typedef struct guestfs_ls_args guestfs_ls_args;
-
-struct guestfs_ls_ret {
- struct {
- u_int listing_len;
- str *listing_val;
- } listing;
-};
-typedef struct guestfs_ls_ret guestfs_ls_ret;
-
-struct guestfs_list_devices_ret {
- struct {
- u_int devices_len;
- str *devices_val;
- } devices;
-};
-typedef struct guestfs_list_devices_ret guestfs_list_devices_ret;
-
-struct guestfs_list_partitions_ret {
- struct {
- u_int partitions_len;
- str *partitions_val;
- } partitions;
-};
-typedef struct guestfs_list_partitions_ret guestfs_list_partitions_ret;
-
-struct guestfs_pvs_ret {
- struct {
- u_int physvols_len;
- str *physvols_val;
- } physvols;
-};
-typedef struct guestfs_pvs_ret guestfs_pvs_ret;
-
-struct guestfs_vgs_ret {
- struct {
- u_int volgroups_len;
- str *volgroups_val;
- } volgroups;
-};
-typedef struct guestfs_vgs_ret guestfs_vgs_ret;
-
-struct guestfs_lvs_ret {
- struct {
- u_int logvols_len;
- str *logvols_val;
- } logvols;
-};
-typedef struct guestfs_lvs_ret guestfs_lvs_ret;
-
-struct guestfs_pvs_full_ret {
- guestfs_lvm_int_pv_list physvols;
-};
-typedef struct guestfs_pvs_full_ret guestfs_pvs_full_ret;
-
-struct guestfs_vgs_full_ret {
- guestfs_lvm_int_vg_list volgroups;
-};
-typedef struct guestfs_vgs_full_ret guestfs_vgs_full_ret;
-
-struct guestfs_lvs_full_ret {
- guestfs_lvm_int_lv_list logvols;
-};
-typedef struct guestfs_lvs_full_ret guestfs_lvs_full_ret;
-
-struct guestfs_read_lines_args {
- char *path;
-};
-typedef struct guestfs_read_lines_args guestfs_read_lines_args;
-
-struct guestfs_read_lines_ret {
- struct {
- u_int lines_len;
- str *lines_val;
- } lines;
-};
-typedef struct guestfs_read_lines_ret guestfs_read_lines_ret;
-
-struct guestfs_aug_init_args {
- char *root;
- int flags;
-};
-typedef struct guestfs_aug_init_args guestfs_aug_init_args;
-
-struct guestfs_aug_defvar_args {
- char *name;
- str *expr;
-};
-typedef struct guestfs_aug_defvar_args guestfs_aug_defvar_args;
-
-struct guestfs_aug_defvar_ret {
- int nrnodes;
-};
-typedef struct guestfs_aug_defvar_ret guestfs_aug_defvar_ret;
-
-struct guestfs_aug_defnode_args {
- char *name;
- char *expr;
- char *val;
-};
-typedef struct guestfs_aug_defnode_args guestfs_aug_defnode_args;
-
-struct guestfs_aug_defnode_ret {
- int nrnodes;
- bool_t created;
-};
-typedef struct guestfs_aug_defnode_ret guestfs_aug_defnode_ret;
-
-struct guestfs_aug_get_args {
- char *path;
-};
-typedef struct guestfs_aug_get_args guestfs_aug_get_args;
-
-struct guestfs_aug_get_ret {
- char *val;
-};
-typedef struct guestfs_aug_get_ret guestfs_aug_get_ret;
-
-struct guestfs_aug_set_args {
- char *path;
- char *val;
-};
-typedef struct guestfs_aug_set_args guestfs_aug_set_args;
-
-struct guestfs_aug_insert_args {
- char *path;
- char *label;
- bool_t before;
-};
-typedef struct guestfs_aug_insert_args guestfs_aug_insert_args;
-
-struct guestfs_aug_rm_args {
- char *path;
-};
-typedef struct guestfs_aug_rm_args guestfs_aug_rm_args;
-
-struct guestfs_aug_rm_ret {
- int nrnodes;
-};
-typedef struct guestfs_aug_rm_ret guestfs_aug_rm_ret;
-
-struct guestfs_aug_mv_args {
- char *src;
- char *dest;
-};
-typedef struct guestfs_aug_mv_args guestfs_aug_mv_args;
-
-struct guestfs_aug_match_args {
- char *path;
-};
-typedef struct guestfs_aug_match_args guestfs_aug_match_args;
-
-struct guestfs_aug_match_ret {
- struct {
- u_int matches_len;
- str *matches_val;
- } matches;
-};
-typedef struct guestfs_aug_match_ret guestfs_aug_match_ret;
-
-struct guestfs_aug_ls_args {
- char *path;
-};
-typedef struct guestfs_aug_ls_args guestfs_aug_ls_args;
-
-struct guestfs_aug_ls_ret {
- struct {
- u_int matches_len;
- str *matches_val;
- } matches;
-};
-typedef struct guestfs_aug_ls_ret guestfs_aug_ls_ret;
-
-struct guestfs_rm_args {
- char *path;
-};
-typedef struct guestfs_rm_args guestfs_rm_args;
-
-struct guestfs_rmdir_args {
- char *path;
-};
-typedef struct guestfs_rmdir_args guestfs_rmdir_args;
-
-struct guestfs_rm_rf_args {
- char *path;
-};
-typedef struct guestfs_rm_rf_args guestfs_rm_rf_args;
-
-struct guestfs_mkdir_args {
- char *path;
-};
-typedef struct guestfs_mkdir_args guestfs_mkdir_args;
-
-struct guestfs_mkdir_p_args {
- char *path;
-};
-typedef struct guestfs_mkdir_p_args guestfs_mkdir_p_args;
-
-struct guestfs_chmod_args {
- int mode;
- char *path;
-};
-typedef struct guestfs_chmod_args guestfs_chmod_args;
-
-struct guestfs_chown_args {
- int owner;
- int group;
- char *path;
-};
-typedef struct guestfs_chown_args guestfs_chown_args;
-
-struct guestfs_exists_args {
- char *path;
-};
-typedef struct guestfs_exists_args guestfs_exists_args;
-
-struct guestfs_exists_ret {
- bool_t existsflag;
-};
-typedef struct guestfs_exists_ret guestfs_exists_ret;
-
-struct guestfs_is_file_args {
- char *path;
-};
-typedef struct guestfs_is_file_args guestfs_is_file_args;
-
-struct guestfs_is_file_ret {
- bool_t fileflag;
-};
-typedef struct guestfs_is_file_ret guestfs_is_file_ret;
-
-struct guestfs_is_dir_args {
- char *path;
-};
-typedef struct guestfs_is_dir_args guestfs_is_dir_args;
-
-struct guestfs_is_dir_ret {
- bool_t dirflag;
-};
-typedef struct guestfs_is_dir_ret guestfs_is_dir_ret;
-
-struct guestfs_pvcreate_args {
- char *device;
-};
-typedef struct guestfs_pvcreate_args guestfs_pvcreate_args;
-
-struct guestfs_vgcreate_args {
- char *volgroup;
- struct {
- u_int physvols_len;
- str *physvols_val;
- } physvols;
-};
-typedef struct guestfs_vgcreate_args guestfs_vgcreate_args;
-
-struct guestfs_lvcreate_args {
- char *logvol;
- char *volgroup;
- int mbytes;
-};
-typedef struct guestfs_lvcreate_args guestfs_lvcreate_args;
-
-struct guestfs_mkfs_args {
- char *fstype;
- char *device;
-};
-typedef struct guestfs_mkfs_args guestfs_mkfs_args;
-
-struct guestfs_sfdisk_args {
- char *device;
- int cyls;
- int heads;
- int sectors;
- struct {
- u_int lines_len;
- str *lines_val;
- } lines;
-};
-typedef struct guestfs_sfdisk_args guestfs_sfdisk_args;
-
-struct guestfs_write_file_args {
- char *path;
- char *content;
- int size;
-};
-typedef struct guestfs_write_file_args guestfs_write_file_args;
-
-struct guestfs_umount_args {
- char *pathordevice;
-};
-typedef struct guestfs_umount_args guestfs_umount_args;
-
-struct guestfs_mounts_ret {
- struct {
- u_int devices_len;
- str *devices_val;
- } devices;
-};
-typedef struct guestfs_mounts_ret guestfs_mounts_ret;
-
-struct guestfs_file_args {
- char *path;
-};
-typedef struct guestfs_file_args guestfs_file_args;
-
-struct guestfs_file_ret {
- char *description;
-};
-typedef struct guestfs_file_ret guestfs_file_ret;
-
-struct guestfs_command_args {
- struct {
- u_int arguments_len;
- str *arguments_val;
- } arguments;
-};
-typedef struct guestfs_command_args guestfs_command_args;
-
-struct guestfs_command_ret {
- char *output;
-};
-typedef struct guestfs_command_ret guestfs_command_ret;
-
-struct guestfs_command_lines_args {
- struct {
- u_int arguments_len;
- str *arguments_val;
- } arguments;
-};
-typedef struct guestfs_command_lines_args guestfs_command_lines_args;
-
-struct guestfs_command_lines_ret {
- struct {
- u_int lines_len;
- str *lines_val;
- } lines;
-};
-typedef struct guestfs_command_lines_ret guestfs_command_lines_ret;
-
-struct guestfs_stat_args {
- char *path;
-};
-typedef struct guestfs_stat_args guestfs_stat_args;
-
-struct guestfs_stat_ret {
- guestfs_int_stat statbuf;
-};
-typedef struct guestfs_stat_ret guestfs_stat_ret;
-
-struct guestfs_lstat_args {
- char *path;
-};
-typedef struct guestfs_lstat_args guestfs_lstat_args;
-
-struct guestfs_lstat_ret {
- guestfs_int_stat statbuf;
-};
-typedef struct guestfs_lstat_ret guestfs_lstat_ret;
-
-struct guestfs_statvfs_args {
- char *path;
-};
-typedef struct guestfs_statvfs_args guestfs_statvfs_args;
-
-struct guestfs_statvfs_ret {
- guestfs_int_statvfs statbuf;
-};
-typedef struct guestfs_statvfs_ret guestfs_statvfs_ret;
-
-struct guestfs_tune2fs_l_args {
- char *device;
-};
-typedef struct guestfs_tune2fs_l_args guestfs_tune2fs_l_args;
-
-struct guestfs_tune2fs_l_ret {
- struct {
- u_int superblock_len;
- str *superblock_val;
- } superblock;
-};
-typedef struct guestfs_tune2fs_l_ret guestfs_tune2fs_l_ret;
-
-struct guestfs_blockdev_setro_args {
- char *device;
-};
-typedef struct guestfs_blockdev_setro_args guestfs_blockdev_setro_args;
-
-struct guestfs_blockdev_setrw_args {
- char *device;
-};
-typedef struct guestfs_blockdev_setrw_args guestfs_blockdev_setrw_args;
-
-struct guestfs_blockdev_getro_args {
- char *device;
-};
-typedef struct guestfs_blockdev_getro_args guestfs_blockdev_getro_args;
-
-struct guestfs_blockdev_getro_ret {
- bool_t ro;
-};
-typedef struct guestfs_blockdev_getro_ret guestfs_blockdev_getro_ret;
-
-struct guestfs_blockdev_getss_args {
- char *device;
-};
-typedef struct guestfs_blockdev_getss_args guestfs_blockdev_getss_args;
-
-struct guestfs_blockdev_getss_ret {
- int sectorsize;
-};
-typedef struct guestfs_blockdev_getss_ret guestfs_blockdev_getss_ret;
-
-struct guestfs_blockdev_getbsz_args {
- char *device;
-};
-typedef struct guestfs_blockdev_getbsz_args guestfs_blockdev_getbsz_args;
-
-struct guestfs_blockdev_getbsz_ret {
- int blocksize;
-};
-typedef struct guestfs_blockdev_getbsz_ret guestfs_blockdev_getbsz_ret;
-
-struct guestfs_blockdev_setbsz_args {
- char *device;
- int blocksize;
-};
-typedef struct guestfs_blockdev_setbsz_args guestfs_blockdev_setbsz_args;
-
-struct guestfs_blockdev_getsz_args {
- char *device;
-};
-typedef struct guestfs_blockdev_getsz_args guestfs_blockdev_getsz_args;
-
-struct guestfs_blockdev_getsz_ret {
- quad_t sizeinsectors;
-};
-typedef struct guestfs_blockdev_getsz_ret guestfs_blockdev_getsz_ret;
-
-struct guestfs_blockdev_getsize64_args {
- char *device;
-};
-typedef struct guestfs_blockdev_getsize64_args guestfs_blockdev_getsize64_args;
-
-struct guestfs_blockdev_getsize64_ret {
- quad_t sizeinbytes;
-};
-typedef struct guestfs_blockdev_getsize64_ret guestfs_blockdev_getsize64_ret;
-
-struct guestfs_blockdev_flushbufs_args {
- char *device;
-};
-typedef struct guestfs_blockdev_flushbufs_args guestfs_blockdev_flushbufs_args;
-
-struct guestfs_blockdev_rereadpt_args {
- char *device;
-};
-typedef struct guestfs_blockdev_rereadpt_args guestfs_blockdev_rereadpt_args;
-
-struct guestfs_upload_args {
- char *remotefilename;
-};
-typedef struct guestfs_upload_args guestfs_upload_args;
-
-struct guestfs_download_args {
- char *remotefilename;
-};
-typedef struct guestfs_download_args guestfs_download_args;
-
-struct guestfs_checksum_args {
- char *csumtype;
- char *path;
-};
-typedef struct guestfs_checksum_args guestfs_checksum_args;
-
-struct guestfs_checksum_ret {
- char *checksum;
-};
-typedef struct guestfs_checksum_ret guestfs_checksum_ret;
-
-struct guestfs_tar_in_args {
- char *directory;
-};
-typedef struct guestfs_tar_in_args guestfs_tar_in_args;
-
-struct guestfs_tar_out_args {
- char *directory;
-};
-typedef struct guestfs_tar_out_args guestfs_tar_out_args;
-
-struct guestfs_tgz_in_args {
- char *directory;
-};
-typedef struct guestfs_tgz_in_args guestfs_tgz_in_args;
-
-struct guestfs_tgz_out_args {
- char *directory;
-};
-typedef struct guestfs_tgz_out_args guestfs_tgz_out_args;
-
-struct guestfs_mount_ro_args {
- char *device;
- char *mountpoint;
-};
-typedef struct guestfs_mount_ro_args guestfs_mount_ro_args;
-
-struct guestfs_mount_options_args {
- char *options;
- char *device;
- char *mountpoint;
-};
-typedef struct guestfs_mount_options_args guestfs_mount_options_args;
-
-struct guestfs_mount_vfs_args {
- char *options;
- char *vfstype;
- char *device;
- char *mountpoint;
-};
-typedef struct guestfs_mount_vfs_args guestfs_mount_vfs_args;
-
-struct guestfs_debug_args {
- char *subcmd;
- struct {
- u_int extraargs_len;
- str *extraargs_val;
- } extraargs;
-};
-typedef struct guestfs_debug_args guestfs_debug_args;
-
-struct guestfs_debug_ret {
- char *result;
-};
-typedef struct guestfs_debug_ret guestfs_debug_ret;
-
-struct guestfs_lvremove_args {
- char *device;
-};
-typedef struct guestfs_lvremove_args guestfs_lvremove_args;
-
-struct guestfs_vgremove_args {
- char *vgname;
-};
-typedef struct guestfs_vgremove_args guestfs_vgremove_args;
-
-struct guestfs_pvremove_args {
- char *device;
-};
-typedef struct guestfs_pvremove_args guestfs_pvremove_args;
-
-struct guestfs_set_e2label_args {
- char *device;
- char *label;
-};
-typedef struct guestfs_set_e2label_args guestfs_set_e2label_args;
-
-struct guestfs_get_e2label_args {
- char *device;
-};
-typedef struct guestfs_get_e2label_args guestfs_get_e2label_args;
-
-struct guestfs_get_e2label_ret {
- char *label;
-};
-typedef struct guestfs_get_e2label_ret guestfs_get_e2label_ret;
-
-struct guestfs_set_e2uuid_args {
- char *device;
- char *uuid;
-};
-typedef struct guestfs_set_e2uuid_args guestfs_set_e2uuid_args;
-
-struct guestfs_get_e2uuid_args {
- char *device;
-};
-typedef struct guestfs_get_e2uuid_args guestfs_get_e2uuid_args;
-
-struct guestfs_get_e2uuid_ret {
- char *uuid;
-};
-typedef struct guestfs_get_e2uuid_ret guestfs_get_e2uuid_ret;
-
-struct guestfs_fsck_args {
- char *fstype;
- char *device;
-};
-typedef struct guestfs_fsck_args guestfs_fsck_args;
-
-struct guestfs_fsck_ret {
- int status;
-};
-typedef struct guestfs_fsck_ret guestfs_fsck_ret;
-
-struct guestfs_zero_args {
- char *device;
-};
-typedef struct guestfs_zero_args guestfs_zero_args;
-
-struct guestfs_grub_install_args {
- char *root;
- char *device;
-};
-typedef struct guestfs_grub_install_args guestfs_grub_install_args;
-
-struct guestfs_cp_args {
- char *src;
- char *dest;
-};
-typedef struct guestfs_cp_args guestfs_cp_args;
-
-struct guestfs_cp_a_args {
- char *src;
- char *dest;
-};
-typedef struct guestfs_cp_a_args guestfs_cp_a_args;
-
-struct guestfs_mv_args {
- char *src;
- char *dest;
-};
-typedef struct guestfs_mv_args guestfs_mv_args;
-
-struct guestfs_drop_caches_args {
- int whattodrop;
-};
-typedef struct guestfs_drop_caches_args guestfs_drop_caches_args;
-
-struct guestfs_dmesg_ret {
- char *kmsgs;
-};
-typedef struct guestfs_dmesg_ret guestfs_dmesg_ret;
-
-struct guestfs_equal_args {
- char *file1;
- char *file2;
-};
-typedef struct guestfs_equal_args guestfs_equal_args;
-
-struct guestfs_equal_ret {
- bool_t equality;
-};
-typedef struct guestfs_equal_ret guestfs_equal_ret;
-
-struct guestfs_strings_args {
- char *path;
-};
-typedef struct guestfs_strings_args guestfs_strings_args;
-
-struct guestfs_strings_ret {
- struct {
- u_int stringsout_len;
- str *stringsout_val;
- } stringsout;
-};
-typedef struct guestfs_strings_ret guestfs_strings_ret;
-
-struct guestfs_strings_e_args {
- char *encoding;
- char *path;
-};
-typedef struct guestfs_strings_e_args guestfs_strings_e_args;
-
-struct guestfs_strings_e_ret {
- struct {
- u_int stringsout_len;
- str *stringsout_val;
- } stringsout;
-};
-typedef struct guestfs_strings_e_ret guestfs_strings_e_ret;
-
-struct guestfs_hexdump_args {
- char *path;
-};
-typedef struct guestfs_hexdump_args guestfs_hexdump_args;
-
-struct guestfs_hexdump_ret {
- char *dump;
-};
-typedef struct guestfs_hexdump_ret guestfs_hexdump_ret;
-
-struct guestfs_zerofree_args {
- char *device;
-};
-typedef struct guestfs_zerofree_args guestfs_zerofree_args;
-
-struct guestfs_pvresize_args {
- char *device;
-};
-typedef struct guestfs_pvresize_args guestfs_pvresize_args;
-
-struct guestfs_sfdisk_N_args {
- char *device;
- int n;
- int cyls;
- int heads;
- int sectors;
- char *line;
-};
-typedef struct guestfs_sfdisk_N_args guestfs_sfdisk_N_args;
-
-struct guestfs_sfdisk_l_args {
- char *device;
-};
-typedef struct guestfs_sfdisk_l_args guestfs_sfdisk_l_args;
-
-struct guestfs_sfdisk_l_ret {
- char *partitions;
-};
-typedef struct guestfs_sfdisk_l_ret guestfs_sfdisk_l_ret;
-
-struct guestfs_sfdisk_kernel_geometry_args {
- char *device;
-};
-typedef struct guestfs_sfdisk_kernel_geometry_args guestfs_sfdisk_kernel_geometry_args;
-
-struct guestfs_sfdisk_kernel_geometry_ret {
- char *partitions;
-};
-typedef struct guestfs_sfdisk_kernel_geometry_ret guestfs_sfdisk_kernel_geometry_ret;
-
-struct guestfs_sfdisk_disk_geometry_args {
- char *device;
-};
-typedef struct guestfs_sfdisk_disk_geometry_args guestfs_sfdisk_disk_geometry_args;
-
-struct guestfs_sfdisk_disk_geometry_ret {
- char *partitions;
-};
-typedef struct guestfs_sfdisk_disk_geometry_ret guestfs_sfdisk_disk_geometry_ret;
-
-struct guestfs_vg_activate_all_args {
- bool_t activate;
-};
-typedef struct guestfs_vg_activate_all_args guestfs_vg_activate_all_args;
-
-struct guestfs_vg_activate_args {
- bool_t activate;
- struct {
- u_int volgroups_len;
- str *volgroups_val;
- } volgroups;
-};
-typedef struct guestfs_vg_activate_args guestfs_vg_activate_args;
-
-struct guestfs_lvresize_args {
- char *device;
- int mbytes;
-};
-typedef struct guestfs_lvresize_args guestfs_lvresize_args;
-
-struct guestfs_resize2fs_args {
- char *device;
-};
-typedef struct guestfs_resize2fs_args guestfs_resize2fs_args;
-
-struct guestfs_find_args {
- char *directory;
-};
-typedef struct guestfs_find_args guestfs_find_args;
-
-struct guestfs_find_ret {
- struct {
- u_int names_len;
- str *names_val;
- } names;
-};
-typedef struct guestfs_find_ret guestfs_find_ret;
-
-struct guestfs_e2fsck_f_args {
- char *device;
-};
-typedef struct guestfs_e2fsck_f_args guestfs_e2fsck_f_args;
-
-struct guestfs_sleep_args {
- int secs;
-};
-typedef struct guestfs_sleep_args guestfs_sleep_args;
-
-struct guestfs_ntfs_3g_probe_args {
- bool_t rw;
- char *device;
-};
-typedef struct guestfs_ntfs_3g_probe_args guestfs_ntfs_3g_probe_args;
-
-struct guestfs_ntfs_3g_probe_ret {
- int status;
-};
-typedef struct guestfs_ntfs_3g_probe_ret guestfs_ntfs_3g_probe_ret;
-
-enum guestfs_procedure {
- GUESTFS_PROC_MOUNT = 1,
- GUESTFS_PROC_SYNC = 2,
- GUESTFS_PROC_TOUCH = 3,
- GUESTFS_PROC_CAT = 4,
- GUESTFS_PROC_LL = 5,
- GUESTFS_PROC_LS = 6,
- GUESTFS_PROC_LIST_DEVICES = 7,
- GUESTFS_PROC_LIST_PARTITIONS = 8,
- GUESTFS_PROC_PVS = 9,
- GUESTFS_PROC_VGS = 10,
- GUESTFS_PROC_LVS = 11,
- GUESTFS_PROC_PVS_FULL = 12,
- GUESTFS_PROC_VGS_FULL = 13,
- GUESTFS_PROC_LVS_FULL = 14,
- GUESTFS_PROC_READ_LINES = 15,
- GUESTFS_PROC_AUG_INIT = 16,
- GUESTFS_PROC_AUG_CLOSE = 26,
- GUESTFS_PROC_AUG_DEFVAR = 17,
- GUESTFS_PROC_AUG_DEFNODE = 18,
- GUESTFS_PROC_AUG_GET = 19,
- GUESTFS_PROC_AUG_SET = 20,
- GUESTFS_PROC_AUG_INSERT = 21,
- GUESTFS_PROC_AUG_RM = 22,
- GUESTFS_PROC_AUG_MV = 23,
- GUESTFS_PROC_AUG_MATCH = 24,
- GUESTFS_PROC_AUG_SAVE = 25,
- GUESTFS_PROC_AUG_LOAD = 27,
- GUESTFS_PROC_AUG_LS = 28,
- GUESTFS_PROC_RM = 29,
- GUESTFS_PROC_RMDIR = 30,
- GUESTFS_PROC_RM_RF = 31,
- GUESTFS_PROC_MKDIR = 32,
- GUESTFS_PROC_MKDIR_P = 33,
- GUESTFS_PROC_CHMOD = 34,
- GUESTFS_PROC_CHOWN = 35,
- GUESTFS_PROC_EXISTS = 36,
- GUESTFS_PROC_IS_FILE = 37,
- GUESTFS_PROC_IS_DIR = 38,
- GUESTFS_PROC_PVCREATE = 39,
- GUESTFS_PROC_VGCREATE = 40,
- GUESTFS_PROC_LVCREATE = 41,
- GUESTFS_PROC_MKFS = 42,
- GUESTFS_PROC_SFDISK = 43,
- GUESTFS_PROC_WRITE_FILE = 44,
- GUESTFS_PROC_UMOUNT = 45,
- GUESTFS_PROC_MOUNTS = 46,
- GUESTFS_PROC_UMOUNT_ALL = 47,
- GUESTFS_PROC_LVM_REMOVE_ALL = 48,
- GUESTFS_PROC_FILE = 49,
- GUESTFS_PROC_COMMAND = 50,
- GUESTFS_PROC_COMMAND_LINES = 51,
- GUESTFS_PROC_STAT = 52,
- GUESTFS_PROC_LSTAT = 53,
- GUESTFS_PROC_STATVFS = 54,
- GUESTFS_PROC_TUNE2FS_L = 55,
- GUESTFS_PROC_BLOCKDEV_SETRO = 56,
- GUESTFS_PROC_BLOCKDEV_SETRW = 57,
- GUESTFS_PROC_BLOCKDEV_GETRO = 58,
- GUESTFS_PROC_BLOCKDEV_GETSS = 59,
- GUESTFS_PROC_BLOCKDEV_GETBSZ = 60,
- GUESTFS_PROC_BLOCKDEV_SETBSZ = 61,
- GUESTFS_PROC_BLOCKDEV_GETSZ = 62,
- GUESTFS_PROC_BLOCKDEV_GETSIZE64 = 63,
- GUESTFS_PROC_BLOCKDEV_FLUSHBUFS = 64,
- GUESTFS_PROC_BLOCKDEV_REREADPT = 65,
- GUESTFS_PROC_UPLOAD = 66,
- GUESTFS_PROC_DOWNLOAD = 67,
- GUESTFS_PROC_CHECKSUM = 68,
- GUESTFS_PROC_TAR_IN = 69,
- GUESTFS_PROC_TAR_OUT = 70,
- GUESTFS_PROC_TGZ_IN = 71,
- GUESTFS_PROC_TGZ_OUT = 72,
- GUESTFS_PROC_MOUNT_RO = 73,
- GUESTFS_PROC_MOUNT_OPTIONS = 74,
- GUESTFS_PROC_MOUNT_VFS = 75,
- GUESTFS_PROC_DEBUG = 76,
- GUESTFS_PROC_LVREMOVE = 77,
- GUESTFS_PROC_VGREMOVE = 78,
- GUESTFS_PROC_PVREMOVE = 79,
- GUESTFS_PROC_SET_E2LABEL = 80,
- GUESTFS_PROC_GET_E2LABEL = 81,
- GUESTFS_PROC_SET_E2UUID = 82,
- GUESTFS_PROC_GET_E2UUID = 83,
- GUESTFS_PROC_FSCK = 84,
- GUESTFS_PROC_ZERO = 85,
- GUESTFS_PROC_GRUB_INSTALL = 86,
- GUESTFS_PROC_CP = 87,
- GUESTFS_PROC_CP_A = 88,
- GUESTFS_PROC_MV = 89,
- GUESTFS_PROC_DROP_CACHES = 90,
- GUESTFS_PROC_DMESG = 91,
- GUESTFS_PROC_PING_DAEMON = 92,
- GUESTFS_PROC_EQUAL = 93,
- GUESTFS_PROC_STRINGS = 94,
- GUESTFS_PROC_STRINGS_E = 95,
- GUESTFS_PROC_HEXDUMP = 96,
- GUESTFS_PROC_ZEROFREE = 97,
- GUESTFS_PROC_PVRESIZE = 98,
- GUESTFS_PROC_SFDISK_N = 99,
- GUESTFS_PROC_SFDISK_L = 100,
- GUESTFS_PROC_SFDISK_KERNEL_GEOMETRY = 101,
- GUESTFS_PROC_SFDISK_DISK_GEOMETRY = 102,
- GUESTFS_PROC_VG_ACTIVATE_ALL = 103,
- GUESTFS_PROC_VG_ACTIVATE = 104,
- GUESTFS_PROC_LVRESIZE = 105,
- GUESTFS_PROC_RESIZE2FS = 106,
- GUESTFS_PROC_FIND = 107,
- GUESTFS_PROC_E2FSCK_F = 108,
- GUESTFS_PROC_SLEEP = 109,
- GUESTFS_PROC_NTFS_3G_PROBE = 110,
- GUESTFS_PROC_NR_PROCS = 110 + 1,
-};
-typedef enum guestfs_procedure guestfs_procedure;
-#define GUESTFS_MESSAGE_MAX 4194304
-#define GUESTFS_PROGRAM 0x2000F5F5
-#define GUESTFS_PROTOCOL_VERSION 1
-#define GUESTFS_LAUNCH_FLAG 0xf5f55ff5
-#define GUESTFS_CANCEL_FLAG 0xffffeeee
-
-enum guestfs_message_direction {
- GUESTFS_DIRECTION_CALL = 0,
- GUESTFS_DIRECTION_REPLY = 1,
-};
-typedef enum guestfs_message_direction guestfs_message_direction;
-
-enum guestfs_message_status {
- GUESTFS_STATUS_OK = 0,
- GUESTFS_STATUS_ERROR = 1,
-};
-typedef enum guestfs_message_status guestfs_message_status;
-#define GUESTFS_ERROR_LEN 256
-
-struct guestfs_message_error {
- char *error_message;
-};
-typedef struct guestfs_message_error guestfs_message_error;
-
-struct guestfs_message_header {
- u_int prog;
- u_int vers;
- guestfs_procedure proc;
- guestfs_message_direction direction;
- u_int serial;
- guestfs_message_status status;
-};
-typedef struct guestfs_message_header guestfs_message_header;
-#define GUESTFS_MAX_CHUNK_SIZE 8192
-
-struct guestfs_chunk {
- int cancel;
- struct {
- u_int data_len;
- char *data_val;
- } data;
-};
-typedef struct guestfs_chunk guestfs_chunk;
-
-/* the xdr functions */
-
-#if defined(__STDC__) || defined(__cplusplus)
-extern bool_t xdr_str (XDR *, str*);
-extern bool_t xdr_guestfs_lvm_int_pv (XDR *, guestfs_lvm_int_pv*);
-extern bool_t xdr_guestfs_lvm_int_pv_list (XDR *, guestfs_lvm_int_pv_list*);
-extern bool_t xdr_guestfs_lvm_int_vg (XDR *, guestfs_lvm_int_vg*);
-extern bool_t xdr_guestfs_lvm_int_vg_list (XDR *, guestfs_lvm_int_vg_list*);
-extern bool_t xdr_guestfs_lvm_int_lv (XDR *, guestfs_lvm_int_lv*);
-extern bool_t xdr_guestfs_lvm_int_lv_list (XDR *, guestfs_lvm_int_lv_list*);
-extern bool_t xdr_guestfs_int_stat (XDR *, guestfs_int_stat*);
-extern bool_t xdr_guestfs_int_statvfs (XDR *, guestfs_int_statvfs*);
-extern bool_t xdr_guestfs_mount_args (XDR *, guestfs_mount_args*);
-extern bool_t xdr_guestfs_touch_args (XDR *, guestfs_touch_args*);
-extern bool_t xdr_guestfs_cat_args (XDR *, guestfs_cat_args*);
-extern bool_t xdr_guestfs_cat_ret (XDR *, guestfs_cat_ret*);
-extern bool_t xdr_guestfs_ll_args (XDR *, guestfs_ll_args*);
-extern bool_t xdr_guestfs_ll_ret (XDR *, guestfs_ll_ret*);
-extern bool_t xdr_guestfs_ls_args (XDR *, guestfs_ls_args*);
-extern bool_t xdr_guestfs_ls_ret (XDR *, guestfs_ls_ret*);
-extern bool_t xdr_guestfs_list_devices_ret (XDR *, guestfs_list_devices_ret*);
-extern bool_t xdr_guestfs_list_partitions_ret (XDR *, guestfs_list_partitions_ret*);
-extern bool_t xdr_guestfs_pvs_ret (XDR *, guestfs_pvs_ret*);
-extern bool_t xdr_guestfs_vgs_ret (XDR *, guestfs_vgs_ret*);
-extern bool_t xdr_guestfs_lvs_ret (XDR *, guestfs_lvs_ret*);
-extern bool_t xdr_guestfs_pvs_full_ret (XDR *, guestfs_pvs_full_ret*);
-extern bool_t xdr_guestfs_vgs_full_ret (XDR *, guestfs_vgs_full_ret*);
-extern bool_t xdr_guestfs_lvs_full_ret (XDR *, guestfs_lvs_full_ret*);
-extern bool_t xdr_guestfs_read_lines_args (XDR *, guestfs_read_lines_args*);
-extern bool_t xdr_guestfs_read_lines_ret (XDR *, guestfs_read_lines_ret*);
-extern bool_t xdr_guestfs_aug_init_args (XDR *, guestfs_aug_init_args*);
-extern bool_t xdr_guestfs_aug_defvar_args (XDR *, guestfs_aug_defvar_args*);
-extern bool_t xdr_guestfs_aug_defvar_ret (XDR *, guestfs_aug_defvar_ret*);
-extern bool_t xdr_guestfs_aug_defnode_args (XDR *, guestfs_aug_defnode_args*);
-extern bool_t xdr_guestfs_aug_defnode_ret (XDR *, guestfs_aug_defnode_ret*);
-extern bool_t xdr_guestfs_aug_get_args (XDR *, guestfs_aug_get_args*);
-extern bool_t xdr_guestfs_aug_get_ret (XDR *, guestfs_aug_get_ret*);
-extern bool_t xdr_guestfs_aug_set_args (XDR *, guestfs_aug_set_args*);
-extern bool_t xdr_guestfs_aug_insert_args (XDR *, guestfs_aug_insert_args*);
-extern bool_t xdr_guestfs_aug_rm_args (XDR *, guestfs_aug_rm_args*);
-extern bool_t xdr_guestfs_aug_rm_ret (XDR *, guestfs_aug_rm_ret*);
-extern bool_t xdr_guestfs_aug_mv_args (XDR *, guestfs_aug_mv_args*);
-extern bool_t xdr_guestfs_aug_match_args (XDR *, guestfs_aug_match_args*);
-extern bool_t xdr_guestfs_aug_match_ret (XDR *, guestfs_aug_match_ret*);
-extern bool_t xdr_guestfs_aug_ls_args (XDR *, guestfs_aug_ls_args*);
-extern bool_t xdr_guestfs_aug_ls_ret (XDR *, guestfs_aug_ls_ret*);
-extern bool_t xdr_guestfs_rm_args (XDR *, guestfs_rm_args*);
-extern bool_t xdr_guestfs_rmdir_args (XDR *, guestfs_rmdir_args*);
-extern bool_t xdr_guestfs_rm_rf_args (XDR *, guestfs_rm_rf_args*);
-extern bool_t xdr_guestfs_mkdir_args (XDR *, guestfs_mkdir_args*);
-extern bool_t xdr_guestfs_mkdir_p_args (XDR *, guestfs_mkdir_p_args*);
-extern bool_t xdr_guestfs_chmod_args (XDR *, guestfs_chmod_args*);
-extern bool_t xdr_guestfs_chown_args (XDR *, guestfs_chown_args*);
-extern bool_t xdr_guestfs_exists_args (XDR *, guestfs_exists_args*);
-extern bool_t xdr_guestfs_exists_ret (XDR *, guestfs_exists_ret*);
-extern bool_t xdr_guestfs_is_file_args (XDR *, guestfs_is_file_args*);
-extern bool_t xdr_guestfs_is_file_ret (XDR *, guestfs_is_file_ret*);
-extern bool_t xdr_guestfs_is_dir_args (XDR *, guestfs_is_dir_args*);
-extern bool_t xdr_guestfs_is_dir_ret (XDR *, guestfs_is_dir_ret*);
-extern bool_t xdr_guestfs_pvcreate_args (XDR *, guestfs_pvcreate_args*);
-extern bool_t xdr_guestfs_vgcreate_args (XDR *, guestfs_vgcreate_args*);
-extern bool_t xdr_guestfs_lvcreate_args (XDR *, guestfs_lvcreate_args*);
-extern bool_t xdr_guestfs_mkfs_args (XDR *, guestfs_mkfs_args*);
-extern bool_t xdr_guestfs_sfdisk_args (XDR *, guestfs_sfdisk_args*);
-extern bool_t xdr_guestfs_write_file_args (XDR *, guestfs_write_file_args*);
-extern bool_t xdr_guestfs_umount_args (XDR *, guestfs_umount_args*);
-extern bool_t xdr_guestfs_mounts_ret (XDR *, guestfs_mounts_ret*);
-extern bool_t xdr_guestfs_file_args (XDR *, guestfs_file_args*);
-extern bool_t xdr_guestfs_file_ret (XDR *, guestfs_file_ret*);
-extern bool_t xdr_guestfs_command_args (XDR *, guestfs_command_args*);
-extern bool_t xdr_guestfs_command_ret (XDR *, guestfs_command_ret*);
-extern bool_t xdr_guestfs_command_lines_args (XDR *, guestfs_command_lines_args*);
-extern bool_t xdr_guestfs_command_lines_ret (XDR *, guestfs_command_lines_ret*);
-extern bool_t xdr_guestfs_stat_args (XDR *, guestfs_stat_args*);
-extern bool_t xdr_guestfs_stat_ret (XDR *, guestfs_stat_ret*);
-extern bool_t xdr_guestfs_lstat_args (XDR *, guestfs_lstat_args*);
-extern bool_t xdr_guestfs_lstat_ret (XDR *, guestfs_lstat_ret*);
-extern bool_t xdr_guestfs_statvfs_args (XDR *, guestfs_statvfs_args*);
-extern bool_t xdr_guestfs_statvfs_ret (XDR *, guestfs_statvfs_ret*);
-extern bool_t xdr_guestfs_tune2fs_l_args (XDR *, guestfs_tune2fs_l_args*);
-extern bool_t xdr_guestfs_tune2fs_l_ret (XDR *, guestfs_tune2fs_l_ret*);
-extern bool_t xdr_guestfs_blockdev_setro_args (XDR *, guestfs_blockdev_setro_args*);
-extern bool_t xdr_guestfs_blockdev_setrw_args (XDR *, guestfs_blockdev_setrw_args*);
-extern bool_t xdr_guestfs_blockdev_getro_args (XDR *, guestfs_blockdev_getro_args*);
-extern bool_t xdr_guestfs_blockdev_getro_ret (XDR *, guestfs_blockdev_getro_ret*);
-extern bool_t xdr_guestfs_blockdev_getss_args (XDR *, guestfs_blockdev_getss_args*);
-extern bool_t xdr_guestfs_blockdev_getss_ret (XDR *, guestfs_blockdev_getss_ret*);
-extern bool_t xdr_guestfs_blockdev_getbsz_args (XDR *, guestfs_blockdev_getbsz_args*);
-extern bool_t xdr_guestfs_blockdev_getbsz_ret (XDR *, guestfs_blockdev_getbsz_ret*);
-extern bool_t xdr_guestfs_blockdev_setbsz_args (XDR *, guestfs_blockdev_setbsz_args*);
-extern bool_t xdr_guestfs_blockdev_getsz_args (XDR *, guestfs_blockdev_getsz_args*);
-extern bool_t xdr_guestfs_blockdev_getsz_ret (XDR *, guestfs_blockdev_getsz_ret*);
-extern bool_t xdr_guestfs_blockdev_getsize64_args (XDR *, guestfs_blockdev_getsize64_args*);
-extern bool_t xdr_guestfs_blockdev_getsize64_ret (XDR *, guestfs_blockdev_getsize64_ret*);
-extern bool_t xdr_guestfs_blockdev_flushbufs_args (XDR *, guestfs_blockdev_flushbufs_args*);
-extern bool_t xdr_guestfs_blockdev_rereadpt_args (XDR *, guestfs_blockdev_rereadpt_args*);
-extern bool_t xdr_guestfs_upload_args (XDR *, guestfs_upload_args*);
-extern bool_t xdr_guestfs_download_args (XDR *, guestfs_download_args*);
-extern bool_t xdr_guestfs_checksum_args (XDR *, guestfs_checksum_args*);
-extern bool_t xdr_guestfs_checksum_ret (XDR *, guestfs_checksum_ret*);
-extern bool_t xdr_guestfs_tar_in_args (XDR *, guestfs_tar_in_args*);
-extern bool_t xdr_guestfs_tar_out_args (XDR *, guestfs_tar_out_args*);
-extern bool_t xdr_guestfs_tgz_in_args (XDR *, guestfs_tgz_in_args*);
-extern bool_t xdr_guestfs_tgz_out_args (XDR *, guestfs_tgz_out_args*);
-extern bool_t xdr_guestfs_mount_ro_args (XDR *, guestfs_mount_ro_args*);
-extern bool_t xdr_guestfs_mount_options_args (XDR *, guestfs_mount_options_args*);
-extern bool_t xdr_guestfs_mount_vfs_args (XDR *, guestfs_mount_vfs_args*);
-extern bool_t xdr_guestfs_debug_args (XDR *, guestfs_debug_args*);
-extern bool_t xdr_guestfs_debug_ret (XDR *, guestfs_debug_ret*);
-extern bool_t xdr_guestfs_lvremove_args (XDR *, guestfs_lvremove_args*);
-extern bool_t xdr_guestfs_vgremove_args (XDR *, guestfs_vgremove_args*);
-extern bool_t xdr_guestfs_pvremove_args (XDR *, guestfs_pvremove_args*);
-extern bool_t xdr_guestfs_set_e2label_args (XDR *, guestfs_set_e2label_args*);
-extern bool_t xdr_guestfs_get_e2label_args (XDR *, guestfs_get_e2label_args*);
-extern bool_t xdr_guestfs_get_e2label_ret (XDR *, guestfs_get_e2label_ret*);
-extern bool_t xdr_guestfs_set_e2uuid_args (XDR *, guestfs_set_e2uuid_args*);
-extern bool_t xdr_guestfs_get_e2uuid_args (XDR *, guestfs_get_e2uuid_args*);
-extern bool_t xdr_guestfs_get_e2uuid_ret (XDR *, guestfs_get_e2uuid_ret*);
-extern bool_t xdr_guestfs_fsck_args (XDR *, guestfs_fsck_args*);
-extern bool_t xdr_guestfs_fsck_ret (XDR *, guestfs_fsck_ret*);
-extern bool_t xdr_guestfs_zero_args (XDR *, guestfs_zero_args*);
-extern bool_t xdr_guestfs_grub_install_args (XDR *, guestfs_grub_install_args*);
-extern bool_t xdr_guestfs_cp_args (XDR *, guestfs_cp_args*);
-extern bool_t xdr_guestfs_cp_a_args (XDR *, guestfs_cp_a_args*);
-extern bool_t xdr_guestfs_mv_args (XDR *, guestfs_mv_args*);
-extern bool_t xdr_guestfs_drop_caches_args (XDR *, guestfs_drop_caches_args*);
-extern bool_t xdr_guestfs_dmesg_ret (XDR *, guestfs_dmesg_ret*);
-extern bool_t xdr_guestfs_equal_args (XDR *, guestfs_equal_args*);
-extern bool_t xdr_guestfs_equal_ret (XDR *, guestfs_equal_ret*);
-extern bool_t xdr_guestfs_strings_args (XDR *, guestfs_strings_args*);
-extern bool_t xdr_guestfs_strings_ret (XDR *, guestfs_strings_ret*);
-extern bool_t xdr_guestfs_strings_e_args (XDR *, guestfs_strings_e_args*);
-extern bool_t xdr_guestfs_strings_e_ret (XDR *, guestfs_strings_e_ret*);
-extern bool_t xdr_guestfs_hexdump_args (XDR *, guestfs_hexdump_args*);
-extern bool_t xdr_guestfs_hexdump_ret (XDR *, guestfs_hexdump_ret*);
-extern bool_t xdr_guestfs_zerofree_args (XDR *, guestfs_zerofree_args*);
-extern bool_t xdr_guestfs_pvresize_args (XDR *, guestfs_pvresize_args*);
-extern bool_t xdr_guestfs_sfdisk_N_args (XDR *, guestfs_sfdisk_N_args*);
-extern bool_t xdr_guestfs_sfdisk_l_args (XDR *, guestfs_sfdisk_l_args*);
-extern bool_t xdr_guestfs_sfdisk_l_ret (XDR *, guestfs_sfdisk_l_ret*);
-extern bool_t xdr_guestfs_sfdisk_kernel_geometry_args (XDR *, guestfs_sfdisk_kernel_geometry_args*);
-extern bool_t xdr_guestfs_sfdisk_kernel_geometry_ret (XDR *, guestfs_sfdisk_kernel_geometry_ret*);
-extern bool_t xdr_guestfs_sfdisk_disk_geometry_args (XDR *, guestfs_sfdisk_disk_geometry_args*);
-extern bool_t xdr_guestfs_sfdisk_disk_geometry_ret (XDR *, guestfs_sfdisk_disk_geometry_ret*);
-extern bool_t xdr_guestfs_vg_activate_all_args (XDR *, guestfs_vg_activate_all_args*);
-extern bool_t xdr_guestfs_vg_activate_args (XDR *, guestfs_vg_activate_args*);
-extern bool_t xdr_guestfs_lvresize_args (XDR *, guestfs_lvresize_args*);
-extern bool_t xdr_guestfs_resize2fs_args (XDR *, guestfs_resize2fs_args*);
-extern bool_t xdr_guestfs_find_args (XDR *, guestfs_find_args*);
-extern bool_t xdr_guestfs_find_ret (XDR *, guestfs_find_ret*);
-extern bool_t xdr_guestfs_e2fsck_f_args (XDR *, guestfs_e2fsck_f_args*);
-extern bool_t xdr_guestfs_sleep_args (XDR *, guestfs_sleep_args*);
-extern bool_t xdr_guestfs_ntfs_3g_probe_args (XDR *, guestfs_ntfs_3g_probe_args*);
-extern bool_t xdr_guestfs_ntfs_3g_probe_ret (XDR *, guestfs_ntfs_3g_probe_ret*);
-extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*);
-extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*);
-extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*);
-extern bool_t xdr_guestfs_message_error (XDR *, guestfs_message_error*);
-extern bool_t xdr_guestfs_message_header (XDR *, guestfs_message_header*);
-extern bool_t xdr_guestfs_chunk (XDR *, guestfs_chunk*);
-
-#else /* K&R C */
-extern bool_t xdr_str ();
-extern bool_t xdr_guestfs_lvm_int_pv ();
-extern bool_t xdr_guestfs_lvm_int_pv_list ();
-extern bool_t xdr_guestfs_lvm_int_vg ();
-extern bool_t xdr_guestfs_lvm_int_vg_list ();
-extern bool_t xdr_guestfs_lvm_int_lv ();
-extern bool_t xdr_guestfs_lvm_int_lv_list ();
-extern bool_t xdr_guestfs_int_stat ();
-extern bool_t xdr_guestfs_int_statvfs ();
-extern bool_t xdr_guestfs_mount_args ();
-extern bool_t xdr_guestfs_touch_args ();
-extern bool_t xdr_guestfs_cat_args ();
-extern bool_t xdr_guestfs_cat_ret ();
-extern bool_t xdr_guestfs_ll_args ();
-extern bool_t xdr_guestfs_ll_ret ();
-extern bool_t xdr_guestfs_ls_args ();
-extern bool_t xdr_guestfs_ls_ret ();
-extern bool_t xdr_guestfs_list_devices_ret ();
-extern bool_t xdr_guestfs_list_partitions_ret ();
-extern bool_t xdr_guestfs_pvs_ret ();
-extern bool_t xdr_guestfs_vgs_ret ();
-extern bool_t xdr_guestfs_lvs_ret ();
-extern bool_t xdr_guestfs_pvs_full_ret ();
-extern bool_t xdr_guestfs_vgs_full_ret ();
-extern bool_t xdr_guestfs_lvs_full_ret ();
-extern bool_t xdr_guestfs_read_lines_args ();
-extern bool_t xdr_guestfs_read_lines_ret ();
-extern bool_t xdr_guestfs_aug_init_args ();
-extern bool_t xdr_guestfs_aug_defvar_args ();
-extern bool_t xdr_guestfs_aug_defvar_ret ();
-extern bool_t xdr_guestfs_aug_defnode_args ();
-extern bool_t xdr_guestfs_aug_defnode_ret ();
-extern bool_t xdr_guestfs_aug_get_args ();
-extern bool_t xdr_guestfs_aug_get_ret ();
-extern bool_t xdr_guestfs_aug_set_args ();
-extern bool_t xdr_guestfs_aug_insert_args ();
-extern bool_t xdr_guestfs_aug_rm_args ();
-extern bool_t xdr_guestfs_aug_rm_ret ();
-extern bool_t xdr_guestfs_aug_mv_args ();
-extern bool_t xdr_guestfs_aug_match_args ();
-extern bool_t xdr_guestfs_aug_match_ret ();
-extern bool_t xdr_guestfs_aug_ls_args ();
-extern bool_t xdr_guestfs_aug_ls_ret ();
-extern bool_t xdr_guestfs_rm_args ();
-extern bool_t xdr_guestfs_rmdir_args ();
-extern bool_t xdr_guestfs_rm_rf_args ();
-extern bool_t xdr_guestfs_mkdir_args ();
-extern bool_t xdr_guestfs_mkdir_p_args ();
-extern bool_t xdr_guestfs_chmod_args ();
-extern bool_t xdr_guestfs_chown_args ();
-extern bool_t xdr_guestfs_exists_args ();
-extern bool_t xdr_guestfs_exists_ret ();
-extern bool_t xdr_guestfs_is_file_args ();
-extern bool_t xdr_guestfs_is_file_ret ();
-extern bool_t xdr_guestfs_is_dir_args ();
-extern bool_t xdr_guestfs_is_dir_ret ();
-extern bool_t xdr_guestfs_pvcreate_args ();
-extern bool_t xdr_guestfs_vgcreate_args ();
-extern bool_t xdr_guestfs_lvcreate_args ();
-extern bool_t xdr_guestfs_mkfs_args ();
-extern bool_t xdr_guestfs_sfdisk_args ();
-extern bool_t xdr_guestfs_write_file_args ();
-extern bool_t xdr_guestfs_umount_args ();
-extern bool_t xdr_guestfs_mounts_ret ();
-extern bool_t xdr_guestfs_file_args ();
-extern bool_t xdr_guestfs_file_ret ();
-extern bool_t xdr_guestfs_command_args ();
-extern bool_t xdr_guestfs_command_ret ();
-extern bool_t xdr_guestfs_command_lines_args ();
-extern bool_t xdr_guestfs_command_lines_ret ();
-extern bool_t xdr_guestfs_stat_args ();
-extern bool_t xdr_guestfs_stat_ret ();
-extern bool_t xdr_guestfs_lstat_args ();
-extern bool_t xdr_guestfs_lstat_ret ();
-extern bool_t xdr_guestfs_statvfs_args ();
-extern bool_t xdr_guestfs_statvfs_ret ();
-extern bool_t xdr_guestfs_tune2fs_l_args ();
-extern bool_t xdr_guestfs_tune2fs_l_ret ();
-extern bool_t xdr_guestfs_blockdev_setro_args ();
-extern bool_t xdr_guestfs_blockdev_setrw_args ();
-extern bool_t xdr_guestfs_blockdev_getro_args ();
-extern bool_t xdr_guestfs_blockdev_getro_ret ();
-extern bool_t xdr_guestfs_blockdev_getss_args ();
-extern bool_t xdr_guestfs_blockdev_getss_ret ();
-extern bool_t xdr_guestfs_blockdev_getbsz_args ();
-extern bool_t xdr_guestfs_blockdev_getbsz_ret ();
-extern bool_t xdr_guestfs_blockdev_setbsz_args ();
-extern bool_t xdr_guestfs_blockdev_getsz_args ();
-extern bool_t xdr_guestfs_blockdev_getsz_ret ();
-extern bool_t xdr_guestfs_blockdev_getsize64_args ();
-extern bool_t xdr_guestfs_blockdev_getsize64_ret ();
-extern bool_t xdr_guestfs_blockdev_flushbufs_args ();
-extern bool_t xdr_guestfs_blockdev_rereadpt_args ();
-extern bool_t xdr_guestfs_upload_args ();
-extern bool_t xdr_guestfs_download_args ();
-extern bool_t xdr_guestfs_checksum_args ();
-extern bool_t xdr_guestfs_checksum_ret ();
-extern bool_t xdr_guestfs_tar_in_args ();
-extern bool_t xdr_guestfs_tar_out_args ();
-extern bool_t xdr_guestfs_tgz_in_args ();
-extern bool_t xdr_guestfs_tgz_out_args ();
-extern bool_t xdr_guestfs_mount_ro_args ();
-extern bool_t xdr_guestfs_mount_options_args ();
-extern bool_t xdr_guestfs_mount_vfs_args ();
-extern bool_t xdr_guestfs_debug_args ();
-extern bool_t xdr_guestfs_debug_ret ();
-extern bool_t xdr_guestfs_lvremove_args ();
-extern bool_t xdr_guestfs_vgremove_args ();
-extern bool_t xdr_guestfs_pvremove_args ();
-extern bool_t xdr_guestfs_set_e2label_args ();
-extern bool_t xdr_guestfs_get_e2label_args ();
-extern bool_t xdr_guestfs_get_e2label_ret ();
-extern bool_t xdr_guestfs_set_e2uuid_args ();
-extern bool_t xdr_guestfs_get_e2uuid_args ();
-extern bool_t xdr_guestfs_get_e2uuid_ret ();
-extern bool_t xdr_guestfs_fsck_args ();
-extern bool_t xdr_guestfs_fsck_ret ();
-extern bool_t xdr_guestfs_zero_args ();
-extern bool_t xdr_guestfs_grub_install_args ();
-extern bool_t xdr_guestfs_cp_args ();
-extern bool_t xdr_guestfs_cp_a_args ();
-extern bool_t xdr_guestfs_mv_args ();
-extern bool_t xdr_guestfs_drop_caches_args ();
-extern bool_t xdr_guestfs_dmesg_ret ();
-extern bool_t xdr_guestfs_equal_args ();
-extern bool_t xdr_guestfs_equal_ret ();
-extern bool_t xdr_guestfs_strings_args ();
-extern bool_t xdr_guestfs_strings_ret ();
-extern bool_t xdr_guestfs_strings_e_args ();
-extern bool_t xdr_guestfs_strings_e_ret ();
-extern bool_t xdr_guestfs_hexdump_args ();
-extern bool_t xdr_guestfs_hexdump_ret ();
-extern bool_t xdr_guestfs_zerofree_args ();
-extern bool_t xdr_guestfs_pvresize_args ();
-extern bool_t xdr_guestfs_sfdisk_N_args ();
-extern bool_t xdr_guestfs_sfdisk_l_args ();
-extern bool_t xdr_guestfs_sfdisk_l_ret ();
-extern bool_t xdr_guestfs_sfdisk_kernel_geometry_args ();
-extern bool_t xdr_guestfs_sfdisk_kernel_geometry_ret ();
-extern bool_t xdr_guestfs_sfdisk_disk_geometry_args ();
-extern bool_t xdr_guestfs_sfdisk_disk_geometry_ret ();
-extern bool_t xdr_guestfs_vg_activate_all_args ();
-extern bool_t xdr_guestfs_vg_activate_args ();
-extern bool_t xdr_guestfs_lvresize_args ();
-extern bool_t xdr_guestfs_resize2fs_args ();
-extern bool_t xdr_guestfs_find_args ();
-extern bool_t xdr_guestfs_find_ret ();
-extern bool_t xdr_guestfs_e2fsck_f_args ();
-extern bool_t xdr_guestfs_sleep_args ();
-extern bool_t xdr_guestfs_ntfs_3g_probe_args ();
-extern bool_t xdr_guestfs_ntfs_3g_probe_ret ();
-extern bool_t xdr_guestfs_procedure ();
-extern bool_t xdr_guestfs_message_direction ();
-extern bool_t xdr_guestfs_message_status ();
-extern bool_t xdr_guestfs_message_error ();
-extern bool_t xdr_guestfs_message_header ();
-extern bool_t xdr_guestfs_chunk ();
-
-#endif /* K&R C */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !_GUESTFS_PROTOCOL_H_RPCGEN */
diff --git a/src/guestfs_protocol.x b/src/guestfs_protocol.x
deleted file mode 100644
index cc514e74..00000000
--- a/src/guestfs_protocol.x
+++ /dev/null
@@ -1,893 +0,0 @@
-/* libguestfs generated file
- * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
- * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-typedef string str<>;
-
-struct guestfs_lvm_int_pv {
- string pv_name<>;
- opaque pv_uuid[32];
- string pv_fmt<>;
- hyper pv_size;
- hyper dev_size;
- hyper pv_free;
- hyper pv_used;
- string pv_attr<>;
- hyper pv_pe_count;
- hyper pv_pe_alloc_count;
- string pv_tags<>;
- hyper pe_start;
- hyper pv_mda_count;
- hyper pv_mda_free;
-};
-
-typedef struct guestfs_lvm_int_pv guestfs_lvm_int_pv_list<>;
-
-struct guestfs_lvm_int_vg {
- string vg_name<>;
- opaque vg_uuid[32];
- string vg_fmt<>;
- string vg_attr<>;
- hyper vg_size;
- hyper vg_free;
- string vg_sysid<>;
- hyper vg_extent_size;
- hyper vg_extent_count;
- hyper vg_free_count;
- hyper max_lv;
- hyper max_pv;
- hyper pv_count;
- hyper lv_count;
- hyper snap_count;
- hyper vg_seqno;
- string vg_tags<>;
- hyper vg_mda_count;
- hyper vg_mda_free;
-};
-
-typedef struct guestfs_lvm_int_vg guestfs_lvm_int_vg_list<>;
-
-struct guestfs_lvm_int_lv {
- string lv_name<>;
- opaque lv_uuid[32];
- string lv_attr<>;
- hyper lv_major;
- hyper lv_minor;
- hyper lv_kernel_major;
- hyper lv_kernel_minor;
- hyper lv_size;
- hyper seg_count;
- string origin<>;
- float snap_percent;
- float copy_percent;
- string move_pv<>;
- string lv_tags<>;
- string mirror_log<>;
- string modules<>;
-};
-
-typedef struct guestfs_lvm_int_lv guestfs_lvm_int_lv_list<>;
-
-struct guestfs_int_stat {
- hyper dev;
- hyper ino;
- hyper mode;
- hyper nlink;
- hyper uid;
- hyper gid;
- hyper rdev;
- hyper size;
- hyper blksize;
- hyper blocks;
- hyper atime;
- hyper mtime;
- hyper ctime;
-};
-
-struct guestfs_int_statvfs {
- hyper bsize;
- hyper frsize;
- hyper blocks;
- hyper bfree;
- hyper bavail;
- hyper files;
- hyper ffree;
- hyper favail;
- hyper fsid;
- hyper flag;
- hyper namemax;
-};
-
-struct guestfs_mount_args {
- string device<>;
- string mountpoint<>;
-};
-
-struct guestfs_touch_args {
- string path<>;
-};
-
-struct guestfs_cat_args {
- string path<>;
-};
-
-struct guestfs_cat_ret {
- string content<>;
-};
-
-struct guestfs_ll_args {
- string directory<>;
-};
-
-struct guestfs_ll_ret {
- string listing<>;
-};
-
-struct guestfs_ls_args {
- string directory<>;
-};
-
-struct guestfs_ls_ret {
- str listing<>;
-};
-
-struct guestfs_list_devices_ret {
- str devices<>;
-};
-
-struct guestfs_list_partitions_ret {
- str partitions<>;
-};
-
-struct guestfs_pvs_ret {
- str physvols<>;
-};
-
-struct guestfs_vgs_ret {
- str volgroups<>;
-};
-
-struct guestfs_lvs_ret {
- str logvols<>;
-};
-
-struct guestfs_pvs_full_ret {
- guestfs_lvm_int_pv_list physvols;
-};
-
-struct guestfs_vgs_full_ret {
- guestfs_lvm_int_vg_list volgroups;
-};
-
-struct guestfs_lvs_full_ret {
- guestfs_lvm_int_lv_list logvols;
-};
-
-struct guestfs_read_lines_args {
- string path<>;
-};
-
-struct guestfs_read_lines_ret {
- str lines<>;
-};
-
-struct guestfs_aug_init_args {
- string root<>;
- int flags;
-};
-
-struct guestfs_aug_defvar_args {
- string name<>;
- str *expr;
-};
-
-struct guestfs_aug_defvar_ret {
- int nrnodes;
-};
-
-struct guestfs_aug_defnode_args {
- string name<>;
- string expr<>;
- string val<>;
-};
-
-struct guestfs_aug_defnode_ret {
- int nrnodes;
- bool created;
-};
-
-struct guestfs_aug_get_args {
- string path<>;
-};
-
-struct guestfs_aug_get_ret {
- string val<>;
-};
-
-struct guestfs_aug_set_args {
- string path<>;
- string val<>;
-};
-
-struct guestfs_aug_insert_args {
- string path<>;
- string label<>;
- bool before;
-};
-
-struct guestfs_aug_rm_args {
- string path<>;
-};
-
-struct guestfs_aug_rm_ret {
- int nrnodes;
-};
-
-struct guestfs_aug_mv_args {
- string src<>;
- string dest<>;
-};
-
-struct guestfs_aug_match_args {
- string path<>;
-};
-
-struct guestfs_aug_match_ret {
- str matches<>;
-};
-
-struct guestfs_aug_ls_args {
- string path<>;
-};
-
-struct guestfs_aug_ls_ret {
- str matches<>;
-};
-
-struct guestfs_rm_args {
- string path<>;
-};
-
-struct guestfs_rmdir_args {
- string path<>;
-};
-
-struct guestfs_rm_rf_args {
- string path<>;
-};
-
-struct guestfs_mkdir_args {
- string path<>;
-};
-
-struct guestfs_mkdir_p_args {
- string path<>;
-};
-
-struct guestfs_chmod_args {
- int mode;
- string path<>;
-};
-
-struct guestfs_chown_args {
- int owner;
- int group;
- string path<>;
-};
-
-struct guestfs_exists_args {
- string path<>;
-};
-
-struct guestfs_exists_ret {
- bool existsflag;
-};
-
-struct guestfs_is_file_args {
- string path<>;
-};
-
-struct guestfs_is_file_ret {
- bool fileflag;
-};
-
-struct guestfs_is_dir_args {
- string path<>;
-};
-
-struct guestfs_is_dir_ret {
- bool dirflag;
-};
-
-struct guestfs_pvcreate_args {
- string device<>;
-};
-
-struct guestfs_vgcreate_args {
- string volgroup<>;
- str physvols<>;
-};
-
-struct guestfs_lvcreate_args {
- string logvol<>;
- string volgroup<>;
- int mbytes;
-};
-
-struct guestfs_mkfs_args {
- string fstype<>;
- string device<>;
-};
-
-struct guestfs_sfdisk_args {
- string device<>;
- int cyls;
- int heads;
- int sectors;
- str lines<>;
-};
-
-struct guestfs_write_file_args {
- string path<>;
- string content<>;
- int size;
-};
-
-struct guestfs_umount_args {
- string pathordevice<>;
-};
-
-struct guestfs_mounts_ret {
- str devices<>;
-};
-
-struct guestfs_file_args {
- string path<>;
-};
-
-struct guestfs_file_ret {
- string description<>;
-};
-
-struct guestfs_command_args {
- str arguments<>;
-};
-
-struct guestfs_command_ret {
- string output<>;
-};
-
-struct guestfs_command_lines_args {
- str arguments<>;
-};
-
-struct guestfs_command_lines_ret {
- str lines<>;
-};
-
-struct guestfs_stat_args {
- string path<>;
-};
-
-struct guestfs_stat_ret {
- guestfs_int_stat statbuf;
-};
-
-struct guestfs_lstat_args {
- string path<>;
-};
-
-struct guestfs_lstat_ret {
- guestfs_int_stat statbuf;
-};
-
-struct guestfs_statvfs_args {
- string path<>;
-};
-
-struct guestfs_statvfs_ret {
- guestfs_int_statvfs statbuf;
-};
-
-struct guestfs_tune2fs_l_args {
- string device<>;
-};
-
-struct guestfs_tune2fs_l_ret {
- str superblock<>;
-};
-
-struct guestfs_blockdev_setro_args {
- string device<>;
-};
-
-struct guestfs_blockdev_setrw_args {
- string device<>;
-};
-
-struct guestfs_blockdev_getro_args {
- string device<>;
-};
-
-struct guestfs_blockdev_getro_ret {
- bool ro;
-};
-
-struct guestfs_blockdev_getss_args {
- string device<>;
-};
-
-struct guestfs_blockdev_getss_ret {
- int sectorsize;
-};
-
-struct guestfs_blockdev_getbsz_args {
- string device<>;
-};
-
-struct guestfs_blockdev_getbsz_ret {
- int blocksize;
-};
-
-struct guestfs_blockdev_setbsz_args {
- string device<>;
- int blocksize;
-};
-
-struct guestfs_blockdev_getsz_args {
- string device<>;
-};
-
-struct guestfs_blockdev_getsz_ret {
- hyper sizeinsectors;
-};
-
-struct guestfs_blockdev_getsize64_args {
- string device<>;
-};
-
-struct guestfs_blockdev_getsize64_ret {
- hyper sizeinbytes;
-};
-
-struct guestfs_blockdev_flushbufs_args {
- string device<>;
-};
-
-struct guestfs_blockdev_rereadpt_args {
- string device<>;
-};
-
-struct guestfs_upload_args {
- string remotefilename<>;
-};
-
-struct guestfs_download_args {
- string remotefilename<>;
-};
-
-struct guestfs_checksum_args {
- string csumtype<>;
- string path<>;
-};
-
-struct guestfs_checksum_ret {
- string checksum<>;
-};
-
-struct guestfs_tar_in_args {
- string directory<>;
-};
-
-struct guestfs_tar_out_args {
- string directory<>;
-};
-
-struct guestfs_tgz_in_args {
- string directory<>;
-};
-
-struct guestfs_tgz_out_args {
- string directory<>;
-};
-
-struct guestfs_mount_ro_args {
- string device<>;
- string mountpoint<>;
-};
-
-struct guestfs_mount_options_args {
- string options<>;
- string device<>;
- string mountpoint<>;
-};
-
-struct guestfs_mount_vfs_args {
- string options<>;
- string vfstype<>;
- string device<>;
- string mountpoint<>;
-};
-
-struct guestfs_debug_args {
- string subcmd<>;
- str extraargs<>;
-};
-
-struct guestfs_debug_ret {
- string result<>;
-};
-
-struct guestfs_lvremove_args {
- string device<>;
-};
-
-struct guestfs_vgremove_args {
- string vgname<>;
-};
-
-struct guestfs_pvremove_args {
- string device<>;
-};
-
-struct guestfs_set_e2label_args {
- string device<>;
- string label<>;
-};
-
-struct guestfs_get_e2label_args {
- string device<>;
-};
-
-struct guestfs_get_e2label_ret {
- string label<>;
-};
-
-struct guestfs_set_e2uuid_args {
- string device<>;
- string uuid<>;
-};
-
-struct guestfs_get_e2uuid_args {
- string device<>;
-};
-
-struct guestfs_get_e2uuid_ret {
- string uuid<>;
-};
-
-struct guestfs_fsck_args {
- string fstype<>;
- string device<>;
-};
-
-struct guestfs_fsck_ret {
- int status;
-};
-
-struct guestfs_zero_args {
- string device<>;
-};
-
-struct guestfs_grub_install_args {
- string root<>;
- string device<>;
-};
-
-struct guestfs_cp_args {
- string src<>;
- string dest<>;
-};
-
-struct guestfs_cp_a_args {
- string src<>;
- string dest<>;
-};
-
-struct guestfs_mv_args {
- string src<>;
- string dest<>;
-};
-
-struct guestfs_drop_caches_args {
- int whattodrop;
-};
-
-struct guestfs_dmesg_ret {
- string kmsgs<>;
-};
-
-struct guestfs_equal_args {
- string file1<>;
- string file2<>;
-};
-
-struct guestfs_equal_ret {
- bool equality;
-};
-
-struct guestfs_strings_args {
- string path<>;
-};
-
-struct guestfs_strings_ret {
- str stringsout<>;
-};
-
-struct guestfs_strings_e_args {
- string encoding<>;
- string path<>;
-};
-
-struct guestfs_strings_e_ret {
- str stringsout<>;
-};
-
-struct guestfs_hexdump_args {
- string path<>;
-};
-
-struct guestfs_hexdump_ret {
- string dump<>;
-};
-
-struct guestfs_zerofree_args {
- string device<>;
-};
-
-struct guestfs_pvresize_args {
- string device<>;
-};
-
-struct guestfs_sfdisk_N_args {
- string device<>;
- int n;
- int cyls;
- int heads;
- int sectors;
- string line<>;
-};
-
-struct guestfs_sfdisk_l_args {
- string device<>;
-};
-
-struct guestfs_sfdisk_l_ret {
- string partitions<>;
-};
-
-struct guestfs_sfdisk_kernel_geometry_args {
- string device<>;
-};
-
-struct guestfs_sfdisk_kernel_geometry_ret {
- string partitions<>;
-};
-
-struct guestfs_sfdisk_disk_geometry_args {
- string device<>;
-};
-
-struct guestfs_sfdisk_disk_geometry_ret {
- string partitions<>;
-};
-
-struct guestfs_vg_activate_all_args {
- bool activate;
-};
-
-struct guestfs_vg_activate_args {
- bool activate;
- str volgroups<>;
-};
-
-struct guestfs_lvresize_args {
- string device<>;
- int mbytes;
-};
-
-struct guestfs_resize2fs_args {
- string device<>;
-};
-
-struct guestfs_find_args {
- string directory<>;
-};
-
-struct guestfs_find_ret {
- str names<>;
-};
-
-struct guestfs_e2fsck_f_args {
- string device<>;
-};
-
-struct guestfs_sleep_args {
- int secs;
-};
-
-struct guestfs_ntfs_3g_probe_args {
- bool rw;
- string device<>;
-};
-
-struct guestfs_ntfs_3g_probe_ret {
- int status;
-};
-
-enum guestfs_procedure {
- GUESTFS_PROC_MOUNT = 1,
- GUESTFS_PROC_SYNC = 2,
- GUESTFS_PROC_TOUCH = 3,
- GUESTFS_PROC_CAT = 4,
- GUESTFS_PROC_LL = 5,
- GUESTFS_PROC_LS = 6,
- GUESTFS_PROC_LIST_DEVICES = 7,
- GUESTFS_PROC_LIST_PARTITIONS = 8,
- GUESTFS_PROC_PVS = 9,
- GUESTFS_PROC_VGS = 10,
- GUESTFS_PROC_LVS = 11,
- GUESTFS_PROC_PVS_FULL = 12,
- GUESTFS_PROC_VGS_FULL = 13,
- GUESTFS_PROC_LVS_FULL = 14,
- GUESTFS_PROC_READ_LINES = 15,
- GUESTFS_PROC_AUG_INIT = 16,
- GUESTFS_PROC_AUG_CLOSE = 26,
- GUESTFS_PROC_AUG_DEFVAR = 17,
- GUESTFS_PROC_AUG_DEFNODE = 18,
- GUESTFS_PROC_AUG_GET = 19,
- GUESTFS_PROC_AUG_SET = 20,
- GUESTFS_PROC_AUG_INSERT = 21,
- GUESTFS_PROC_AUG_RM = 22,
- GUESTFS_PROC_AUG_MV = 23,
- GUESTFS_PROC_AUG_MATCH = 24,
- GUESTFS_PROC_AUG_SAVE = 25,
- GUESTFS_PROC_AUG_LOAD = 27,
- GUESTFS_PROC_AUG_LS = 28,
- GUESTFS_PROC_RM = 29,
- GUESTFS_PROC_RMDIR = 30,
- GUESTFS_PROC_RM_RF = 31,
- GUESTFS_PROC_MKDIR = 32,
- GUESTFS_PROC_MKDIR_P = 33,
- GUESTFS_PROC_CHMOD = 34,
- GUESTFS_PROC_CHOWN = 35,
- GUESTFS_PROC_EXISTS = 36,
- GUESTFS_PROC_IS_FILE = 37,
- GUESTFS_PROC_IS_DIR = 38,
- GUESTFS_PROC_PVCREATE = 39,
- GUESTFS_PROC_VGCREATE = 40,
- GUESTFS_PROC_LVCREATE = 41,
- GUESTFS_PROC_MKFS = 42,
- GUESTFS_PROC_SFDISK = 43,
- GUESTFS_PROC_WRITE_FILE = 44,
- GUESTFS_PROC_UMOUNT = 45,
- GUESTFS_PROC_MOUNTS = 46,
- GUESTFS_PROC_UMOUNT_ALL = 47,
- GUESTFS_PROC_LVM_REMOVE_ALL = 48,
- GUESTFS_PROC_FILE = 49,
- GUESTFS_PROC_COMMAND = 50,
- GUESTFS_PROC_COMMAND_LINES = 51,
- GUESTFS_PROC_STAT = 52,
- GUESTFS_PROC_LSTAT = 53,
- GUESTFS_PROC_STATVFS = 54,
- GUESTFS_PROC_TUNE2FS_L = 55,
- GUESTFS_PROC_BLOCKDEV_SETRO = 56,
- GUESTFS_PROC_BLOCKDEV_SETRW = 57,
- GUESTFS_PROC_BLOCKDEV_GETRO = 58,
- GUESTFS_PROC_BLOCKDEV_GETSS = 59,
- GUESTFS_PROC_BLOCKDEV_GETBSZ = 60,
- GUESTFS_PROC_BLOCKDEV_SETBSZ = 61,
- GUESTFS_PROC_BLOCKDEV_GETSZ = 62,
- GUESTFS_PROC_BLOCKDEV_GETSIZE64 = 63,
- GUESTFS_PROC_BLOCKDEV_FLUSHBUFS = 64,
- GUESTFS_PROC_BLOCKDEV_REREADPT = 65,
- GUESTFS_PROC_UPLOAD = 66,
- GUESTFS_PROC_DOWNLOAD = 67,
- GUESTFS_PROC_CHECKSUM = 68,
- GUESTFS_PROC_TAR_IN = 69,
- GUESTFS_PROC_TAR_OUT = 70,
- GUESTFS_PROC_TGZ_IN = 71,
- GUESTFS_PROC_TGZ_OUT = 72,
- GUESTFS_PROC_MOUNT_RO = 73,
- GUESTFS_PROC_MOUNT_OPTIONS = 74,
- GUESTFS_PROC_MOUNT_VFS = 75,
- GUESTFS_PROC_DEBUG = 76,
- GUESTFS_PROC_LVREMOVE = 77,
- GUESTFS_PROC_VGREMOVE = 78,
- GUESTFS_PROC_PVREMOVE = 79,
- GUESTFS_PROC_SET_E2LABEL = 80,
- GUESTFS_PROC_GET_E2LABEL = 81,
- GUESTFS_PROC_SET_E2UUID = 82,
- GUESTFS_PROC_GET_E2UUID = 83,
- GUESTFS_PROC_FSCK = 84,
- GUESTFS_PROC_ZERO = 85,
- GUESTFS_PROC_GRUB_INSTALL = 86,
- GUESTFS_PROC_CP = 87,
- GUESTFS_PROC_CP_A = 88,
- GUESTFS_PROC_MV = 89,
- GUESTFS_PROC_DROP_CACHES = 90,
- GUESTFS_PROC_DMESG = 91,
- GUESTFS_PROC_PING_DAEMON = 92,
- GUESTFS_PROC_EQUAL = 93,
- GUESTFS_PROC_STRINGS = 94,
- GUESTFS_PROC_STRINGS_E = 95,
- GUESTFS_PROC_HEXDUMP = 96,
- GUESTFS_PROC_ZEROFREE = 97,
- GUESTFS_PROC_PVRESIZE = 98,
- GUESTFS_PROC_SFDISK_N = 99,
- GUESTFS_PROC_SFDISK_L = 100,
- GUESTFS_PROC_SFDISK_KERNEL_GEOMETRY = 101,
- GUESTFS_PROC_SFDISK_DISK_GEOMETRY = 102,
- GUESTFS_PROC_VG_ACTIVATE_ALL = 103,
- GUESTFS_PROC_VG_ACTIVATE = 104,
- GUESTFS_PROC_LVRESIZE = 105,
- GUESTFS_PROC_RESIZE2FS = 106,
- GUESTFS_PROC_FIND = 107,
- GUESTFS_PROC_E2FSCK_F = 108,
- GUESTFS_PROC_SLEEP = 109,
- GUESTFS_PROC_NTFS_3G_PROBE = 110,
- GUESTFS_PROC_NR_PROCS
-};
-
-const GUESTFS_MESSAGE_MAX = 4194304;
-
-/* The communication protocol is now documented in the guestfs(3)
- * manpage.
- */
-
-const GUESTFS_PROGRAM = 0x2000F5F5;
-const GUESTFS_PROTOCOL_VERSION = 1;
-
-/* These constants must be larger than any possible message length. */
-const GUESTFS_LAUNCH_FLAG = 0xf5f55ff5;
-const GUESTFS_CANCEL_FLAG = 0xffffeeee;
-
-enum guestfs_message_direction {
- GUESTFS_DIRECTION_CALL = 0, /* client -> daemon */
- GUESTFS_DIRECTION_REPLY = 1 /* daemon -> client */
-};
-
-enum guestfs_message_status {
- GUESTFS_STATUS_OK = 0,
- GUESTFS_STATUS_ERROR = 1
-};
-
-const GUESTFS_ERROR_LEN = 256;
-
-struct guestfs_message_error {
- string error_message<GUESTFS_ERROR_LEN>;
-};
-
-struct guestfs_message_header {
- unsigned prog; /* GUESTFS_PROGRAM */
- unsigned vers; /* GUESTFS_PROTOCOL_VERSION */
- guestfs_procedure proc; /* GUESTFS_PROC_x */
- guestfs_message_direction direction;
- unsigned serial; /* message serial number */
- guestfs_message_status status;
-};
-
-const GUESTFS_MAX_CHUNK_SIZE = 8192;
-
-struct guestfs_chunk {
- int cancel; /* if non-zero, transfer is cancelled */
- /* data size is 0 bytes if the transfer has finished successfully */
- opaque data<GUESTFS_MAX_CHUNK_SIZE>;
-};