capitests/test-command
capitests/test*.img
capitests/test*.tmp
+capitests/tests.c
capitests/tests
compile
config.h
config.log
config.status
configure
+daemon/actions.h
daemon/guestfsd
daemon/install-sh
daemon/missing
+daemon/stubs.c
depcomp
emptydisk
examples/hello
examples/to-xml
+fish/cmds.c
+fish/completion.c
fish/guestfish
guestfish.1
+guestfish-actions.pod
+guestfs-actions.pod
+guestfs-structs.pod
guestfs.3
+haskell/Bindtests.hs
haskell/Bindtests
+haskell/Guestfs.hs
haskell/Guestfs005Load
haskell/Guestfs010Launch
haskell/Guestfs050LVCreate
inspector/virt-inspector.1
install-sh
java/api
+java/Bindtests.java
java/com_redhat_et_libguestfs_GuestFS.h
+java/com_redhat_et_libguestfs_GuestFS.c
+java/com/redhat/et/libguestfs/Dirent.java
+java/com/redhat/et/libguestfs/GuestFS.java
+java/com/redhat/et/libguestfs/LV.java
+java/com/redhat/et/libguestfs/PV.java
+java/com/redhat/et/libguestfs/Stat.java
+java/com/redhat/et/libguestfs/StatVFS.java
+java/com/redhat/et/libguestfs/VG.java
java/doc-stamp
missing
libguestfs.pc
m4/ltversion.m4
m4/lt~obsolete.m4
ocaml/META
+ocaml/bindtests.ml
ocaml/bindtests
ocaml/examples/lvs
+ocaml/guestfs.mli
+ocaml/guestfs.ml
+ocaml/guestfs_c_actions.c
ocaml/t/guestfs_005_load
ocaml/t/guestfs_010_launch
ocaml/t/guestfs_050_lvcreate
ocaml/t/guestfs_060_readdir
+perl/bindtests.pl
+perl/blib
perl/Guestfs.c
perl/Guestfs.bs
+perl/Guestfs.xs
+perl/lib/Sys/Guestfs.pm
perl/Makefile-pl
perl/Makefile.PL
-perl/blib
perl/pm_to_blib
po/*.gmo
po/Makevars.template
po/stamp-it
po/stamp-po
pod2htm?.tmp
+python/bindtests.py
+python/guestfs-py.c
+python/guestfs.py
python/guestfs.pyc
ruby/Rakefile
+ruby/bindtests.rb
+ruby/ext/guestfs/_guestfs.c
ruby/ext/guestfs/extconf.h
ruby/ext/guestfs/mkmf.log
+src/MAX_PROC_NR
+src/guestfs-actions.c
+src/guestfs-actions.h
+src/guestfs-bindtests.c
+src/guestfs_protocol.x
+src/guestfs-structs.h
src/stamp-generator
stamp-h1
+++ /dev/null
-/* 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 program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; 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 <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-
-#include "guestfs.h"
-
-static guestfs_h *g;
-static int suppress_error = 0;
-
-static void print_error (guestfs_h *g, void *data, const char *msg)
-{
- if (!suppress_error)
- fprintf (stderr, "%s\n", msg);
-}
-
-static void print_strings (char * const * const argv)
-{
- int argc;
-
- for (argc = 0; argv[argc] != NULL; ++argc)
- printf ("\t%s\n", argv[argc]);
-}
-
-/*
-static void print_table (char * const * const argv)
-{
- int i;
-
- for (i = 0; argv[i] != NULL; i += 2)
- printf ("%s: %s\n", argv[i], argv[i+1]);
-}
-*/
-
-static void no_test_warnings (void)
-{
- fprintf (stderr, "warning: \"guestfs_test0\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rint\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rinterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rint64\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rint64err\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rbool\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rboolerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rconststring\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rconststringerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstring\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstringerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstringlist\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstringlisterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rintbool\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rintboolerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rpvlist\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rpvlisterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rvglist\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rvglisterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rlvlist\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rlvlisterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstat\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstaterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstatvfs\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstatvfserr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rhashtable\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rhashtableerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_add_drive_ro\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_append\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_append\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_end_busy\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_memsize\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_memsize\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_pvresize\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk_N\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk_l\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk_kernel_geometry\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk_disk_geometry\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_vg_activate_all\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_vg_activate\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_resize2fs\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_e2fsck_f\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sh\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sh_lines\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_scrub_freespace\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_df\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_df_h\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_mount_loop\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_umask\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_readdir\" has no tests\n");
-}
-
-static int test_mknod_c_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mknod_c") == NULL;
- str = getenv ("SKIP_TEST_MKNOD_C_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKNOD_C");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mknod_c_0 (void)
-{
- if (test_mknod_c_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mknod_c_0");
- return 0;
- }
-
- /* InitBasicFS for test_mknod_c_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mknod_c (0) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mknod_c (g, 511, 99, 66, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 8685) {
- fprintf (stderr, "test_mknod_c_0: mode was %d, expected 8685\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mknod_b_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mknod_b") == NULL;
- str = getenv ("SKIP_TEST_MKNOD_B_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKNOD_B");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mknod_b_0 (void)
-{
- if (test_mknod_b_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mknod_b_0");
- return 0;
- }
-
- /* InitBasicFS for test_mknod_b_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mknod_b (0) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mknod_b (g, 511, 99, 66, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 25069) {
- fprintf (stderr, "test_mknod_b_0: mode was %d, expected 25069\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mkfifo_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkfifo") == NULL;
- str = getenv ("SKIP_TEST_MKFIFO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKFIFO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkfifo_0 (void)
-{
- if (test_mkfifo_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkfifo_0");
- return 0;
- }
-
- /* InitBasicFS for test_mkfifo_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mkfifo (0) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mkfifo (g, 511, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 4589) {
- fprintf (stderr, "test_mkfifo_0: mode was %d, expected 4589\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mknod_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mknod") == NULL;
- str = getenv ("SKIP_TEST_MKNOD_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKNOD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mknod_0 (void)
-{
- if (test_mknod_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mknod_0");
- return 0;
- }
-
- /* InitBasicFS for test_mknod_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mknod (0) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mknod (g, 4607, 0, 0, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 4589) {
- fprintf (stderr, "test_mknod_0: mode was %d, expected 4589\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mknod_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mknod") == NULL;
- str = getenv ("SKIP_TEST_MKNOD_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKNOD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mknod_1 (void)
-{
- if (test_mknod_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mknod_1");
- return 0;
- }
-
- /* InitBasicFS for test_mknod_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mknod (1) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mknod (g, 25087, 66, 99, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 25069) {
- fprintf (stderr, "test_mknod_1: mode was %d, expected 25069\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mkswap_U_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkswap_U") == NULL;
- str = getenv ("SKIP_TEST_MKSWAP_U_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKSWAP_U");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkswap_U_0 (void)
-{
- if (test_mkswap_U_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkswap_U_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mkswap_U_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for mkswap_U (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkswap_U (g, uuid, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mkswap_L_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkswap_L") == NULL;
- str = getenv ("SKIP_TEST_MKSWAP_L_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKSWAP_L");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkswap_L_0 (void)
-{
- if (test_mkswap_L_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkswap_L_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mkswap_L_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for mkswap_L (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char label[] = "hello";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkswap_L (g, label, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mkswap_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkswap") == NULL;
- str = getenv ("SKIP_TEST_MKSWAP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKSWAP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkswap_0 (void)
-{
- if (test_mkswap_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkswap_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mkswap_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for mkswap (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkswap (g, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_initrd_list_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "initrd_list") == NULL;
- str = getenv ("SKIP_TEST_INITRD_LIST_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_INITRD_LIST");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_initrd_list_0 (void)
-{
- if (test_initrd_list_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_initrd_list_0");
- return 0;
- }
-
- /* InitBasicFS for test_initrd_list_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for initrd_list (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/initrd";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_initrd_list (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_initrd_list_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "empty";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_initrd_list_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_initrd_list_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "known-1";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_initrd_list_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_initrd_list_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "known-2";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_initrd_list_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_initrd_list_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "known-3";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_initrd_list_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_initrd_list_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_du_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "du") == NULL;
- str = getenv ("SKIP_TEST_DU_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_DU");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_du_0 (void)
-{
- if (test_du_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_du_0");
- return 0;
- }
-
- /* InitBasicFS for test_du_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for du (0) */
- {
- char path[] = "/p";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/p";
- int64_t r;
- suppress_error = 0;
- r = guestfs_du (g, path);
- if (r == -1)
- return -1;
- if (r != 1) {
- fprintf (stderr, "test_du_0: expected 1 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_tail_n_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tail_n") == NULL;
- str = getenv ("SKIP_TEST_TAIL_N_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAIL_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tail_n_0 (void)
-{
- if (test_tail_n_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tail_n_0");
- return 0;
- }
-
- /* InitBasicFS for test_tail_n_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for tail_n (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_tail_n (g, 3, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_tail_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9997abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_tail_n_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_tail_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9998abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_tail_n_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_tail_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9999abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_tail_n_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_tail_n_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_tail_n_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tail_n") == NULL;
- str = getenv ("SKIP_TEST_TAIL_N_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAIL_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tail_n_1 (void)
-{
- if (test_tail_n_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tail_n_1");
- return 0;
- }
-
- /* InitBasicFS for test_tail_n_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for tail_n (1) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_tail_n (g, -9998, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_tail_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9997abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_tail_n_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_tail_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9998abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_tail_n_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_tail_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9999abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_tail_n_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_tail_n_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_tail_n_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tail_n") == NULL;
- str = getenv ("SKIP_TEST_TAIL_N_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAIL_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tail_n_2 (void)
-{
- if (test_tail_n_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tail_n_2");
- return 0;
- }
-
- /* InitBasicFS for test_tail_n_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for tail_n (2) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_tail_n (g, 0, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_tail_n_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_tail_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tail") == NULL;
- str = getenv ("SKIP_TEST_TAIL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAIL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tail_0 (void)
-{
- if (test_tail_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tail_0");
- return 0;
- }
-
- /* InitBasicFS for test_tail_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for tail (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_tail (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9990abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9991abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9992abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9993abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (!r[4]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9994abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[4], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
- return -1;
- }
- }
- if (!r[5]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9995abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[5], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[5]);
- return -1;
- }
- }
- if (!r[6]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9996abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[6], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[6]);
- return -1;
- }
- }
- if (!r[7]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9997abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[7], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[7]);
- return -1;
- }
- }
- if (!r[8]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9998abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[8], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[8]);
- return -1;
- }
- }
- if (!r[9]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9999abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[9], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[9]);
- return -1;
- }
- }
- if (r[10] != NULL) {
- fprintf (stderr, "test_tail_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_head_n_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "head_n") == NULL;
- str = getenv ("SKIP_TEST_HEAD_N_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEAD_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_head_n_0 (void)
-{
- if (test_head_n_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_head_n_0");
- return 0;
- }
-
- /* InitBasicFS for test_head_n_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for head_n (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_head_n (g, 3, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_head_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "0abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_head_n_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_head_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "1abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_head_n_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_head_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "2abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_head_n_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_head_n_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_head_n_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "head_n") == NULL;
- str = getenv ("SKIP_TEST_HEAD_N_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEAD_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_head_n_1 (void)
-{
- if (test_head_n_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_head_n_1");
- return 0;
- }
-
- /* InitBasicFS for test_head_n_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for head_n (1) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_head_n (g, -9997, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_head_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "0abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_head_n_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_head_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "1abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_head_n_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_head_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "2abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_head_n_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_head_n_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_head_n_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "head_n") == NULL;
- str = getenv ("SKIP_TEST_HEAD_N_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEAD_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_head_n_2 (void)
-{
- if (test_head_n_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_head_n_2");
- return 0;
- }
-
- /* InitBasicFS for test_head_n_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for head_n (2) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_head_n (g, 0, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_head_n_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_head_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "head") == NULL;
- str = getenv ("SKIP_TEST_HEAD_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEAD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_head_0 (void)
-{
- if (test_head_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_head_0");
- return 0;
- }
-
- /* InitBasicFS for test_head_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for head (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_head (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "0abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "1abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "2abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "3abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (!r[4]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "4abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[4], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
- return -1;
- }
- }
- if (!r[5]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "5abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[5], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[5]);
- return -1;
- }
- }
- if (!r[6]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "6abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[6], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[6]);
- return -1;
- }
- }
- if (!r[7]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "7abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[7], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[7]);
- return -1;
- }
- }
- if (!r[8]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "8abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[8], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[8]);
- return -1;
- }
- }
- if (!r[9]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[9], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[9]);
- return -1;
- }
- }
- if (r[10] != NULL) {
- fprintf (stderr, "test_head_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_wc_c_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "wc_c") == NULL;
- str = getenv ("SKIP_TEST_WC_C_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WC_C");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_wc_c_0 (void)
-{
- if (test_wc_c_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_wc_c_0");
- return 0;
- }
-
- /* InitBasicFS for test_wc_c_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for wc_c (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/100kallspaces";
- int r;
- suppress_error = 0;
- r = guestfs_wc_c (g, path);
- if (r == -1)
- return -1;
- if (r != 102400) {
- fprintf (stderr, "test_wc_c_0: expected 102400 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_wc_w_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "wc_w") == NULL;
- str = getenv ("SKIP_TEST_WC_W_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WC_W");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_wc_w_0 (void)
-{
- if (test_wc_w_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_wc_w_0");
- return 0;
- }
-
- /* InitBasicFS for test_wc_w_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for wc_w (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- int r;
- suppress_error = 0;
- r = guestfs_wc_w (g, path);
- if (r == -1)
- return -1;
- if (r != 10000) {
- fprintf (stderr, "test_wc_w_0: expected 10000 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_wc_l_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "wc_l") == NULL;
- str = getenv ("SKIP_TEST_WC_L_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WC_L");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_wc_l_0 (void)
-{
- if (test_wc_l_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_wc_l_0");
- return 0;
- }
-
- /* InitBasicFS for test_wc_l_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for wc_l (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- int r;
- suppress_error = 0;
- r = guestfs_wc_l (g, path);
- if (r == -1)
- return -1;
- if (r != 10000) {
- fprintf (stderr, "test_wc_l_0: expected 10000 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdtemp_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdtemp") == NULL;
- str = getenv ("SKIP_TEST_MKDTEMP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDTEMP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdtemp_0 (void)
-{
- if (test_mkdtemp_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdtemp_0");
- return 0;
- }
-
- /* InitBasicFS for test_mkdtemp_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for mkdtemp (0) */
- {
- char path[] = "/tmp";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char template[] = "/tmp/tmpXXXXXX";
- char *r;
- suppress_error = 0;
- r = guestfs_mkdtemp (g, template);
- if (r == NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_scrub_file_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "scrub_file") == NULL;
- str = getenv ("SKIP_TEST_SCRUB_FILE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SCRUB_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_scrub_file_0 (void)
-{
- if (test_scrub_file_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_scrub_file_0");
- return 0;
- }
-
- /* InitBasicFS for test_scrub_file_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for scrub_file (0) */
- {
- char path[] = "/file";
- char content[] = "content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char file[] = "/file";
- int r;
- suppress_error = 0;
- r = guestfs_scrub_file (g, file);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_scrub_device_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "scrub_device") == NULL;
- str = getenv ("SKIP_TEST_SCRUB_DEVICE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SCRUB_DEVICE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_scrub_device_0 (void)
-{
- if (test_scrub_device_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_scrub_device_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_scrub_device_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for scrub_device (0) */
- {
- char device[] = "/dev/sdc";
- int r;
- suppress_error = 0;
- r = guestfs_scrub_device (g, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_glob_expand_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "glob_expand") == NULL;
- str = getenv ("SKIP_TEST_GLOB_EXPAND_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_GLOB_EXPAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_glob_expand_0 (void)
-{
- if (test_glob_expand_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_glob_expand_0");
- return 0;
- }
-
- /* InitBasicFS for test_glob_expand_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for glob_expand (0) */
- {
- char path[] = "/a/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/d";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/e";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char pattern[] = "/a/b/c/*";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_glob_expand (g, pattern);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_glob_expand_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/a/b/c/d";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_glob_expand_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_glob_expand_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/a/b/c/e";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_glob_expand_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_glob_expand_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_glob_expand_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "glob_expand") == NULL;
- str = getenv ("SKIP_TEST_GLOB_EXPAND_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_GLOB_EXPAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_glob_expand_1 (void)
-{
- if (test_glob_expand_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_glob_expand_1");
- return 0;
- }
-
- /* InitBasicFS for test_glob_expand_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for glob_expand (1) */
- {
- char path[] = "/a/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/d";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/e";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char pattern[] = "/a/*/c/*";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_glob_expand (g, pattern);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_glob_expand_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/a/b/c/d";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_glob_expand_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_glob_expand_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/a/b/c/e";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_glob_expand_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_glob_expand_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_glob_expand_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "glob_expand") == NULL;
- str = getenv ("SKIP_TEST_GLOB_EXPAND_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_GLOB_EXPAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_glob_expand_2 (void)
-{
- if (test_glob_expand_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_glob_expand_2");
- return 0;
- }
-
- /* InitBasicFS for test_glob_expand_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for glob_expand (2) */
- {
- char path[] = "/a/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/d";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/e";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char pattern[] = "/a/*/x/*";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_glob_expand (g, pattern);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_glob_expand_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_ntfs_3g_probe_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "ntfs_3g_probe") == NULL;
- str = getenv ("SKIP_TEST_NTFS_3G_PROBE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_NTFS_3G_PROBE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_ntfs_3g_probe_0 (void)
-{
- if (test_ntfs_3g_probe_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_ntfs_3g_probe_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_ntfs_3g_probe_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for ntfs_3g_probe (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ntfs";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_ntfs_3g_probe (g, 1, device);
- if (r == -1)
- return -1;
- if (r != 0) {
- fprintf (stderr, "test_ntfs_3g_probe_0: expected 0 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_ntfs_3g_probe_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "ntfs_3g_probe") == NULL;
- str = getenv ("SKIP_TEST_NTFS_3G_PROBE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_NTFS_3G_PROBE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_ntfs_3g_probe_1 (void)
-{
- if (test_ntfs_3g_probe_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_ntfs_3g_probe_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_ntfs_3g_probe_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for ntfs_3g_probe (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_ntfs_3g_probe (g, 1, device);
- if (r == -1)
- return -1;
- if (r != 12) {
- fprintf (stderr, "test_ntfs_3g_probe_1: expected 12 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_sleep_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "sleep") == NULL;
- str = getenv ("SKIP_TEST_SLEEP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SLEEP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_sleep_0 (void)
-{
- if (test_sleep_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_sleep_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_sleep_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for sleep (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_sleep (g, 1);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_find_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "find") == NULL;
- str = getenv ("SKIP_TEST_FIND_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FIND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_find_0 (void)
-{
- if (test_find_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_find_0");
- return 0;
- }
-
- /* InitBasicFS for test_find_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for find (0) */
- {
- char directory[] = "/";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_find (g, directory);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_find_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "lost+found";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_find_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_find_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_find_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "find") == NULL;
- str = getenv ("SKIP_TEST_FIND_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FIND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_find_1 (void)
-{
- if (test_find_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_find_1");
- return 0;
- }
-
- /* InitBasicFS for test_find_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for find (1) */
- {
- char path[] = "/a";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/b";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char directory[] = "/";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_find (g, directory);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_find_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "a";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_find_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "b";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_find_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "b/c";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_find_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "lost+found";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_find_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_find_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "find") == NULL;
- str = getenv ("SKIP_TEST_FIND_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FIND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_find_2 (void)
-{
- if (test_find_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_find_2");
- return 0;
- }
-
- /* InitBasicFS for test_find_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for find (2) */
- {
- char path[] = "/a/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/d";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char directory[] = "/a/b/";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_find (g, directory);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_find_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "c";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_find_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "c/d";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_find_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvresize_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvresize") == NULL;
- str = getenv ("SKIP_TEST_LVRESIZE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVRESIZE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvresize_0 (void)
-{
- if (test_lvresize_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvresize_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvresize_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutput for lvresize (0) */
- char expected[] = "test content";
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 10);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char content[] = "test content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char pathordevice[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_lvresize (g, device, 20);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_e2fsck_f (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_resize2fs (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_lvresize_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_zerofree_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "zerofree") == NULL;
- str = getenv ("SKIP_TEST_ZEROFREE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_ZEROFREE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_zerofree_0 (void)
-{
- if (test_zerofree_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_zerofree_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_zerofree_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutput for zerofree (0) */
- char expected[] = "test file";
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext3";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char content[] = "test file";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char pathordevice[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_zerofree (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_zerofree_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_hexdump_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "hexdump") == NULL;
- str = getenv ("SKIP_TEST_HEXDUMP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEXDUMP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_hexdump_0 (void)
-{
- if (test_hexdump_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_hexdump_0");
- return 0;
- }
-
- /* InitBasicFS for test_hexdump_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for hexdump (0) */
- char expected[] = "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n";
- {
- char path[] = "/new";
- char content[] = "hello\nworld\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 12);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_hexdump (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_hexdump_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "hexdump") == NULL;
- str = getenv ("SKIP_TEST_HEXDUMP_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEXDUMP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_hexdump_1 (void)
-{
- if (test_hexdump_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_hexdump_1");
- return 0;
- }
-
- /* InitBasicFS for test_hexdump_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for hexdump (1) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/100krandom";
- char *r;
- suppress_error = 0;
- r = guestfs_hexdump (g, path);
- if (r == NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_strings_e_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "strings_e") == NULL;
- str = getenv ("SKIP_TEST_STRINGS_E_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STRINGS_E");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_strings_e_0 (void)
-{
- if (test_strings_e_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_strings_e_0");
- return 0;
- }
-
- /* InitBasicFS for test_strings_e_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for strings_e (0) */
- {
- char path[] = "/new";
- char content[] = "hello\nworld\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char encoding[] = "b";
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_strings_e (g, encoding, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_strings_e_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "strings_e") == NULL;
- str = getenv ("SKIP_TEST_STRINGS_E_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STRINGS_E");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_strings_e_1 (void)
-{
- if (test_strings_e_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_strings_e_1");
- return 0;
- }
-
- printf (" %s skipped (reason: test disabled in generator)\n", "test_strings_e_1");
- return 0;
-}
-
-static int test_strings_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "strings") == NULL;
- str = getenv ("SKIP_TEST_STRINGS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STRINGS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_strings_0 (void)
-{
- if (test_strings_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_strings_0");
- return 0;
- }
-
- /* InitBasicFS for test_strings_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for strings (0) */
- {
- char path[] = "/new";
- char content[] = "hello\nworld\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_strings (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_strings_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "hello";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_strings_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "world";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_strings_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_strings_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "strings") == NULL;
- str = getenv ("SKIP_TEST_STRINGS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STRINGS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_strings_1 (void)
-{
- if (test_strings_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_strings_1");
- return 0;
- }
-
- /* InitBasicFS for test_strings_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for strings (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_strings (g, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_strings_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_equal_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "equal") == NULL;
- str = getenv ("SKIP_TEST_EQUAL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EQUAL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_equal_0 (void)
-{
- if (test_equal_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_equal_0");
- return 0;
- }
-
- /* InitBasicFS for test_equal_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for equal (0) */
- {
- char path[] = "/file1";
- char content[] = "contents of a file";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/file1";
- char dest[] = "/file2";
- int r;
- suppress_error = 0;
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char file1[] = "/file1";
- char file2[] = "/file2";
- int r;
- suppress_error = 0;
- r = guestfs_equal (g, file1, file2);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_equal_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_equal_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "equal") == NULL;
- str = getenv ("SKIP_TEST_EQUAL_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EQUAL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_equal_1 (void)
-{
- if (test_equal_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_equal_1");
- return 0;
- }
-
- /* InitBasicFS for test_equal_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for equal (1) */
- {
- char path[] = "/file1";
- char content[] = "contents of a file";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/file2";
- char content[] = "contents of another file";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char file1[] = "/file1";
- char file2[] = "/file2";
- int r;
- suppress_error = 0;
- r = guestfs_equal (g, file1, file2);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_equal_1: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_equal_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "equal") == NULL;
- str = getenv ("SKIP_TEST_EQUAL_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EQUAL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_equal_2 (void)
-{
- if (test_equal_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_equal_2");
- return 0;
- }
-
- /* InitBasicFS for test_equal_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for equal (2) */
- {
- char file1[] = "/file1";
- char file2[] = "/file2";
- int r;
- suppress_error = 1;
- r = guestfs_equal (g, file1, file2);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_ping_daemon_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "ping_daemon") == NULL;
- str = getenv ("SKIP_TEST_PING_DAEMON_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PING_DAEMON");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_ping_daemon_0 (void)
-{
- if (test_ping_daemon_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_ping_daemon_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_ping_daemon_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for ping_daemon (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_ping_daemon (g);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_dmesg_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "dmesg") == NULL;
- str = getenv ("SKIP_TEST_DMESG_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_DMESG");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_dmesg_0 (void)
-{
- if (test_dmesg_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_dmesg_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_dmesg_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for dmesg (0) */
- {
- char *r;
- suppress_error = 0;
- r = guestfs_dmesg (g);
- if (r == NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_drop_caches_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "drop_caches") == NULL;
- str = getenv ("SKIP_TEST_DROP_CACHES_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_DROP_CACHES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_drop_caches_0 (void)
-{
- if (test_drop_caches_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_drop_caches_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_drop_caches_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for drop_caches (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_drop_caches (g, 3);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mv_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mv") == NULL;
- str = getenv ("SKIP_TEST_MV_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MV");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mv_0 (void)
-{
- if (test_mv_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mv_0");
- return 0;
- }
-
- /* InitBasicFS for test_mv_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for mv (0) */
- char expected[] = "file content";
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mv (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mv_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mv") == NULL;
- str = getenv ("SKIP_TEST_MV_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MV");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mv_1 (void)
-{
- if (test_mv_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mv_1");
- return 0;
- }
-
- /* InitBasicFS for test_mv_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for mv (1) */
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mv (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/old";
- int r;
- suppress_error = 0;
- r = guestfs_is_file (g, path);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_mv_1: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_cp_a_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cp_a") == NULL;
- str = getenv ("SKIP_TEST_CP_A_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CP_A");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cp_a_0 (void)
-{
- if (test_cp_a_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cp_a_0");
- return 0;
- }
-
- /* InitBasicFS for test_cp_a_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for cp_a (0) */
- char expected[] = "file content";
- {
- char path[] = "/olddir";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/newdir";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/olddir/file";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/olddir";
- char dest[] = "/newdir";
- int r;
- suppress_error = 0;
- r = guestfs_cp_a (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/newdir/olddir/file";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_cp_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cp") == NULL;
- str = getenv ("SKIP_TEST_CP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cp_0 (void)
-{
- if (test_cp_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cp_0");
- return 0;
- }
-
- /* InitBasicFS for test_cp_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for cp (0) */
- char expected[] = "file content";
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_cp_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cp") == NULL;
- str = getenv ("SKIP_TEST_CP_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cp_1 (void)
-{
- if (test_cp_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cp_1");
- return 0;
- }
-
- /* InitBasicFS for test_cp_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for cp (1) */
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/old";
- int r;
- suppress_error = 0;
- r = guestfs_is_file (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_cp_1: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_cp_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cp") == NULL;
- str = getenv ("SKIP_TEST_CP_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cp_2 (void)
-{
- if (test_cp_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cp_2");
- return 0;
- }
-
- /* InitBasicFS for test_cp_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for cp (2) */
- char expected[] = "file content";
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/dir";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/dir/new";
- int r;
- suppress_error = 0;
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/dir/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_grub_install_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "grub_install") == NULL;
- str = getenv ("SKIP_TEST_GRUB_INSTALL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_GRUB_INSTALL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_grub_install_0 (void)
-{
- if (test_grub_install_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_grub_install_0");
- return 0;
- }
-
- printf (" %s skipped (reason: test disabled in generator)\n", "test_grub_install_0");
- return 0;
-}
-
-static int test_zero_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "zero") == NULL;
- str = getenv ("SKIP_TEST_ZERO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_ZERO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_zero_0 (void)
-{
- if (test_zero_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_zero_0");
- return 0;
- }
-
- /* InitBasicFS for test_zero_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for zero (0) */
- char expected[] = "data";
- {
- char pathordevice[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_zero (g, device);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/dev/sda1";
- char *r;
- suppress_error = 0;
- r = guestfs_file (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_fsck_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "fsck") == NULL;
- str = getenv ("SKIP_TEST_FSCK_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FSCK");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_fsck_0 (void)
-{
- if (test_fsck_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_fsck_0");
- return 0;
- }
-
- /* InitBasicFS for test_fsck_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for fsck (0) */
- {
- char pathordevice[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_fsck (g, fstype, device);
- if (r == -1)
- return -1;
- if (r != 0) {
- fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_fsck_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "fsck") == NULL;
- str = getenv ("SKIP_TEST_FSCK_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FSCK");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_fsck_1 (void)
-{
- if (test_fsck_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_fsck_1");
- return 0;
- }
-
- /* InitBasicFS for test_fsck_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for fsck (1) */
- {
- char pathordevice[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_zero (g, device);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_fsck (g, fstype, device);
- if (r == -1)
- return -1;
- if (r != 8) {
- fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_set_e2uuid_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2uuid") == NULL;
- str = getenv ("SKIP_TEST_SET_E2UUID_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2UUID");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2uuid_0 (void)
-{
- if (test_set_e2uuid_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2uuid_0");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2uuid_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for set_e2uuid (0) */
- char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
- {
- char device[] = "/dev/sda1";
- char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char *r;
- suppress_error = 0;
- r = guestfs_get_e2uuid (g, device);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_set_e2uuid_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2uuid") == NULL;
- str = getenv ("SKIP_TEST_SET_E2UUID_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2UUID");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2uuid_1 (void)
-{
- if (test_set_e2uuid_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2uuid_1");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2uuid_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for set_e2uuid (1) */
- char expected[] = "";
- {
- char device[] = "/dev/sda1";
- char uuid[] = "clear";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char *r;
- suppress_error = 0;
- r = guestfs_get_e2uuid (g, device);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_set_e2uuid_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2uuid") == NULL;
- str = getenv ("SKIP_TEST_SET_E2UUID_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2UUID");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2uuid_2 (void)
-{
- if (test_set_e2uuid_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2uuid_2");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2uuid_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for set_e2uuid (2) */
- {
- char device[] = "/dev/sda1";
- char uuid[] = "random";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_set_e2uuid_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2uuid") == NULL;
- str = getenv ("SKIP_TEST_SET_E2UUID_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2UUID");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2uuid_3 (void)
-{
- if (test_set_e2uuid_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2uuid_3");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2uuid_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for set_e2uuid (3) */
- {
- char device[] = "/dev/sda1";
- char uuid[] = "time";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_set_e2label_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2label") == NULL;
- str = getenv ("SKIP_TEST_SET_E2LABEL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2LABEL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2label_0 (void)
-{
- if (test_set_e2label_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2label_0");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2label_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for set_e2label (0) */
- char expected[] = "testlabel";
- {
- char device[] = "/dev/sda1";
- char label[] = "testlabel";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2label (g, device, label);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char *r;
- suppress_error = 0;
- r = guestfs_get_e2label (g, device);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_pvremove_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvremove") == NULL;
- str = getenv ("SKIP_TEST_PVREMOVE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvremove_0 (void)
-{
- if (test_pvremove_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvremove_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvremove_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for pvremove (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvremove_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvremove") == NULL;
- str = getenv ("SKIP_TEST_PVREMOVE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvremove_1 (void)
-{
- if (test_pvremove_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvremove_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvremove_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for pvremove (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvremove_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvremove") == NULL;
- str = getenv ("SKIP_TEST_PVREMOVE_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvremove_2 (void)
-{
- if (test_pvremove_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvremove_2");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvremove_2 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for pvremove (2) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_pvs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgremove_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgremove") == NULL;
- str = getenv ("SKIP_TEST_VGREMOVE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgremove_0 (void)
-{
- if (test_vgremove_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgremove_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_vgremove_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for vgremove (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgremove_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgremove") == NULL;
- str = getenv ("SKIP_TEST_VGREMOVE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgremove_1 (void)
-{
- if (test_vgremove_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgremove_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_vgremove_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for vgremove (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvremove_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvremove") == NULL;
- str = getenv ("SKIP_TEST_LVREMOVE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvremove_0 (void)
-{
- if (test_lvremove_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvremove_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvremove_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for lvremove (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV1";
- int r;
- suppress_error = 0;
- r = guestfs_lvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvremove_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG/LV2";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvremove_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvremove") == NULL;
- str = getenv ("SKIP_TEST_LVREMOVE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvremove_1 (void)
-{
- if (test_lvremove_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvremove_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvremove_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for lvremove (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvremove_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvremove") == NULL;
- str = getenv ("SKIP_TEST_LVREMOVE_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvremove_2 (void)
-{
- if (test_lvremove_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvremove_2");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvremove_2 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for lvremove (2) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvremove_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_mount_ro_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mount_ro") == NULL;
- str = getenv ("SKIP_TEST_MOUNT_RO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MOUNT_RO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mount_ro_0 (void)
-{
- if (test_mount_ro_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mount_ro_0");
- return 0;
- }
-
- /* InitBasicFS for test_mount_ro_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for mount_ro (0) */
- {
- char pathordevice[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_ro (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_touch (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mount_ro_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mount_ro") == NULL;
- str = getenv ("SKIP_TEST_MOUNT_RO_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MOUNT_RO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mount_ro_1 (void)
-{
- if (test_mount_ro_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mount_ro_1");
- return 0;
- }
-
- /* InitBasicFS for test_mount_ro_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for mount_ro (1) */
- char expected[] = "data";
- {
- char path[] = "/new";
- char content[] = "data";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char pathordevice[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_ro (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_tgz_in_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tgz_in") == NULL;
- str = getenv ("SKIP_TEST_TGZ_IN_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TGZ_IN");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tgz_in_0 (void)
-{
- if (test_tgz_in_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tgz_in_0");
- return 0;
- }
-
- /* InitBasicFS for test_tgz_in_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for tgz_in (0) */
- char expected[] = "hello\n";
- {
- char directory[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_tgz_in (g, "../images/helloworld.tar.gz", directory);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/hello";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_tar_in_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tar_in") == NULL;
- str = getenv ("SKIP_TEST_TAR_IN_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAR_IN");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tar_in_0 (void)
-{
- if (test_tar_in_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tar_in_0");
- return 0;
- }
-
- /* InitBasicFS for test_tar_in_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for tar_in (0) */
- char expected[] = "hello\n";
- {
- char directory[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_tar_in (g, "../images/helloworld.tar", directory);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/hello";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_0 (void)
-{
- if (test_checksum_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_0");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (0) */
- char expected[] = "935282863";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "crc";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_1 (void)
-{
- if (test_checksum_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_1");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for checksum (1) */
- {
- char csumtype[] = "crc";
- char path[] = "/new";
- char *r;
- suppress_error = 1;
- r = guestfs_checksum (g, csumtype, path);
- if (r != NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_2 (void)
-{
- if (test_checksum_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_2");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (2) */
- char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "md5";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_3 (void)
-{
- if (test_checksum_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_3");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (3) */
- char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha1";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_4 (void)
-{
- if (test_checksum_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_4");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (4) */
- char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha224";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_5_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_5");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_5 (void)
-{
- if (test_checksum_5_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_5");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_5: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (5) */
- char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha256";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_6_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_6");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_6 (void)
-{
- if (test_checksum_6_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_6");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_6: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (6) */
- char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha384";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_7_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_7");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_7 (void)
-{
- if (test_checksum_7_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_7");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_7: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (7) */
- char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha512";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_8_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_8");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_8 (void)
-{
- if (test_checksum_8_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_8");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_8: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (8) */
- char expected[] = "46d6ca27ee07cdc6fa99c2e138cc522c";
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "md5";
- char path[] = "/known-3";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_8: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_download_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "download") == NULL;
- str = getenv ("SKIP_TEST_DOWNLOAD_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_DOWNLOAD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_download_0 (void)
-{
- if (test_download_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_download_0");
- return 0;
- }
-
- /* InitBasicFS for test_download_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for download (0) */
- char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
- {
- char remotefilename[] = "/COPYING.LIB";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char remotefilename[] = "/COPYING.LIB";
- int r;
- suppress_error = 0;
- r = guestfs_download (g, remotefilename, "testdownload.tmp");
- if (r == -1)
- return -1;
- }
- {
- char remotefilename[] = "/upload";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "testdownload.tmp", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "md5";
- char path[] = "/upload";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_upload_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "upload") == NULL;
- str = getenv ("SKIP_TEST_UPLOAD_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UPLOAD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_upload_0 (void)
-{
- if (test_upload_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_upload_0");
- return 0;
- }
-
- /* InitBasicFS for test_upload_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for upload (0) */
- char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
- {
- char remotefilename[] = "/COPYING.LIB";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "md5";
- char path[] = "/COPYING.LIB";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_blockdev_rereadpt_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_rereadpt") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_rereadpt_0 (void)
-{
- if (test_blockdev_rereadpt_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_rereadpt_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_rereadpt_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for blockdev_rereadpt (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_rereadpt (g, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_blockdev_flushbufs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_flushbufs") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_flushbufs_0 (void)
-{
- if (test_blockdev_flushbufs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_flushbufs_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_flushbufs_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for blockdev_flushbufs (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_flushbufs (g, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_blockdev_getsize64_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getsize64") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getsize64_0 (void)
-{
- if (test_blockdev_getsize64_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getsize64_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getsize64_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for blockdev_getsize64 (0) */
- {
- char device[] = "/dev/sda";
- int64_t r;
- suppress_error = 0;
- r = guestfs_blockdev_getsize64 (g, device);
- if (r == -1)
- return -1;
- if (r != 524288000) {
- fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_getsz_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getsz") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getsz_0 (void)
-{
- if (test_blockdev_getsz_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getsz_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getsz_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for blockdev_getsz (0) */
- {
- char device[] = "/dev/sda";
- int64_t r;
- suppress_error = 0;
- r = guestfs_blockdev_getsz (g, device);
- if (r == -1)
- return -1;
- if (r != 1024000) {
- fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_getbsz_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getbsz") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getbsz_0 (void)
-{
- if (test_blockdev_getbsz_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getbsz_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getbsz_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for blockdev_getbsz (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getbsz (g, device);
- if (r == -1)
- return -1;
- if (r != 4096) {
- fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_getss_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getss") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getss_0 (void)
-{
- if (test_blockdev_getss_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getss_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getss_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for blockdev_getss (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getss (g, device);
- if (r == -1)
- return -1;
- if (r != 512) {
- fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_getro_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getro") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETRO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETRO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getro_0 (void)
-{
- if (test_blockdev_getro_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getro_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getro_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for blockdev_getro (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setro (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getro (g, device);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_setrw_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_setrw") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_SETRW_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_SETRW");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_setrw_0 (void)
-{
- if (test_blockdev_setrw_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_setrw_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_setrw_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for blockdev_setrw (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getro (g, device);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_setro_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_setro") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_SETRO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_SETRO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_setro_0 (void)
-{
- if (test_blockdev_setro_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_setro_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_setro_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for blockdev_setro (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setro (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getro (g, device);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_statvfs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "statvfs") == NULL;
- str = getenv ("SKIP_TEST_STATVFS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STATVFS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_statvfs_0 (void)
-{
- if (test_statvfs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_statvfs_0");
- return 0;
- }
-
- /* InitBasicFS for test_statvfs_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for statvfs (0) */
- {
- char path[] = "/";
- struct guestfs_statvfs *r;
- suppress_error = 0;
- r = guestfs_statvfs (g, path);
- if (r == NULL)
- return -1;
- if (r->namemax != 255) {
- fprintf (stderr, "test_statvfs_0: namemax was %d, expected 255\n",
- (int) r->namemax);
- return -1;
- }
- if (r->bsize != 1024) {
- fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
- (int) r->bsize);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_lstat_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lstat") == NULL;
- str = getenv ("SKIP_TEST_LSTAT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LSTAT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lstat_0 (void)
-{
- if (test_lstat_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lstat_0");
- return 0;
- }
-
- /* InitBasicFS for test_lstat_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for lstat (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_lstat (g, path);
- if (r == NULL)
- return -1;
- if (r->size != 0) {
- fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
- (int) r->size);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_stat_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "stat") == NULL;
- str = getenv ("SKIP_TEST_STAT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STAT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_stat_0 (void)
-{
- if (test_stat_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_stat_0");
- return 0;
- }
-
- /* InitBasicFS for test_stat_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for stat (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->size != 0) {
- fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
- (int) r->size);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_0 (void)
-{
- if (test_command_lines_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_0");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (0) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "1";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_command_lines_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_1 (void)
-{
- if (test_command_lines_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_1");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (1) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "2";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result2";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_command_lines_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_2 (void)
-{
- if (test_command_lines_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_2");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (2) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "3";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result3";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_3 (void)
-{
- if (test_command_lines_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_3");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (3) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "4";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_3: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_3: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result4";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_3: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_4 (void)
-{
- if (test_command_lines_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_4");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (4) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "5";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_4: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_4: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result5";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_command_lines_4: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_command_lines_4: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_5_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_5");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_5 (void)
-{
- if (test_command_lines_5_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_5");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_5: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (5) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "6";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_5: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_5: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_command_lines_5: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result6";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_command_lines_5: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_command_lines_5: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_6_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_6");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_6 (void)
-{
- if (test_command_lines_6_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_6");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_6: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (6) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "7";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_command_lines_6: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_7_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_7");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_7 (void)
-{
- if (test_command_lines_7_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_7");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_7: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (7) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "8";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_7: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_7: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_command_lines_7: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_8_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_8");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_8 (void)
-{
- if (test_command_lines_8_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_8");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_8: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (8) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "9";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_8: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_8: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_8: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_9_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_9");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_9 (void)
-{
- if (test_command_lines_9_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_9");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_9: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (9) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "10";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_9: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result10-1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_9: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result10-2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_9: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_10_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_10");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_10 (void)
-{
- if (test_command_lines_10_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_10");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_10: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (10) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "11";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_10: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result11-1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_10: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result11-2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_10: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_0 (void)
-{
- if (test_command_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_0");
- return 0;
- }
-
- /* InitBasicFS for test_command_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (0) */
- char expected[] = "Result1";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "1";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_1 (void)
-{
- if (test_command_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_1");
- return 0;
- }
-
- /* InitBasicFS for test_command_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (1) */
- char expected[] = "Result2\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "2";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_2 (void)
-{
- if (test_command_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_2");
- return 0;
- }
-
- /* InitBasicFS for test_command_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (2) */
- char expected[] = "\nResult3";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "3";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_2: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_3 (void)
-{
- if (test_command_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_3");
- return 0;
- }
-
- /* InitBasicFS for test_command_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (3) */
- char expected[] = "\nResult4\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "4";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_3: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_4 (void)
-{
- if (test_command_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_4");
- return 0;
- }
-
- /* InitBasicFS for test_command_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (4) */
- char expected[] = "\nResult5\n\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "5";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_4: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_5_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_5");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_5 (void)
-{
- if (test_command_5_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_5");
- return 0;
- }
-
- /* InitBasicFS for test_command_5: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (5) */
- char expected[] = "\n\nResult6\n\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "6";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_5: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_6_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_6");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_6 (void)
-{
- if (test_command_6_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_6");
- return 0;
- }
-
- /* InitBasicFS for test_command_6: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (6) */
- char expected[] = "";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "7";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_6: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_7_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_7");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_7 (void)
-{
- if (test_command_7_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_7");
- return 0;
- }
-
- /* InitBasicFS for test_command_7: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (7) */
- char expected[] = "\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "8";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_7: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_8_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_8");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_8 (void)
-{
- if (test_command_8_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_8");
- return 0;
- }
-
- /* InitBasicFS for test_command_8: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (8) */
- char expected[] = "\n\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "9";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_8: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_9_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_9");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_9 (void)
-{
- if (test_command_9_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_9");
- return 0;
- }
-
- /* InitBasicFS for test_command_9: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (9) */
- char expected[] = "Result10-1\nResult10-2\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "10";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_9: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_10_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_10");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_10 (void)
-{
- if (test_command_10_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_10");
- return 0;
- }
-
- /* InitBasicFS for test_command_10: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (10) */
- char expected[] = "Result11-1\nResult11-2";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "11";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_10: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_11_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_11");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_11 (void)
-{
- if (test_command_11_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_11");
- return 0;
- }
-
- /* InitBasicFS for test_command_11: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for command (11) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char *arguments[] = {
- arguments_0,
- NULL
- };
- char *r;
- suppress_error = 1;
- r = guestfs_command (g, arguments);
- if (r != NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_file_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "file") == NULL;
- str = getenv ("SKIP_TEST_FILE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_file_0 (void)
-{
- if (test_file_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_file_0");
- return 0;
- }
-
- /* InitBasicFS for test_file_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for file (0) */
- char expected[] = "empty";
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_file (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_file_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "file") == NULL;
- str = getenv ("SKIP_TEST_FILE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_file_1 (void)
-{
- if (test_file_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_file_1");
- return 0;
- }
-
- /* InitBasicFS for test_file_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for file (1) */
- char expected[] = "ASCII text";
- {
- char path[] = "/new";
- char content[] = "some content\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_file (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_file_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "file") == NULL;
- str = getenv ("SKIP_TEST_FILE_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_file_2 (void)
-{
- if (test_file_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_file_2");
- return 0;
- }
-
- /* InitBasicFS for test_file_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for file (2) */
- {
- char path[] = "/nofile";
- char *r;
- suppress_error = 1;
- r = guestfs_file (g, path);
- if (r != NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_umount_all_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "umount_all") == NULL;
- str = getenv ("SKIP_TEST_UMOUNT_ALL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UMOUNT_ALL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_umount_all_0 (void)
-{
- if (test_umount_all_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_umount_all_0");
- return 0;
- }
-
- /* InitBasicFS for test_umount_all_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for umount_all (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_umount_all_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "umount_all") == NULL;
- str = getenv ("SKIP_TEST_UMOUNT_ALL_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UMOUNT_ALL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_umount_all_1 (void)
-{
- if (test_umount_all_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_umount_all_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_umount_all_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for umount_all (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/mp1";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- char mountpoint[] = "/mp1";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/mp1/mp2";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- char mountpoint[] = "/mp1/mp2";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/mp1/mp2/mp3";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_mounts_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mounts") == NULL;
- str = getenv ("SKIP_TEST_MOUNTS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MOUNTS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mounts_0 (void)
-{
- if (test_mounts_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mounts_0");
- return 0;
- }
-
- /* InitBasicFS for test_mounts_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for mounts (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_mounts_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_umount_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "umount") == NULL;
- str = getenv ("SKIP_TEST_UMOUNT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UMOUNT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_umount_0 (void)
-{
- if (test_umount_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_umount_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_umount_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for umount (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_umount_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_umount_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_umount_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "umount") == NULL;
- str = getenv ("SKIP_TEST_UMOUNT_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UMOUNT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_umount_1 (void)
-{
- if (test_umount_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_umount_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_umount_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for umount (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char pathordevice[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_umount_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_0 (void)
-{
- if (test_write_file_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_0");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (0) */
- char expected[] = "new file contents";
- {
- char path[] = "/new";
- char content[] = "new file contents";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_1 (void)
-{
- if (test_write_file_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_1");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (1) */
- char expected[] = "\nnew file contents\n";
- {
- char path[] = "/new";
- char content[] = "\nnew file contents\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_2 (void)
-{
- if (test_write_file_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_2");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (2) */
- char expected[] = "\n\n";
- {
- char path[] = "/new";
- char content[] = "\n\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_3 (void)
-{
- if (test_write_file_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_3");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (3) */
- char expected[] = "";
- {
- char path[] = "/new";
- char content[] = "";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_4 (void)
-{
- if (test_write_file_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_4");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (4) */
- char expected[] = "\n\n\n";
- {
- char path[] = "/new";
- char content[] = "\n\n\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_5_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_5");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_5 (void)
-{
- if (test_write_file_5_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_5");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_5: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (5) */
- char expected[] = "\n";
- {
- char path[] = "/new";
- char content[] = "\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mkfs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkfs") == NULL;
- str = getenv ("SKIP_TEST_MKFS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKFS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkfs_0 (void)
-{
- if (test_mkfs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkfs_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mkfs_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutput for mkfs (0) */
- char expected[] = "new file contents";
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char content[] = "new file contents";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_lvcreate_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvcreate") == NULL;
- str = getenv ("SKIP_TEST_LVCREATE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVCREATE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvcreate_0 (void)
-{
- if (test_lvcreate_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvcreate_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvcreate_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for lvcreate (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG1";
- char physvols_0[] = "/dev/sda1";
- char physvols_1[] = "/dev/sda2";
- char *physvols[] = {
- physvols_0,
- physvols_1,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG2";
- char physvols_0[] = "/dev/sda3";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG1";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG1";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV3";
- char volgroup[] = "VG2";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV4";
- char volgroup[] = "VG2";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV5";
- char volgroup[] = "VG2";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG1/LV1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG1/LV2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG2/LV3";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG2/LV4";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (!r[4]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG2/LV5";
- if (strcmp (r[4], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
- return -1;
- }
- }
- if (r[5] != NULL) {
- fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgcreate_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgcreate") == NULL;
- str = getenv ("SKIP_TEST_VGCREATE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGCREATE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgcreate_0 (void)
-{
- if (test_vgcreate_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgcreate_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_vgcreate_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for vgcreate (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG1";
- char physvols_0[] = "/dev/sda1";
- char physvols_1[] = "/dev/sda2";
- char *physvols[] = {
- physvols_0,
- physvols_1,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG2";
- char physvols_0[] = "/dev/sda3";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvcreate_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvcreate") == NULL;
- str = getenv ("SKIP_TEST_PVCREATE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVCREATE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvcreate_0 (void)
-{
- if (test_pvcreate_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvcreate_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvcreate_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for pvcreate (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_pvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda2";
- r[1][5] = 's';
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda3";
- r[2][5] = 's';
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_is_dir_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "is_dir") == NULL;
- str = getenv ("SKIP_TEST_IS_DIR_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_IS_DIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_is_dir_0 (void)
-{
- if (test_is_dir_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_is_dir_0");
- return 0;
- }
-
- /* InitBasicFS for test_is_dir_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for is_dir (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_is_dir_0: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_is_dir_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "is_dir") == NULL;
- str = getenv ("SKIP_TEST_IS_DIR_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_IS_DIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_is_dir_1 (void)
-{
- if (test_is_dir_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_is_dir_1");
- return 0;
- }
-
- /* InitBasicFS for test_is_dir_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for is_dir (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_is_dir_1: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_is_file_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "is_file") == NULL;
- str = getenv ("SKIP_TEST_IS_FILE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_IS_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_is_file_0 (void)
-{
- if (test_is_file_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_is_file_0");
- return 0;
- }
-
- /* InitBasicFS for test_is_file_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for is_file (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_file (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_is_file_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_is_file_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "is_file") == NULL;
- str = getenv ("SKIP_TEST_IS_FILE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_IS_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_is_file_1 (void)
-{
- if (test_is_file_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_is_file_1");
- return 0;
- }
-
- /* InitBasicFS for test_is_file_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for is_file (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_file (g, path);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_is_file_1: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_exists_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "exists") == NULL;
- str = getenv ("SKIP_TEST_EXISTS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EXISTS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_exists_0 (void)
-{
- if (test_exists_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_exists_0");
- return 0;
- }
-
- /* InitBasicFS for test_exists_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for exists (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_exists (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_exists_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_exists_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "exists") == NULL;
- str = getenv ("SKIP_TEST_EXISTS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EXISTS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_exists_1 (void)
-{
- if (test_exists_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_exists_1");
- return 0;
- }
-
- /* InitBasicFS for test_exists_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for exists (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_exists (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_exists_1: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_p_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_0 (void)
-{
- if (test_mkdir_p_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_0");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for mkdir_p (0) */
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_p_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_1 (void)
-{
- if (test_mkdir_p_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_1");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for mkdir_p (1) */
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new/foo";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_p_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_2 (void)
-{
- if (test_mkdir_p_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_2");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for mkdir_p (2) */
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_p_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_3 (void)
-{
- if (test_mkdir_p_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_3");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for mkdir_p (3) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mkdir_p_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_4 (void)
-{
- if (test_mkdir_p_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_4");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for mkdir_p (4) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_mkdir_p (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mkdir_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_0 (void)
-{
- if (test_mkdir_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_0");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for mkdir (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_mkdir_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_1 (void)
-{
- if (test_mkdir_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_1");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for mkdir (1) */
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 1;
- r = guestfs_mkdir (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rm_rf_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rm_rf") == NULL;
- str = getenv ("SKIP_TEST_RM_RF_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RM_RF");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rm_rf_0 (void)
-{
- if (test_rm_rf_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rm_rf_0");
- return 0;
- }
-
- /* InitBasicFS for test_rm_rf_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for rm_rf (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new/foo";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_rm_rf (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_exists (g, path);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_rmdir_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rmdir") == NULL;
- str = getenv ("SKIP_TEST_RMDIR_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RMDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rmdir_0 (void)
-{
- if (test_rmdir_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rmdir_0");
- return 0;
- }
-
- /* InitBasicFS for test_rmdir_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for rmdir (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_rmdir (g, path);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rmdir_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rmdir") == NULL;
- str = getenv ("SKIP_TEST_RMDIR_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RMDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rmdir_1 (void)
-{
- if (test_rmdir_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rmdir_1");
- return 0;
- }
-
- /* InitBasicFS for test_rmdir_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for rmdir (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_rmdir (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rmdir_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rmdir") == NULL;
- str = getenv ("SKIP_TEST_RMDIR_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RMDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rmdir_2 (void)
-{
- if (test_rmdir_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rmdir_2");
- return 0;
- }
-
- /* InitBasicFS for test_rmdir_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for rmdir (2) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_rmdir (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rm_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rm") == NULL;
- str = getenv ("SKIP_TEST_RM_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rm_0 (void)
-{
- if (test_rm_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rm_0");
- return 0;
- }
-
- /* InitBasicFS for test_rm_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for rm (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_rm (g, path);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rm_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rm") == NULL;
- str = getenv ("SKIP_TEST_RM_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rm_1 (void)
-{
- if (test_rm_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rm_1");
- return 0;
- }
-
- /* InitBasicFS for test_rm_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for rm (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_rm (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rm_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rm") == NULL;
- str = getenv ("SKIP_TEST_RM_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rm_2 (void)
-{
- if (test_rm_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rm_2");
- return 0;
- }
-
- /* InitBasicFS for test_rm_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for rm (2) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_rm (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_read_lines_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "read_lines") == NULL;
- str = getenv ("SKIP_TEST_READ_LINES_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_READ_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_read_lines_0 (void)
-{
- if (test_read_lines_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_read_lines_0");
- return 0;
- }
-
- /* InitBasicFS for test_read_lines_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for read_lines (0) */
- {
- char path[] = "/new";
- char content[] = "line1\r\nline2\nline3";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_read_lines (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_read_lines_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "line1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_read_lines_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "line2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_read_lines_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "line3";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_read_lines_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "read_lines") == NULL;
- str = getenv ("SKIP_TEST_READ_LINES_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_READ_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_read_lines_1 (void)
-{
- if (test_read_lines_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_read_lines_1");
- return 0;
- }
-
- /* InitBasicFS for test_read_lines_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for read_lines (1) */
- {
- char path[] = "/new";
- char content[] = "";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_read_lines (g, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvs") == NULL;
- str = getenv ("SKIP_TEST_LVS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvs_0 (void)
-{
- if (test_lvs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvs_0");
- return 0;
- }
-
- /* InitBasicFSonLVM for test_lvs_0: create ext2 on /dev/VG/LV */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 8);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for lvs (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvs_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG/LV";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvs_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvs") == NULL;
- str = getenv ("SKIP_TEST_LVS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvs_1 (void)
-{
- if (test_lvs_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvs_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvs_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for lvs (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG1";
- char physvols_0[] = "/dev/sda1";
- char physvols_1[] = "/dev/sda2";
- char *physvols[] = {
- physvols_0,
- physvols_1,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG2";
- char physvols_0[] = "/dev/sda3";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG1";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG1";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV3";
- char volgroup[] = "VG2";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG1/LV1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_lvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG1/LV2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_lvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG2/LV3";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgs") == NULL;
- str = getenv ("SKIP_TEST_VGS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgs_0 (void)
-{
- if (test_vgs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgs_0");
- return 0;
- }
-
- /* InitBasicFSonLVM for test_vgs_0: create ext2 on /dev/VG/LV */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 8);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for vgs (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_vgs_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgs_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgs") == NULL;
- str = getenv ("SKIP_TEST_VGS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgs_1 (void)
-{
- if (test_vgs_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgs_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_vgs_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for vgs (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG1";
- char physvols_0[] = "/dev/sda1";
- char physvols_1[] = "/dev/sda2";
- char *physvols[] = {
- physvols_0,
- physvols_1,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG2";
- char physvols_0[] = "/dev/sda3";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_vgs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_vgs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvs") == NULL;
- str = getenv ("SKIP_TEST_PVS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvs_0 (void)
-{
- if (test_pvs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvs_0");
- return 0;
- }
-
- /* InitBasicFSonLVM for test_pvs_0: create ext2 on /dev/VG/LV */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 8);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for pvs (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_pvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_pvs_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvs_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvs") == NULL;
- str = getenv ("SKIP_TEST_PVS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvs_1 (void)
-{
- if (test_pvs_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvs_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvs_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for pvs (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_pvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_pvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_pvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda2";
- r[1][5] = 's';
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_pvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda3";
- r[2][5] = 's';
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_list_partitions_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "list_partitions") == NULL;
- str = getenv ("SKIP_TEST_LIST_PARTITIONS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LIST_PARTITIONS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_list_partitions_0 (void)
-{
- if (test_list_partitions_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_list_partitions_0");
- return 0;
- }
-
- /* InitBasicFS for test_list_partitions_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for list_partitions (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_list_partitions (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_list_partitions_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "list_partitions") == NULL;
- str = getenv ("SKIP_TEST_LIST_PARTITIONS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LIST_PARTITIONS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_list_partitions_1 (void)
-{
- if (test_list_partitions_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_list_partitions_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_list_partitions_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for list_partitions (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_list_partitions (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda2";
- r[1][5] = 's';
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda3";
- r[2][5] = 's';
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_list_devices_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "list_devices") == NULL;
- str = getenv ("SKIP_TEST_LIST_DEVICES_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LIST_DEVICES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_list_devices_0 (void)
-{
- if (test_list_devices_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_list_devices_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_list_devices_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for list_devices (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_list_devices (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_list_devices_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_list_devices_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sdb";
- r[1][5] = 's';
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_list_devices_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sdc";
- r[2][5] = 's';
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_list_devices_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sdd";
- r[3][5] = 's';
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_ls_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "ls") == NULL;
- str = getenv ("SKIP_TEST_LS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_ls_0 (void)
-{
- if (test_ls_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_ls_0");
- return 0;
- }
-
- /* InitBasicFS for test_ls_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for ls (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/newer";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/newest";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char directory[] = "/";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_ls (g, directory);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_ls_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "lost+found";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_ls_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "new";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_ls_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "newer";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_ls_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "newest";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_ls_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_cat_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cat") == NULL;
- str = getenv ("SKIP_TEST_CAT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CAT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cat_0 (void)
-{
- if (test_cat_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cat_0");
- return 0;
- }
-
- /* InitBasicFS for test_cat_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for cat (0) */
- char expected[] = "new file contents";
- {
- char path[] = "/new";
- char content[] = "new file contents";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_touch_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "touch") == NULL;
- str = getenv ("SKIP_TEST_TOUCH_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TOUCH");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_touch_0 (void)
-{
- if (test_touch_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_touch_0");
- return 0;
- }
-
- /* InitBasicFS for test_touch_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for touch (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_exists (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_touch_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_sync_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "sync") == NULL;
- str = getenv ("SKIP_TEST_SYNC_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SYNC");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_sync_0 (void)
-{
- if (test_sync_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_sync_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_sync_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestRun for sync (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_sync (g);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mount_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mount") == NULL;
- str = getenv ("SKIP_TEST_MOUNT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MOUNT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mount_0 (void)
-{
- if (test_mount_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mount_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mount_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- return -1;
- }
- /* TestOutput for mount (0) */
- char expected[] = "new file contents";
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char content[] = "new file contents";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-int main (int argc, char *argv[])
-{
- char c = 0;
- int failed = 0;
- const char *filename;
- int fd;
- int nr_tests, test_num = 0;
-
- setbuf (stdout, NULL);
-
- no_test_warnings ();
-
- g = guestfs_create ();
- if (g == NULL) {
- printf ("guestfs_create FAILED\n");
- exit (1);
- }
-
- guestfs_set_error_handler (g, print_error, NULL);
-
- guestfs_set_path (g, "../appliance");
-
- filename = "test1.img";
- fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
- if (fd == -1) {
- perror (filename);
- exit (1);
- }
- if (lseek (fd, 524288000, SEEK_SET) == -1) {
- perror ("lseek");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (write (fd, &c, 1) == -1) {
- perror ("write");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (close (fd) == -1) {
- perror (filename);
- unlink (filename);
- exit (1);
- }
- if (guestfs_add_drive (g, filename) == -1) {
- printf ("guestfs_add_drive %s FAILED\n", filename);
- exit (1);
- }
-
- filename = "test2.img";
- fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
- if (fd == -1) {
- perror (filename);
- exit (1);
- }
- if (lseek (fd, 52428800, SEEK_SET) == -1) {
- perror ("lseek");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (write (fd, &c, 1) == -1) {
- perror ("write");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (close (fd) == -1) {
- perror (filename);
- unlink (filename);
- exit (1);
- }
- if (guestfs_add_drive (g, filename) == -1) {
- printf ("guestfs_add_drive %s FAILED\n", filename);
- exit (1);
- }
-
- filename = "test3.img";
- fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
- if (fd == -1) {
- perror (filename);
- exit (1);
- }
- if (lseek (fd, 10485760, SEEK_SET) == -1) {
- perror ("lseek");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (write (fd, &c, 1) == -1) {
- perror ("write");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (close (fd) == -1) {
- perror (filename);
- unlink (filename);
- exit (1);
- }
- if (guestfs_add_drive (g, filename) == -1) {
- printf ("guestfs_add_drive %s FAILED\n", filename);
- exit (1);
- }
-
- if (guestfs_add_drive_ro (g, "../images/test.sqsh") == -1) {
- printf ("guestfs_add_drive_ro ../images/test.sqsh FAILED\n");
- exit (1);
- }
-
- if (guestfs_launch (g) == -1) {
- 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 = 174;
-
- test_num++;
- printf ("%3d/%3d test_mknod_c_0\n", test_num, nr_tests);
- if (test_mknod_c_0 () == -1) {
- printf ("test_mknod_c_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mknod_b_0\n", test_num, nr_tests);
- if (test_mknod_b_0 () == -1) {
- printf ("test_mknod_b_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkfifo_0\n", test_num, nr_tests);
- if (test_mkfifo_0 () == -1) {
- printf ("test_mkfifo_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mknod_0\n", test_num, nr_tests);
- if (test_mknod_0 () == -1) {
- printf ("test_mknod_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mknod_1\n", test_num, nr_tests);
- if (test_mknod_1 () == -1) {
- printf ("test_mknod_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkswap_U_0\n", test_num, nr_tests);
- if (test_mkswap_U_0 () == -1) {
- printf ("test_mkswap_U_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkswap_L_0\n", test_num, nr_tests);
- if (test_mkswap_L_0 () == -1) {
- printf ("test_mkswap_L_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkswap_0\n", test_num, nr_tests);
- if (test_mkswap_0 () == -1) {
- printf ("test_mkswap_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_initrd_list_0\n", test_num, nr_tests);
- if (test_initrd_list_0 () == -1) {
- printf ("test_initrd_list_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_du_0\n", test_num, nr_tests);
- if (test_du_0 () == -1) {
- printf ("test_du_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tail_n_0\n", test_num, nr_tests);
- if (test_tail_n_0 () == -1) {
- printf ("test_tail_n_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tail_n_1\n", test_num, nr_tests);
- if (test_tail_n_1 () == -1) {
- printf ("test_tail_n_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tail_n_2\n", test_num, nr_tests);
- if (test_tail_n_2 () == -1) {
- printf ("test_tail_n_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tail_0\n", test_num, nr_tests);
- if (test_tail_0 () == -1) {
- printf ("test_tail_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_head_n_0\n", test_num, nr_tests);
- if (test_head_n_0 () == -1) {
- printf ("test_head_n_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_head_n_1\n", test_num, nr_tests);
- if (test_head_n_1 () == -1) {
- printf ("test_head_n_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_head_n_2\n", test_num, nr_tests);
- if (test_head_n_2 () == -1) {
- printf ("test_head_n_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_head_0\n", test_num, nr_tests);
- if (test_head_0 () == -1) {
- printf ("test_head_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_wc_c_0\n", test_num, nr_tests);
- if (test_wc_c_0 () == -1) {
- printf ("test_wc_c_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_wc_w_0\n", test_num, nr_tests);
- if (test_wc_w_0 () == -1) {
- printf ("test_wc_w_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_wc_l_0\n", test_num, nr_tests);
- if (test_wc_l_0 () == -1) {
- printf ("test_wc_l_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdtemp_0\n", test_num, nr_tests);
- if (test_mkdtemp_0 () == -1) {
- printf ("test_mkdtemp_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_scrub_file_0\n", test_num, nr_tests);
- if (test_scrub_file_0 () == -1) {
- printf ("test_scrub_file_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_scrub_device_0\n", test_num, nr_tests);
- if (test_scrub_device_0 () == -1) {
- printf ("test_scrub_device_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_glob_expand_0\n", test_num, nr_tests);
- if (test_glob_expand_0 () == -1) {
- printf ("test_glob_expand_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_glob_expand_1\n", test_num, nr_tests);
- if (test_glob_expand_1 () == -1) {
- printf ("test_glob_expand_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_glob_expand_2\n", test_num, nr_tests);
- if (test_glob_expand_2 () == -1) {
- printf ("test_glob_expand_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_ntfs_3g_probe_0\n", test_num, nr_tests);
- if (test_ntfs_3g_probe_0 () == -1) {
- printf ("test_ntfs_3g_probe_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_ntfs_3g_probe_1\n", test_num, nr_tests);
- if (test_ntfs_3g_probe_1 () == -1) {
- printf ("test_ntfs_3g_probe_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_sleep_0\n", test_num, nr_tests);
- if (test_sleep_0 () == -1) {
- printf ("test_sleep_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_find_0\n", test_num, nr_tests);
- if (test_find_0 () == -1) {
- printf ("test_find_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_find_1\n", test_num, nr_tests);
- if (test_find_1 () == -1) {
- printf ("test_find_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_find_2\n", test_num, nr_tests);
- if (test_find_2 () == -1) {
- printf ("test_find_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvresize_0\n", test_num, nr_tests);
- if (test_lvresize_0 () == -1) {
- printf ("test_lvresize_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_zerofree_0\n", test_num, nr_tests);
- if (test_zerofree_0 () == -1) {
- printf ("test_zerofree_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
- if (test_hexdump_0 () == -1) {
- printf ("test_hexdump_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_hexdump_1\n", test_num, nr_tests);
- if (test_hexdump_1 () == -1) {
- printf ("test_hexdump_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
- if (test_strings_e_0 () == -1) {
- printf ("test_strings_e_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_strings_e_1\n", test_num, nr_tests);
- if (test_strings_e_1 () == -1) {
- printf ("test_strings_e_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
- if (test_strings_0 () == -1) {
- printf ("test_strings_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_strings_1\n", test_num, nr_tests);
- if (test_strings_1 () == -1) {
- printf ("test_strings_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
- if (test_equal_0 () == -1) {
- printf ("test_equal_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
- if (test_equal_1 () == -1) {
- printf ("test_equal_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
- if (test_equal_2 () == -1) {
- printf ("test_equal_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
- if (test_ping_daemon_0 () == -1) {
- printf ("test_ping_daemon_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
- if (test_dmesg_0 () == -1) {
- printf ("test_dmesg_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
- if (test_drop_caches_0 () == -1) {
- printf ("test_drop_caches_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
- if (test_mv_0 () == -1) {
- printf ("test_mv_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
- if (test_mv_1 () == -1) {
- printf ("test_mv_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
- if (test_cp_a_0 () == -1) {
- printf ("test_cp_a_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
- if (test_cp_0 () == -1) {
- printf ("test_cp_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
- if (test_cp_1 () == -1) {
- printf ("test_cp_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
- if (test_cp_2 () == -1) {
- printf ("test_cp_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
- if (test_grub_install_0 () == -1) {
- printf ("test_grub_install_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
- if (test_zero_0 () == -1) {
- printf ("test_zero_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
- if (test_fsck_0 () == -1) {
- printf ("test_fsck_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
- if (test_fsck_1 () == -1) {
- printf ("test_fsck_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
- if (test_set_e2uuid_0 () == -1) {
- printf ("test_set_e2uuid_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
- if (test_set_e2uuid_1 () == -1) {
- printf ("test_set_e2uuid_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
- if (test_set_e2uuid_2 () == -1) {
- printf ("test_set_e2uuid_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
- if (test_set_e2uuid_3 () == -1) {
- printf ("test_set_e2uuid_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
- if (test_set_e2label_0 () == -1) {
- printf ("test_set_e2label_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
- if (test_pvremove_0 () == -1) {
- printf ("test_pvremove_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
- if (test_pvremove_1 () == -1) {
- printf ("test_pvremove_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
- if (test_pvremove_2 () == -1) {
- printf ("test_pvremove_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
- if (test_vgremove_0 () == -1) {
- printf ("test_vgremove_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
- if (test_vgremove_1 () == -1) {
- printf ("test_vgremove_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
- if (test_lvremove_0 () == -1) {
- printf ("test_lvremove_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
- if (test_lvremove_1 () == -1) {
- printf ("test_lvremove_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
- if (test_lvremove_2 () == -1) {
- printf ("test_lvremove_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
- if (test_mount_ro_0 () == -1) {
- printf ("test_mount_ro_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
- if (test_mount_ro_1 () == -1) {
- printf ("test_mount_ro_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
- if (test_tgz_in_0 () == -1) {
- printf ("test_tgz_in_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
- if (test_tar_in_0 () == -1) {
- printf ("test_tar_in_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
- if (test_checksum_0 () == -1) {
- printf ("test_checksum_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
- if (test_checksum_1 () == -1) {
- printf ("test_checksum_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
- if (test_checksum_2 () == -1) {
- printf ("test_checksum_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
- if (test_checksum_3 () == -1) {
- printf ("test_checksum_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
- if (test_checksum_4 () == -1) {
- printf ("test_checksum_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
- if (test_checksum_5 () == -1) {
- printf ("test_checksum_5 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
- if (test_checksum_6 () == -1) {
- printf ("test_checksum_6 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
- if (test_checksum_7 () == -1) {
- printf ("test_checksum_7 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_8\n", test_num, nr_tests);
- if (test_checksum_8 () == -1) {
- printf ("test_checksum_8 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
- if (test_download_0 () == -1) {
- printf ("test_download_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
- if (test_upload_0 () == -1) {
- printf ("test_upload_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
- if (test_blockdev_rereadpt_0 () == -1) {
- printf ("test_blockdev_rereadpt_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
- if (test_blockdev_flushbufs_0 () == -1) {
- printf ("test_blockdev_flushbufs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
- if (test_blockdev_getsize64_0 () == -1) {
- printf ("test_blockdev_getsize64_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
- if (test_blockdev_getsz_0 () == -1) {
- printf ("test_blockdev_getsz_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
- if (test_blockdev_getbsz_0 () == -1) {
- printf ("test_blockdev_getbsz_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
- if (test_blockdev_getss_0 () == -1) {
- printf ("test_blockdev_getss_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
- if (test_blockdev_getro_0 () == -1) {
- printf ("test_blockdev_getro_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
- if (test_blockdev_setrw_0 () == -1) {
- printf ("test_blockdev_setrw_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
- if (test_blockdev_setro_0 () == -1) {
- printf ("test_blockdev_setro_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
- if (test_statvfs_0 () == -1) {
- printf ("test_statvfs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
- if (test_lstat_0 () == -1) {
- printf ("test_lstat_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
- if (test_stat_0 () == -1) {
- printf ("test_stat_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_0\n", test_num, nr_tests);
- if (test_command_lines_0 () == -1) {
- printf ("test_command_lines_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_1\n", test_num, nr_tests);
- if (test_command_lines_1 () == -1) {
- printf ("test_command_lines_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_2\n", test_num, nr_tests);
- if (test_command_lines_2 () == -1) {
- printf ("test_command_lines_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_3\n", test_num, nr_tests);
- if (test_command_lines_3 () == -1) {
- printf ("test_command_lines_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_4\n", test_num, nr_tests);
- if (test_command_lines_4 () == -1) {
- printf ("test_command_lines_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_5\n", test_num, nr_tests);
- if (test_command_lines_5 () == -1) {
- printf ("test_command_lines_5 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_6\n", test_num, nr_tests);
- if (test_command_lines_6 () == -1) {
- printf ("test_command_lines_6 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_7\n", test_num, nr_tests);
- if (test_command_lines_7 () == -1) {
- printf ("test_command_lines_7 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_8\n", test_num, nr_tests);
- if (test_command_lines_8 () == -1) {
- printf ("test_command_lines_8 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_9\n", test_num, nr_tests);
- if (test_command_lines_9 () == -1) {
- printf ("test_command_lines_9 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_10\n", test_num, nr_tests);
- if (test_command_lines_10 () == -1) {
- printf ("test_command_lines_10 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_0\n", test_num, nr_tests);
- if (test_command_0 () == -1) {
- printf ("test_command_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_1\n", test_num, nr_tests);
- if (test_command_1 () == -1) {
- printf ("test_command_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_2\n", test_num, nr_tests);
- if (test_command_2 () == -1) {
- printf ("test_command_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_3\n", test_num, nr_tests);
- if (test_command_3 () == -1) {
- printf ("test_command_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_4\n", test_num, nr_tests);
- if (test_command_4 () == -1) {
- printf ("test_command_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_5\n", test_num, nr_tests);
- if (test_command_5 () == -1) {
- printf ("test_command_5 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_6\n", test_num, nr_tests);
- if (test_command_6 () == -1) {
- printf ("test_command_6 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_7\n", test_num, nr_tests);
- if (test_command_7 () == -1) {
- printf ("test_command_7 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_8\n", test_num, nr_tests);
- if (test_command_8 () == -1) {
- printf ("test_command_8 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_9\n", test_num, nr_tests);
- if (test_command_9 () == -1) {
- printf ("test_command_9 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_10\n", test_num, nr_tests);
- if (test_command_10 () == -1) {
- printf ("test_command_10 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_11\n", test_num, nr_tests);
- if (test_command_11 () == -1) {
- printf ("test_command_11 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
- if (test_file_0 () == -1) {
- printf ("test_file_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
- if (test_file_1 () == -1) {
- printf ("test_file_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
- if (test_file_2 () == -1) {
- printf ("test_file_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
- if (test_umount_all_0 () == -1) {
- printf ("test_umount_all_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
- if (test_umount_all_1 () == -1) {
- printf ("test_umount_all_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
- if (test_mounts_0 () == -1) {
- printf ("test_mounts_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
- if (test_umount_0 () == -1) {
- printf ("test_umount_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
- if (test_umount_1 () == -1) {
- printf ("test_umount_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
- if (test_write_file_0 () == -1) {
- printf ("test_write_file_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
- if (test_write_file_1 () == -1) {
- printf ("test_write_file_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
- if (test_write_file_2 () == -1) {
- printf ("test_write_file_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
- if (test_write_file_3 () == -1) {
- printf ("test_write_file_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
- if (test_write_file_4 () == -1) {
- printf ("test_write_file_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
- if (test_write_file_5 () == -1) {
- printf ("test_write_file_5 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
- if (test_mkfs_0 () == -1) {
- printf ("test_mkfs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
- if (test_lvcreate_0 () == -1) {
- printf ("test_lvcreate_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
- if (test_vgcreate_0 () == -1) {
- printf ("test_vgcreate_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
- if (test_pvcreate_0 () == -1) {
- printf ("test_pvcreate_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
- if (test_is_dir_0 () == -1) {
- printf ("test_is_dir_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
- if (test_is_dir_1 () == -1) {
- printf ("test_is_dir_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
- if (test_is_file_0 () == -1) {
- printf ("test_is_file_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
- if (test_is_file_1 () == -1) {
- printf ("test_is_file_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
- if (test_exists_0 () == -1) {
- printf ("test_exists_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
- if (test_exists_1 () == -1) {
- printf ("test_exists_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
- if (test_mkdir_p_0 () == -1) {
- printf ("test_mkdir_p_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
- if (test_mkdir_p_1 () == -1) {
- printf ("test_mkdir_p_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
- if (test_mkdir_p_2 () == -1) {
- printf ("test_mkdir_p_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_3\n", test_num, nr_tests);
- if (test_mkdir_p_3 () == -1) {
- printf ("test_mkdir_p_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_4\n", test_num, nr_tests);
- if (test_mkdir_p_4 () == -1) {
- printf ("test_mkdir_p_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
- if (test_mkdir_0 () == -1) {
- printf ("test_mkdir_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
- if (test_mkdir_1 () == -1) {
- printf ("test_mkdir_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
- if (test_rm_rf_0 () == -1) {
- printf ("test_rm_rf_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
- if (test_rmdir_0 () == -1) {
- printf ("test_rmdir_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
- if (test_rmdir_1 () == -1) {
- printf ("test_rmdir_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
- if (test_rmdir_2 () == -1) {
- printf ("test_rmdir_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
- if (test_rm_0 () == -1) {
- printf ("test_rm_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
- if (test_rm_1 () == -1) {
- printf ("test_rm_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
- if (test_rm_2 () == -1) {
- printf ("test_rm_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
- if (test_read_lines_0 () == -1) {
- printf ("test_read_lines_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
- if (test_read_lines_1 () == -1) {
- printf ("test_read_lines_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
- if (test_lvs_0 () == -1) {
- printf ("test_lvs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
- if (test_lvs_1 () == -1) {
- printf ("test_lvs_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
- if (test_vgs_0 () == -1) {
- printf ("test_vgs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
- if (test_vgs_1 () == -1) {
- printf ("test_vgs_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
- if (test_pvs_0 () == -1) {
- printf ("test_pvs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
- if (test_pvs_1 () == -1) {
- printf ("test_pvs_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
- if (test_list_partitions_0 () == -1) {
- printf ("test_list_partitions_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
- if (test_list_partitions_1 () == -1) {
- printf ("test_list_partitions_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
- if (test_list_devices_0 () == -1) {
- printf ("test_list_devices_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
- if (test_ls_0 () == -1) {
- printf ("test_ls_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
- if (test_cat_0 () == -1) {
- printf ("test_cat_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
- if (test_touch_0 () == -1) {
- printf ("test_touch_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
- if (test_sync_0 () == -1) {
- printf ("test_sync_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
- if (test_mount_0 () == -1) {
- printf ("test_mount_0 FAILED\n");
- failed++;
- }
-
- guestfs_close (g);
- unlink ("test1.img");
- unlink ("test2.img");
- unlink ("test3.img");
-
- if (failed > 0) {
- printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);
- exit (1);
- }
-
- exit (0);
-}
+++ /dev/null
-/* 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 program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "../src/guestfs_protocol.h"
-
-extern int do_mount (char *device, char *mountpoint);
-extern int do_sync (void);
-extern int do_touch (char *path);
-extern char *do_cat (char *path);
-extern char *do_ll (char *directory);
-extern char **do_ls (char *directory);
-extern char **do_list_devices (void);
-extern char **do_list_partitions (void);
-extern char **do_pvs (void);
-extern char **do_vgs (void);
-extern char **do_lvs (void);
-extern guestfs_lvm_int_pv_list *do_pvs_full (void);
-extern guestfs_lvm_int_vg_list *do_vgs_full (void);
-extern guestfs_lvm_int_lv_list *do_lvs_full (void);
-extern char **do_read_lines (char *path);
-extern int do_aug_init (char *root, int flags);
-extern int do_aug_close (void);
-extern int do_aug_defvar (char *name, char *expr);
-extern guestfs_aug_defnode_ret *do_aug_defnode (char *name, char *expr, char *val);
-extern char *do_aug_get (char *path);
-extern int do_aug_set (char *path, char *val);
-extern int do_aug_insert (char *path, char *label, int before);
-extern int do_aug_rm (char *path);
-extern int do_aug_mv (char *src, char *dest);
-extern char **do_aug_match (char *path);
-extern int do_aug_save (void);
-extern int do_aug_load (void);
-extern char **do_aug_ls (char *path);
-extern int do_rm (char *path);
-extern int do_rmdir (char *path);
-extern int do_rm_rf (char *path);
-extern int do_mkdir (char *path);
-extern int do_mkdir_p (char *path);
-extern int do_chmod (int mode, char *path);
-extern int do_chown (int owner, int group, char *path);
-extern int do_exists (char *path);
-extern int do_is_file (char *path);
-extern int do_is_dir (char *path);
-extern int do_pvcreate (char *device);
-extern int do_vgcreate (char *volgroup, char **physvols);
-extern int do_lvcreate (char *logvol, char *volgroup, int mbytes);
-extern int do_mkfs (char *fstype, char *device);
-extern int do_sfdisk (char *device, int cyls, int heads, int sectors, char **lines);
-extern int do_write_file (char *path, char *content, int size);
-extern int do_umount (char *pathordevice);
-extern char **do_mounts (void);
-extern int do_umount_all (void);
-extern int do_lvm_remove_all (void);
-extern char *do_file (char *path);
-extern char *do_command (char **arguments);
-extern char **do_command_lines (char **arguments);
-extern guestfs_int_stat *do_stat (char *path);
-extern guestfs_int_stat *do_lstat (char *path);
-extern guestfs_int_statvfs *do_statvfs (char *path);
-extern char **do_tune2fs_l (char *device);
-extern int do_blockdev_setro (char *device);
-extern int do_blockdev_setrw (char *device);
-extern int do_blockdev_getro (char *device);
-extern int do_blockdev_getss (char *device);
-extern int do_blockdev_getbsz (char *device);
-extern int do_blockdev_setbsz (char *device, int blocksize);
-extern int64_t do_blockdev_getsz (char *device);
-extern int64_t do_blockdev_getsize64 (char *device);
-extern int do_blockdev_flushbufs (char *device);
-extern int do_blockdev_rereadpt (char *device);
-extern int do_upload (char *remotefilename);
-extern int do_download (char *remotefilename);
-extern char *do_checksum (char *csumtype, char *path);
-extern int do_tar_in (char *directory);
-extern int do_tar_out (char *directory);
-extern int do_tgz_in (char *directory);
-extern int do_tgz_out (char *directory);
-extern int do_mount_ro (char *device, char *mountpoint);
-extern int do_mount_options (char *options, char *device, char *mountpoint);
-extern int do_mount_vfs (char *options, char *vfstype, char *device, char *mountpoint);
-extern char *do_debug (char *subcmd, char **extraargs);
-extern int do_lvremove (char *device);
-extern int do_vgremove (char *vgname);
-extern int do_pvremove (char *device);
-extern int do_set_e2label (char *device, char *label);
-extern char *do_get_e2label (char *device);
-extern int do_set_e2uuid (char *device, char *uuid);
-extern char *do_get_e2uuid (char *device);
-extern int do_fsck (char *fstype, char *device);
-extern int do_zero (char *device);
-extern int do_grub_install (char *root, char *device);
-extern int do_cp (char *src, char *dest);
-extern int do_cp_a (char *src, char *dest);
-extern int do_mv (char *src, char *dest);
-extern int do_drop_caches (int whattodrop);
-extern char *do_dmesg (void);
-extern int do_ping_daemon (void);
-extern int do_equal (char *file1, char *file2);
-extern char **do_strings (char *path);
-extern char **do_strings_e (char *encoding, char *path);
-extern char *do_hexdump (char *path);
-extern int do_zerofree (char *device);
-extern int do_pvresize (char *device);
-extern int do_sfdisk_N (char *device, int partnum, int cyls, int heads, int sectors, char *line);
-extern char *do_sfdisk_l (char *device);
-extern char *do_sfdisk_kernel_geometry (char *device);
-extern char *do_sfdisk_disk_geometry (char *device);
-extern int do_vg_activate_all (int activate);
-extern int do_vg_activate (int activate, char **volgroups);
-extern int do_lvresize (char *device, int mbytes);
-extern int do_resize2fs (char *device);
-extern char **do_find (char *directory);
-extern int do_e2fsck_f (char *device);
-extern int do_sleep (int secs);
-extern int do_ntfs_3g_probe (int rw, char *device);
-extern char *do_sh (char *command);
-extern char **do_sh_lines (char *command);
-extern char **do_glob_expand (char *pattern);
-extern int do_scrub_device (char *device);
-extern int do_scrub_file (char *file);
-extern int do_scrub_freespace (char *dir);
-extern char *do_mkdtemp (char *template);
-extern int do_wc_l (char *path);
-extern int do_wc_w (char *path);
-extern int do_wc_c (char *path);
-extern char **do_head (char *path);
-extern char **do_head_n (int nrlines, char *path);
-extern char **do_tail (char *path);
-extern char **do_tail_n (int nrlines, char *path);
-extern char *do_df (void);
-extern char *do_df_h (void);
-extern int64_t do_du (char *path);
-extern char **do_initrd_list (char *path);
-extern int do_mount_loop (char *file, char *mountpoint);
-extern int do_mkswap (char *device);
-extern int do_mkswap_L (char *label, char *device);
-extern int do_mkswap_U (char *uuid, char *device);
-extern int do_mknod (int mode, int devmajor, int devminor, char *path);
-extern int do_mkfifo (int mode, char *path);
-extern int do_mknod_b (int mode, int devmajor, int devminor, char *path);
-extern int do_mknod_c (int mode, int devmajor, int devminor, char *path);
-extern int do_umask (int mask);
-extern guestfs_int_dirent_list *do_readdir (char *dir);
+++ /dev/null
-/* 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 program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include <ctype.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-
-#include "daemon.h"
-#include "../src/guestfs_protocol.h"
-#include "actions.h"
-
-static void mount_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mount_args args;
- char *device;
- char *mountpoint;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mount_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mount");
- return;
- }
- device = args.device;
- mountpoint = args.mountpoint;
-
- r = do_mount (device, mountpoint);
- if (r == -1)
- /* do_mount has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mount_args, (char *) &args);
-}
-
-static void sync_stub (XDR *xdr_in)
-{
- int r;
-
- r = do_sync ();
- if (r == -1)
- /* do_sync has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done: ;
-}
-
-static void touch_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_touch_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_touch_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "touch");
- return;
- }
- path = args.path;
-
- r = do_touch (path);
- if (r == -1)
- /* do_touch has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_touch_args, (char *) &args);
-}
-
-static void cat_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_cat_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_cat_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "cat");
- return;
- }
- path = args.path;
-
- r = do_cat (path);
- if (r == NULL)
- /* do_cat has already called reply_with_error */
- goto done;
-
- struct guestfs_cat_ret ret;
- ret.content = r;
- reply ((xdrproc_t) &xdr_guestfs_cat_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_cat_args, (char *) &args);
-}
-
-static void ll_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_ll_args args;
- char *directory;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_ll_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "ll");
- return;
- }
- directory = args.directory;
-
- r = do_ll (directory);
- if (r == NULL)
- /* do_ll has already called reply_with_error */
- goto done;
-
- struct guestfs_ll_ret ret;
- ret.listing = r;
- reply ((xdrproc_t) &xdr_guestfs_ll_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_ll_args, (char *) &args);
-}
-
-static void ls_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_ls_args args;
- char *directory;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_ls_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "ls");
- return;
- }
- directory = args.directory;
-
- r = do_ls (directory);
- if (r == NULL)
- /* do_ls has already called reply_with_error */
- goto done;
-
- struct guestfs_ls_ret ret;
- ret.listing.listing_len = count_strings (r);
- ret.listing.listing_val = r;
- reply ((xdrproc_t) &xdr_guestfs_ls_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_ls_args, (char *) &args);
-}
-
-static void list_devices_stub (XDR *xdr_in)
-{
- char **r;
-
- r = do_list_devices ();
- if (r == NULL)
- /* do_list_devices has already called reply_with_error */
- goto done;
-
- struct guestfs_list_devices_ret ret;
- ret.devices.devices_len = count_strings (r);
- ret.devices.devices_val = r;
- reply ((xdrproc_t) &xdr_guestfs_list_devices_ret, (char *) &ret);
- free_strings (r);
-done: ;
-}
-
-static void list_partitions_stub (XDR *xdr_in)
-{
- char **r;
-
- r = do_list_partitions ();
- if (r == NULL)
- /* do_list_partitions has already called reply_with_error */
- goto done;
-
- struct guestfs_list_partitions_ret ret;
- ret.partitions.partitions_len = count_strings (r);
- ret.partitions.partitions_val = r;
- reply ((xdrproc_t) &xdr_guestfs_list_partitions_ret, (char *) &ret);
- free_strings (r);
-done: ;
-}
-
-static void pvs_stub (XDR *xdr_in)
-{
- char **r;
-
- r = do_pvs ();
- if (r == NULL)
- /* do_pvs has already called reply_with_error */
- goto done;
-
- struct guestfs_pvs_ret ret;
- ret.physvols.physvols_len = count_strings (r);
- ret.physvols.physvols_val = r;
- reply ((xdrproc_t) &xdr_guestfs_pvs_ret, (char *) &ret);
- free_strings (r);
-done: ;
-}
-
-static void vgs_stub (XDR *xdr_in)
-{
- char **r;
-
- r = do_vgs ();
- if (r == NULL)
- /* do_vgs has already called reply_with_error */
- goto done;
-
- struct guestfs_vgs_ret ret;
- ret.volgroups.volgroups_len = count_strings (r);
- ret.volgroups.volgroups_val = r;
- reply ((xdrproc_t) &xdr_guestfs_vgs_ret, (char *) &ret);
- free_strings (r);
-done: ;
-}
-
-static void lvs_stub (XDR *xdr_in)
-{
- char **r;
-
- r = do_lvs ();
- if (r == NULL)
- /* do_lvs has already called reply_with_error */
- goto done;
-
- struct guestfs_lvs_ret ret;
- ret.logvols.logvols_len = count_strings (r);
- ret.logvols.logvols_val = r;
- reply ((xdrproc_t) &xdr_guestfs_lvs_ret, (char *) &ret);
- free_strings (r);
-done: ;
-}
-
-static void pvs_full_stub (XDR *xdr_in)
-{
- guestfs_lvm_int_pv_list *r;
-
- r = do_pvs_full ();
- if (r == NULL)
- /* do_pvs_full has already called reply_with_error */
- goto done;
-
- struct guestfs_pvs_full_ret ret;
- ret.physvols = *r;
- reply ((xdrproc_t) xdr_guestfs_pvs_full_ret, (char *) &ret);
- xdr_free ((xdrproc_t) xdr_guestfs_pvs_full_ret, (char *) &ret);
-done: ;
-}
-
-static void vgs_full_stub (XDR *xdr_in)
-{
- guestfs_lvm_int_vg_list *r;
-
- r = do_vgs_full ();
- if (r == NULL)
- /* do_vgs_full has already called reply_with_error */
- goto done;
-
- struct guestfs_vgs_full_ret ret;
- ret.volgroups = *r;
- reply ((xdrproc_t) xdr_guestfs_vgs_full_ret, (char *) &ret);
- xdr_free ((xdrproc_t) xdr_guestfs_vgs_full_ret, (char *) &ret);
-done: ;
-}
-
-static void lvs_full_stub (XDR *xdr_in)
-{
- guestfs_lvm_int_lv_list *r;
-
- r = do_lvs_full ();
- if (r == NULL)
- /* do_lvs_full has already called reply_with_error */
- goto done;
-
- struct guestfs_lvs_full_ret ret;
- ret.logvols = *r;
- reply ((xdrproc_t) xdr_guestfs_lvs_full_ret, (char *) &ret);
- xdr_free ((xdrproc_t) xdr_guestfs_lvs_full_ret, (char *) &ret);
-done: ;
-}
-
-static void read_lines_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_read_lines_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_read_lines_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "read_lines");
- return;
- }
- path = args.path;
-
- r = do_read_lines (path);
- if (r == NULL)
- /* do_read_lines has already called reply_with_error */
- goto done;
-
- struct guestfs_read_lines_ret ret;
- ret.lines.lines_len = count_strings (r);
- ret.lines.lines_val = r;
- reply ((xdrproc_t) &xdr_guestfs_read_lines_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_read_lines_args, (char *) &args);
-}
-
-static void aug_init_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_aug_init_args args;
- char *root;
- int flags;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_init_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_init");
- return;
- }
- root = args.root;
- flags = args.flags;
-
- r = do_aug_init (root, flags);
- if (r == -1)
- /* do_aug_init has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_init_args, (char *) &args);
-}
-
-static void aug_close_stub (XDR *xdr_in)
-{
- int r;
-
- r = do_aug_close ();
- if (r == -1)
- /* do_aug_close has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done: ;
-}
-
-static void aug_defvar_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_aug_defvar_args args;
- char *name;
- char *expr;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_defvar_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_defvar");
- return;
- }
- name = args.name;
- expr = args.expr ? *args.expr : NULL;
-
- r = do_aug_defvar (name, expr);
- if (r == -1)
- /* do_aug_defvar has already called reply_with_error */
- goto done;
-
- struct guestfs_aug_defvar_ret ret;
- ret.nrnodes = r;
- reply ((xdrproc_t) &xdr_guestfs_aug_defvar_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_defvar_args, (char *) &args);
-}
-
-static void aug_defnode_stub (XDR *xdr_in)
-{
- guestfs_aug_defnode_ret *r;
- struct guestfs_aug_defnode_args args;
- char *name;
- char *expr;
- char *val;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_defnode_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_defnode");
- return;
- }
- name = args.name;
- expr = args.expr;
- val = args.val;
-
- r = do_aug_defnode (name, expr, val);
- if (r == NULL)
- /* do_aug_defnode has already called reply_with_error */
- goto done;
-
- reply ((xdrproc_t) xdr_guestfs_aug_defnode_ret, (char *) r);
- xdr_free ((xdrproc_t) xdr_guestfs_aug_defnode_ret, (char *) r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_defnode_args, (char *) &args);
-}
-
-static void aug_get_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_aug_get_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_get_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_get");
- return;
- }
- path = args.path;
-
- r = do_aug_get (path);
- if (r == NULL)
- /* do_aug_get has already called reply_with_error */
- goto done;
-
- struct guestfs_aug_get_ret ret;
- ret.val = r;
- reply ((xdrproc_t) &xdr_guestfs_aug_get_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_get_args, (char *) &args);
-}
-
-static void aug_set_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_aug_set_args args;
- char *path;
- char *val;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_set_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_set");
- return;
- }
- path = args.path;
- val = args.val;
-
- r = do_aug_set (path, val);
- if (r == -1)
- /* do_aug_set has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_set_args, (char *) &args);
-}
-
-static void aug_insert_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_aug_insert_args args;
- char *path;
- char *label;
- int before;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_insert_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_insert");
- return;
- }
- path = args.path;
- label = args.label;
- before = args.before;
-
- r = do_aug_insert (path, label, before);
- if (r == -1)
- /* do_aug_insert has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_insert_args, (char *) &args);
-}
-
-static void aug_rm_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_aug_rm_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_rm_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_rm");
- return;
- }
- path = args.path;
-
- r = do_aug_rm (path);
- if (r == -1)
- /* do_aug_rm has already called reply_with_error */
- goto done;
-
- struct guestfs_aug_rm_ret ret;
- ret.nrnodes = r;
- reply ((xdrproc_t) &xdr_guestfs_aug_rm_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_rm_args, (char *) &args);
-}
-
-static void aug_mv_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_aug_mv_args args;
- char *src;
- char *dest;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_mv_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_mv");
- return;
- }
- src = args.src;
- dest = args.dest;
-
- r = do_aug_mv (src, dest);
- if (r == -1)
- /* do_aug_mv has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_mv_args, (char *) &args);
-}
-
-static void aug_match_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_aug_match_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_match_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_match");
- return;
- }
- path = args.path;
-
- r = do_aug_match (path);
- if (r == NULL)
- /* do_aug_match has already called reply_with_error */
- goto done;
-
- struct guestfs_aug_match_ret ret;
- ret.matches.matches_len = count_strings (r);
- ret.matches.matches_val = r;
- reply ((xdrproc_t) &xdr_guestfs_aug_match_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_match_args, (char *) &args);
-}
-
-static void aug_save_stub (XDR *xdr_in)
-{
- int r;
-
- r = do_aug_save ();
- if (r == -1)
- /* do_aug_save has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done: ;
-}
-
-static void aug_load_stub (XDR *xdr_in)
-{
- int r;
-
- r = do_aug_load ();
- if (r == -1)
- /* do_aug_load has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done: ;
-}
-
-static void aug_ls_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_aug_ls_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_aug_ls_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_ls");
- return;
- }
- path = args.path;
-
- r = do_aug_ls (path);
- if (r == NULL)
- /* do_aug_ls has already called reply_with_error */
- goto done;
-
- struct guestfs_aug_ls_ret ret;
- ret.matches.matches_len = count_strings (r);
- ret.matches.matches_val = r;
- reply ((xdrproc_t) &xdr_guestfs_aug_ls_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_aug_ls_args, (char *) &args);
-}
-
-static void rm_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_rm_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_rm_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "rm");
- return;
- }
- path = args.path;
-
- r = do_rm (path);
- if (r == -1)
- /* do_rm has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_rm_args, (char *) &args);
-}
-
-static void rmdir_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_rmdir_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_rmdir_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "rmdir");
- return;
- }
- path = args.path;
-
- r = do_rmdir (path);
- if (r == -1)
- /* do_rmdir has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_rmdir_args, (char *) &args);
-}
-
-static void rm_rf_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_rm_rf_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_rm_rf_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "rm_rf");
- return;
- }
- path = args.path;
-
- r = do_rm_rf (path);
- if (r == -1)
- /* do_rm_rf has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_rm_rf_args, (char *) &args);
-}
-
-static void mkdir_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mkdir_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mkdir_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mkdir");
- return;
- }
- path = args.path;
-
- r = do_mkdir (path);
- if (r == -1)
- /* do_mkdir has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mkdir_args, (char *) &args);
-}
-
-static void mkdir_p_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mkdir_p_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mkdir_p_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mkdir_p");
- return;
- }
- path = args.path;
-
- r = do_mkdir_p (path);
- if (r == -1)
- /* do_mkdir_p has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mkdir_p_args, (char *) &args);
-}
-
-static void chmod_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_chmod_args args;
- int mode;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_chmod_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "chmod");
- return;
- }
- mode = args.mode;
- path = args.path;
-
- r = do_chmod (mode, path);
- if (r == -1)
- /* do_chmod has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_chmod_args, (char *) &args);
-}
-
-static void chown_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_chown_args args;
- int owner;
- int group;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_chown_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "chown");
- return;
- }
- owner = args.owner;
- group = args.group;
- path = args.path;
-
- r = do_chown (owner, group, path);
- if (r == -1)
- /* do_chown has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_chown_args, (char *) &args);
-}
-
-static void exists_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_exists_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_exists_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "exists");
- return;
- }
- path = args.path;
-
- r = do_exists (path);
- if (r == -1)
- /* do_exists has already called reply_with_error */
- goto done;
-
- struct guestfs_exists_ret ret;
- ret.existsflag = r;
- reply ((xdrproc_t) &xdr_guestfs_exists_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_exists_args, (char *) &args);
-}
-
-static void is_file_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_is_file_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_is_file_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "is_file");
- return;
- }
- path = args.path;
-
- r = do_is_file (path);
- if (r == -1)
- /* do_is_file has already called reply_with_error */
- goto done;
-
- struct guestfs_is_file_ret ret;
- ret.fileflag = r;
- reply ((xdrproc_t) &xdr_guestfs_is_file_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_is_file_args, (char *) &args);
-}
-
-static void is_dir_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_is_dir_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_is_dir_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "is_dir");
- return;
- }
- path = args.path;
-
- r = do_is_dir (path);
- if (r == -1)
- /* do_is_dir has already called reply_with_error */
- goto done;
-
- struct guestfs_is_dir_ret ret;
- ret.dirflag = r;
- reply ((xdrproc_t) &xdr_guestfs_is_dir_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_is_dir_args, (char *) &args);
-}
-
-static void pvcreate_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_pvcreate_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_pvcreate_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "pvcreate");
- return;
- }
- device = args.device;
-
- r = do_pvcreate (device);
- if (r == -1)
- /* do_pvcreate has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_pvcreate_args, (char *) &args);
-}
-
-static void vgcreate_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_vgcreate_args args;
- char *volgroup;
- char **physvols;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_vgcreate_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "vgcreate");
- return;
- }
- volgroup = args.volgroup;
- physvols = realloc (args.physvols.physvols_val,
- sizeof (char *) * (args.physvols.physvols_len+1));
- if (physvols == NULL) {
- reply_with_perror ("realloc");
- goto done;
- }
- physvols[args.physvols.physvols_len] = NULL;
- args.physvols.physvols_val = physvols;
-
- r = do_vgcreate (volgroup, physvols);
- if (r == -1)
- /* do_vgcreate has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_vgcreate_args, (char *) &args);
-}
-
-static void lvcreate_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_lvcreate_args args;
- char *logvol;
- char *volgroup;
- int mbytes;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_lvcreate_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "lvcreate");
- return;
- }
- logvol = args.logvol;
- volgroup = args.volgroup;
- mbytes = args.mbytes;
-
- r = do_lvcreate (logvol, volgroup, mbytes);
- if (r == -1)
- /* do_lvcreate has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_lvcreate_args, (char *) &args);
-}
-
-static void mkfs_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mkfs_args args;
- char *fstype;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mkfs_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mkfs");
- return;
- }
- fstype = args.fstype;
- device = args.device;
-
- r = do_mkfs (fstype, device);
- if (r == -1)
- /* do_mkfs has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mkfs_args, (char *) &args);
-}
-
-static void sfdisk_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_sfdisk_args args;
- char *device;
- int cyls;
- int heads;
- int sectors;
- char **lines;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_sfdisk_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "sfdisk");
- return;
- }
- device = args.device;
- cyls = args.cyls;
- heads = args.heads;
- sectors = args.sectors;
- lines = realloc (args.lines.lines_val,
- sizeof (char *) * (args.lines.lines_len+1));
- if (lines == NULL) {
- reply_with_perror ("realloc");
- goto done;
- }
- lines[args.lines.lines_len] = NULL;
- args.lines.lines_val = lines;
-
- r = do_sfdisk (device, cyls, heads, sectors, lines);
- if (r == -1)
- /* do_sfdisk has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_sfdisk_args, (char *) &args);
-}
-
-static void write_file_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_write_file_args args;
- char *path;
- char *content;
- int size;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_write_file_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "write_file");
- return;
- }
- path = args.path;
- content = args.content;
- size = args.size;
-
- r = do_write_file (path, content, size);
- if (r == -1)
- /* do_write_file has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_write_file_args, (char *) &args);
-}
-
-static void umount_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_umount_args args;
- char *pathordevice;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_umount_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "umount");
- return;
- }
- pathordevice = args.pathordevice;
-
- r = do_umount (pathordevice);
- if (r == -1)
- /* do_umount has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_umount_args, (char *) &args);
-}
-
-static void mounts_stub (XDR *xdr_in)
-{
- char **r;
-
- r = do_mounts ();
- if (r == NULL)
- /* do_mounts has already called reply_with_error */
- goto done;
-
- struct guestfs_mounts_ret ret;
- ret.devices.devices_len = count_strings (r);
- ret.devices.devices_val = r;
- reply ((xdrproc_t) &xdr_guestfs_mounts_ret, (char *) &ret);
- free_strings (r);
-done: ;
-}
-
-static void umount_all_stub (XDR *xdr_in)
-{
- int r;
-
- r = do_umount_all ();
- if (r == -1)
- /* do_umount_all has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done: ;
-}
-
-static void lvm_remove_all_stub (XDR *xdr_in)
-{
- int r;
-
- r = do_lvm_remove_all ();
- if (r == -1)
- /* do_lvm_remove_all has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done: ;
-}
-
-static void file_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_file_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_file_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "file");
- return;
- }
- path = args.path;
-
- r = do_file (path);
- if (r == NULL)
- /* do_file has already called reply_with_error */
- goto done;
-
- struct guestfs_file_ret ret;
- ret.description = r;
- reply ((xdrproc_t) &xdr_guestfs_file_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_file_args, (char *) &args);
-}
-
-static void command_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_command_args args;
- char **arguments;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_command_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "command");
- return;
- }
- arguments = realloc (args.arguments.arguments_val,
- sizeof (char *) * (args.arguments.arguments_len+1));
- if (arguments == NULL) {
- reply_with_perror ("realloc");
- goto done;
- }
- arguments[args.arguments.arguments_len] = NULL;
- args.arguments.arguments_val = arguments;
-
- r = do_command (arguments);
- if (r == NULL)
- /* do_command has already called reply_with_error */
- goto done;
-
- struct guestfs_command_ret ret;
- ret.output = r;
- reply ((xdrproc_t) &xdr_guestfs_command_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_command_args, (char *) &args);
-}
-
-static void command_lines_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_command_lines_args args;
- char **arguments;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_command_lines_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "command_lines");
- return;
- }
- arguments = realloc (args.arguments.arguments_val,
- sizeof (char *) * (args.arguments.arguments_len+1));
- if (arguments == NULL) {
- reply_with_perror ("realloc");
- goto done;
- }
- arguments[args.arguments.arguments_len] = NULL;
- args.arguments.arguments_val = arguments;
-
- r = do_command_lines (arguments);
- if (r == NULL)
- /* do_command_lines has already called reply_with_error */
- goto done;
-
- struct guestfs_command_lines_ret ret;
- ret.lines.lines_len = count_strings (r);
- ret.lines.lines_val = r;
- reply ((xdrproc_t) &xdr_guestfs_command_lines_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_command_lines_args, (char *) &args);
-}
-
-static void stat_stub (XDR *xdr_in)
-{
- guestfs_int_stat *r;
- struct guestfs_stat_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_stat_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "stat");
- return;
- }
- path = args.path;
-
- r = do_stat (path);
- if (r == NULL)
- /* do_stat has already called reply_with_error */
- goto done;
-
- struct guestfs_stat_ret ret;
- ret.statbuf = *r;
- reply ((xdrproc_t) xdr_guestfs_stat_ret, (char *) &ret);
- xdr_free ((xdrproc_t) xdr_guestfs_stat_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_stat_args, (char *) &args);
-}
-
-static void lstat_stub (XDR *xdr_in)
-{
- guestfs_int_stat *r;
- struct guestfs_lstat_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_lstat_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "lstat");
- return;
- }
- path = args.path;
-
- r = do_lstat (path);
- if (r == NULL)
- /* do_lstat has already called reply_with_error */
- goto done;
-
- struct guestfs_lstat_ret ret;
- ret.statbuf = *r;
- reply ((xdrproc_t) xdr_guestfs_lstat_ret, (char *) &ret);
- xdr_free ((xdrproc_t) xdr_guestfs_lstat_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_lstat_args, (char *) &args);
-}
-
-static void statvfs_stub (XDR *xdr_in)
-{
- guestfs_int_statvfs *r;
- struct guestfs_statvfs_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_statvfs_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "statvfs");
- return;
- }
- path = args.path;
-
- r = do_statvfs (path);
- if (r == NULL)
- /* do_statvfs has already called reply_with_error */
- goto done;
-
- struct guestfs_statvfs_ret ret;
- ret.statbuf = *r;
- reply ((xdrproc_t) xdr_guestfs_statvfs_ret, (char *) &ret);
- xdr_free ((xdrproc_t) xdr_guestfs_statvfs_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_statvfs_args, (char *) &args);
-}
-
-static void tune2fs_l_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_tune2fs_l_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_tune2fs_l_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "tune2fs_l");
- return;
- }
- device = args.device;
-
- r = do_tune2fs_l (device);
- if (r == NULL)
- /* do_tune2fs_l has already called reply_with_error */
- goto done;
-
- struct guestfs_tune2fs_l_ret ret;
- ret.superblock.superblock_len = count_strings (r);
- ret.superblock.superblock_val = r;
- reply ((xdrproc_t) &xdr_guestfs_tune2fs_l_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_tune2fs_l_args, (char *) &args);
-}
-
-static void blockdev_setro_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_blockdev_setro_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_setro_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_setro");
- return;
- }
- device = args.device;
-
- r = do_blockdev_setro (device);
- if (r == -1)
- /* do_blockdev_setro has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_setro_args, (char *) &args);
-}
-
-static void blockdev_setrw_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_blockdev_setrw_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_setrw_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_setrw");
- return;
- }
- device = args.device;
-
- r = do_blockdev_setrw (device);
- if (r == -1)
- /* do_blockdev_setrw has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_setrw_args, (char *) &args);
-}
-
-static void blockdev_getro_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_blockdev_getro_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_getro_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getro");
- return;
- }
- device = args.device;
-
- r = do_blockdev_getro (device);
- if (r == -1)
- /* do_blockdev_getro has already called reply_with_error */
- goto done;
-
- struct guestfs_blockdev_getro_ret ret;
- ret.ro = r;
- reply ((xdrproc_t) &xdr_guestfs_blockdev_getro_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getro_args, (char *) &args);
-}
-
-static void blockdev_getss_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_blockdev_getss_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_getss_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getss");
- return;
- }
- device = args.device;
-
- r = do_blockdev_getss (device);
- if (r == -1)
- /* do_blockdev_getss has already called reply_with_error */
- goto done;
-
- struct guestfs_blockdev_getss_ret ret;
- ret.sectorsize = r;
- reply ((xdrproc_t) &xdr_guestfs_blockdev_getss_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getss_args, (char *) &args);
-}
-
-static void blockdev_getbsz_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_blockdev_getbsz_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_getbsz_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getbsz");
- return;
- }
- device = args.device;
-
- r = do_blockdev_getbsz (device);
- if (r == -1)
- /* do_blockdev_getbsz has already called reply_with_error */
- goto done;
-
- struct guestfs_blockdev_getbsz_ret ret;
- ret.blocksize = r;
- reply ((xdrproc_t) &xdr_guestfs_blockdev_getbsz_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getbsz_args, (char *) &args);
-}
-
-static void blockdev_setbsz_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_blockdev_setbsz_args args;
- char *device;
- int blocksize;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_setbsz_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_setbsz");
- return;
- }
- device = args.device;
- blocksize = args.blocksize;
-
- r = do_blockdev_setbsz (device, blocksize);
- if (r == -1)
- /* do_blockdev_setbsz has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_setbsz_args, (char *) &args);
-}
-
-static void blockdev_getsz_stub (XDR *xdr_in)
-{
- int64_t r;
- struct guestfs_blockdev_getsz_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_getsz_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getsz");
- return;
- }
- device = args.device;
-
- r = do_blockdev_getsz (device);
- if (r == -1)
- /* do_blockdev_getsz has already called reply_with_error */
- goto done;
-
- struct guestfs_blockdev_getsz_ret ret;
- ret.sizeinsectors = r;
- reply ((xdrproc_t) &xdr_guestfs_blockdev_getsz_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getsz_args, (char *) &args);
-}
-
-static void blockdev_getsize64_stub (XDR *xdr_in)
-{
- int64_t r;
- struct guestfs_blockdev_getsize64_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_getsize64_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getsize64");
- return;
- }
- device = args.device;
-
- r = do_blockdev_getsize64 (device);
- if (r == -1)
- /* do_blockdev_getsize64 has already called reply_with_error */
- goto done;
-
- struct guestfs_blockdev_getsize64_ret ret;
- ret.sizeinbytes = r;
- reply ((xdrproc_t) &xdr_guestfs_blockdev_getsize64_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getsize64_args, (char *) &args);
-}
-
-static void blockdev_flushbufs_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_blockdev_flushbufs_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_flushbufs_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_flushbufs");
- return;
- }
- device = args.device;
-
- r = do_blockdev_flushbufs (device);
- if (r == -1)
- /* do_blockdev_flushbufs has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_flushbufs_args, (char *) &args);
-}
-
-static void blockdev_rereadpt_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_blockdev_rereadpt_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_blockdev_rereadpt_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_rereadpt");
- return;
- }
- device = args.device;
-
- r = do_blockdev_rereadpt (device);
- if (r == -1)
- /* do_blockdev_rereadpt has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_blockdev_rereadpt_args, (char *) &args);
-}
-
-static void upload_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_upload_args args;
- char *remotefilename;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_upload_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "upload");
- return;
- }
- remotefilename = args.remotefilename;
-
- r = do_upload (remotefilename);
- if (r == -1)
- /* do_upload has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_upload_args, (char *) &args);
-}
-
-static void download_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_download_args args;
- char *remotefilename;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_download_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "download");
- return;
- }
- remotefilename = args.remotefilename;
-
- r = do_download (remotefilename);
- if (r == -1)
- /* do_download has already called reply_with_error */
- goto done;
-
- /* do_download has already sent a reply */
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_download_args, (char *) &args);
-}
-
-static void checksum_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_checksum_args args;
- char *csumtype;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_checksum_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "checksum");
- return;
- }
- csumtype = args.csumtype;
- path = args.path;
-
- r = do_checksum (csumtype, path);
- if (r == NULL)
- /* do_checksum has already called reply_with_error */
- goto done;
-
- struct guestfs_checksum_ret ret;
- ret.checksum = r;
- reply ((xdrproc_t) &xdr_guestfs_checksum_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_checksum_args, (char *) &args);
-}
-
-static void tar_in_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_tar_in_args args;
- char *directory;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_tar_in_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "tar_in");
- return;
- }
- directory = args.directory;
-
- r = do_tar_in (directory);
- if (r == -1)
- /* do_tar_in has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_tar_in_args, (char *) &args);
-}
-
-static void tar_out_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_tar_out_args args;
- char *directory;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_tar_out_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "tar_out");
- return;
- }
- directory = args.directory;
-
- r = do_tar_out (directory);
- if (r == -1)
- /* do_tar_out has already called reply_with_error */
- goto done;
-
- /* do_tar_out has already sent a reply */
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_tar_out_args, (char *) &args);
-}
-
-static void tgz_in_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_tgz_in_args args;
- char *directory;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_tgz_in_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "tgz_in");
- return;
- }
- directory = args.directory;
-
- r = do_tgz_in (directory);
- if (r == -1)
- /* do_tgz_in has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_tgz_in_args, (char *) &args);
-}
-
-static void tgz_out_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_tgz_out_args args;
- char *directory;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_tgz_out_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "tgz_out");
- return;
- }
- directory = args.directory;
-
- r = do_tgz_out (directory);
- if (r == -1)
- /* do_tgz_out has already called reply_with_error */
- goto done;
-
- /* do_tgz_out has already sent a reply */
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_tgz_out_args, (char *) &args);
-}
-
-static void mount_ro_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mount_ro_args args;
- char *device;
- char *mountpoint;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mount_ro_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mount_ro");
- return;
- }
- device = args.device;
- mountpoint = args.mountpoint;
-
- r = do_mount_ro (device, mountpoint);
- if (r == -1)
- /* do_mount_ro has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mount_ro_args, (char *) &args);
-}
-
-static void mount_options_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mount_options_args args;
- char *options;
- char *device;
- char *mountpoint;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mount_options_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mount_options");
- return;
- }
- options = args.options;
- device = args.device;
- mountpoint = args.mountpoint;
-
- r = do_mount_options (options, device, mountpoint);
- if (r == -1)
- /* do_mount_options has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mount_options_args, (char *) &args);
-}
-
-static void mount_vfs_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mount_vfs_args args;
- char *options;
- char *vfstype;
- char *device;
- char *mountpoint;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mount_vfs_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mount_vfs");
- return;
- }
- options = args.options;
- vfstype = args.vfstype;
- device = args.device;
- mountpoint = args.mountpoint;
-
- r = do_mount_vfs (options, vfstype, device, mountpoint);
- if (r == -1)
- /* do_mount_vfs has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mount_vfs_args, (char *) &args);
-}
-
-static void debug_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_debug_args args;
- char *subcmd;
- char **extraargs;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_debug_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "debug");
- return;
- }
- subcmd = args.subcmd;
- extraargs = realloc (args.extraargs.extraargs_val,
- sizeof (char *) * (args.extraargs.extraargs_len+1));
- if (extraargs == NULL) {
- reply_with_perror ("realloc");
- goto done;
- }
- extraargs[args.extraargs.extraargs_len] = NULL;
- args.extraargs.extraargs_val = extraargs;
-
- r = do_debug (subcmd, extraargs);
- if (r == NULL)
- /* do_debug has already called reply_with_error */
- goto done;
-
- struct guestfs_debug_ret ret;
- ret.result = r;
- reply ((xdrproc_t) &xdr_guestfs_debug_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_debug_args, (char *) &args);
-}
-
-static void lvremove_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_lvremove_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_lvremove_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "lvremove");
- return;
- }
- device = args.device;
-
- r = do_lvremove (device);
- if (r == -1)
- /* do_lvremove has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_lvremove_args, (char *) &args);
-}
-
-static void vgremove_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_vgremove_args args;
- char *vgname;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_vgremove_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "vgremove");
- return;
- }
- vgname = args.vgname;
-
- r = do_vgremove (vgname);
- if (r == -1)
- /* do_vgremove has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_vgremove_args, (char *) &args);
-}
-
-static void pvremove_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_pvremove_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_pvremove_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "pvremove");
- return;
- }
- device = args.device;
-
- r = do_pvremove (device);
- if (r == -1)
- /* do_pvremove has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_pvremove_args, (char *) &args);
-}
-
-static void set_e2label_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_set_e2label_args args;
- char *device;
- char *label;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_set_e2label_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "set_e2label");
- return;
- }
- device = args.device;
- label = args.label;
-
- r = do_set_e2label (device, label);
- if (r == -1)
- /* do_set_e2label has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_set_e2label_args, (char *) &args);
-}
-
-static void get_e2label_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_get_e2label_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_get_e2label_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "get_e2label");
- return;
- }
- device = args.device;
-
- r = do_get_e2label (device);
- if (r == NULL)
- /* do_get_e2label has already called reply_with_error */
- goto done;
-
- struct guestfs_get_e2label_ret ret;
- ret.label = r;
- reply ((xdrproc_t) &xdr_guestfs_get_e2label_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_get_e2label_args, (char *) &args);
-}
-
-static void set_e2uuid_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_set_e2uuid_args args;
- char *device;
- char *uuid;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_set_e2uuid_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "set_e2uuid");
- return;
- }
- device = args.device;
- uuid = args.uuid;
-
- r = do_set_e2uuid (device, uuid);
- if (r == -1)
- /* do_set_e2uuid has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_set_e2uuid_args, (char *) &args);
-}
-
-static void get_e2uuid_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_get_e2uuid_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_get_e2uuid_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "get_e2uuid");
- return;
- }
- device = args.device;
-
- r = do_get_e2uuid (device);
- if (r == NULL)
- /* do_get_e2uuid has already called reply_with_error */
- goto done;
-
- struct guestfs_get_e2uuid_ret ret;
- ret.uuid = r;
- reply ((xdrproc_t) &xdr_guestfs_get_e2uuid_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_get_e2uuid_args, (char *) &args);
-}
-
-static void fsck_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_fsck_args args;
- char *fstype;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_fsck_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "fsck");
- return;
- }
- fstype = args.fstype;
- device = args.device;
-
- r = do_fsck (fstype, device);
- if (r == -1)
- /* do_fsck has already called reply_with_error */
- goto done;
-
- struct guestfs_fsck_ret ret;
- ret.status = r;
- reply ((xdrproc_t) &xdr_guestfs_fsck_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_fsck_args, (char *) &args);
-}
-
-static void zero_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_zero_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_zero_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "zero");
- return;
- }
- device = args.device;
-
- r = do_zero (device);
- if (r == -1)
- /* do_zero has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_zero_args, (char *) &args);
-}
-
-static void grub_install_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_grub_install_args args;
- char *root;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_grub_install_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "grub_install");
- return;
- }
- root = args.root;
- device = args.device;
-
- r = do_grub_install (root, device);
- if (r == -1)
- /* do_grub_install has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_grub_install_args, (char *) &args);
-}
-
-static void cp_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_cp_args args;
- char *src;
- char *dest;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_cp_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "cp");
- return;
- }
- src = args.src;
- dest = args.dest;
-
- r = do_cp (src, dest);
- if (r == -1)
- /* do_cp has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_cp_args, (char *) &args);
-}
-
-static void cp_a_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_cp_a_args args;
- char *src;
- char *dest;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_cp_a_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "cp_a");
- return;
- }
- src = args.src;
- dest = args.dest;
-
- r = do_cp_a (src, dest);
- if (r == -1)
- /* do_cp_a has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_cp_a_args, (char *) &args);
-}
-
-static void mv_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mv_args args;
- char *src;
- char *dest;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mv_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mv");
- return;
- }
- src = args.src;
- dest = args.dest;
-
- r = do_mv (src, dest);
- if (r == -1)
- /* do_mv has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mv_args, (char *) &args);
-}
-
-static void drop_caches_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_drop_caches_args args;
- int whattodrop;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_drop_caches_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "drop_caches");
- return;
- }
- whattodrop = args.whattodrop;
-
- r = do_drop_caches (whattodrop);
- if (r == -1)
- /* do_drop_caches has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_drop_caches_args, (char *) &args);
-}
-
-static void dmesg_stub (XDR *xdr_in)
-{
- char *r;
-
- r = do_dmesg ();
- if (r == NULL)
- /* do_dmesg has already called reply_with_error */
- goto done;
-
- struct guestfs_dmesg_ret ret;
- ret.kmsgs = r;
- reply ((xdrproc_t) &xdr_guestfs_dmesg_ret, (char *) &ret);
- free (r);
-done: ;
-}
-
-static void ping_daemon_stub (XDR *xdr_in)
-{
- int r;
-
- r = do_ping_daemon ();
- if (r == -1)
- /* do_ping_daemon has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done: ;
-}
-
-static void equal_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_equal_args args;
- char *file1;
- char *file2;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_equal_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "equal");
- return;
- }
- file1 = args.file1;
- file2 = args.file2;
-
- r = do_equal (file1, file2);
- if (r == -1)
- /* do_equal has already called reply_with_error */
- goto done;
-
- struct guestfs_equal_ret ret;
- ret.equality = r;
- reply ((xdrproc_t) &xdr_guestfs_equal_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_equal_args, (char *) &args);
-}
-
-static void strings_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_strings_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_strings_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "strings");
- return;
- }
- path = args.path;
-
- r = do_strings (path);
- if (r == NULL)
- /* do_strings has already called reply_with_error */
- goto done;
-
- struct guestfs_strings_ret ret;
- ret.stringsout.stringsout_len = count_strings (r);
- ret.stringsout.stringsout_val = r;
- reply ((xdrproc_t) &xdr_guestfs_strings_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_strings_args, (char *) &args);
-}
-
-static void strings_e_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_strings_e_args args;
- char *encoding;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_strings_e_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "strings_e");
- return;
- }
- encoding = args.encoding;
- path = args.path;
-
- r = do_strings_e (encoding, path);
- if (r == NULL)
- /* do_strings_e has already called reply_with_error */
- goto done;
-
- struct guestfs_strings_e_ret ret;
- ret.stringsout.stringsout_len = count_strings (r);
- ret.stringsout.stringsout_val = r;
- reply ((xdrproc_t) &xdr_guestfs_strings_e_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_strings_e_args, (char *) &args);
-}
-
-static void hexdump_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_hexdump_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_hexdump_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "hexdump");
- return;
- }
- path = args.path;
-
- r = do_hexdump (path);
- if (r == NULL)
- /* do_hexdump has already called reply_with_error */
- goto done;
-
- struct guestfs_hexdump_ret ret;
- ret.dump = r;
- reply ((xdrproc_t) &xdr_guestfs_hexdump_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_hexdump_args, (char *) &args);
-}
-
-static void zerofree_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_zerofree_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_zerofree_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "zerofree");
- return;
- }
- device = args.device;
-
- r = do_zerofree (device);
- if (r == -1)
- /* do_zerofree has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_zerofree_args, (char *) &args);
-}
-
-static void pvresize_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_pvresize_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_pvresize_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "pvresize");
- return;
- }
- device = args.device;
-
- r = do_pvresize (device);
- if (r == -1)
- /* do_pvresize has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_pvresize_args, (char *) &args);
-}
-
-static void sfdisk_N_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_sfdisk_N_args args;
- char *device;
- int partnum;
- int cyls;
- int heads;
- int sectors;
- char *line;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_sfdisk_N_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "sfdisk_N");
- return;
- }
- device = args.device;
- partnum = args.partnum;
- cyls = args.cyls;
- heads = args.heads;
- sectors = args.sectors;
- line = args.line;
-
- r = do_sfdisk_N (device, partnum, cyls, heads, sectors, line);
- if (r == -1)
- /* do_sfdisk_N has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_sfdisk_N_args, (char *) &args);
-}
-
-static void sfdisk_l_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_sfdisk_l_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_sfdisk_l_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "sfdisk_l");
- return;
- }
- device = args.device;
-
- r = do_sfdisk_l (device);
- if (r == NULL)
- /* do_sfdisk_l has already called reply_with_error */
- goto done;
-
- struct guestfs_sfdisk_l_ret ret;
- ret.partitions = r;
- reply ((xdrproc_t) &xdr_guestfs_sfdisk_l_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_sfdisk_l_args, (char *) &args);
-}
-
-static void sfdisk_kernel_geometry_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_sfdisk_kernel_geometry_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_sfdisk_kernel_geometry_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "sfdisk_kernel_geometry");
- return;
- }
- device = args.device;
-
- r = do_sfdisk_kernel_geometry (device);
- if (r == NULL)
- /* do_sfdisk_kernel_geometry has already called reply_with_error */
- goto done;
-
- struct guestfs_sfdisk_kernel_geometry_ret ret;
- ret.partitions = r;
- reply ((xdrproc_t) &xdr_guestfs_sfdisk_kernel_geometry_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_sfdisk_kernel_geometry_args, (char *) &args);
-}
-
-static void sfdisk_disk_geometry_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_sfdisk_disk_geometry_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_sfdisk_disk_geometry_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "sfdisk_disk_geometry");
- return;
- }
- device = args.device;
-
- r = do_sfdisk_disk_geometry (device);
- if (r == NULL)
- /* do_sfdisk_disk_geometry has already called reply_with_error */
- goto done;
-
- struct guestfs_sfdisk_disk_geometry_ret ret;
- ret.partitions = r;
- reply ((xdrproc_t) &xdr_guestfs_sfdisk_disk_geometry_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_sfdisk_disk_geometry_args, (char *) &args);
-}
-
-static void vg_activate_all_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_vg_activate_all_args args;
- int activate;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_vg_activate_all_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "vg_activate_all");
- return;
- }
- activate = args.activate;
-
- r = do_vg_activate_all (activate);
- if (r == -1)
- /* do_vg_activate_all has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_vg_activate_all_args, (char *) &args);
-}
-
-static void vg_activate_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_vg_activate_args args;
- int activate;
- char **volgroups;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_vg_activate_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "vg_activate");
- return;
- }
- activate = args.activate;
- volgroups = realloc (args.volgroups.volgroups_val,
- sizeof (char *) * (args.volgroups.volgroups_len+1));
- if (volgroups == NULL) {
- reply_with_perror ("realloc");
- goto done;
- }
- volgroups[args.volgroups.volgroups_len] = NULL;
- args.volgroups.volgroups_val = volgroups;
-
- r = do_vg_activate (activate, volgroups);
- if (r == -1)
- /* do_vg_activate has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_vg_activate_args, (char *) &args);
-}
-
-static void lvresize_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_lvresize_args args;
- char *device;
- int mbytes;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_lvresize_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "lvresize");
- return;
- }
- device = args.device;
- mbytes = args.mbytes;
-
- r = do_lvresize (device, mbytes);
- if (r == -1)
- /* do_lvresize has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_lvresize_args, (char *) &args);
-}
-
-static void resize2fs_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_resize2fs_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_resize2fs_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "resize2fs");
- return;
- }
- device = args.device;
-
- r = do_resize2fs (device);
- if (r == -1)
- /* do_resize2fs has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_resize2fs_args, (char *) &args);
-}
-
-static void find_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_find_args args;
- char *directory;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_find_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "find");
- return;
- }
- directory = args.directory;
-
- r = do_find (directory);
- if (r == NULL)
- /* do_find has already called reply_with_error */
- goto done;
-
- struct guestfs_find_ret ret;
- ret.names.names_len = count_strings (r);
- ret.names.names_val = r;
- reply ((xdrproc_t) &xdr_guestfs_find_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_find_args, (char *) &args);
-}
-
-static void e2fsck_f_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_e2fsck_f_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_e2fsck_f_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "e2fsck_f");
- return;
- }
- device = args.device;
-
- r = do_e2fsck_f (device);
- if (r == -1)
- /* do_e2fsck_f has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_e2fsck_f_args, (char *) &args);
-}
-
-static void sleep_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_sleep_args args;
- int secs;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_sleep_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "sleep");
- return;
- }
- secs = args.secs;
-
- r = do_sleep (secs);
- if (r == -1)
- /* do_sleep has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_sleep_args, (char *) &args);
-}
-
-static void ntfs_3g_probe_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_ntfs_3g_probe_args args;
- int rw;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_ntfs_3g_probe_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "ntfs_3g_probe");
- return;
- }
- rw = args.rw;
- device = args.device;
-
- r = do_ntfs_3g_probe (rw, device);
- if (r == -1)
- /* do_ntfs_3g_probe has already called reply_with_error */
- goto done;
-
- struct guestfs_ntfs_3g_probe_ret ret;
- ret.status = r;
- reply ((xdrproc_t) &xdr_guestfs_ntfs_3g_probe_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_ntfs_3g_probe_args, (char *) &args);
-}
-
-static void sh_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_sh_args args;
- char *command;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_sh_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "sh");
- return;
- }
- command = args.command;
-
- r = do_sh (command);
- if (r == NULL)
- /* do_sh has already called reply_with_error */
- goto done;
-
- struct guestfs_sh_ret ret;
- ret.output = r;
- reply ((xdrproc_t) &xdr_guestfs_sh_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_sh_args, (char *) &args);
-}
-
-static void sh_lines_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_sh_lines_args args;
- char *command;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_sh_lines_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "sh_lines");
- return;
- }
- command = args.command;
-
- r = do_sh_lines (command);
- if (r == NULL)
- /* do_sh_lines has already called reply_with_error */
- goto done;
-
- struct guestfs_sh_lines_ret ret;
- ret.lines.lines_len = count_strings (r);
- ret.lines.lines_val = r;
- reply ((xdrproc_t) &xdr_guestfs_sh_lines_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_sh_lines_args, (char *) &args);
-}
-
-static void glob_expand_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_glob_expand_args args;
- char *pattern;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_glob_expand_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "glob_expand");
- return;
- }
- pattern = args.pattern;
-
- r = do_glob_expand (pattern);
- if (r == NULL)
- /* do_glob_expand has already called reply_with_error */
- goto done;
-
- struct guestfs_glob_expand_ret ret;
- ret.paths.paths_len = count_strings (r);
- ret.paths.paths_val = r;
- reply ((xdrproc_t) &xdr_guestfs_glob_expand_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_glob_expand_args, (char *) &args);
-}
-
-static void scrub_device_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_scrub_device_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_scrub_device_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "scrub_device");
- return;
- }
- device = args.device;
-
- r = do_scrub_device (device);
- if (r == -1)
- /* do_scrub_device has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_scrub_device_args, (char *) &args);
-}
-
-static void scrub_file_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_scrub_file_args args;
- char *file;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_scrub_file_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "scrub_file");
- return;
- }
- file = args.file;
-
- r = do_scrub_file (file);
- if (r == -1)
- /* do_scrub_file has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_scrub_file_args, (char *) &args);
-}
-
-static void scrub_freespace_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_scrub_freespace_args args;
- char *dir;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_scrub_freespace_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "scrub_freespace");
- return;
- }
- dir = args.dir;
-
- r = do_scrub_freespace (dir);
- if (r == -1)
- /* do_scrub_freespace has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_scrub_freespace_args, (char *) &args);
-}
-
-static void mkdtemp_stub (XDR *xdr_in)
-{
- char *r;
- struct guestfs_mkdtemp_args args;
- char *template;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mkdtemp_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mkdtemp");
- return;
- }
- template = args.template;
-
- r = do_mkdtemp (template);
- if (r == NULL)
- /* do_mkdtemp has already called reply_with_error */
- goto done;
-
- struct guestfs_mkdtemp_ret ret;
- ret.dir = r;
- reply ((xdrproc_t) &xdr_guestfs_mkdtemp_ret, (char *) &ret);
- free (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mkdtemp_args, (char *) &args);
-}
-
-static void wc_l_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_wc_l_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_wc_l_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "wc_l");
- return;
- }
- path = args.path;
-
- r = do_wc_l (path);
- if (r == -1)
- /* do_wc_l has already called reply_with_error */
- goto done;
-
- struct guestfs_wc_l_ret ret;
- ret.lines = r;
- reply ((xdrproc_t) &xdr_guestfs_wc_l_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_wc_l_args, (char *) &args);
-}
-
-static void wc_w_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_wc_w_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_wc_w_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "wc_w");
- return;
- }
- path = args.path;
-
- r = do_wc_w (path);
- if (r == -1)
- /* do_wc_w has already called reply_with_error */
- goto done;
-
- struct guestfs_wc_w_ret ret;
- ret.words = r;
- reply ((xdrproc_t) &xdr_guestfs_wc_w_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_wc_w_args, (char *) &args);
-}
-
-static void wc_c_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_wc_c_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_wc_c_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "wc_c");
- return;
- }
- path = args.path;
-
- r = do_wc_c (path);
- if (r == -1)
- /* do_wc_c has already called reply_with_error */
- goto done;
-
- struct guestfs_wc_c_ret ret;
- ret.chars = r;
- reply ((xdrproc_t) &xdr_guestfs_wc_c_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_wc_c_args, (char *) &args);
-}
-
-static void head_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_head_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_head_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "head");
- return;
- }
- path = args.path;
-
- r = do_head (path);
- if (r == NULL)
- /* do_head has already called reply_with_error */
- goto done;
-
- struct guestfs_head_ret ret;
- ret.lines.lines_len = count_strings (r);
- ret.lines.lines_val = r;
- reply ((xdrproc_t) &xdr_guestfs_head_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_head_args, (char *) &args);
-}
-
-static void head_n_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_head_n_args args;
- int nrlines;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_head_n_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "head_n");
- return;
- }
- nrlines = args.nrlines;
- path = args.path;
-
- r = do_head_n (nrlines, path);
- if (r == NULL)
- /* do_head_n has already called reply_with_error */
- goto done;
-
- struct guestfs_head_n_ret ret;
- ret.lines.lines_len = count_strings (r);
- ret.lines.lines_val = r;
- reply ((xdrproc_t) &xdr_guestfs_head_n_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_head_n_args, (char *) &args);
-}
-
-static void tail_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_tail_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_tail_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "tail");
- return;
- }
- path = args.path;
-
- r = do_tail (path);
- if (r == NULL)
- /* do_tail has already called reply_with_error */
- goto done;
-
- struct guestfs_tail_ret ret;
- ret.lines.lines_len = count_strings (r);
- ret.lines.lines_val = r;
- reply ((xdrproc_t) &xdr_guestfs_tail_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_tail_args, (char *) &args);
-}
-
-static void tail_n_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_tail_n_args args;
- int nrlines;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_tail_n_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "tail_n");
- return;
- }
- nrlines = args.nrlines;
- path = args.path;
-
- r = do_tail_n (nrlines, path);
- if (r == NULL)
- /* do_tail_n has already called reply_with_error */
- goto done;
-
- struct guestfs_tail_n_ret ret;
- ret.lines.lines_len = count_strings (r);
- ret.lines.lines_val = r;
- reply ((xdrproc_t) &xdr_guestfs_tail_n_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_tail_n_args, (char *) &args);
-}
-
-static void df_stub (XDR *xdr_in)
-{
- char *r;
-
- r = do_df ();
- if (r == NULL)
- /* do_df has already called reply_with_error */
- goto done;
-
- struct guestfs_df_ret ret;
- ret.output = r;
- reply ((xdrproc_t) &xdr_guestfs_df_ret, (char *) &ret);
- free (r);
-done: ;
-}
-
-static void df_h_stub (XDR *xdr_in)
-{
- char *r;
-
- r = do_df_h ();
- if (r == NULL)
- /* do_df_h has already called reply_with_error */
- goto done;
-
- struct guestfs_df_h_ret ret;
- ret.output = r;
- reply ((xdrproc_t) &xdr_guestfs_df_h_ret, (char *) &ret);
- free (r);
-done: ;
-}
-
-static void du_stub (XDR *xdr_in)
-{
- int64_t r;
- struct guestfs_du_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_du_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "du");
- return;
- }
- path = args.path;
-
- r = do_du (path);
- if (r == -1)
- /* do_du has already called reply_with_error */
- goto done;
-
- struct guestfs_du_ret ret;
- ret.sizekb = r;
- reply ((xdrproc_t) &xdr_guestfs_du_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_du_args, (char *) &args);
-}
-
-static void initrd_list_stub (XDR *xdr_in)
-{
- char **r;
- struct guestfs_initrd_list_args args;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_initrd_list_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "initrd_list");
- return;
- }
- path = args.path;
-
- r = do_initrd_list (path);
- if (r == NULL)
- /* do_initrd_list has already called reply_with_error */
- goto done;
-
- struct guestfs_initrd_list_ret ret;
- ret.filenames.filenames_len = count_strings (r);
- ret.filenames.filenames_val = r;
- reply ((xdrproc_t) &xdr_guestfs_initrd_list_ret, (char *) &ret);
- free_strings (r);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_initrd_list_args, (char *) &args);
-}
-
-static void mount_loop_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mount_loop_args args;
- char *file;
- char *mountpoint;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mount_loop_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mount_loop");
- return;
- }
- file = args.file;
- mountpoint = args.mountpoint;
-
- r = do_mount_loop (file, mountpoint);
- if (r == -1)
- /* do_mount_loop has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mount_loop_args, (char *) &args);
-}
-
-static void mkswap_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mkswap_args args;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mkswap_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mkswap");
- return;
- }
- device = args.device;
-
- r = do_mkswap (device);
- if (r == -1)
- /* do_mkswap has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mkswap_args, (char *) &args);
-}
-
-static void mkswap_L_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mkswap_L_args args;
- char *label;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mkswap_L_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mkswap_L");
- return;
- }
- label = args.label;
- device = args.device;
-
- r = do_mkswap_L (label, device);
- if (r == -1)
- /* do_mkswap_L has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mkswap_L_args, (char *) &args);
-}
-
-static void mkswap_U_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mkswap_U_args args;
- char *uuid;
- char *device;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mkswap_U_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mkswap_U");
- return;
- }
- uuid = args.uuid;
- device = args.device;
-
- r = do_mkswap_U (uuid, device);
- if (r == -1)
- /* do_mkswap_U has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mkswap_U_args, (char *) &args);
-}
-
-static void mknod_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mknod_args args;
- int mode;
- int devmajor;
- int devminor;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mknod_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mknod");
- return;
- }
- mode = args.mode;
- devmajor = args.devmajor;
- devminor = args.devminor;
- path = args.path;
-
- r = do_mknod (mode, devmajor, devminor, path);
- if (r == -1)
- /* do_mknod has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mknod_args, (char *) &args);
-}
-
-static void mkfifo_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mkfifo_args args;
- int mode;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mkfifo_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mkfifo");
- return;
- }
- mode = args.mode;
- path = args.path;
-
- r = do_mkfifo (mode, path);
- if (r == -1)
- /* do_mkfifo has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mkfifo_args, (char *) &args);
-}
-
-static void mknod_b_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mknod_b_args args;
- int mode;
- int devmajor;
- int devminor;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mknod_b_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mknod_b");
- return;
- }
- mode = args.mode;
- devmajor = args.devmajor;
- devminor = args.devminor;
- path = args.path;
-
- r = do_mknod_b (mode, devmajor, devminor, path);
- if (r == -1)
- /* do_mknod_b has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mknod_b_args, (char *) &args);
-}
-
-static void mknod_c_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_mknod_c_args args;
- int mode;
- int devmajor;
- int devminor;
- char *path;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_mknod_c_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "mknod_c");
- return;
- }
- mode = args.mode;
- devmajor = args.devmajor;
- devminor = args.devminor;
- path = args.path;
-
- r = do_mknod_c (mode, devmajor, devminor, path);
- if (r == -1)
- /* do_mknod_c has already called reply_with_error */
- goto done;
-
- reply (NULL, NULL);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_mknod_c_args, (char *) &args);
-}
-
-static void umask_stub (XDR *xdr_in)
-{
- int r;
- struct guestfs_umask_args args;
- int mask;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_umask_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "umask");
- return;
- }
- mask = args.mask;
-
- r = do_umask (mask);
- if (r == -1)
- /* do_umask has already called reply_with_error */
- goto done;
-
- struct guestfs_umask_ret ret;
- ret.oldmask = r;
- reply ((xdrproc_t) &xdr_guestfs_umask_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_umask_args, (char *) &args);
-}
-
-static void readdir_stub (XDR *xdr_in)
-{
- guestfs_int_dirent_list *r;
- struct guestfs_readdir_args args;
- char *dir;
-
- memset (&args, 0, sizeof args);
-
- if (!xdr_guestfs_readdir_args (xdr_in, &args)) {
- reply_with_error ("%s: daemon failed to decode procedure arguments", "readdir");
- return;
- }
- dir = args.dir;
-
- r = do_readdir (dir);
- if (r == NULL)
- /* do_readdir has already called reply_with_error */
- goto done;
-
- struct guestfs_readdir_ret ret;
- ret.entries = *r;
- reply ((xdrproc_t) xdr_guestfs_readdir_ret, (char *) &ret);
- xdr_free ((xdrproc_t) xdr_guestfs_readdir_ret, (char *) &ret);
-done:
- xdr_free ((xdrproc_t) xdr_guestfs_readdir_args, (char *) &args);
-}
-
-void dispatch_incoming_message (XDR *xdr_in)
-{
- switch (proc_nr) {
- case GUESTFS_PROC_MOUNT:
- mount_stub (xdr_in);
- break;
- case GUESTFS_PROC_SYNC:
- sync_stub (xdr_in);
- break;
- case GUESTFS_PROC_TOUCH:
- touch_stub (xdr_in);
- break;
- case GUESTFS_PROC_CAT:
- cat_stub (xdr_in);
- break;
- case GUESTFS_PROC_LL:
- ll_stub (xdr_in);
- break;
- case GUESTFS_PROC_LS:
- ls_stub (xdr_in);
- break;
- case GUESTFS_PROC_LIST_DEVICES:
- list_devices_stub (xdr_in);
- break;
- case GUESTFS_PROC_LIST_PARTITIONS:
- list_partitions_stub (xdr_in);
- break;
- case GUESTFS_PROC_PVS:
- pvs_stub (xdr_in);
- break;
- case GUESTFS_PROC_VGS:
- vgs_stub (xdr_in);
- break;
- case GUESTFS_PROC_LVS:
- lvs_stub (xdr_in);
- break;
- case GUESTFS_PROC_PVS_FULL:
- pvs_full_stub (xdr_in);
- break;
- case GUESTFS_PROC_VGS_FULL:
- vgs_full_stub (xdr_in);
- break;
- case GUESTFS_PROC_LVS_FULL:
- lvs_full_stub (xdr_in);
- break;
- case GUESTFS_PROC_READ_LINES:
- read_lines_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_INIT:
- aug_init_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_CLOSE:
- aug_close_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_DEFVAR:
- aug_defvar_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_DEFNODE:
- aug_defnode_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_GET:
- aug_get_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_SET:
- aug_set_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_INSERT:
- aug_insert_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_RM:
- aug_rm_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_MV:
- aug_mv_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_MATCH:
- aug_match_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_SAVE:
- aug_save_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_LOAD:
- aug_load_stub (xdr_in);
- break;
- case GUESTFS_PROC_AUG_LS:
- aug_ls_stub (xdr_in);
- break;
- case GUESTFS_PROC_RM:
- rm_stub (xdr_in);
- break;
- case GUESTFS_PROC_RMDIR:
- rmdir_stub (xdr_in);
- break;
- case GUESTFS_PROC_RM_RF:
- rm_rf_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKDIR:
- mkdir_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKDIR_P:
- mkdir_p_stub (xdr_in);
- break;
- case GUESTFS_PROC_CHMOD:
- chmod_stub (xdr_in);
- break;
- case GUESTFS_PROC_CHOWN:
- chown_stub (xdr_in);
- break;
- case GUESTFS_PROC_EXISTS:
- exists_stub (xdr_in);
- break;
- case GUESTFS_PROC_IS_FILE:
- is_file_stub (xdr_in);
- break;
- case GUESTFS_PROC_IS_DIR:
- is_dir_stub (xdr_in);
- break;
- case GUESTFS_PROC_PVCREATE:
- pvcreate_stub (xdr_in);
- break;
- case GUESTFS_PROC_VGCREATE:
- vgcreate_stub (xdr_in);
- break;
- case GUESTFS_PROC_LVCREATE:
- lvcreate_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKFS:
- mkfs_stub (xdr_in);
- break;
- case GUESTFS_PROC_SFDISK:
- sfdisk_stub (xdr_in);
- break;
- case GUESTFS_PROC_WRITE_FILE:
- write_file_stub (xdr_in);
- break;
- case GUESTFS_PROC_UMOUNT:
- umount_stub (xdr_in);
- break;
- case GUESTFS_PROC_MOUNTS:
- mounts_stub (xdr_in);
- break;
- case GUESTFS_PROC_UMOUNT_ALL:
- umount_all_stub (xdr_in);
- break;
- case GUESTFS_PROC_LVM_REMOVE_ALL:
- lvm_remove_all_stub (xdr_in);
- break;
- case GUESTFS_PROC_FILE:
- file_stub (xdr_in);
- break;
- case GUESTFS_PROC_COMMAND:
- command_stub (xdr_in);
- break;
- case GUESTFS_PROC_COMMAND_LINES:
- command_lines_stub (xdr_in);
- break;
- case GUESTFS_PROC_STAT:
- stat_stub (xdr_in);
- break;
- case GUESTFS_PROC_LSTAT:
- lstat_stub (xdr_in);
- break;
- case GUESTFS_PROC_STATVFS:
- statvfs_stub (xdr_in);
- break;
- case GUESTFS_PROC_TUNE2FS_L:
- tune2fs_l_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_SETRO:
- blockdev_setro_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_SETRW:
- blockdev_setrw_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_GETRO:
- blockdev_getro_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_GETSS:
- blockdev_getss_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_GETBSZ:
- blockdev_getbsz_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_SETBSZ:
- blockdev_setbsz_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_GETSZ:
- blockdev_getsz_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_GETSIZE64:
- blockdev_getsize64_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_FLUSHBUFS:
- blockdev_flushbufs_stub (xdr_in);
- break;
- case GUESTFS_PROC_BLOCKDEV_REREADPT:
- blockdev_rereadpt_stub (xdr_in);
- break;
- case GUESTFS_PROC_UPLOAD:
- upload_stub (xdr_in);
- break;
- case GUESTFS_PROC_DOWNLOAD:
- download_stub (xdr_in);
- break;
- case GUESTFS_PROC_CHECKSUM:
- checksum_stub (xdr_in);
- break;
- case GUESTFS_PROC_TAR_IN:
- tar_in_stub (xdr_in);
- break;
- case GUESTFS_PROC_TAR_OUT:
- tar_out_stub (xdr_in);
- break;
- case GUESTFS_PROC_TGZ_IN:
- tgz_in_stub (xdr_in);
- break;
- case GUESTFS_PROC_TGZ_OUT:
- tgz_out_stub (xdr_in);
- break;
- case GUESTFS_PROC_MOUNT_RO:
- mount_ro_stub (xdr_in);
- break;
- case GUESTFS_PROC_MOUNT_OPTIONS:
- mount_options_stub (xdr_in);
- break;
- case GUESTFS_PROC_MOUNT_VFS:
- mount_vfs_stub (xdr_in);
- break;
- case GUESTFS_PROC_DEBUG:
- debug_stub (xdr_in);
- break;
- case GUESTFS_PROC_LVREMOVE:
- lvremove_stub (xdr_in);
- break;
- case GUESTFS_PROC_VGREMOVE:
- vgremove_stub (xdr_in);
- break;
- case GUESTFS_PROC_PVREMOVE:
- pvremove_stub (xdr_in);
- break;
- case GUESTFS_PROC_SET_E2LABEL:
- set_e2label_stub (xdr_in);
- break;
- case GUESTFS_PROC_GET_E2LABEL:
- get_e2label_stub (xdr_in);
- break;
- case GUESTFS_PROC_SET_E2UUID:
- set_e2uuid_stub (xdr_in);
- break;
- case GUESTFS_PROC_GET_E2UUID:
- get_e2uuid_stub (xdr_in);
- break;
- case GUESTFS_PROC_FSCK:
- fsck_stub (xdr_in);
- break;
- case GUESTFS_PROC_ZERO:
- zero_stub (xdr_in);
- break;
- case GUESTFS_PROC_GRUB_INSTALL:
- grub_install_stub (xdr_in);
- break;
- case GUESTFS_PROC_CP:
- cp_stub (xdr_in);
- break;
- case GUESTFS_PROC_CP_A:
- cp_a_stub (xdr_in);
- break;
- case GUESTFS_PROC_MV:
- mv_stub (xdr_in);
- break;
- case GUESTFS_PROC_DROP_CACHES:
- drop_caches_stub (xdr_in);
- break;
- case GUESTFS_PROC_DMESG:
- dmesg_stub (xdr_in);
- break;
- case GUESTFS_PROC_PING_DAEMON:
- ping_daemon_stub (xdr_in);
- break;
- case GUESTFS_PROC_EQUAL:
- equal_stub (xdr_in);
- break;
- case GUESTFS_PROC_STRINGS:
- strings_stub (xdr_in);
- break;
- case GUESTFS_PROC_STRINGS_E:
- strings_e_stub (xdr_in);
- break;
- case GUESTFS_PROC_HEXDUMP:
- hexdump_stub (xdr_in);
- break;
- case GUESTFS_PROC_ZEROFREE:
- zerofree_stub (xdr_in);
- break;
- case GUESTFS_PROC_PVRESIZE:
- pvresize_stub (xdr_in);
- break;
- case GUESTFS_PROC_SFDISK_N:
- sfdisk_N_stub (xdr_in);
- break;
- case GUESTFS_PROC_SFDISK_L:
- sfdisk_l_stub (xdr_in);
- break;
- case GUESTFS_PROC_SFDISK_KERNEL_GEOMETRY:
- sfdisk_kernel_geometry_stub (xdr_in);
- break;
- case GUESTFS_PROC_SFDISK_DISK_GEOMETRY:
- sfdisk_disk_geometry_stub (xdr_in);
- break;
- case GUESTFS_PROC_VG_ACTIVATE_ALL:
- vg_activate_all_stub (xdr_in);
- break;
- case GUESTFS_PROC_VG_ACTIVATE:
- vg_activate_stub (xdr_in);
- break;
- case GUESTFS_PROC_LVRESIZE:
- lvresize_stub (xdr_in);
- break;
- case GUESTFS_PROC_RESIZE2FS:
- resize2fs_stub (xdr_in);
- break;
- case GUESTFS_PROC_FIND:
- find_stub (xdr_in);
- break;
- case GUESTFS_PROC_E2FSCK_F:
- e2fsck_f_stub (xdr_in);
- break;
- case GUESTFS_PROC_SLEEP:
- sleep_stub (xdr_in);
- break;
- case GUESTFS_PROC_NTFS_3G_PROBE:
- ntfs_3g_probe_stub (xdr_in);
- break;
- case GUESTFS_PROC_SH:
- sh_stub (xdr_in);
- break;
- case GUESTFS_PROC_SH_LINES:
- sh_lines_stub (xdr_in);
- break;
- case GUESTFS_PROC_GLOB_EXPAND:
- glob_expand_stub (xdr_in);
- break;
- case GUESTFS_PROC_SCRUB_DEVICE:
- scrub_device_stub (xdr_in);
- break;
- case GUESTFS_PROC_SCRUB_FILE:
- scrub_file_stub (xdr_in);
- break;
- case GUESTFS_PROC_SCRUB_FREESPACE:
- scrub_freespace_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKDTEMP:
- mkdtemp_stub (xdr_in);
- break;
- case GUESTFS_PROC_WC_L:
- wc_l_stub (xdr_in);
- break;
- case GUESTFS_PROC_WC_W:
- wc_w_stub (xdr_in);
- break;
- case GUESTFS_PROC_WC_C:
- wc_c_stub (xdr_in);
- break;
- case GUESTFS_PROC_HEAD:
- head_stub (xdr_in);
- break;
- case GUESTFS_PROC_HEAD_N:
- head_n_stub (xdr_in);
- break;
- case GUESTFS_PROC_TAIL:
- tail_stub (xdr_in);
- break;
- case GUESTFS_PROC_TAIL_N:
- tail_n_stub (xdr_in);
- break;
- case GUESTFS_PROC_DF:
- df_stub (xdr_in);
- break;
- case GUESTFS_PROC_DF_H:
- df_h_stub (xdr_in);
- break;
- case GUESTFS_PROC_DU:
- du_stub (xdr_in);
- break;
- case GUESTFS_PROC_INITRD_LIST:
- initrd_list_stub (xdr_in);
- break;
- case GUESTFS_PROC_MOUNT_LOOP:
- mount_loop_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKSWAP:
- mkswap_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKSWAP_L:
- mkswap_L_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKSWAP_U:
- mkswap_U_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKNOD:
- mknod_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKFIFO:
- mkfifo_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKNOD_B:
- mknod_b_stub (xdr_in);
- break;
- case GUESTFS_PROC_MKNOD_C:
- mknod_c_stub (xdr_in);
- break;
- case GUESTFS_PROC_UMASK:
- umask_stub (xdr_in);
- break;
- case GUESTFS_PROC_READDIR:
- readdir_stub (xdr_in);
- break;
- default:
- reply_with_error ("dispatch_incoming_message: unknown procedure number %d, set LIBGUESTFS_PATH to point to the matching libguestfs appliance directory", proc_nr);
- }
-}
-
-static const char *lvm_pv_cols = "pv_name,pv_uuid,pv_fmt,pv_size,dev_size,pv_free,pv_used,pv_attr,pv_pe_count,pv_pe_alloc_count,pv_tags,pe_start,pv_mda_count,pv_mda_free";
-
-static int lvm_tokenize_pv (char *str, struct guestfs_lvm_int_pv *r)
-{
- char *tok, *p, *next;
- int i, j;
-
- if (!str) {
- fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
- return -1;
- }
- if (!*str || isspace (*str)) {
- fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
- return -1;
- }
- tok = str;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_name");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->pv_name = strdup (tok);
- if (r->pv_name == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_uuid");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- for (i = j = 0; i < 32; ++j) {
- if (tok[j] == '\0') {
- fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
- return -1;
- } else if (tok[j] != '-')
- r->pv_uuid[i++] = tok[j];
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_fmt");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->pv_fmt = strdup (tok);
- if (r->pv_fmt == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_size");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->pv_size) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_size");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "dev_size");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->dev_size) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "dev_size");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_free");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->pv_free) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_free");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_used");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->pv_used) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_used");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_attr");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->pv_attr = strdup (tok);
- if (r->pv_attr == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->pv_pe_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_alloc_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->pv_pe_alloc_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_alloc_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_tags");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->pv_tags = strdup (tok);
- if (r->pv_tags == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pe_start");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->pe_start) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pe_start");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->pv_mda_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_mda_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_free");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->pv_mda_free) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_mda_free");
- return -1;
- }
- tok = next;
- if (tok != NULL) {
- fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
- return -1;
- }
- return 0;
-}
-
-guestfs_lvm_int_pv_list *
-parse_command_line_pvs (void)
-{
- char *out, *err;
- char *p, *pend;
- int r, i;
- guestfs_lvm_int_pv_list *ret;
- void *newp;
-
- ret = malloc (sizeof *ret);
- if (!ret) {
- reply_with_perror ("malloc");
- return NULL;
- }
-
- ret->guestfs_lvm_int_pv_list_len = 0;
- ret->guestfs_lvm_int_pv_list_val = NULL;
-
- r = command (&out, &err,
- "/sbin/lvm", "pvs",
- "-o", lvm_pv_cols, "--unbuffered", "--noheadings",
- "--nosuffix", "--separator", ",", "--units", "b", NULL);
- if (r == -1) {
- reply_with_error ("%s", err);
- free (out);
- free (err);
- free (ret);
- return NULL;
- }
-
- free (err);
-
- /* Tokenize each line of the output. */
- p = out;
- i = 0;
- while (p) {
- pend = strchr (p, '\n'); /* Get the next line of output. */
- if (pend) {
- *pend = '\0';
- pend++;
- }
-
- while (*p && isspace (*p)) /* Skip any leading whitespace. */
- p++;
-
- if (!*p) { /* Empty line? Skip it. */
- p = pend;
- continue;
- }
-
- /* Allocate some space to store this next entry. */
- newp = realloc (ret->guestfs_lvm_int_pv_list_val,
- sizeof (guestfs_lvm_int_pv) * (i+1));
- if (newp == NULL) {
- reply_with_perror ("realloc");
- free (ret->guestfs_lvm_int_pv_list_val);
- free (ret);
- free (out);
- return NULL;
- }
- ret->guestfs_lvm_int_pv_list_val = newp;
-
- /* Tokenize the next entry. */
- r = lvm_tokenize_pv (p, &ret->guestfs_lvm_int_pv_list_val[i]);
- if (r == -1) {
- reply_with_error ("failed to parse output of 'pvs' command");
- free (ret->guestfs_lvm_int_pv_list_val);
- free (ret);
- free (out);
- return NULL;
- }
-
- ++i;
- p = pend;
- }
-
- ret->guestfs_lvm_int_pv_list_len = i;
-
- free (out);
- return ret;
-}
-static const char *lvm_vg_cols = "vg_name,vg_uuid,vg_fmt,vg_attr,vg_size,vg_free,vg_sysid,vg_extent_size,vg_extent_count,vg_free_count,max_lv,max_pv,pv_count,lv_count,snap_count,vg_seqno,vg_tags,vg_mda_count,vg_mda_free";
-
-static int lvm_tokenize_vg (char *str, struct guestfs_lvm_int_vg *r)
-{
- char *tok, *p, *next;
- int i, j;
-
- if (!str) {
- fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
- return -1;
- }
- if (!*str || isspace (*str)) {
- fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
- return -1;
- }
- tok = str;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_name");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->vg_name = strdup (tok);
- if (r->vg_name == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_uuid");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- for (i = j = 0; i < 32; ++j) {
- if (tok[j] == '\0') {
- fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
- return -1;
- } else if (tok[j] != '-')
- r->vg_uuid[i++] = tok[j];
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_fmt");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->vg_fmt = strdup (tok);
- if (r->vg_fmt == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_attr");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->vg_attr = strdup (tok);
- if (r->vg_attr == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_size");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->vg_size) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_size");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->vg_free) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_free");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_sysid");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->vg_sysid = strdup (tok);
- if (r->vg_sysid == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_size");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->vg_extent_size) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_extent_size");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->vg_extent_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_extent_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->vg_free_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_free_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_lv");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->max_lv) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_lv");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_pv");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->max_pv) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_pv");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->pv_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->lv_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->snap_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "snap_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_seqno");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->vg_seqno) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_seqno");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_tags");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->vg_tags = strdup (tok);
- if (r->vg_tags == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->vg_mda_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_mda_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_free");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->vg_mda_free) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_mda_free");
- return -1;
- }
- tok = next;
- if (tok != NULL) {
- fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
- return -1;
- }
- return 0;
-}
-
-guestfs_lvm_int_vg_list *
-parse_command_line_vgs (void)
-{
- char *out, *err;
- char *p, *pend;
- int r, i;
- guestfs_lvm_int_vg_list *ret;
- void *newp;
-
- ret = malloc (sizeof *ret);
- if (!ret) {
- reply_with_perror ("malloc");
- return NULL;
- }
-
- ret->guestfs_lvm_int_vg_list_len = 0;
- ret->guestfs_lvm_int_vg_list_val = NULL;
-
- r = command (&out, &err,
- "/sbin/lvm", "vgs",
- "-o", lvm_vg_cols, "--unbuffered", "--noheadings",
- "--nosuffix", "--separator", ",", "--units", "b", NULL);
- if (r == -1) {
- reply_with_error ("%s", err);
- free (out);
- free (err);
- free (ret);
- return NULL;
- }
-
- free (err);
-
- /* Tokenize each line of the output. */
- p = out;
- i = 0;
- while (p) {
- pend = strchr (p, '\n'); /* Get the next line of output. */
- if (pend) {
- *pend = '\0';
- pend++;
- }
-
- while (*p && isspace (*p)) /* Skip any leading whitespace. */
- p++;
-
- if (!*p) { /* Empty line? Skip it. */
- p = pend;
- continue;
- }
-
- /* Allocate some space to store this next entry. */
- newp = realloc (ret->guestfs_lvm_int_vg_list_val,
- sizeof (guestfs_lvm_int_vg) * (i+1));
- if (newp == NULL) {
- reply_with_perror ("realloc");
- free (ret->guestfs_lvm_int_vg_list_val);
- free (ret);
- free (out);
- return NULL;
- }
- ret->guestfs_lvm_int_vg_list_val = newp;
-
- /* Tokenize the next entry. */
- r = lvm_tokenize_vg (p, &ret->guestfs_lvm_int_vg_list_val[i]);
- if (r == -1) {
- reply_with_error ("failed to parse output of 'vgs' command");
- free (ret->guestfs_lvm_int_vg_list_val);
- free (ret);
- free (out);
- return NULL;
- }
-
- ++i;
- p = pend;
- }
-
- ret->guestfs_lvm_int_vg_list_len = i;
-
- free (out);
- return ret;
-}
-static const char *lvm_lv_cols = "lv_name,lv_uuid,lv_attr,lv_major,lv_minor,lv_kernel_major,lv_kernel_minor,lv_size,seg_count,origin,snap_percent,copy_percent,move_pv,lv_tags,mirror_log,modules";
-
-static int lvm_tokenize_lv (char *str, struct guestfs_lvm_int_lv *r)
-{
- char *tok, *p, *next;
- int i, j;
-
- if (!str) {
- fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
- return -1;
- }
- if (!*str || isspace (*str)) {
- fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
- return -1;
- }
- tok = str;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_name");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->lv_name = strdup (tok);
- if (r->lv_name == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_uuid");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- for (i = j = 0; i < 32; ++j) {
- if (tok[j] == '\0') {
- fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
- return -1;
- } else if (tok[j] != '-')
- r->lv_uuid[i++] = tok[j];
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_attr");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->lv_attr = strdup (tok);
- if (r->lv_attr == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_major");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->lv_major) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_major");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_minor");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->lv_minor) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_minor");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_major");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->lv_kernel_major) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_major");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_minor");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->lv_kernel_minor) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_minor");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_size");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNu64, &r->lv_size) != 1) {
- fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "lv_size");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "seg_count");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (sscanf (tok, "%"SCNi64, &r->seg_count) != 1) {
- fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "seg_count");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "origin");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->origin = strdup (tok);
- if (r->origin == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_percent");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (tok[0] == '\0')
- r->snap_percent = -1;
- else if (sscanf (tok, "%f", &r->snap_percent) != 1) {
- fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "snap_percent");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "copy_percent");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- if (tok[0] == '\0')
- r->copy_percent = -1;
- else if (sscanf (tok, "%f", &r->copy_percent) != 1) {
- fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "copy_percent");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "move_pv");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->move_pv = strdup (tok);
- if (r->move_pv == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_tags");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->lv_tags = strdup (tok);
- if (r->lv_tags == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "mirror_log");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->mirror_log = strdup (tok);
- if (r->mirror_log == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (!tok) {
- fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "modules");
- return -1;
- }
- p = strchrnul (tok, ',');
- if (*p) next = p+1; else next = NULL;
- *p = '\0';
- r->modules = strdup (tok);
- if (r->modules == NULL) {
- perror ("strdup");
- return -1;
- }
- tok = next;
- if (tok != NULL) {
- fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
- return -1;
- }
- return 0;
-}
-
-guestfs_lvm_int_lv_list *
-parse_command_line_lvs (void)
-{
- char *out, *err;
- char *p, *pend;
- int r, i;
- guestfs_lvm_int_lv_list *ret;
- void *newp;
-
- ret = malloc (sizeof *ret);
- if (!ret) {
- reply_with_perror ("malloc");
- return NULL;
- }
-
- ret->guestfs_lvm_int_lv_list_len = 0;
- ret->guestfs_lvm_int_lv_list_val = NULL;
-
- r = command (&out, &err,
- "/sbin/lvm", "lvs",
- "-o", lvm_lv_cols, "--unbuffered", "--noheadings",
- "--nosuffix", "--separator", ",", "--units", "b", NULL);
- if (r == -1) {
- reply_with_error ("%s", err);
- free (out);
- free (err);
- free (ret);
- return NULL;
- }
-
- free (err);
-
- /* Tokenize each line of the output. */
- p = out;
- i = 0;
- while (p) {
- pend = strchr (p, '\n'); /* Get the next line of output. */
- if (pend) {
- *pend = '\0';
- pend++;
- }
-
- while (*p && isspace (*p)) /* Skip any leading whitespace. */
- p++;
-
- if (!*p) { /* Empty line? Skip it. */
- p = pend;
- continue;
- }
-
- /* Allocate some space to store this next entry. */
- newp = realloc (ret->guestfs_lvm_int_lv_list_val,
- sizeof (guestfs_lvm_int_lv) * (i+1));
- if (newp == NULL) {
- reply_with_perror ("realloc");
- free (ret->guestfs_lvm_int_lv_list_val);
- free (ret);
- free (out);
- return NULL;
- }
- ret->guestfs_lvm_int_lv_list_val = newp;
-
- /* Tokenize the next entry. */
- r = lvm_tokenize_lv (p, &ret->guestfs_lvm_int_lv_list_val[i]);
- if (r == -1) {
- reply_with_error ("failed to parse output of 'lvs' command");
- free (ret->guestfs_lvm_int_lv_list_val);
- free (ret);
- free (out);
- return NULL;
- }
-
- ++i;
- p = pend;
- }
-
- ret->guestfs_lvm_int_lv_list_len = i;
-
- free (out);
- return ret;
-}
+++ /dev/null
-/* 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 program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; 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 <string.h>
-#include <inttypes.h>
-
-#include <guestfs.h>
-#include "fish.h"
-
-void list_commands (void)
-{
- printf (" %-16s %s\n", "Command", "Description");
- list_builtin_commands ();
- printf ("%-20s %s\n", "add-cdrom", "add a CD-ROM disk image to examine");
- printf ("%-20s %s\n", "add-drive", "add an image to examine or modify");
- printf ("%-20s %s\n", "add-drive-ro", "add a drive in snapshot mode (read-only)");
- printf ("%-20s %s\n", "aug-close", "close the current Augeas handle");
- printf ("%-20s %s\n", "aug-defnode", "define an Augeas node");
- printf ("%-20s %s\n", "aug-defvar", "define an Augeas variable");
- printf ("%-20s %s\n", "aug-get", "look up the value of an Augeas path");
- printf ("%-20s %s\n", "aug-init", "create a new Augeas handle");
- printf ("%-20s %s\n", "aug-insert", "insert a sibling Augeas node");
- printf ("%-20s %s\n", "aug-load", "load files into the tree");
- printf ("%-20s %s\n", "aug-ls", "list Augeas nodes under a path");
- printf ("%-20s %s\n", "aug-match", "return Augeas nodes which match path");
- printf ("%-20s %s\n", "aug-mv", "move Augeas node");
- printf ("%-20s %s\n", "aug-rm", "remove an Augeas path");
- printf ("%-20s %s\n", "aug-save", "write all pending Augeas changes to disk");
- printf ("%-20s %s\n", "aug-set", "set Augeas path to value");
- printf ("%-20s %s\n", "blockdev-flushbufs", "flush device buffers");
- printf ("%-20s %s\n", "blockdev-getbsz", "get blocksize of block device");
- printf ("%-20s %s\n", "blockdev-getro", "is block device set to read-only");
- printf ("%-20s %s\n", "blockdev-getsize64", "get total size of device in bytes");
- printf ("%-20s %s\n", "blockdev-getss", "get sectorsize of block device");
- printf ("%-20s %s\n", "blockdev-getsz", "get total size of device in 512-byte sectors");
- printf ("%-20s %s\n", "blockdev-rereadpt", "reread partition table");
- printf ("%-20s %s\n", "blockdev-setbsz", "set blocksize of block device");
- printf ("%-20s %s\n", "blockdev-setro", "set block device to read-only");
- printf ("%-20s %s\n", "blockdev-setrw", "set block device to read-write");
- printf ("%-20s %s\n", "cat", "list the contents of a file");
- printf ("%-20s %s\n", "checksum", "compute MD5, SHAx or CRC checksum of file");
- printf ("%-20s %s\n", "chmod", "change file mode");
- printf ("%-20s %s\n", "chown", "change file owner and group");
- printf ("%-20s %s\n", "command", "run a command from the guest filesystem");
- printf ("%-20s %s\n", "command-lines", "run a command, returning lines");
- printf ("%-20s %s\n", "config", "add qemu parameters");
- printf ("%-20s %s\n", "cp", "copy a file");
- printf ("%-20s %s\n", "cp-a", "copy a file or directory recursively");
- printf ("%-20s %s\n", "debug", "debugging and internals");
- printf ("%-20s %s\n", "df", "report file system disk space usage");
- printf ("%-20s %s\n", "df-h", "report file system disk space usage (human readable)");
- printf ("%-20s %s\n", "dmesg", "return kernel messages");
- printf ("%-20s %s\n", "download", "download a file to the local machine");
- printf ("%-20s %s\n", "drop-caches", "drop kernel page cache, dentries and inodes");
- printf ("%-20s %s\n", "du", "estimate file space usage");
- printf ("%-20s %s\n", "e2fsck-f", "check an ext2/ext3 filesystem");
- printf ("%-20s %s\n", "equal", "test if two files have equal contents");
- printf ("%-20s %s\n", "exists", "test if file or directory exists");
- printf ("%-20s %s\n", "file", "determine file type");
- printf ("%-20s %s\n", "find", "find all files and directories");
- printf ("%-20s %s\n", "fsck", "run the filesystem checker");
- printf ("%-20s %s\n", "get-append", "get the additional kernel options");
- printf ("%-20s %s\n", "get-autosync", "get autosync mode");
- printf ("%-20s %s\n", "get-e2label", "get the ext2/3/4 filesystem label");
- printf ("%-20s %s\n", "get-e2uuid", "get the ext2/3/4 filesystem UUID");
- printf ("%-20s %s\n", "get-memsize", "get memory allocated to the qemu subprocess");
- printf ("%-20s %s\n", "get-path", "get the search path");
- printf ("%-20s %s\n", "get-qemu", "get the qemu binary");
- printf ("%-20s %s\n", "get-state", "get the current state");
- printf ("%-20s %s\n", "get-verbose", "get verbose mode");
- printf ("%-20s %s\n", "glob-expand", "expand a wildcard path");
- printf ("%-20s %s\n", "grub-install", "install GRUB");
- printf ("%-20s %s\n", "head", "return first 10 lines of a file");
- printf ("%-20s %s\n", "head-n", "return first N lines of a file");
- printf ("%-20s %s\n", "hexdump", "dump a file in hexadecimal");
- printf ("%-20s %s\n", "initrd-list", "list files in an initrd");
- printf ("%-20s %s\n", "is-busy", "is busy processing a command");
- printf ("%-20s %s\n", "is-config", "is in configuration state");
- printf ("%-20s %s\n", "is-dir", "test if file exists");
- printf ("%-20s %s\n", "is-file", "test if file exists");
- printf ("%-20s %s\n", "is-launching", "is launching subprocess");
- printf ("%-20s %s\n", "is-ready", "is ready to accept commands");
- printf ("%-20s %s\n", "kill-subprocess", "kill the qemu subprocess");
- printf ("%-20s %s\n", "launch", "launch the qemu subprocess");
- printf ("%-20s %s\n", "list-devices", "list the block devices");
- printf ("%-20s %s\n", "list-partitions", "list the partitions");
- printf ("%-20s %s\n", "ll", "list the files in a directory (long format)");
- printf ("%-20s %s\n", "ls", "list the files in a directory");
- printf ("%-20s %s\n", "lstat", "get file information for a symbolic link");
- printf ("%-20s %s\n", "lvcreate", "create an LVM volume group");
- printf ("%-20s %s\n", "lvm-remove-all", "remove all LVM LVs, VGs and PVs");
- printf ("%-20s %s\n", "lvremove", "remove an LVM logical volume");
- printf ("%-20s %s\n", "lvresize", "resize an LVM logical volume");
- printf ("%-20s %s\n", "lvs", "list the LVM logical volumes (LVs)");
- printf ("%-20s %s\n", "lvs-full", "list the LVM logical volumes (LVs)");
- printf ("%-20s %s\n", "mkdir", "create a directory");
- printf ("%-20s %s\n", "mkdir-p", "create a directory and parents");
- printf ("%-20s %s\n", "mkdtemp", "create a temporary directory");
- printf ("%-20s %s\n", "mkfifo", "make FIFO (named pipe)");
- printf ("%-20s %s\n", "mkfs", "make a filesystem");
- printf ("%-20s %s\n", "mknod", "make block, character or FIFO devices");
- printf ("%-20s %s\n", "mknod-b", "make block device node");
- printf ("%-20s %s\n", "mknod-c", "make char device node");
- printf ("%-20s %s\n", "mkswap", "create a swap partition");
- printf ("%-20s %s\n", "mkswap-L", "create a swap partition with a label");
- printf ("%-20s %s\n", "mkswap-U", "create a swap partition with an explicit UUID");
- printf ("%-20s %s\n", "mount", "mount a guest disk at a position in the filesystem");
- printf ("%-20s %s\n", "mount-loop", "mount a file using the loop device");
- printf ("%-20s %s\n", "mount-options", "mount a guest disk with mount options");
- printf ("%-20s %s\n", "mount-ro", "mount a guest disk, read-only");
- printf ("%-20s %s\n", "mount-vfs", "mount a guest disk with mount options and vfstype");
- printf ("%-20s %s\n", "mounts", "show mounted filesystems");
- printf ("%-20s %s\n", "mv", "move a file");
- printf ("%-20s %s\n", "ntfs-3g-probe", "probe NTFS volume");
- printf ("%-20s %s\n", "ping-daemon", "ping the guest daemon");
- printf ("%-20s %s\n", "pvcreate", "create an LVM physical volume");
- printf ("%-20s %s\n", "pvremove", "remove an LVM physical volume");
- printf ("%-20s %s\n", "pvresize", "resize an LVM physical volume");
- printf ("%-20s %s\n", "pvs", "list the LVM physical volumes (PVs)");
- printf ("%-20s %s\n", "pvs-full", "list the LVM physical volumes (PVs)");
- printf ("%-20s %s\n", "read-lines", "read file as lines");
- printf ("%-20s %s\n", "readdir", "read directories entries");
- printf ("%-20s %s\n", "resize2fs", "resize an ext2/ext3 filesystem");
- printf ("%-20s %s\n", "rm", "remove a file");
- printf ("%-20s %s\n", "rm-rf", "remove a file or directory recursively");
- printf ("%-20s %s\n", "rmdir", "remove a directory");
- printf ("%-20s %s\n", "scrub-device", "scrub (securely wipe) a device");
- printf ("%-20s %s\n", "scrub-file", "scrub (securely wipe) a file");
- printf ("%-20s %s\n", "scrub-freespace", "scrub (securely wipe) free space");
- printf ("%-20s %s\n", "set-append", "add options to kernel command line");
- printf ("%-20s %s\n", "set-autosync", "set autosync mode");
- printf ("%-20s %s\n", "set-e2label", "set the ext2/3/4 filesystem label");
- printf ("%-20s %s\n", "set-e2uuid", "set the ext2/3/4 filesystem UUID");
- printf ("%-20s %s\n", "set-memsize", "set memory allocated to the qemu subprocess");
- printf ("%-20s %s\n", "set-path", "set the search path");
- printf ("%-20s %s\n", "set-qemu", "set the qemu binary");
- printf ("%-20s %s\n", "set-verbose", "set verbose mode");
- printf ("%-20s %s\n", "sfdisk", "create partitions on a block device");
- printf ("%-20s %s\n", "sfdisk-N", "modify a single partition on a block device");
- printf ("%-20s %s\n", "sfdisk-disk-geometry", "display the disk geometry from the partition table");
- printf ("%-20s %s\n", "sfdisk-kernel-geometry", "display the kernel geometry");
- printf ("%-20s %s\n", "sfdisk-l", "display the partition table");
- printf ("%-20s %s\n", "sh", "run a command via the shell");
- printf ("%-20s %s\n", "sh-lines", "run a command via the shell returning lines");
- printf ("%-20s %s\n", "sleep", "sleep for some seconds");
- printf ("%-20s %s\n", "stat", "get file information");
- printf ("%-20s %s\n", "statvfs", "get file system statistics");
- printf ("%-20s %s\n", "strings", "print the printable strings in a file");
- printf ("%-20s %s\n", "strings-e", "print the printable strings in a file");
- printf ("%-20s %s\n", "sync", "sync disks, writes are flushed through to the disk image");
- printf ("%-20s %s\n", "tail", "return last 10 lines of a file");
- printf ("%-20s %s\n", "tail-n", "return last N lines of a file");
- printf ("%-20s %s\n", "tar-in", "unpack tarfile to directory");
- printf ("%-20s %s\n", "tar-out", "pack directory into tarfile");
- printf ("%-20s %s\n", "tgz-in", "unpack compressed tarball to directory");
- printf ("%-20s %s\n", "tgz-out", "pack directory into compressed tarball");
- printf ("%-20s %s\n", "touch", "update file timestamps or create a new file");
- printf ("%-20s %s\n", "tune2fs-l", "get ext2/ext3/ext4 superblock details");
- printf ("%-20s %s\n", "umask", "set file mode creation mask (umask)");
- printf ("%-20s %s\n", "umount", "unmount a filesystem");
- printf ("%-20s %s\n", "umount-all", "unmount all filesystems");
- printf ("%-20s %s\n", "upload", "upload a file from the local machine");
- printf ("%-20s %s\n", "vg-activate", "activate or deactivate some volume groups");
- printf ("%-20s %s\n", "vg-activate-all", "activate or deactivate all volume groups");
- printf ("%-20s %s\n", "vgcreate", "create an LVM volume group");
- printf ("%-20s %s\n", "vgremove", "remove an LVM volume group");
- printf ("%-20s %s\n", "vgs", "list the LVM volume groups (VGs)");
- printf ("%-20s %s\n", "vgs-full", "list the LVM volume groups (VGs)");
- printf ("%-20s %s\n", "wc-c", "count characters in a file");
- printf ("%-20s %s\n", "wc-l", "count lines in a file");
- printf ("%-20s %s\n", "wc-w", "count words in a file");
- printf ("%-20s %s\n", "write-file", "create a file");
- printf ("%-20s %s\n", "zero", "write zeroes to the device");
- printf ("%-20s %s\n", "zerofree", "zero unused inodes and disk blocks on ext2/3 filesystem");
- printf (" Use -h <cmd> / help <cmd> to show detailed help for a command.\n");
-}
-
-void display_command (const char *cmd)
-{
- if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
- pod2text ("launch - launch the qemu subprocess", " launch\n\nInternally libguestfs is implemented by running a virtual machine\nusing L<qemu(1)>.\n\nYou should call this after configuring the handle\n(eg. adding drives) but before performing any actions.\n\nYou can use 'run' as an alias for this command.");
- else
- if (strcasecmp (cmd, "kill_subprocess") == 0 || strcasecmp (cmd, "kill-subprocess") == 0)
- pod2text ("kill-subprocess - kill the qemu subprocess", " kill-subprocess\n\nThis kills the qemu subprocess. You should never need to call this.");
- else
- if (strcasecmp (cmd, "add_drive") == 0 || strcasecmp (cmd, "add-drive") == 0 || strcasecmp (cmd, "add") == 0)
- pod2text ("add-drive - add an image to examine or modify", " add-drive <filename>\n\nThis function adds a virtual machine disk image C<filename> to the\nguest. The first time you call this function, the disk appears as IDE\ndisk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and\nso on.\n\nYou don't necessarily need to be root when using libguestfs. However\nyou obviously do need sufficient permissions to access the filename\nfor whatever operations you want to perform (ie. read access if you\njust want to read the image or write access if you want to modify the\nimage).\n\nThis is equivalent to the qemu parameter\nC<-drive file=filename,cache=off,if=virtio>.\n\nNote that this call checks for the existence of C<filename>. This\nstops you from specifying other types of drive which are supported\nby qemu such as C<nbd:> and C<http:> URLs. To specify those, use\nthe general C<config> call instead.\n\nYou can use 'add' as an alias for this command.");
- else
- if (strcasecmp (cmd, "add_cdrom") == 0 || strcasecmp (cmd, "add-cdrom") == 0 || strcasecmp (cmd, "cdrom") == 0)
- pod2text ("add-cdrom - add a CD-ROM disk image to examine", " add-cdrom <filename>\n\nThis function adds a virtual CD-ROM disk image to the guest.\n\nThis is equivalent to the qemu parameter C<-cdrom filename>.\n\nNote that this call checks for the existence of C<filename>. This\nstops you from specifying other types of drive which are supported\nby qemu such as C<nbd:> and C<http:> URLs. To specify those, use\nthe general C<config> call instead.\n\nYou can use 'cdrom' as an alias for this command.");
- else
- if (strcasecmp (cmd, "add_drive_ro") == 0 || strcasecmp (cmd, "add-drive-ro") == 0 || strcasecmp (cmd, "add-ro") == 0)
- pod2text ("add-drive-ro - add a drive in snapshot mode (read-only)", " add-drive-ro <filename>\n\nThis adds a drive in snapshot mode, making it effectively\nread-only.\n\nNote that writes to the device are allowed, and will be seen for\nthe duration of the guestfs handle, but they are written\nto a temporary file which is discarded as soon as the guestfs\nhandle is closed. We don't currently have any method to enable\nchanges to be committed, although qemu can support this.\n\nThis is equivalent to the qemu parameter\nC<-drive file=filename,snapshot=on,if=virtio>.\n\nNote that this call checks for the existence of C<filename>. This\nstops you from specifying other types of drive which are supported\nby qemu such as C<nbd:> and C<http:> URLs. To specify those, use\nthe general C<config> call instead.\n\nYou can use 'add-ro' as an alias for this command.");
- else
- if (strcasecmp (cmd, "config") == 0)
- pod2text ("config - add qemu parameters", " config <qemuparam> <qemuvalue>\n\nThis can be used to add arbitrary qemu command line parameters\nof the form C<-param value>. Actually it's not quite arbitrary - we\nprevent you from setting some parameters which would interfere with\nparameters that we use.\n\nThe first character of C<param> string must be a C<-> (dash).\n\nC<value> can be NULL.");
- else
- if (strcasecmp (cmd, "set_qemu") == 0 || strcasecmp (cmd, "set-qemu") == 0 || strcasecmp (cmd, "qemu") == 0)
- pod2text ("set-qemu - set the qemu binary", " set-qemu <qemu>\n\nSet the qemu binary that we will use.\n\nThe default is chosen when the library was compiled by the\nconfigure script.\n\nYou can also override this by setting the C<LIBGUESTFS_QEMU>\nenvironment variable.\n\nSetting C<qemu> to C<NULL> restores the default qemu binary.\n\nYou can use 'qemu' as an alias for this command.");
- else
- if (strcasecmp (cmd, "get_qemu") == 0 || strcasecmp (cmd, "get-qemu") == 0)
- pod2text ("get-qemu - get the qemu binary", " get-qemu\n\nReturn the current qemu binary.\n\nThis is always non-NULL. If it wasn't set already, then this will\nreturn the default qemu binary name.");
- else
- if (strcasecmp (cmd, "set_path") == 0 || strcasecmp (cmd, "set-path") == 0 || strcasecmp (cmd, "path") == 0)
- pod2text ("set-path - set the search path", " set-path <path>\n\nSet the path that libguestfs searches for kernel and initrd.img.\n\nThe default is C<$libdir/guestfs> unless overridden by setting\nC<LIBGUESTFS_PATH> environment variable.\n\nSetting C<path> to C<NULL> restores the default path.\n\nYou can use 'path' as an alias for this command.");
- else
- if (strcasecmp (cmd, "get_path") == 0 || strcasecmp (cmd, "get-path") == 0)
- pod2text ("get-path - get the search path", " get-path\n\nReturn the current search path.\n\nThis is always non-NULL. If it wasn't set already, then this will\nreturn the default path.");
- else
- if (strcasecmp (cmd, "set_append") == 0 || strcasecmp (cmd, "set-append") == 0 || strcasecmp (cmd, "append") == 0)
- pod2text ("set-append - add options to kernel command line", " set-append <append>\n\nThis function is used to add additional options to the\nguest kernel command line.\n\nThe default is C<NULL> unless overridden by setting\nC<LIBGUESTFS_APPEND> environment variable.\n\nSetting C<append> to C<NULL> means I<no> additional options\nare passed (libguestfs always adds a few of its own).\n\nYou can use 'append' as an alias for this command.");
- else
- if (strcasecmp (cmd, "get_append") == 0 || strcasecmp (cmd, "get-append") == 0)
- pod2text ("get-append - get the additional kernel options", " get-append\n\nReturn the additional kernel options which are added to the\nguest kernel command line.\n\nIf C<NULL> then no options are added.");
- else
- if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0)
- pod2text ("set-autosync - set autosync mode", " set-autosync <autosync>\n\nIf C<autosync> is true, this enables autosync. Libguestfs will make a\nbest effort attempt to run C<umount_all> followed by\nC<sync> when the handle is closed\n(also if the program exits without closing handles).\n\nThis is disabled by default (except in guestfish where it is\nenabled by default).\n\nYou can use 'autosync' as an alias for this command.");
- else
- if (strcasecmp (cmd, "get_autosync") == 0 || strcasecmp (cmd, "get-autosync") == 0)
- pod2text ("get-autosync - get autosync mode", " get-autosync\n\nGet the autosync flag.");
- else
- if (strcasecmp (cmd, "set_verbose") == 0 || strcasecmp (cmd, "set-verbose") == 0 || strcasecmp (cmd, "verbose") == 0)
- pod2text ("set-verbose - set verbose mode", " set-verbose <verbose>\n\nIf C<verbose> is true, this turns on verbose messages (to C<stderr>).\n\nVerbose messages are disabled unless the environment variable\nC<LIBGUESTFS_DEBUG> is defined and set to C<1>.\n\nYou can use 'verbose' as an alias for this command.");
- else
- if (strcasecmp (cmd, "get_verbose") == 0 || strcasecmp (cmd, "get-verbose") == 0)
- pod2text ("get-verbose - get verbose mode", " get-verbose\n\nThis returns the verbose messages flag.");
- else
- if (strcasecmp (cmd, "is_ready") == 0 || strcasecmp (cmd, "is-ready") == 0)
- pod2text ("is-ready - is ready to accept commands", " is-ready\n\nThis returns true iff this handle is ready to accept commands\n(in the C<READY> state).\n\nFor more information on states, see L<guestfs(3)>.");
- else
- if (strcasecmp (cmd, "is_config") == 0 || strcasecmp (cmd, "is-config") == 0)
- pod2text ("is-config - is in configuration state", " is-config\n\nThis returns true iff this handle is being configured\n(in the C<CONFIG> state).\n\nFor more information on states, see L<guestfs(3)>.");
- else
- if (strcasecmp (cmd, "is_launching") == 0 || strcasecmp (cmd, "is-launching") == 0)
- pod2text ("is-launching - is launching subprocess", " is-launching\n\nThis returns true iff this handle is launching the subprocess\n(in the C<LAUNCHING> state).\n\nFor more information on states, see L<guestfs(3)>.");
- else
- if (strcasecmp (cmd, "is_busy") == 0 || strcasecmp (cmd, "is-busy") == 0)
- pod2text ("is-busy - is busy processing a command", " is-busy\n\nThis returns true iff this handle is busy processing a command\n(in the C<BUSY> state).\n\nFor more information on states, see L<guestfs(3)>.");
- else
- if (strcasecmp (cmd, "get_state") == 0 || strcasecmp (cmd, "get-state") == 0)
- pod2text ("get-state - get the current state", " get-state\n\nThis returns the current state as an opaque integer. This is\nonly useful for printing debug and internal error messages.\n\nFor more information on states, see L<guestfs(3)>.");
- else
- if (strcasecmp (cmd, "set_memsize") == 0 || strcasecmp (cmd, "set-memsize") == 0 || strcasecmp (cmd, "memsize") == 0)
- pod2text ("set-memsize - set memory allocated to the qemu subprocess", " set-memsize <memsize>\n\nThis sets the memory size in megabytes allocated to the\nqemu subprocess. This only has any effect if called before\nC<launch>.\n\nYou can also change this by setting the environment\nvariable C<LIBGUESTFS_MEMSIZE> before the handle is\ncreated.\n\nFor more information on the architecture of libguestfs,\nsee L<guestfs(3)>.\n\nYou can use 'memsize' as an alias for this command.");
- else
- if (strcasecmp (cmd, "get_memsize") == 0 || strcasecmp (cmd, "get-memsize") == 0)
- pod2text ("get-memsize - get memory allocated to the qemu subprocess", " get-memsize\n\nThis gets the memory size in megabytes allocated to the\nqemu subprocess.\n\nIf C<set_memsize> was not called\non this handle, and if C<LIBGUESTFS_MEMSIZE> was not set,\nthen this returns the compiled-in default value for memsize.\n\nFor more information on the architecture of libguestfs,\nsee L<guestfs(3)>.");
- else
- if (strcasecmp (cmd, "mount") == 0)
- pod2text ("mount - mount a guest disk at a position in the filesystem", " mount <device> <mountpoint>\n\nMount a guest disk at a position in the filesystem. Block devices\nare named C</dev/sda>, C</dev/sdb> and so on, as they were added to\nthe guest. If those block devices contain partitions, they will have\nthe usual names (eg. C</dev/sda1>). Also LVM C</dev/VG/LV>-style\nnames can be used.\n\nThe rules are the same as for L<mount(2)>: A filesystem must\nfirst be mounted on C</> before others can be mounted. Other\nfilesystems can only be mounted on directories which already\nexist.\n\nThe mounted filesystem is writable, if we have sufficient permissions\non the underlying device.\n\nThe filesystem options C<sync> and C<noatime> are set with this\ncall, in order to improve reliability.");
- else
- if (strcasecmp (cmd, "sync") == 0)
- pod2text ("sync - sync disks, writes are flushed through to the disk image", " sync\n\nThis syncs the disk, so that any writes are flushed through to the\nunderlying disk image.\n\nYou should always call this if you have modified a disk image, before\nclosing the handle.");
- else
- if (strcasecmp (cmd, "touch") == 0)
- pod2text ("touch - update file timestamps or create a new file", " touch <path>\n\nTouch acts like the L<touch(1)> command. It can be used to\nupdate the timestamps on a file, or, if the file does not exist,\nto create a new zero-length file.");
- else
- if (strcasecmp (cmd, "cat") == 0)
- pod2text ("cat - list the contents of a file", " cat <path>\n\nReturn the contents of the file named C<path>.\n\nNote that this function cannot correctly handle binary files\n(specifically, files containing C<\\0> character which is treated\nas end of string). For those you need to use the C<download>\nfunction which has a more complex interface.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "ll") == 0)
- pod2text ("ll - list the files in a directory (long format)", " ll <directory>\n\nList the files in C<directory> (relative to the root directory,\nthere is no cwd) in the format of 'ls -la'.\n\nThis command is mostly useful for interactive sessions. It\nis I<not> intended that you try to parse the output string.");
- else
- if (strcasecmp (cmd, "ls") == 0)
- pod2text ("ls - list the files in a directory", " ls <directory>\n\nList the files in C<directory> (relative to the root directory,\nthere is no cwd). The '.' and '..' entries are not returned, but\nhidden files are shown.\n\nThis command is mostly useful for interactive sessions. Programs\nshould probably use C<readdir> instead.");
- else
- if (strcasecmp (cmd, "list_devices") == 0 || strcasecmp (cmd, "list-devices") == 0)
- pod2text ("list-devices - list the block devices", " list-devices\n\nList all the block devices.\n\nThe full block device names are returned, eg. C</dev/sda>");
- else
- if (strcasecmp (cmd, "list_partitions") == 0 || strcasecmp (cmd, "list-partitions") == 0)
- pod2text ("list-partitions - list the partitions", " list-partitions\n\nList all the partitions detected on all block devices.\n\nThe full partition device names are returned, eg. C</dev/sda1>\n\nThis does not return logical volumes. For that you will need to\ncall C<lvs>.");
- else
- if (strcasecmp (cmd, "pvs") == 0)
- pod2text ("pvs - list the LVM physical volumes (PVs)", " pvs\n\nList all the physical volumes detected. This is the equivalent\nof the L<pvs(8)> command.\n\nThis returns a list of just the device names that contain\nPVs (eg. C</dev/sda2>).\n\nSee also C<pvs_full>.");
- else
- if (strcasecmp (cmd, "vgs") == 0)
- pod2text ("vgs - list the LVM volume groups (VGs)", " vgs\n\nList all the volumes groups detected. This is the equivalent\nof the L<vgs(8)> command.\n\nThis returns a list of just the volume group names that were\ndetected (eg. C<VolGroup00>).\n\nSee also C<vgs_full>.");
- else
- if (strcasecmp (cmd, "lvs") == 0)
- pod2text ("lvs - list the LVM logical volumes (LVs)", " lvs\n\nList all the logical volumes detected. This is the equivalent\nof the L<lvs(8)> command.\n\nThis returns a list of the logical volume device names\n(eg. C</dev/VolGroup00/LogVol00>).\n\nSee also C<lvs_full>.");
- else
- if (strcasecmp (cmd, "pvs_full") == 0 || strcasecmp (cmd, "pvs-full") == 0)
- pod2text ("pvs-full - list the LVM physical volumes (PVs)", " pvs-full\n\nList all the physical volumes detected. This is the equivalent\nof the L<pvs(8)> command. The \"full\" version includes all fields.");
- else
- if (strcasecmp (cmd, "vgs_full") == 0 || strcasecmp (cmd, "vgs-full") == 0)
- pod2text ("vgs-full - list the LVM volume groups (VGs)", " vgs-full\n\nList all the volumes groups detected. This is the equivalent\nof the L<vgs(8)> command. The \"full\" version includes all fields.");
- else
- if (strcasecmp (cmd, "lvs_full") == 0 || strcasecmp (cmd, "lvs-full") == 0)
- pod2text ("lvs-full - list the LVM logical volumes (LVs)", " lvs-full\n\nList all the logical volumes detected. This is the equivalent\nof the L<lvs(8)> command. The \"full\" version includes all fields.");
- else
- if (strcasecmp (cmd, "read_lines") == 0 || strcasecmp (cmd, "read-lines") == 0)
- pod2text ("read-lines - read file as lines", " read-lines <path>\n\nReturn the contents of the file named C<path>.\n\nThe file contents are returned as a list of lines. Trailing\nC<LF> and C<CRLF> character sequences are I<not> returned.\n\nNote that this function cannot correctly handle binary files\n(specifically, files containing C<\\0> character which is treated\nas end of line). For those you need to use the C<read_file>\nfunction which has a more complex interface.");
- else
- if (strcasecmp (cmd, "aug_init") == 0 || strcasecmp (cmd, "aug-init") == 0)
- pod2text ("aug-init - create a new Augeas handle", " aug-init <root> <flags>\n\nCreate a new Augeas handle for editing configuration files.\nIf there was any previous Augeas handle associated with this\nguestfs session, then it is closed.\n\nYou must call this before using any other C<aug_*>\ncommands.\n\nC<root> is the filesystem root. C<root> must not be NULL,\nuse C</> instead.\n\nThe flags are the same as the flags defined in\nE<lt>augeas.hE<gt>, the logical I<or> of the following\nintegers:\n\n=over 4\n\n=item C<AUG_SAVE_BACKUP> = 1\n\nKeep the original file with a C<.augsave> extension.\n\n=item C<AUG_SAVE_NEWFILE> = 2\n\nSave changes into a file with extension C<.augnew>, and\ndo not overwrite original. Overrides C<AUG_SAVE_BACKUP>.\n\n=item C<AUG_TYPE_CHECK> = 4\n\nTypecheck lenses (can be expensive).\n\n=item C<AUG_NO_STDINC> = 8\n\nDo not use standard load path for modules.\n\n=item C<AUG_SAVE_NOOP> = 16\n\nMake save a no-op, just record what would have been changed.\n\n=item C<AUG_NO_LOAD> = 32\n\nDo not load the tree in C<aug_init>.\n\n=back\n\nTo close the handle, you can call C<aug_close>.\n\nTo find out more about Augeas, see L<http://augeas.net/>.");
- else
- if (strcasecmp (cmd, "aug_close") == 0 || strcasecmp (cmd, "aug-close") == 0)
- pod2text ("aug-close - close the current Augeas handle", " aug-close\n\nClose the current Augeas handle and free up any resources\nused by it. After calling this, you have to call\nC<aug_init> again before you can use any other\nAugeas functions.");
- else
- if (strcasecmp (cmd, "aug_defvar") == 0 || strcasecmp (cmd, "aug-defvar") == 0)
- pod2text ("aug-defvar - define an Augeas variable", " aug-defvar <name> <expr>\n\nDefines an Augeas variable C<name> whose value is the result\nof evaluating C<expr>. If C<expr> is NULL, then C<name> is\nundefined.\n\nOn success this returns the number of nodes in C<expr>, or\nC<0> if C<expr> evaluates to something which is not a nodeset.");
- else
- if (strcasecmp (cmd, "aug_defnode") == 0 || strcasecmp (cmd, "aug-defnode") == 0)
- pod2text ("aug-defnode - define an Augeas node", " aug-defnode <name> <expr> <val>\n\nDefines a variable C<name> whose value is the result of\nevaluating C<expr>.\n\nIf C<expr> evaluates to an empty nodeset, a node is created,\nequivalent to calling C<aug_set> C<expr>, C<value>.\nC<name> will be the nodeset containing that single node.\n\nOn success this returns a pair containing the\nnumber of nodes in the nodeset, and a boolean flag\nif a node was created.");
- else
- if (strcasecmp (cmd, "aug_get") == 0 || strcasecmp (cmd, "aug-get") == 0)
- pod2text ("aug-get - look up the value of an Augeas path", " aug-get <path>\n\nLook up the value associated with C<path>. If C<path>\nmatches exactly one node, the C<value> is returned.");
- else
- if (strcasecmp (cmd, "aug_set") == 0 || strcasecmp (cmd, "aug-set") == 0)
- pod2text ("aug-set - set Augeas path to value", " aug-set <path> <val>\n\nSet the value associated with C<path> to C<value>.");
- else
- if (strcasecmp (cmd, "aug_insert") == 0 || strcasecmp (cmd, "aug-insert") == 0)
- pod2text ("aug-insert - insert a sibling Augeas node", " aug-insert <path> <label> <before>\n\nCreate a new sibling C<label> for C<path>, inserting it into\nthe tree before or after C<path> (depending on the boolean\nflag C<before>).\n\nC<path> must match exactly one existing node in the tree, and\nC<label> must be a label, ie. not contain C</>, C<*> or end\nwith a bracketed index C<[N]>.");
- else
- if (strcasecmp (cmd, "aug_rm") == 0 || strcasecmp (cmd, "aug-rm") == 0)
- pod2text ("aug-rm - remove an Augeas path", " aug-rm <path>\n\nRemove C<path> and all of its children.\n\nOn success this returns the number of entries which were removed.");
- else
- if (strcasecmp (cmd, "aug_mv") == 0 || strcasecmp (cmd, "aug-mv") == 0)
- pod2text ("aug-mv - move Augeas node", " aug-mv <src> <dest>\n\nMove the node C<src> to C<dest>. C<src> must match exactly\none node. C<dest> is overwritten if it exists.");
- else
- if (strcasecmp (cmd, "aug_match") == 0 || strcasecmp (cmd, "aug-match") == 0)
- pod2text ("aug-match - return Augeas nodes which match path", " aug-match <path>\n\nReturns a list of paths which match the path expression C<path>.\nThe returned paths are sufficiently qualified so that they match\nexactly one node in the current tree.");
- else
- if (strcasecmp (cmd, "aug_save") == 0 || strcasecmp (cmd, "aug-save") == 0)
- pod2text ("aug-save - write all pending Augeas changes to disk", " aug-save\n\nThis writes all pending changes to disk.\n\nThe flags which were passed to C<aug_init> affect exactly\nhow files are saved.");
- else
- if (strcasecmp (cmd, "aug_load") == 0 || strcasecmp (cmd, "aug-load") == 0)
- pod2text ("aug-load - load files into the tree", " aug-load\n\nLoad files into the tree.\n\nSee C<aug_load> in the Augeas documentation for the full gory\ndetails.");
- else
- if (strcasecmp (cmd, "aug_ls") == 0 || strcasecmp (cmd, "aug-ls") == 0)
- pod2text ("aug-ls - list Augeas nodes under a path", " aug-ls <path>\n\nThis is just a shortcut for listing C<aug_match>\nC<path/*> and sorting the resulting nodes into alphabetical order.");
- else
- if (strcasecmp (cmd, "rm") == 0)
- pod2text ("rm - remove a file", " rm <path>\n\nRemove the single file C<path>.");
- else
- if (strcasecmp (cmd, "rmdir") == 0)
- pod2text ("rmdir - remove a directory", " rmdir <path>\n\nRemove the single directory C<path>.");
- else
- if (strcasecmp (cmd, "rm_rf") == 0 || strcasecmp (cmd, "rm-rf") == 0)
- pod2text ("rm-rf - remove a file or directory recursively", " rm-rf <path>\n\nRemove the file or directory C<path>, recursively removing the\ncontents if its a directory. This is like the C<rm -rf> shell\ncommand.");
- else
- if (strcasecmp (cmd, "mkdir") == 0)
- pod2text ("mkdir - create a directory", " mkdir <path>\n\nCreate a directory named C<path>.");
- else
- if (strcasecmp (cmd, "mkdir_p") == 0 || strcasecmp (cmd, "mkdir-p") == 0)
- pod2text ("mkdir-p - create a directory and parents", " mkdir-p <path>\n\nCreate a directory named C<path>, creating any parent directories\nas necessary. This is like the C<mkdir -p> shell command.");
- else
- if (strcasecmp (cmd, "chmod") == 0)
- pod2text ("chmod - change file mode", " chmod <mode> <path>\n\nChange the mode (permissions) of C<path> to C<mode>. Only\nnumeric modes are supported.");
- else
- if (strcasecmp (cmd, "chown") == 0)
- pod2text ("chown - change file owner and group", " chown <owner> <group> <path>\n\nChange the file owner to C<owner> and group to C<group>.\n\nOnly numeric uid and gid are supported. If you want to use\nnames, you will need to locate and parse the password file\nyourself (Augeas support makes this relatively easy).");
- else
- if (strcasecmp (cmd, "exists") == 0)
- pod2text ("exists - test if file or directory exists", " exists <path>\n\nThis returns C<true> if and only if there is a file, directory\n(or anything) with the given C<path> name.\n\nSee also C<is_file>, C<is_dir>, C<stat>.");
- else
- if (strcasecmp (cmd, "is_file") == 0 || strcasecmp (cmd, "is-file") == 0)
- pod2text ("is-file - test if file exists", " is-file <path>\n\nThis returns C<true> if and only if there is a file\nwith the given C<path> name. Note that it returns false for\nother objects like directories.\n\nSee also C<stat>.");
- else
- if (strcasecmp (cmd, "is_dir") == 0 || strcasecmp (cmd, "is-dir") == 0)
- pod2text ("is-dir - test if file exists", " is-dir <path>\n\nThis returns C<true> if and only if there is a directory\nwith the given C<path> name. Note that it returns false for\nother objects like files.\n\nSee also C<stat>.");
- else
- if (strcasecmp (cmd, "pvcreate") == 0)
- pod2text ("pvcreate - create an LVM physical volume", " pvcreate <device>\n\nThis creates an LVM physical volume on the named C<device>,\nwhere C<device> should usually be a partition name such\nas C</dev/sda1>.");
- else
- if (strcasecmp (cmd, "vgcreate") == 0)
- pod2text ("vgcreate - create an LVM volume group", " vgcreate <volgroup> <physvols>\n\nThis creates an LVM volume group called C<volgroup>\nfrom the non-empty list of physical volumes C<physvols>.");
- else
- if (strcasecmp (cmd, "lvcreate") == 0)
- pod2text ("lvcreate - create an LVM volume group", " lvcreate <logvol> <volgroup> <mbytes>\n\nThis creates an LVM volume group called C<logvol>\non the volume group C<volgroup>, with C<size> megabytes.");
- else
- if (strcasecmp (cmd, "mkfs") == 0)
- pod2text ("mkfs - make a filesystem", " mkfs <fstype> <device>\n\nThis creates a filesystem on C<device> (usually a partition\nor LVM logical volume). The filesystem type is C<fstype>, for\nexample C<ext3>.");
- else
- if (strcasecmp (cmd, "sfdisk") == 0)
- pod2text ("sfdisk - create partitions on a block device", " sfdisk <device> <cyls> <heads> <sectors> <lines>\n\nThis is a direct interface to the L<sfdisk(8)> program for creating\npartitions on block devices.\n\nC<device> should be a block device, for example C</dev/sda>.\n\nC<cyls>, C<heads> and C<sectors> are the number of cylinders, heads\nand sectors on the device, which are passed directly to sfdisk as\nthe I<-C>, I<-H> and I<-S> parameters. If you pass C<0> for any\nof these, then the corresponding parameter is omitted. Usually for\n'large' disks, you can just pass C<0> for these, but for small\n(floppy-sized) disks, sfdisk (or rather, the kernel) cannot work\nout the right geometry and you will need to tell it.\n\nC<lines> is a list of lines that we feed to C<sfdisk>. For more\ninformation refer to the L<sfdisk(8)> manpage.\n\nTo create a single partition occupying the whole disk, you would\npass C<lines> as a single element list, when the single element being\nthe string C<,> (comma).\n\nSee also: C<sfdisk_l>, C<sfdisk_N>\n\nB<This command is dangerous. Without careful use you\ncan easily destroy all your data>.");
- else
- if (strcasecmp (cmd, "write_file") == 0 || strcasecmp (cmd, "write-file") == 0)
- pod2text ("write-file - create a file", " write-file <path> <content> <size>\n\nThis call creates a file called C<path>. The contents of the\nfile is the string C<content> (which can contain any 8 bit data),\nwith length C<size>.\n\nAs a special case, if C<size> is C<0>\nthen the length is calculated using C<strlen> (so in this case\nthe content cannot contain embedded ASCII NULs).\n\nI<NB.> Owing to a bug, writing content containing ASCII NUL\ncharacters does I<not> work, even if the length is specified.\nWe hope to resolve this bug in a future version. In the meantime\nuse C<upload>.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "umount") == 0 || strcasecmp (cmd, "unmount") == 0)
- pod2text ("umount - unmount a filesystem", " umount <pathordevice>\n\nThis unmounts the given filesystem. The filesystem may be\nspecified either by its mountpoint (path) or the device which\ncontains the filesystem.\n\nYou can use 'unmount' as an alias for this command.");
- else
- if (strcasecmp (cmd, "mounts") == 0)
- pod2text ("mounts - show mounted filesystems", " mounts\n\nThis returns the list of currently mounted filesystems. It returns\nthe list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).\n\nSome internal mounts are not shown.");
- else
- if (strcasecmp (cmd, "umount_all") == 0 || strcasecmp (cmd, "umount-all") == 0 || strcasecmp (cmd, "unmount-all") == 0)
- pod2text ("umount-all - unmount all filesystems", " umount-all\n\nThis unmounts all mounted filesystems.\n\nSome internal mounts are not unmounted by this call.\n\nYou can use 'unmount-all' as an alias for this command.");
- else
- if (strcasecmp (cmd, "lvm_remove_all") == 0 || strcasecmp (cmd, "lvm-remove-all") == 0)
- pod2text ("lvm-remove-all - remove all LVM LVs, VGs and PVs", " lvm-remove-all\n\nThis command removes all LVM logical volumes, volume groups\nand physical volumes.\n\nB<This command is dangerous. Without careful use you\ncan easily destroy all your data>.");
- else
- if (strcasecmp (cmd, "file") == 0)
- pod2text ("file - determine file type", " file <path>\n\nThis call uses the standard L<file(1)> command to determine\nthe type or contents of the file. This also works on devices,\nfor example to find out whether a partition contains a filesystem.\n\nThe exact command which runs is C<file -bsL path>. Note in\nparticular that the filename is not prepended to the output\n(the C<-b> option).");
- else
- if (strcasecmp (cmd, "command") == 0)
- pod2text ("command - run a command from the guest filesystem", " command <arguments>\n\nThis call runs a command from the guest filesystem. The\nfilesystem must be mounted, and must contain a compatible\noperating system (ie. something Linux, with the same\nor compatible processor architecture).\n\nThe single parameter is an argv-style list of arguments.\nThe first element is the name of the program to run.\nSubsequent elements are parameters. The list must be\nnon-empty (ie. must contain a program name). Note that\nthe command runs directly, and is I<not> invoked via\nthe shell (see C<sh>).\n\nThe return value is anything printed to I<stdout> by\nthe command.\n\nIf the command returns a non-zero exit status, then\nthis function returns an error message. The error message\nstring is the content of I<stderr> from the command.\n\nThe C<$PATH> environment variable will contain at least\nC</usr/bin> and C</bin>. If you require a program from\nanother location, you should provide the full path in the\nfirst parameter.\n\nShared libraries and data files required by the program\nmust be available on filesystems which are mounted in the\ncorrect places. It is the caller's responsibility to ensure\nall filesystems that are needed are mounted at the right\nlocations.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "command_lines") == 0 || strcasecmp (cmd, "command-lines") == 0)
- pod2text ("command-lines - run a command, returning lines", " command-lines <arguments>\n\nThis is the same as C<command>, but splits the\nresult into a list of lines.\n\nSee also: C<sh_lines>\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "stat") == 0)
- pod2text ("stat - get file information", " stat <path>\n\nReturns file information for the given C<path>.\n\nThis is the same as the C<stat(2)> system call.");
- else
- if (strcasecmp (cmd, "lstat") == 0)
- pod2text ("lstat - get file information for a symbolic link", " lstat <path>\n\nReturns file information for the given C<path>.\n\nThis is the same as C<stat> except that if C<path>\nis a symbolic link, then the link is stat-ed, not the file it\nrefers to.\n\nThis is the same as the C<lstat(2)> system call.");
- else
- if (strcasecmp (cmd, "statvfs") == 0)
- pod2text ("statvfs - get file system statistics", " statvfs <path>\n\nReturns file system statistics for any mounted file system.\nC<path> should be a file or directory in the mounted file system\n(typically it is the mount point itself, but it doesn't need to be).\n\nThis is the same as the C<statvfs(2)> system call.");
- else
- if (strcasecmp (cmd, "tune2fs_l") == 0 || strcasecmp (cmd, "tune2fs-l") == 0)
- pod2text ("tune2fs-l - get ext2/ext3/ext4 superblock details", " tune2fs-l <device>\n\nThis returns the contents of the ext2, ext3 or ext4 filesystem\nsuperblock on C<device>.\n\nIt is the same as running C<tune2fs -l device>. See L<tune2fs(8)>\nmanpage for more details. The list of fields returned isn't\nclearly defined, and depends on both the version of C<tune2fs>\nthat libguestfs was built against, and the filesystem itself.");
- else
- if (strcasecmp (cmd, "blockdev_setro") == 0 || strcasecmp (cmd, "blockdev-setro") == 0)
- pod2text ("blockdev-setro - set block device to read-only", " blockdev-setro <device>\n\nSets the block device named C<device> to read-only.\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "blockdev_setrw") == 0 || strcasecmp (cmd, "blockdev-setrw") == 0)
- pod2text ("blockdev-setrw - set block device to read-write", " blockdev-setrw <device>\n\nSets the block device named C<device> to read-write.\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "blockdev_getro") == 0 || strcasecmp (cmd, "blockdev-getro") == 0)
- pod2text ("blockdev-getro - is block device set to read-only", " blockdev-getro <device>\n\nReturns a boolean indicating if the block device is read-only\n(true if read-only, false if not).\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "blockdev_getss") == 0 || strcasecmp (cmd, "blockdev-getss") == 0)
- pod2text ("blockdev-getss - get sectorsize of block device", " blockdev-getss <device>\n\nThis returns the size of sectors on a block device.\nUsually 512, but can be larger for modern devices.\n\n(Note, this is not the size in sectors, use C<blockdev_getsz>\nfor that).\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "blockdev_getbsz") == 0 || strcasecmp (cmd, "blockdev-getbsz") == 0)
- pod2text ("blockdev-getbsz - get blocksize of block device", " blockdev-getbsz <device>\n\nThis returns the block size of a device.\n\n(Note this is different from both I<size in blocks> and\nI<filesystem block size>).\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "blockdev_setbsz") == 0 || strcasecmp (cmd, "blockdev-setbsz") == 0)
- pod2text ("blockdev-setbsz - set blocksize of block device", " blockdev-setbsz <device> <blocksize>\n\nThis sets the block size of a device.\n\n(Note this is different from both I<size in blocks> and\nI<filesystem block size>).\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "blockdev_getsz") == 0 || strcasecmp (cmd, "blockdev-getsz") == 0)
- pod2text ("blockdev-getsz - get total size of device in 512-byte sectors", " blockdev-getsz <device>\n\nThis returns the size of the device in units of 512-byte sectors\n(even if the sectorsize isn't 512 bytes ... weird).\n\nSee also C<blockdev_getss> for the real sector size of\nthe device, and C<blockdev_getsize64> for the more\nuseful I<size in bytes>.\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "blockdev_getsize64") == 0 || strcasecmp (cmd, "blockdev-getsize64") == 0)
- pod2text ("blockdev-getsize64 - get total size of device in bytes", " blockdev-getsize64 <device>\n\nThis returns the size of the device in bytes.\n\nSee also C<blockdev_getsz>.\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "blockdev_flushbufs") == 0 || strcasecmp (cmd, "blockdev-flushbufs") == 0)
- pod2text ("blockdev-flushbufs - flush device buffers", " blockdev-flushbufs <device>\n\nThis tells the kernel to flush internal buffers associated\nwith C<device>.\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "blockdev_rereadpt") == 0 || strcasecmp (cmd, "blockdev-rereadpt") == 0)
- pod2text ("blockdev-rereadpt - reread partition table", " blockdev-rereadpt <device>\n\nReread the partition table on C<device>.\n\nThis uses the L<blockdev(8)> command.");
- else
- if (strcasecmp (cmd, "upload") == 0)
- pod2text ("upload - upload a file from the local machine", " upload <filename> <remotefilename>\n\nUpload local file C<filename> to C<remotefilename> on the\nfilesystem.\n\nC<filename> can also be a named pipe.\n\nSee also C<download>.");
- else
- if (strcasecmp (cmd, "download") == 0)
- pod2text ("download - download a file to the local machine", " download <remotefilename> <filename>\n\nDownload file C<remotefilename> and save it as C<filename>\non the local machine.\n\nC<filename> can also be a named pipe.\n\nSee also C<upload>, C<cat>.");
- else
- if (strcasecmp (cmd, "checksum") == 0)
- pod2text ("checksum - compute MD5, SHAx or CRC checksum of file", " checksum <csumtype> <path>\n\nThis call computes the MD5, SHAx or CRC checksum of the\nfile named C<path>.\n\nThe type of checksum to compute is given by the C<csumtype>\nparameter which must have one of the following values:\n\n=over 4\n\n=item C<crc>\n\nCompute the cyclic redundancy check (CRC) specified by POSIX\nfor the C<cksum> command.\n\n=item C<md5>\n\nCompute the MD5 hash (using the C<md5sum> program).\n\n=item C<sha1>\n\nCompute the SHA1 hash (using the C<sha1sum> program).\n\n=item C<sha224>\n\nCompute the SHA224 hash (using the C<sha224sum> program).\n\n=item C<sha256>\n\nCompute the SHA256 hash (using the C<sha256sum> program).\n\n=item C<sha384>\n\nCompute the SHA384 hash (using the C<sha384sum> program).\n\n=item C<sha512>\n\nCompute the SHA512 hash (using the C<sha512sum> program).\n\n=back\n\nThe checksum is returned as a printable string.");
- else
- if (strcasecmp (cmd, "tar_in") == 0 || strcasecmp (cmd, "tar-in") == 0)
- pod2text ("tar-in - unpack tarfile to directory", " tar-in <tarfile> <directory>\n\nThis command uploads and unpacks local file C<tarfile> (an\nI<uncompressed> tar file) into C<directory>.\n\nTo upload a compressed tarball, use C<tgz_in>.");
- else
- if (strcasecmp (cmd, "tar_out") == 0 || strcasecmp (cmd, "tar-out") == 0)
- pod2text ("tar-out - pack directory into tarfile", " tar-out <directory> <tarfile>\n\nThis command packs the contents of C<directory> and downloads\nit to local file C<tarfile>.\n\nTo download a compressed tarball, use C<tgz_out>.");
- else
- if (strcasecmp (cmd, "tgz_in") == 0 || strcasecmp (cmd, "tgz-in") == 0)
- pod2text ("tgz-in - unpack compressed tarball to directory", " tgz-in <tarball> <directory>\n\nThis command uploads and unpacks local file C<tarball> (a\nI<gzip compressed> tar file) into C<directory>.\n\nTo upload an uncompressed tarball, use C<tar_in>.");
- else
- if (strcasecmp (cmd, "tgz_out") == 0 || strcasecmp (cmd, "tgz-out") == 0)
- pod2text ("tgz-out - pack directory into compressed tarball", " tgz-out <directory> <tarball>\n\nThis command packs the contents of C<directory> and downloads\nit to local file C<tarball>.\n\nTo download an uncompressed tarball, use C<tar_out>.");
- else
- if (strcasecmp (cmd, "mount_ro") == 0 || strcasecmp (cmd, "mount-ro") == 0)
- pod2text ("mount-ro - mount a guest disk, read-only", " mount-ro <device> <mountpoint>\n\nThis is the same as the C<mount> command, but it\nmounts the filesystem with the read-only (I<-o ro>) flag.");
- else
- if (strcasecmp (cmd, "mount_options") == 0 || strcasecmp (cmd, "mount-options") == 0)
- pod2text ("mount-options - mount a guest disk with mount options", " mount-options <options> <device> <mountpoint>\n\nThis is the same as the C<mount> command, but it\nallows you to set the mount options as for the\nL<mount(8)> I<-o> flag.");
- else
- if (strcasecmp (cmd, "mount_vfs") == 0 || strcasecmp (cmd, "mount-vfs") == 0)
- pod2text ("mount-vfs - mount a guest disk with mount options and vfstype", " mount-vfs <options> <vfstype> <device> <mountpoint>\n\nThis is the same as the C<mount> command, but it\nallows you to set both the mount options and the vfstype\nas for the L<mount(8)> I<-o> and I<-t> flags.");
- else
- if (strcasecmp (cmd, "debug") == 0)
- pod2text ("debug - debugging and internals", " debug <subcmd> <extraargs>\n\nThe C<debug> command exposes some internals of\nC<guestfsd> (the guestfs daemon) that runs inside the\nqemu subprocess.\n\nThere is no comprehensive help for this command. You have\nto look at the file C<daemon/debug.c> in the libguestfs source\nto find out what you can do.");
- else
- if (strcasecmp (cmd, "lvremove") == 0)
- pod2text ("lvremove - remove an LVM logical volume", " lvremove <device>\n\nRemove an LVM logical volume C<device>, where C<device> is\nthe path to the LV, such as C</dev/VG/LV>.\n\nYou can also remove all LVs in a volume group by specifying\nthe VG name, C</dev/VG>.");
- else
- if (strcasecmp (cmd, "vgremove") == 0)
- pod2text ("vgremove - remove an LVM volume group", " vgremove <vgname>\n\nRemove an LVM volume group C<vgname>, (for example C<VG>).\n\nThis also forcibly removes all logical volumes in the volume\ngroup (if any).");
- else
- if (strcasecmp (cmd, "pvremove") == 0)
- pod2text ("pvremove - remove an LVM physical volume", " pvremove <device>\n\nThis wipes a physical volume C<device> so that LVM will no longer\nrecognise it.\n\nThe implementation uses the C<pvremove> command which refuses to\nwipe physical volumes that contain any volume groups, so you have\nto remove those first.");
- else
- if (strcasecmp (cmd, "set_e2label") == 0 || strcasecmp (cmd, "set-e2label") == 0)
- pod2text ("set-e2label - set the ext2/3/4 filesystem label", " set-e2label <device> <label>\n\nThis sets the ext2/3/4 filesystem label of the filesystem on\nC<device> to C<label>. Filesystem labels are limited to\n16 characters.\n\nYou can use either C<tune2fs_l> or C<get_e2label>\nto return the existing label on a filesystem.");
- else
- if (strcasecmp (cmd, "get_e2label") == 0 || strcasecmp (cmd, "get-e2label") == 0)
- pod2text ("get-e2label - get the ext2/3/4 filesystem label", " get-e2label <device>\n\nThis returns the ext2/3/4 filesystem label of the filesystem on\nC<device>.");
- else
- if (strcasecmp (cmd, "set_e2uuid") == 0 || strcasecmp (cmd, "set-e2uuid") == 0)
- pod2text ("set-e2uuid - set the ext2/3/4 filesystem UUID", " set-e2uuid <device> <uuid>\n\nThis sets the ext2/3/4 filesystem UUID of the filesystem on\nC<device> to C<uuid>. The format of the UUID and alternatives\nsuch as C<clear>, C<random> and C<time> are described in the\nL<tune2fs(8)> manpage.\n\nYou can use either C<tune2fs_l> or C<get_e2uuid>\nto return the existing UUID of a filesystem.");
- else
- if (strcasecmp (cmd, "get_e2uuid") == 0 || strcasecmp (cmd, "get-e2uuid") == 0)
- pod2text ("get-e2uuid - get the ext2/3/4 filesystem UUID", " get-e2uuid <device>\n\nThis returns the ext2/3/4 filesystem UUID of the filesystem on\nC<device>.");
- else
- if (strcasecmp (cmd, "fsck") == 0)
- pod2text ("fsck - run the filesystem checker", " fsck <fstype> <device>\n\nThis runs the filesystem checker (fsck) on C<device> which\nshould have filesystem type C<fstype>.\n\nThe returned integer is the status. See L<fsck(8)> for the\nlist of status codes from C<fsck>.\n\nNotes:\n\n=over 4\n\n=item *\n\nMultiple status codes can be summed together.\n\n=item *\n\nA non-zero return code can mean \"success\", for example if\nerrors have been corrected on the filesystem.\n\n=item *\n\nChecking or repairing NTFS volumes is not supported\n(by linux-ntfs).\n\n=back\n\nThis command is entirely equivalent to running C<fsck -a -t fstype device>.");
- else
- if (strcasecmp (cmd, "zero") == 0)
- pod2text ("zero - write zeroes to the device", " zero <device>\n\nThis command writes zeroes over the first few blocks of C<device>.\n\nHow many blocks are zeroed isn't specified (but it's I<not> enough\nto securely wipe the device). It should be sufficient to remove\nany partition tables, filesystem superblocks and so on.\n\nSee also: C<scrub_device>.");
- else
- if (strcasecmp (cmd, "grub_install") == 0 || strcasecmp (cmd, "grub-install") == 0)
- pod2text ("grub-install - install GRUB", " grub-install <root> <device>\n\nThis command installs GRUB (the Grand Unified Bootloader) on\nC<device>, with the root directory being C<root>.");
- else
- if (strcasecmp (cmd, "cp") == 0)
- pod2text ("cp - copy a file", " cp <src> <dest>\n\nThis copies a file from C<src> to C<dest> where C<dest> is\neither a destination filename or destination directory.");
- else
- if (strcasecmp (cmd, "cp_a") == 0 || strcasecmp (cmd, "cp-a") == 0)
- pod2text ("cp-a - copy a file or directory recursively", " cp-a <src> <dest>\n\nThis copies a file or directory from C<src> to C<dest>\nrecursively using the C<cp -a> command.");
- else
- if (strcasecmp (cmd, "mv") == 0)
- pod2text ("mv - move a file", " mv <src> <dest>\n\nThis moves a file from C<src> to C<dest> where C<dest> is\neither a destination filename or destination directory.");
- else
- if (strcasecmp (cmd, "drop_caches") == 0 || strcasecmp (cmd, "drop-caches") == 0)
- pod2text ("drop-caches - drop kernel page cache, dentries and inodes", " drop-caches <whattodrop>\n\nThis instructs the guest kernel to drop its page cache,\nand/or dentries and inode caches. The parameter C<whattodrop>\ntells the kernel what precisely to drop, see\nL<http://linux-mm.org/Drop_Caches>\n\nSetting C<whattodrop> to 3 should drop everything.\n\nThis automatically calls L<sync(2)> before the operation,\nso that the maximum guest memory is freed.");
- else
- if (strcasecmp (cmd, "dmesg") == 0)
- pod2text ("dmesg - return kernel messages", " dmesg\n\nThis returns the kernel messages (C<dmesg> output) from\nthe guest kernel. This is sometimes useful for extended\ndebugging of problems.\n\nAnother way to get the same information is to enable\nverbose messages with C<set_verbose> or by setting\nthe environment variable C<LIBGUESTFS_DEBUG=1> before\nrunning the program.");
- else
- if (strcasecmp (cmd, "ping_daemon") == 0 || strcasecmp (cmd, "ping-daemon") == 0)
- pod2text ("ping-daemon - ping the guest daemon", " ping-daemon\n\nThis is a test probe into the guestfs daemon running inside\nthe qemu subprocess. Calling this function checks that the\ndaemon responds to the ping message, without affecting the daemon\nor attached block device(s) in any other way.");
- else
- if (strcasecmp (cmd, "equal") == 0)
- pod2text ("equal - test if two files have equal contents", " equal <file1> <file2>\n\nThis compares the two files C<file1> and C<file2> and returns\ntrue if their content is exactly equal, or false otherwise.\n\nThe external L<cmp(1)> program is used for the comparison.");
- else
- if (strcasecmp (cmd, "strings") == 0)
- pod2text ("strings - print the printable strings in a file", " strings <path>\n\nThis runs the L<strings(1)> command on a file and returns\nthe list of printable strings found.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "strings_e") == 0 || strcasecmp (cmd, "strings-e") == 0)
- pod2text ("strings-e - print the printable strings in a file", " strings-e <encoding> <path>\n\nThis is like the C<strings> command, but allows you to\nspecify the encoding.\n\nSee the L<strings(1)> manpage for the full list of encodings.\n\nCommonly useful encodings are C<l> (lower case L) which will\nshow strings inside Windows/x86 files.\n\nThe returned strings are transcoded to UTF-8.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "hexdump") == 0)
- pod2text ("hexdump - dump a file in hexadecimal", " hexdump <path>\n\nThis runs C<hexdump -C> on the given C<path>. The result is\nthe human-readable, canonical hex dump of the file.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "zerofree") == 0)
- pod2text ("zerofree - zero unused inodes and disk blocks on ext2/3 filesystem", " zerofree <device>\n\nThis runs the I<zerofree> program on C<device>. This program\nclaims to zero unused inodes and disk blocks on an ext2/3\nfilesystem, thus making it possible to compress the filesystem\nmore effectively.\n\nYou should B<not> run this program if the filesystem is\nmounted.\n\nIt is possible that using this program can damage the filesystem\nor data on the filesystem.");
- else
- if (strcasecmp (cmd, "pvresize") == 0)
- pod2text ("pvresize - resize an LVM physical volume", " pvresize <device>\n\nThis resizes (expands or shrinks) an existing LVM physical\nvolume to match the new size of the underlying device.");
- else
- if (strcasecmp (cmd, "sfdisk_N") == 0 || strcasecmp (cmd, "sfdisk-N") == 0)
- pod2text ("sfdisk-N - modify a single partition on a block device", " sfdisk-N <device> <partnum> <cyls> <heads> <sectors> <line>\n\nThis runs L<sfdisk(8)> option to modify just the single\npartition C<n> (note: C<n> counts from 1).\n\nFor other parameters, see C<sfdisk>. You should usually\npass C<0> for the cyls/heads/sectors parameters.\n\nB<This command is dangerous. Without careful use you\ncan easily destroy all your data>.");
- else
- if (strcasecmp (cmd, "sfdisk_l") == 0 || strcasecmp (cmd, "sfdisk-l") == 0)
- pod2text ("sfdisk-l - display the partition table", " sfdisk-l <device>\n\nThis displays the partition table on C<device>, in the\nhuman-readable output of the L<sfdisk(8)> command. It is\nnot intended to be parsed.");
- else
- if (strcasecmp (cmd, "sfdisk_kernel_geometry") == 0 || strcasecmp (cmd, "sfdisk-kernel-geometry") == 0)
- pod2text ("sfdisk-kernel-geometry - display the kernel geometry", " sfdisk-kernel-geometry <device>\n\nThis displays the kernel's idea of the geometry of C<device>.\n\nThe result is in human-readable format, and not designed to\nbe parsed.");
- else
- if (strcasecmp (cmd, "sfdisk_disk_geometry") == 0 || strcasecmp (cmd, "sfdisk-disk-geometry") == 0)
- pod2text ("sfdisk-disk-geometry - display the disk geometry from the partition table", " sfdisk-disk-geometry <device>\n\nThis displays the disk geometry of C<device> read from the\npartition table. Especially in the case where the underlying\nblock device has been resized, this can be different from the\nkernel's idea of the geometry (see C<sfdisk_kernel_geometry>).\n\nThe result is in human-readable format, and not designed to\nbe parsed.");
- else
- if (strcasecmp (cmd, "vg_activate_all") == 0 || strcasecmp (cmd, "vg-activate-all") == 0)
- pod2text ("vg-activate-all - activate or deactivate all volume groups", " vg-activate-all <activate>\n\nThis command activates or (if C<activate> is false) deactivates\nall logical volumes in all volume groups.\nIf activated, then they are made known to the\nkernel, ie. they appear as C</dev/mapper> devices. If deactivated,\nthen those devices disappear.\n\nThis command is the same as running C<vgchange -a y|n>");
- else
- if (strcasecmp (cmd, "vg_activate") == 0 || strcasecmp (cmd, "vg-activate") == 0)
- pod2text ("vg-activate - activate or deactivate some volume groups", " vg-activate <activate> <volgroups>\n\nThis command activates or (if C<activate> is false) deactivates\nall logical volumes in the listed volume groups C<volgroups>.\nIf activated, then they are made known to the\nkernel, ie. they appear as C</dev/mapper> devices. If deactivated,\nthen those devices disappear.\n\nThis command is the same as running C<vgchange -a y|n volgroups...>\n\nNote that if C<volgroups> is an empty list then B<all> volume groups\nare activated or deactivated.");
- else
- if (strcasecmp (cmd, "lvresize") == 0)
- pod2text ("lvresize - resize an LVM logical volume", " lvresize <device> <mbytes>\n\nThis resizes (expands or shrinks) an existing LVM logical\nvolume to C<mbytes>. When reducing, data in the reduced part\nis lost.");
- else
- if (strcasecmp (cmd, "resize2fs") == 0)
- pod2text ("resize2fs - resize an ext2/ext3 filesystem", " resize2fs <device>\n\nThis resizes an ext2 or ext3 filesystem to match the size of\nthe underlying device.\n\nI<Note:> It is sometimes required that you run C<e2fsck_f>\non the C<device> before calling this command. For unknown reasons\nC<resize2fs> sometimes gives an error about this and sometimes not.\nIn any case, it is always safe to call C<e2fsck_f> before\ncalling this function.");
- else
- if (strcasecmp (cmd, "find") == 0)
- pod2text ("find - find all files and directories", " find <directory>\n\nThis command lists out all files and directories, recursively,\nstarting at C<directory>. It is essentially equivalent to\nrunning the shell command C<find directory -print> but some\npost-processing happens on the output, described below.\n\nThis returns a list of strings I<without any prefix>. Thus\nif the directory structure was:\n\n /tmp/a\n /tmp/b\n /tmp/c/d\n\nthen the returned list from C<find> C</tmp> would be\n4 elements:\n\n a\n b\n c\n c/d\n\nIf C<directory> is not a directory, then this command returns\nan error.\n\nThe returned list is sorted.");
- else
- if (strcasecmp (cmd, "e2fsck_f") == 0 || strcasecmp (cmd, "e2fsck-f") == 0)
- pod2text ("e2fsck-f - check an ext2/ext3 filesystem", " e2fsck-f <device>\n\nThis runs C<e2fsck -p -f device>, ie. runs the ext2/ext3\nfilesystem checker on C<device>, noninteractively (C<-p>),\neven if the filesystem appears to be clean (C<-f>).\n\nThis command is only needed because of C<resize2fs>\n(q.v.). Normally you should use C<fsck>.");
- else
- if (strcasecmp (cmd, "sleep") == 0)
- pod2text ("sleep - sleep for some seconds", " sleep <secs>\n\nSleep for C<secs> seconds.");
- else
- if (strcasecmp (cmd, "ntfs_3g_probe") == 0 || strcasecmp (cmd, "ntfs-3g-probe") == 0)
- pod2text ("ntfs-3g-probe - probe NTFS volume", " ntfs-3g-probe <rw> <device>\n\nThis command runs the L<ntfs-3g.probe(8)> command which probes\nan NTFS C<device> for mountability. (Not all NTFS volumes can\nbe mounted read-write, and some cannot be mounted at all).\n\nC<rw> is a boolean flag. Set it to true if you want to test\nif the volume can be mounted read-write. Set it to false if\nyou want to test if the volume can be mounted read-only.\n\nThe return value is an integer which C<0> if the operation\nwould succeed, or some non-zero value documented in the\nL<ntfs-3g.probe(8)> manual page.");
- else
- if (strcasecmp (cmd, "sh") == 0)
- pod2text ("sh - run a command via the shell", " sh <command>\n\nThis call runs a command from the guest filesystem via the\nguest's C</bin/sh>.\n\nThis is like C<command>, but passes the command to:\n\n /bin/sh -c \"command\"\n\nDepending on the guest's shell, this usually results in\nwildcards being expanded, shell expressions being interpolated\nand so on.\n\nAll the provisos about C<command> apply to this call.");
- else
- if (strcasecmp (cmd, "sh_lines") == 0 || strcasecmp (cmd, "sh-lines") == 0)
- pod2text ("sh-lines - run a command via the shell returning lines", " sh-lines <command>\n\nThis is the same as C<sh>, but splits the result\ninto a list of lines.\n\nSee also: C<command_lines>");
- else
- if (strcasecmp (cmd, "glob_expand") == 0 || strcasecmp (cmd, "glob-expand") == 0)
- pod2text ("glob-expand - expand a wildcard path", " glob-expand <pattern>\n\nThis command searches for all the pathnames matching\nC<pattern> according to the wildcard expansion rules\nused by the shell.\n\nIf no paths match, then this returns an empty list\n(note: not an error).\n\nIt is just a wrapper around the C L<glob(3)> function\nwith flags C<GLOB_MARK|GLOB_BRACE>.\nSee that manual page for more details.");
- else
- if (strcasecmp (cmd, "scrub_device") == 0 || strcasecmp (cmd, "scrub-device") == 0)
- pod2text ("scrub-device - scrub (securely wipe) a device", " scrub-device <device>\n\nThis command writes patterns over C<device> to make data retrieval\nmore difficult.\n\nIt is an interface to the L<scrub(1)> program. See that\nmanual page for more details.\n\nB<This command is dangerous. Without careful use you\ncan easily destroy all your data>.");
- else
- if (strcasecmp (cmd, "scrub_file") == 0 || strcasecmp (cmd, "scrub-file") == 0)
- pod2text ("scrub-file - scrub (securely wipe) a file", " scrub-file <file>\n\nThis command writes patterns over a file to make data retrieval\nmore difficult.\n\nThe file is I<removed> after scrubbing.\n\nIt is an interface to the L<scrub(1)> program. See that\nmanual page for more details.");
- else
- if (strcasecmp (cmd, "scrub_freespace") == 0 || strcasecmp (cmd, "scrub-freespace") == 0)
- pod2text ("scrub-freespace - scrub (securely wipe) free space", " scrub-freespace <dir>\n\nThis command creates the directory C<dir> and then fills it\nwith files until the filesystem is full, and scrubs the files\nas for C<scrub_file>, and deletes them.\nThe intention is to scrub any free space on the partition\ncontaining C<dir>.\n\nIt is an interface to the L<scrub(1)> program. See that\nmanual page for more details.");
- else
- if (strcasecmp (cmd, "mkdtemp") == 0)
- pod2text ("mkdtemp - create a temporary directory", " mkdtemp <template>\n\nThis command creates a temporary directory. The\nC<template> parameter should be a full pathname for the\ntemporary directory name with the final six characters being\n\"XXXXXX\".\n\nFor example: \"/tmp/myprogXXXXXX\" or \"/Temp/myprogXXXXXX\",\nthe second one being suitable for Windows filesystems.\n\nThe name of the temporary directory that was created\nis returned.\n\nThe temporary directory is created with mode 0700\nand is owned by root.\n\nThe caller is responsible for deleting the temporary\ndirectory and its contents after use.\n\nSee also: L<mkdtemp(3)>");
- else
- if (strcasecmp (cmd, "wc_l") == 0 || strcasecmp (cmd, "wc-l") == 0)
- pod2text ("wc-l - count lines in a file", " wc-l <path>\n\nThis command counts the lines in a file, using the\nC<wc -l> external command.");
- else
- if (strcasecmp (cmd, "wc_w") == 0 || strcasecmp (cmd, "wc-w") == 0)
- pod2text ("wc-w - count words in a file", " wc-w <path>\n\nThis command counts the words in a file, using the\nC<wc -w> external command.");
- else
- if (strcasecmp (cmd, "wc_c") == 0 || strcasecmp (cmd, "wc-c") == 0)
- pod2text ("wc-c - count characters in a file", " wc-c <path>\n\nThis command counts the characters in a file, using the\nC<wc -c> external command.");
- else
- if (strcasecmp (cmd, "head") == 0)
- pod2text ("head - return first 10 lines of a file", " head <path>\n\nThis command returns up to the first 10 lines of a file as\na list of strings.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "head_n") == 0 || strcasecmp (cmd, "head-n") == 0)
- pod2text ("head-n - return first N lines of a file", " head-n <nrlines> <path>\n\nIf the parameter C<nrlines> is a positive number, this returns the first\nC<nrlines> lines of the file C<path>.\n\nIf the parameter C<nrlines> is a negative number, this returns lines\nfrom the file C<path>, excluding the last C<nrlines> lines.\n\nIf the parameter C<nrlines> is zero, this returns an empty list.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "tail") == 0)
- pod2text ("tail - return last 10 lines of a file", " tail <path>\n\nThis command returns up to the last 10 lines of a file as\na list of strings.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "tail_n") == 0 || strcasecmp (cmd, "tail-n") == 0)
- pod2text ("tail-n - return last N lines of a file", " tail-n <nrlines> <path>\n\nIf the parameter C<nrlines> is a positive number, this returns the last\nC<nrlines> lines of the file C<path>.\n\nIf the parameter C<nrlines> is a negative number, this returns lines\nfrom the file C<path>, starting with the C<-nrlines>th line.\n\nIf the parameter C<nrlines> is zero, this returns an empty list.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP.");
- else
- if (strcasecmp (cmd, "df") == 0)
- pod2text ("df - report file system disk space usage", " df\n\nThis command runs the C<df> command to report disk space used.\n\nThis command is mostly useful for interactive sessions. It\nis I<not> intended that you try to parse the output string.\nUse C<statvfs> from programs.");
- else
- if (strcasecmp (cmd, "df_h") == 0 || strcasecmp (cmd, "df-h") == 0)
- pod2text ("df-h - report file system disk space usage (human readable)", " df-h\n\nThis command runs the C<df -h> command to report disk space used\nin human-readable format.\n\nThis command is mostly useful for interactive sessions. It\nis I<not> intended that you try to parse the output string.\nUse C<statvfs> from programs.");
- else
- if (strcasecmp (cmd, "du") == 0)
- pod2text ("du - estimate file space usage", " du <path>\n\nThis command runs the C<du -s> command to estimate file space\nusage for C<path>.\n\nC<path> can be a file or a directory. If C<path> is a directory\nthen the estimate includes the contents of the directory and all\nsubdirectories (recursively).\n\nThe result is the estimated size in I<kilobytes>\n(ie. units of 1024 bytes).");
- else
- if (strcasecmp (cmd, "initrd_list") == 0 || strcasecmp (cmd, "initrd-list") == 0)
- pod2text ("initrd-list - list files in an initrd", " initrd-list <path>\n\nThis command lists out files contained in an initrd.\n\nThe files are listed without any initial C</> character. The\nfiles are listed in the order they appear (not necessarily\nalphabetical). Directory names are listed as separate items.\n\nOld Linux kernels (2.4 and earlier) used a compressed ext2\nfilesystem as initrd. We I<only> support the newer initramfs\nformat (compressed cpio files).");
- else
- if (strcasecmp (cmd, "mount_loop") == 0 || strcasecmp (cmd, "mount-loop") == 0)
- pod2text ("mount-loop - mount a file using the loop device", " mount-loop <file> <mountpoint>\n\nThis command lets you mount C<file> (a filesystem image\nin a file) on a mount point. It is entirely equivalent to\nthe command C<mount -o loop file mountpoint>.");
- else
- if (strcasecmp (cmd, "mkswap") == 0)
- pod2text ("mkswap - create a swap partition", " mkswap <device>\n\nCreate a swap partition on C<device>.");
- else
- if (strcasecmp (cmd, "mkswap_L") == 0 || strcasecmp (cmd, "mkswap-L") == 0)
- pod2text ("mkswap-L - create a swap partition with a label", " mkswap-L <label> <device>\n\nCreate a swap partition on C<device> with label C<label>.");
- else
- if (strcasecmp (cmd, "mkswap_U") == 0 || strcasecmp (cmd, "mkswap-U") == 0)
- pod2text ("mkswap-U - create a swap partition with an explicit UUID", " mkswap-U <uuid> <device>\n\nCreate a swap partition on C<device> with UUID C<uuid>.");
- else
- if (strcasecmp (cmd, "mknod") == 0)
- pod2text ("mknod - make block, character or FIFO devices", " mknod <mode> <devmajor> <devminor> <path>\n\nThis call creates block or character special devices, or\nnamed pipes (FIFOs).\n\nThe C<mode> parameter should be the mode, using the standard\nconstants. C<devmajor> and C<devminor> are the\ndevice major and minor numbers, only used when creating block\nand character special devices.");
- else
- if (strcasecmp (cmd, "mkfifo") == 0)
- pod2text ("mkfifo - make FIFO (named pipe)", " mkfifo <mode> <path>\n\nThis call creates a FIFO (named pipe) called C<path> with\nmode C<mode>. It is just a convenient wrapper around\nC<mknod>.");
- else
- if (strcasecmp (cmd, "mknod_b") == 0 || strcasecmp (cmd, "mknod-b") == 0)
- pod2text ("mknod-b - make block device node", " mknod-b <mode> <devmajor> <devminor> <path>\n\nThis call creates a block device node called C<path> with\nmode C<mode> and device major/minor C<devmajor> and C<devminor>.\nIt is just a convenient wrapper around C<mknod>.");
- else
- if (strcasecmp (cmd, "mknod_c") == 0 || strcasecmp (cmd, "mknod-c") == 0)
- pod2text ("mknod-c - make char device node", " mknod-c <mode> <devmajor> <devminor> <path>\n\nThis call creates a char device node called C<path> with\nmode C<mode> and device major/minor C<devmajor> and C<devminor>.\nIt is just a convenient wrapper around C<mknod>.");
- else
- if (strcasecmp (cmd, "umask") == 0)
- pod2text ("umask - set file mode creation mask (umask)", " umask <mask>\n\nThis function sets the mask used for creating new files and\ndevice nodes to C<mask & 0777>.\n\nTypical umask values would be C<022> which creates new files\nwith permissions like \"-rw-r--r--\" or \"-rwxr-xr-x\", and\nC<002> which creates new files with permissions like\n\"-rw-rw-r--\" or \"-rwxrwxr-x\".\n\nThe default umask is C<022>. This is important because it\nmeans that directories and device nodes will be created with\nC<0644> or C<0755> mode even if you specify C<0777>.\n\nSee also L<umask(2)>, C<mknod>, C<mkdir>.\n\nThis call returns the previous umask.");
- else
- if (strcasecmp (cmd, "readdir") == 0)
- pod2text ("readdir - read directories entries", " readdir <dir>\n\nThis returns the list of directory entries in directory C<dir>.\n\nAll entries in the directory are returned, including C<.> and\nC<..>. The entries are I<not> sorted, but returned in the same\norder as the underlying filesystem.\n\nThis function is primarily intended for use by programs. To\nget a simple list of names, use C<ls>. To get a printable\ndirectory for human consumption, use C<ll>.");
- else
- display_builtin_command (cmd);
-}
-
-static void print_pv (struct guestfs_lvm_pv *pv)
-{
- int i;
-
- printf ("pv_name: %s\n", pv->pv_name);
- printf ("pv_uuid: ");
- for (i = 0; i < 32; ++i)
- printf ("%c", pv->pv_uuid[i]);
- printf ("\n");
- printf ("pv_fmt: %s\n", pv->pv_fmt);
- printf ("pv_size: %" PRIu64 "\n", pv->pv_size);
- printf ("dev_size: %" PRIu64 "\n", pv->dev_size);
- printf ("pv_free: %" PRIu64 "\n", pv->pv_free);
- printf ("pv_used: %" PRIu64 "\n", pv->pv_used);
- printf ("pv_attr: %s\n", pv->pv_attr);
- printf ("pv_pe_count: %" PRIi64 "\n", pv->pv_pe_count);
- printf ("pv_pe_alloc_count: %" PRIi64 "\n", pv->pv_pe_alloc_count);
- printf ("pv_tags: %s\n", pv->pv_tags);
- printf ("pe_start: %" PRIu64 "\n", pv->pe_start);
- printf ("pv_mda_count: %" PRIi64 "\n", pv->pv_mda_count);
- printf ("pv_mda_free: %" PRIu64 "\n", pv->pv_mda_free);
-}
-
-static void print_pv_list (struct guestfs_lvm_pv_list *pvs)
-{
- int i;
-
- for (i = 0; i < pvs->len; ++i)
- print_pv (&pvs->val[i]);
-}
-
-static void print_vg (struct guestfs_lvm_vg *vg)
-{
- int i;
-
- printf ("vg_name: %s\n", vg->vg_name);
- printf ("vg_uuid: ");
- for (i = 0; i < 32; ++i)
- printf ("%c", vg->vg_uuid[i]);
- printf ("\n");
- printf ("vg_fmt: %s\n", vg->vg_fmt);
- printf ("vg_attr: %s\n", vg->vg_attr);
- printf ("vg_size: %" PRIu64 "\n", vg->vg_size);
- printf ("vg_free: %" PRIu64 "\n", vg->vg_free);
- printf ("vg_sysid: %s\n", vg->vg_sysid);
- printf ("vg_extent_size: %" PRIu64 "\n", vg->vg_extent_size);
- printf ("vg_extent_count: %" PRIi64 "\n", vg->vg_extent_count);
- printf ("vg_free_count: %" PRIi64 "\n", vg->vg_free_count);
- printf ("max_lv: %" PRIi64 "\n", vg->max_lv);
- printf ("max_pv: %" PRIi64 "\n", vg->max_pv);
- printf ("pv_count: %" PRIi64 "\n", vg->pv_count);
- printf ("lv_count: %" PRIi64 "\n", vg->lv_count);
- printf ("snap_count: %" PRIi64 "\n", vg->snap_count);
- printf ("vg_seqno: %" PRIi64 "\n", vg->vg_seqno);
- printf ("vg_tags: %s\n", vg->vg_tags);
- printf ("vg_mda_count: %" PRIi64 "\n", vg->vg_mda_count);
- printf ("vg_mda_free: %" PRIu64 "\n", vg->vg_mda_free);
-}
-
-static void print_vg_list (struct guestfs_lvm_vg_list *vgs)
-{
- int i;
-
- for (i = 0; i < vgs->len; ++i)
- print_vg (&vgs->val[i]);
-}
-
-static void print_lv (struct guestfs_lvm_lv *lv)
-{
- int i;
-
- printf ("lv_name: %s\n", lv->lv_name);
- printf ("lv_uuid: ");
- for (i = 0; i < 32; ++i)
- printf ("%c", lv->lv_uuid[i]);
- printf ("\n");
- printf ("lv_attr: %s\n", lv->lv_attr);
- printf ("lv_major: %" PRIi64 "\n", lv->lv_major);
- printf ("lv_minor: %" PRIi64 "\n", lv->lv_minor);
- printf ("lv_kernel_major: %" PRIi64 "\n", lv->lv_kernel_major);
- printf ("lv_kernel_minor: %" PRIi64 "\n", lv->lv_kernel_minor);
- printf ("lv_size: %" PRIu64 "\n", lv->lv_size);
- printf ("seg_count: %" PRIi64 "\n", lv->seg_count);
- printf ("origin: %s\n", lv->origin);
- if (lv->snap_percent >= 0) printf ("snap_percent: %g %%\n", lv->snap_percent);
- else printf ("snap_percent: \n");
- if (lv->copy_percent >= 0) printf ("copy_percent: %g %%\n", lv->copy_percent);
- else printf ("copy_percent: \n");
- printf ("move_pv: %s\n", lv->move_pv);
- printf ("lv_tags: %s\n", lv->lv_tags);
- printf ("mirror_log: %s\n", lv->mirror_log);
- printf ("modules: %s\n", lv->modules);
-}
-
-static void print_lv_list (struct guestfs_lvm_lv_list *lvs)
-{
- int i;
-
- for (i = 0; i < lvs->len; ++i)
- print_lv (&lvs->val[i]);
-}
-
-static void print_stat (struct guestfs_stat *stat)
-{
- printf ("dev: %" PRIi64 "\n", stat->dev);
- printf ("ino: %" PRIi64 "\n", stat->ino);
- printf ("mode: %" PRIi64 "\n", stat->mode);
- printf ("nlink: %" PRIi64 "\n", stat->nlink);
- printf ("uid: %" PRIi64 "\n", stat->uid);
- printf ("gid: %" PRIi64 "\n", stat->gid);
- printf ("rdev: %" PRIi64 "\n", stat->rdev);
- printf ("size: %" PRIi64 "\n", stat->size);
- printf ("blksize: %" PRIi64 "\n", stat->blksize);
- printf ("blocks: %" PRIi64 "\n", stat->blocks);
- printf ("atime: %" PRIi64 "\n", stat->atime);
- printf ("mtime: %" PRIi64 "\n", stat->mtime);
- printf ("ctime: %" PRIi64 "\n", stat->ctime);
-}
-
-static void print_statvfs (struct guestfs_statvfs *statvfs)
-{
- printf ("bsize: %" PRIi64 "\n", statvfs->bsize);
- printf ("frsize: %" PRIi64 "\n", statvfs->frsize);
- printf ("blocks: %" PRIi64 "\n", statvfs->blocks);
- printf ("bfree: %" PRIi64 "\n", statvfs->bfree);
- printf ("bavail: %" PRIi64 "\n", statvfs->bavail);
- printf ("files: %" PRIi64 "\n", statvfs->files);
- printf ("ffree: %" PRIi64 "\n", statvfs->ffree);
- printf ("favail: %" PRIi64 "\n", statvfs->favail);
- printf ("fsid: %" PRIi64 "\n", statvfs->fsid);
- printf ("flag: %" PRIi64 "\n", statvfs->flag);
- printf ("namemax: %" PRIi64 "\n", statvfs->namemax);
-}
-
-static void print_dirent (struct guestfs_dirent *dirent)
-{
- printf ("ino: %" PRIi64 "\n", dirent->ino);
- printf ("ftyp: %c\n", dirent->ftyp);
- printf ("name: %s\n", dirent->name);
-}
-
-static void print_dirent_list (struct guestfs_dirent_list *dirents)
-{
- int i;
-
- for (i = 0; i < dirents->len; ++i)
- print_dirent (&dirents->val[i]);
-}
-
-static int run_launch (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = launch (g);
- return r;
-}
-
-static int run_kill_subprocess (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_kill_subprocess (g);
- return r;
-}
-
-static int run_add_drive (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *filename;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- filename = argv[0];
- r = guestfs_add_drive (g, filename);
- return r;
-}
-
-static int run_add_cdrom (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *filename;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- filename = argv[0];
- r = guestfs_add_cdrom (g, filename);
- return r;
-}
-
-static int run_add_drive_ro (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *filename;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- filename = argv[0];
- r = guestfs_add_drive_ro (g, filename);
- return r;
-}
-
-static int run_config (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *qemuparam;
- const char *qemuvalue;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- qemuparam = argv[0];
- qemuvalue = strcmp (argv[1], "") != 0 ? argv[1] : NULL;
- r = guestfs_config (g, qemuparam, qemuvalue);
- return r;
-}
-
-static int run_set_qemu (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *qemu;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- qemu = argv[0];
- r = guestfs_set_qemu (g, qemu);
- return r;
-}
-
-static int run_get_qemu (const char *cmd, int argc, char *argv[])
-{
- const char *r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_get_qemu (g);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- return 0;
-}
-
-static int run_set_path (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_set_path (g, path);
- return r;
-}
-
-static int run_get_path (const char *cmd, int argc, char *argv[])
-{
- const char *r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_get_path (g);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- return 0;
-}
-
-static int run_set_append (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *append;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- append = argv[0];
- r = guestfs_set_append (g, append);
- return r;
-}
-
-static int run_get_append (const char *cmd, int argc, char *argv[])
-{
- const char *r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_get_append (g);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- return 0;
-}
-
-static int run_set_autosync (const char *cmd, int argc, char *argv[])
-{
- int r;
- int autosync;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- autosync = is_true (argv[0]) ? 1 : 0;
- r = guestfs_set_autosync (g, autosync);
- return r;
-}
-
-static int run_get_autosync (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_get_autosync (g);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_set_verbose (const char *cmd, int argc, char *argv[])
-{
- int r;
- int verbose;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- verbose = is_true (argv[0]) ? 1 : 0;
- r = guestfs_set_verbose (g, verbose);
- return r;
-}
-
-static int run_get_verbose (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_get_verbose (g);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_is_ready (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_is_ready (g);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_is_config (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_is_config (g);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_is_launching (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_is_launching (g);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_is_busy (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_is_busy (g);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_get_state (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_get_state (g);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_set_memsize (const char *cmd, int argc, char *argv[])
-{
- int r;
- int memsize;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- memsize = atoi (argv[0]);
- r = guestfs_set_memsize (g, memsize);
- return r;
-}
-
-static int run_get_memsize (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_get_memsize (g);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_mount (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- const char *mountpoint;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- mountpoint = argv[1];
- r = guestfs_mount (g, device, mountpoint);
- return r;
-}
-
-static int run_sync (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_sync (g);
- return r;
-}
-
-static int run_touch (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_touch (g, path);
- return r;
-}
-
-static int run_cat (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_cat (g, path);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_ll (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *directory;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- directory = argv[0];
- r = guestfs_ll (g, directory);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_ls (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *directory;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- directory = argv[0];
- r = guestfs_ls (g, directory);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_list_devices (const char *cmd, int argc, char *argv[])
-{
- char **r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_list_devices (g);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_list_partitions (const char *cmd, int argc, char *argv[])
-{
- char **r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_list_partitions (g);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_pvs (const char *cmd, int argc, char *argv[])
-{
- char **r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_pvs (g);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_vgs (const char *cmd, int argc, char *argv[])
-{
- char **r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_vgs (g);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_lvs (const char *cmd, int argc, char *argv[])
-{
- char **r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_lvs (g);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_pvs_full (const char *cmd, int argc, char *argv[])
-{
- struct guestfs_lvm_pv_list *r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_pvs_full (g);
- if (r == NULL) return -1;
- print_pv_list (r);
- guestfs_free_lvm_pv_list (r);
- return 0;
-}
-
-static int run_vgs_full (const char *cmd, int argc, char *argv[])
-{
- struct guestfs_lvm_vg_list *r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_vgs_full (g);
- if (r == NULL) return -1;
- print_vg_list (r);
- guestfs_free_lvm_vg_list (r);
- return 0;
-}
-
-static int run_lvs_full (const char *cmd, int argc, char *argv[])
-{
- struct guestfs_lvm_lv_list *r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_lvs_full (g);
- if (r == NULL) return -1;
- print_lv_list (r);
- guestfs_free_lvm_lv_list (r);
- return 0;
-}
-
-static int run_read_lines (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_read_lines (g, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_aug_init (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *root;
- int flags;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- root = argv[0];
- flags = atoi (argv[1]);
- r = guestfs_aug_init (g, root, flags);
- return r;
-}
-
-static int run_aug_close (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_aug_close (g);
- return r;
-}
-
-static int run_aug_defvar (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *name;
- const char *expr;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- name = argv[0];
- expr = strcmp (argv[1], "") != 0 ? argv[1] : NULL;
- r = guestfs_aug_defvar (g, name, expr);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_aug_defnode (const char *cmd, int argc, char *argv[])
-{
- struct guestfs_int_bool *r;
- const char *name;
- const char *expr;
- const char *val;
- if (argc != 3) {
- fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- name = argv[0];
- expr = argv[1];
- val = argv[2];
- r = guestfs_aug_defnode (g, name, expr, val);
- if (r == NULL) return -1;
- printf ("%d, %s\n", r->i,
- r->b ? "true" : "false");
- guestfs_free_int_bool (r);
- return 0;
-}
-
-static int run_aug_get (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_aug_get (g, path);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_aug_set (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- const char *val;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- val = argv[1];
- r = guestfs_aug_set (g, path, val);
- return r;
-}
-
-static int run_aug_insert (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- const char *label;
- int before;
- if (argc != 3) {
- fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- label = argv[1];
- before = is_true (argv[2]) ? 1 : 0;
- r = guestfs_aug_insert (g, path, label, before);
- return r;
-}
-
-static int run_aug_rm (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_aug_rm (g, path);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_aug_mv (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *src;
- const char *dest;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- src = argv[0];
- dest = argv[1];
- r = guestfs_aug_mv (g, src, dest);
- return r;
-}
-
-static int run_aug_match (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_aug_match (g, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_aug_save (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_aug_save (g);
- return r;
-}
-
-static int run_aug_load (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_aug_load (g);
- return r;
-}
-
-static int run_aug_ls (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_aug_ls (g, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_rm (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_rm (g, path);
- return r;
-}
-
-static int run_rmdir (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_rmdir (g, path);
- return r;
-}
-
-static int run_rm_rf (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_rm_rf (g, path);
- return r;
-}
-
-static int run_mkdir (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_mkdir (g, path);
- return r;
-}
-
-static int run_mkdir_p (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_mkdir_p (g, path);
- return r;
-}
-
-static int run_chmod (const char *cmd, int argc, char *argv[])
-{
- int r;
- int mode;
- const char *path;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- mode = atoi (argv[0]);
- path = argv[1];
- r = guestfs_chmod (g, mode, path);
- return r;
-}
-
-static int run_chown (const char *cmd, int argc, char *argv[])
-{
- int r;
- int owner;
- int group;
- const char *path;
- if (argc != 3) {
- fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- owner = atoi (argv[0]);
- group = atoi (argv[1]);
- path = argv[2];
- r = guestfs_chown (g, owner, group, path);
- return r;
-}
-
-static int run_exists (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_exists (g, path);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_is_file (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_is_file (g, path);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_is_dir (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_is_dir (g, path);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_pvcreate (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_pvcreate (g, device);
- return r;
-}
-
-static int run_vgcreate (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *volgroup;
- char **physvols;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- volgroup = argv[0];
- physvols = parse_string_list (argv[1]);
- r = guestfs_vgcreate (g, volgroup, physvols);
- return r;
-}
-
-static int run_lvcreate (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *logvol;
- const char *volgroup;
- int mbytes;
- if (argc != 3) {
- fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- logvol = argv[0];
- volgroup = argv[1];
- mbytes = atoi (argv[2]);
- r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
- return r;
-}
-
-static int run_mkfs (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *fstype;
- const char *device;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- fstype = argv[0];
- device = argv[1];
- r = guestfs_mkfs (g, fstype, device);
- return r;
-}
-
-static int run_sfdisk (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- int cyls;
- int heads;
- int sectors;
- char **lines;
- if (argc != 5) {
- fprintf (stderr, "%s should have 5 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- cyls = atoi (argv[1]);
- heads = atoi (argv[2]);
- sectors = atoi (argv[3]);
- lines = parse_string_list (argv[4]);
- r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
- return r;
-}
-
-static int run_write_file (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- const char *content;
- int size;
- if (argc != 3) {
- fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- content = argv[1];
- size = atoi (argv[2]);
- r = guestfs_write_file (g, path, content, size);
- return r;
-}
-
-static int run_umount (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *pathordevice;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- pathordevice = argv[0];
- r = guestfs_umount (g, pathordevice);
- return r;
-}
-
-static int run_mounts (const char *cmd, int argc, char *argv[])
-{
- char **r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_mounts (g);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_umount_all (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_umount_all (g);
- return r;
-}
-
-static int run_lvm_remove_all (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_lvm_remove_all (g);
- return r;
-}
-
-static int run_file (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_file (g, path);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_command (const char *cmd, int argc, char *argv[])
-{
- char *r;
- char **arguments;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- arguments = parse_string_list (argv[0]);
- r = guestfs_command (g, arguments);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_command_lines (const char *cmd, int argc, char *argv[])
-{
- char **r;
- char **arguments;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- arguments = parse_string_list (argv[0]);
- r = guestfs_command_lines (g, arguments);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_stat (const char *cmd, int argc, char *argv[])
-{
- struct guestfs_stat *r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_stat (g, path);
- if (r == NULL) return -1;
- print_stat (r);
- free (r);
- return 0;
-}
-
-static int run_lstat (const char *cmd, int argc, char *argv[])
-{
- struct guestfs_stat *r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_lstat (g, path);
- if (r == NULL) return -1;
- print_stat (r);
- free (r);
- return 0;
-}
-
-static int run_statvfs (const char *cmd, int argc, char *argv[])
-{
- struct guestfs_statvfs *r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_statvfs (g, path);
- if (r == NULL) return -1;
- print_statvfs (r);
- free (r);
- return 0;
-}
-
-static int run_tune2fs_l (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_tune2fs_l (g, device);
- if (r == NULL) return -1;
- print_table (r);
- free_strings (r);
- return 0;
-}
-
-static int run_blockdev_setro (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_blockdev_setro (g, device);
- return r;
-}
-
-static int run_blockdev_setrw (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_blockdev_setrw (g, device);
- return r;
-}
-
-static int run_blockdev_getro (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_blockdev_getro (g, device);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_blockdev_getss (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_blockdev_getss (g, device);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_blockdev_getbsz (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_blockdev_getbsz (g, device);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_blockdev_setbsz (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- int blocksize;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- blocksize = atoi (argv[1]);
- r = guestfs_blockdev_setbsz (g, device, blocksize);
- return r;
-}
-
-static int run_blockdev_getsz (const char *cmd, int argc, char *argv[])
-{
- int64_t r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_blockdev_getsz (g, device);
- if (r == -1) return -1;
- printf ("%" PRIi64 "\n", r);
- return 0;
-}
-
-static int run_blockdev_getsize64 (const char *cmd, int argc, char *argv[])
-{
- int64_t r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_blockdev_getsize64 (g, device);
- if (r == -1) return -1;
- printf ("%" PRIi64 "\n", r);
- return 0;
-}
-
-static int run_blockdev_flushbufs (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_blockdev_flushbufs (g, device);
- return r;
-}
-
-static int run_blockdev_rereadpt (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_blockdev_rereadpt (g, device);
- return r;
-}
-
-static int run_upload (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *filename;
- const char *remotefilename;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- filename = strcmp (argv[0], "-") != 0 ? argv[0] : "/dev/stdin";
- remotefilename = argv[1];
- r = guestfs_upload (g, filename, remotefilename);
- return r;
-}
-
-static int run_download (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *remotefilename;
- const char *filename;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- remotefilename = argv[0];
- filename = strcmp (argv[1], "-") != 0 ? argv[1] : "/dev/stdout";
- r = guestfs_download (g, remotefilename, filename);
- return r;
-}
-
-static int run_checksum (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *csumtype;
- const char *path;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- csumtype = argv[0];
- path = argv[1];
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_tar_in (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *tarfile;
- const char *directory;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- tarfile = strcmp (argv[0], "-") != 0 ? argv[0] : "/dev/stdin";
- directory = argv[1];
- r = guestfs_tar_in (g, tarfile, directory);
- return r;
-}
-
-static int run_tar_out (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *directory;
- const char *tarfile;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- directory = argv[0];
- tarfile = strcmp (argv[1], "-") != 0 ? argv[1] : "/dev/stdout";
- r = guestfs_tar_out (g, directory, tarfile);
- return r;
-}
-
-static int run_tgz_in (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *tarball;
- const char *directory;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- tarball = strcmp (argv[0], "-") != 0 ? argv[0] : "/dev/stdin";
- directory = argv[1];
- r = guestfs_tgz_in (g, tarball, directory);
- return r;
-}
-
-static int run_tgz_out (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *directory;
- const char *tarball;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- directory = argv[0];
- tarball = strcmp (argv[1], "-") != 0 ? argv[1] : "/dev/stdout";
- r = guestfs_tgz_out (g, directory, tarball);
- return r;
-}
-
-static int run_mount_ro (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- const char *mountpoint;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- mountpoint = argv[1];
- r = guestfs_mount_ro (g, device, mountpoint);
- return r;
-}
-
-static int run_mount_options (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *options;
- const char *device;
- const char *mountpoint;
- if (argc != 3) {
- fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- options = argv[0];
- device = argv[1];
- mountpoint = argv[2];
- r = guestfs_mount_options (g, options, device, mountpoint);
- return r;
-}
-
-static int run_mount_vfs (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *options;
- const char *vfstype;
- const char *device;
- const char *mountpoint;
- if (argc != 4) {
- fprintf (stderr, "%s should have 4 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- options = argv[0];
- vfstype = argv[1];
- device = argv[2];
- mountpoint = argv[3];
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- return r;
-}
-
-static int run_debug (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *subcmd;
- char **extraargs;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- subcmd = argv[0];
- extraargs = parse_string_list (argv[1]);
- r = guestfs_debug (g, subcmd, extraargs);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_lvremove (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_lvremove (g, device);
- return r;
-}
-
-static int run_vgremove (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *vgname;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- vgname = argv[0];
- r = guestfs_vgremove (g, vgname);
- return r;
-}
-
-static int run_pvremove (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_pvremove (g, device);
- return r;
-}
-
-static int run_set_e2label (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- const char *label;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- label = argv[1];
- r = guestfs_set_e2label (g, device, label);
- return r;
-}
-
-static int run_get_e2label (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_get_e2label (g, device);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_set_e2uuid (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- const char *uuid;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- uuid = argv[1];
- r = guestfs_set_e2uuid (g, device, uuid);
- return r;
-}
-
-static int run_get_e2uuid (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_get_e2uuid (g, device);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_fsck (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *fstype;
- const char *device;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- fstype = argv[0];
- device = argv[1];
- r = guestfs_fsck (g, fstype, device);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_zero (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_zero (g, device);
- return r;
-}
-
-static int run_grub_install (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *root;
- const char *device;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- root = argv[0];
- device = argv[1];
- r = guestfs_grub_install (g, root, device);
- return r;
-}
-
-static int run_cp (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *src;
- const char *dest;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- src = argv[0];
- dest = argv[1];
- r = guestfs_cp (g, src, dest);
- return r;
-}
-
-static int run_cp_a (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *src;
- const char *dest;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- src = argv[0];
- dest = argv[1];
- r = guestfs_cp_a (g, src, dest);
- return r;
-}
-
-static int run_mv (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *src;
- const char *dest;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- src = argv[0];
- dest = argv[1];
- r = guestfs_mv (g, src, dest);
- return r;
-}
-
-static int run_drop_caches (const char *cmd, int argc, char *argv[])
-{
- int r;
- int whattodrop;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- whattodrop = atoi (argv[0]);
- r = guestfs_drop_caches (g, whattodrop);
- return r;
-}
-
-static int run_dmesg (const char *cmd, int argc, char *argv[])
-{
- char *r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_dmesg (g);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_ping_daemon (const char *cmd, int argc, char *argv[])
-{
- int r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_ping_daemon (g);
- return r;
-}
-
-static int run_equal (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *file1;
- const char *file2;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- file1 = argv[0];
- file2 = argv[1];
- r = guestfs_equal (g, file1, file2);
- if (r == -1) return -1;
- if (r) printf ("true\n"); else printf ("false\n");
- return 0;
-}
-
-static int run_strings (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_strings (g, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_strings_e (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *encoding;
- const char *path;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- encoding = argv[0];
- path = argv[1];
- r = guestfs_strings_e (g, encoding, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_hexdump (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_hexdump (g, path);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_zerofree (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_zerofree (g, device);
- return r;
-}
-
-static int run_pvresize (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_pvresize (g, device);
- return r;
-}
-
-static int run_sfdisk_N (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- int partnum;
- int cyls;
- int heads;
- int sectors;
- const char *line;
- if (argc != 6) {
- fprintf (stderr, "%s should have 6 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- partnum = atoi (argv[1]);
- cyls = atoi (argv[2]);
- heads = atoi (argv[3]);
- sectors = atoi (argv[4]);
- line = argv[5];
- r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
- return r;
-}
-
-static int run_sfdisk_l (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_sfdisk_l (g, device);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_sfdisk_kernel_geometry (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_sfdisk_kernel_geometry (g, device);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_sfdisk_disk_geometry (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_sfdisk_disk_geometry (g, device);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_vg_activate_all (const char *cmd, int argc, char *argv[])
-{
- int r;
- int activate;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- activate = is_true (argv[0]) ? 1 : 0;
- r = guestfs_vg_activate_all (g, activate);
- return r;
-}
-
-static int run_vg_activate (const char *cmd, int argc, char *argv[])
-{
- int r;
- int activate;
- char **volgroups;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- activate = is_true (argv[0]) ? 1 : 0;
- volgroups = parse_string_list (argv[1]);
- r = guestfs_vg_activate (g, activate, volgroups);
- return r;
-}
-
-static int run_lvresize (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- int mbytes;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- mbytes = atoi (argv[1]);
- r = guestfs_lvresize (g, device, mbytes);
- return r;
-}
-
-static int run_resize2fs (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_resize2fs (g, device);
- return r;
-}
-
-static int run_find (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *directory;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- directory = argv[0];
- r = guestfs_find (g, directory);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_e2fsck_f (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_e2fsck_f (g, device);
- return r;
-}
-
-static int run_sleep (const char *cmd, int argc, char *argv[])
-{
- int r;
- int secs;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- secs = atoi (argv[0]);
- r = guestfs_sleep (g, secs);
- return r;
-}
-
-static int run_ntfs_3g_probe (const char *cmd, int argc, char *argv[])
-{
- int r;
- int rw;
- const char *device;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- rw = is_true (argv[0]) ? 1 : 0;
- device = argv[1];
- r = guestfs_ntfs_3g_probe (g, rw, device);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_sh (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *command;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- command = argv[0];
- r = guestfs_sh (g, command);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_sh_lines (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *command;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- command = argv[0];
- r = guestfs_sh_lines (g, command);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_glob_expand (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *pattern;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- pattern = argv[0];
- r = guestfs_glob_expand (g, pattern);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_scrub_device (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_scrub_device (g, device);
- return r;
-}
-
-static int run_scrub_file (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *file;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- file = argv[0];
- r = guestfs_scrub_file (g, file);
- return r;
-}
-
-static int run_scrub_freespace (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *dir;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- dir = argv[0];
- r = guestfs_scrub_freespace (g, dir);
- return r;
-}
-
-static int run_mkdtemp (const char *cmd, int argc, char *argv[])
-{
- char *r;
- const char *template;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- template = argv[0];
- r = guestfs_mkdtemp (g, template);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_wc_l (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_wc_l (g, path);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_wc_w (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_wc_w (g, path);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_wc_c (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_wc_c (g, path);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_head (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_head (g, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_head_n (const char *cmd, int argc, char *argv[])
-{
- char **r;
- int nrlines;
- const char *path;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- nrlines = atoi (argv[0]);
- path = argv[1];
- r = guestfs_head_n (g, nrlines, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_tail (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_tail (g, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_tail_n (const char *cmd, int argc, char *argv[])
-{
- char **r;
- int nrlines;
- const char *path;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- nrlines = atoi (argv[0]);
- path = argv[1];
- r = guestfs_tail_n (g, nrlines, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_df (const char *cmd, int argc, char *argv[])
-{
- char *r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_df (g);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_df_h (const char *cmd, int argc, char *argv[])
-{
- char *r;
- if (argc != 0) {
- fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- r = guestfs_df_h (g);
- if (r == NULL) return -1;
- printf ("%s\n", r);
- free (r);
- return 0;
-}
-
-static int run_du (const char *cmd, int argc, char *argv[])
-{
- int64_t r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_du (g, path);
- if (r == -1) return -1;
- printf ("%" PRIi64 "\n", r);
- return 0;
-}
-
-static int run_initrd_list (const char *cmd, int argc, char *argv[])
-{
- char **r;
- const char *path;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- path = argv[0];
- r = guestfs_initrd_list (g, path);
- if (r == NULL) return -1;
- print_strings (r);
- free_strings (r);
- return 0;
-}
-
-static int run_mount_loop (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *file;
- const char *mountpoint;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- file = argv[0];
- mountpoint = argv[1];
- r = guestfs_mount_loop (g, file, mountpoint);
- return r;
-}
-
-static int run_mkswap (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *device;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- device = argv[0];
- r = guestfs_mkswap (g, device);
- return r;
-}
-
-static int run_mkswap_L (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *label;
- const char *device;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- label = argv[0];
- device = argv[1];
- r = guestfs_mkswap_L (g, label, device);
- return r;
-}
-
-static int run_mkswap_U (const char *cmd, int argc, char *argv[])
-{
- int r;
- const char *uuid;
- const char *device;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- uuid = argv[0];
- device = argv[1];
- r = guestfs_mkswap_U (g, uuid, device);
- return r;
-}
-
-static int run_mknod (const char *cmd, int argc, char *argv[])
-{
- int r;
- int mode;
- int devmajor;
- int devminor;
- const char *path;
- if (argc != 4) {
- fprintf (stderr, "%s should have 4 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- mode = atoi (argv[0]);
- devmajor = atoi (argv[1]);
- devminor = atoi (argv[2]);
- path = argv[3];
- r = guestfs_mknod (g, mode, devmajor, devminor, path);
- return r;
-}
-
-static int run_mkfifo (const char *cmd, int argc, char *argv[])
-{
- int r;
- int mode;
- const char *path;
- if (argc != 2) {
- fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- mode = atoi (argv[0]);
- path = argv[1];
- r = guestfs_mkfifo (g, mode, path);
- return r;
-}
-
-static int run_mknod_b (const char *cmd, int argc, char *argv[])
-{
- int r;
- int mode;
- int devmajor;
- int devminor;
- const char *path;
- if (argc != 4) {
- fprintf (stderr, "%s should have 4 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- mode = atoi (argv[0]);
- devmajor = atoi (argv[1]);
- devminor = atoi (argv[2]);
- path = argv[3];
- r = guestfs_mknod_b (g, mode, devmajor, devminor, path);
- return r;
-}
-
-static int run_mknod_c (const char *cmd, int argc, char *argv[])
-{
- int r;
- int mode;
- int devmajor;
- int devminor;
- const char *path;
- if (argc != 4) {
- fprintf (stderr, "%s should have 4 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- mode = atoi (argv[0]);
- devmajor = atoi (argv[1]);
- devminor = atoi (argv[2]);
- path = argv[3];
- r = guestfs_mknod_c (g, mode, devmajor, devminor, path);
- return r;
-}
-
-static int run_umask (const char *cmd, int argc, char *argv[])
-{
- int r;
- int mask;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- mask = atoi (argv[0]);
- r = guestfs_umask (g, mask);
- if (r == -1) return -1;
- printf ("%d\n", r);
- return 0;
-}
-
-static int run_readdir (const char *cmd, int argc, char *argv[])
-{
- struct guestfs_dirent_list *r;
- const char *dir;
- if (argc != 1) {
- fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
- fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
- return -1;
- }
- dir = argv[0];
- r = guestfs_readdir (g, dir);
- if (r == NULL) return -1;
- print_dirent_list (r);
- guestfs_free_dirent_list (r);
- return 0;
-}
-
-int run_action (const char *cmd, int argc, char *argv[])
-{
- if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
- return run_launch (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "kill_subprocess") == 0 || strcasecmp (cmd, "kill-subprocess") == 0)
- return run_kill_subprocess (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "add_drive") == 0 || strcasecmp (cmd, "add-drive") == 0 || strcasecmp (cmd, "add") == 0)
- return run_add_drive (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "add_cdrom") == 0 || strcasecmp (cmd, "add-cdrom") == 0 || strcasecmp (cmd, "cdrom") == 0)
- return run_add_cdrom (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "add_drive_ro") == 0 || strcasecmp (cmd, "add-drive-ro") == 0 || strcasecmp (cmd, "add-ro") == 0)
- return run_add_drive_ro (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "config") == 0)
- return run_config (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_qemu") == 0 || strcasecmp (cmd, "set-qemu") == 0 || strcasecmp (cmd, "qemu") == 0)
- return run_set_qemu (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_qemu") == 0 || strcasecmp (cmd, "get-qemu") == 0)
- return run_get_qemu (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_path") == 0 || strcasecmp (cmd, "set-path") == 0 || strcasecmp (cmd, "path") == 0)
- return run_set_path (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_path") == 0 || strcasecmp (cmd, "get-path") == 0)
- return run_get_path (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_append") == 0 || strcasecmp (cmd, "set-append") == 0 || strcasecmp (cmd, "append") == 0)
- return run_set_append (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_append") == 0 || strcasecmp (cmd, "get-append") == 0)
- return run_get_append (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0)
- return run_set_autosync (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_autosync") == 0 || strcasecmp (cmd, "get-autosync") == 0)
- return run_get_autosync (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_verbose") == 0 || strcasecmp (cmd, "set-verbose") == 0 || strcasecmp (cmd, "verbose") == 0)
- return run_set_verbose (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_verbose") == 0 || strcasecmp (cmd, "get-verbose") == 0)
- return run_get_verbose (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_ready") == 0 || strcasecmp (cmd, "is-ready") == 0)
- return run_is_ready (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_config") == 0 || strcasecmp (cmd, "is-config") == 0)
- return run_is_config (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_launching") == 0 || strcasecmp (cmd, "is-launching") == 0)
- return run_is_launching (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_busy") == 0 || strcasecmp (cmd, "is-busy") == 0)
- return run_is_busy (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_state") == 0 || strcasecmp (cmd, "get-state") == 0)
- return run_get_state (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_memsize") == 0 || strcasecmp (cmd, "set-memsize") == 0 || strcasecmp (cmd, "memsize") == 0)
- return run_set_memsize (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_memsize") == 0 || strcasecmp (cmd, "get-memsize") == 0)
- return run_get_memsize (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mount") == 0)
- return run_mount (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sync") == 0)
- return run_sync (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "touch") == 0)
- return run_touch (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "cat") == 0)
- return run_cat (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "ll") == 0)
- return run_ll (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "ls") == 0)
- return run_ls (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "list_devices") == 0 || strcasecmp (cmd, "list-devices") == 0)
- return run_list_devices (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "list_partitions") == 0 || strcasecmp (cmd, "list-partitions") == 0)
- return run_list_partitions (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "pvs") == 0)
- return run_pvs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "vgs") == 0)
- return run_vgs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lvs") == 0)
- return run_lvs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "pvs_full") == 0 || strcasecmp (cmd, "pvs-full") == 0)
- return run_pvs_full (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "vgs_full") == 0 || strcasecmp (cmd, "vgs-full") == 0)
- return run_vgs_full (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lvs_full") == 0 || strcasecmp (cmd, "lvs-full") == 0)
- return run_lvs_full (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "read_lines") == 0 || strcasecmp (cmd, "read-lines") == 0)
- return run_read_lines (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_init") == 0 || strcasecmp (cmd, "aug-init") == 0)
- return run_aug_init (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_close") == 0 || strcasecmp (cmd, "aug-close") == 0)
- return run_aug_close (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_defvar") == 0 || strcasecmp (cmd, "aug-defvar") == 0)
- return run_aug_defvar (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_defnode") == 0 || strcasecmp (cmd, "aug-defnode") == 0)
- return run_aug_defnode (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_get") == 0 || strcasecmp (cmd, "aug-get") == 0)
- return run_aug_get (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_set") == 0 || strcasecmp (cmd, "aug-set") == 0)
- return run_aug_set (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_insert") == 0 || strcasecmp (cmd, "aug-insert") == 0)
- return run_aug_insert (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_rm") == 0 || strcasecmp (cmd, "aug-rm") == 0)
- return run_aug_rm (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_mv") == 0 || strcasecmp (cmd, "aug-mv") == 0)
- return run_aug_mv (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_match") == 0 || strcasecmp (cmd, "aug-match") == 0)
- return run_aug_match (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_save") == 0 || strcasecmp (cmd, "aug-save") == 0)
- return run_aug_save (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_load") == 0 || strcasecmp (cmd, "aug-load") == 0)
- return run_aug_load (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_ls") == 0 || strcasecmp (cmd, "aug-ls") == 0)
- return run_aug_ls (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "rm") == 0)
- return run_rm (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "rmdir") == 0)
- return run_rmdir (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "rm_rf") == 0 || strcasecmp (cmd, "rm-rf") == 0)
- return run_rm_rf (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkdir") == 0)
- return run_mkdir (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkdir_p") == 0 || strcasecmp (cmd, "mkdir-p") == 0)
- return run_mkdir_p (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "chmod") == 0)
- return run_chmod (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "chown") == 0)
- return run_chown (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "exists") == 0)
- return run_exists (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_file") == 0 || strcasecmp (cmd, "is-file") == 0)
- return run_is_file (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_dir") == 0 || strcasecmp (cmd, "is-dir") == 0)
- return run_is_dir (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "pvcreate") == 0)
- return run_pvcreate (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "vgcreate") == 0)
- return run_vgcreate (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lvcreate") == 0)
- return run_lvcreate (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkfs") == 0)
- return run_mkfs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sfdisk") == 0)
- return run_sfdisk (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "write_file") == 0 || strcasecmp (cmd, "write-file") == 0)
- return run_write_file (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "umount") == 0 || strcasecmp (cmd, "unmount") == 0)
- return run_umount (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mounts") == 0)
- return run_mounts (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "umount_all") == 0 || strcasecmp (cmd, "umount-all") == 0 || strcasecmp (cmd, "unmount-all") == 0)
- return run_umount_all (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lvm_remove_all") == 0 || strcasecmp (cmd, "lvm-remove-all") == 0)
- return run_lvm_remove_all (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "file") == 0)
- return run_file (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "command") == 0)
- return run_command (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "command_lines") == 0 || strcasecmp (cmd, "command-lines") == 0)
- return run_command_lines (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "stat") == 0)
- return run_stat (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lstat") == 0)
- return run_lstat (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "statvfs") == 0)
- return run_statvfs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "tune2fs_l") == 0 || strcasecmp (cmd, "tune2fs-l") == 0)
- return run_tune2fs_l (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_setro") == 0 || strcasecmp (cmd, "blockdev-setro") == 0)
- return run_blockdev_setro (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_setrw") == 0 || strcasecmp (cmd, "blockdev-setrw") == 0)
- return run_blockdev_setrw (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_getro") == 0 || strcasecmp (cmd, "blockdev-getro") == 0)
- return run_blockdev_getro (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_getss") == 0 || strcasecmp (cmd, "blockdev-getss") == 0)
- return run_blockdev_getss (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_getbsz") == 0 || strcasecmp (cmd, "blockdev-getbsz") == 0)
- return run_blockdev_getbsz (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_setbsz") == 0 || strcasecmp (cmd, "blockdev-setbsz") == 0)
- return run_blockdev_setbsz (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_getsz") == 0 || strcasecmp (cmd, "blockdev-getsz") == 0)
- return run_blockdev_getsz (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_getsize64") == 0 || strcasecmp (cmd, "blockdev-getsize64") == 0)
- return run_blockdev_getsize64 (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_flushbufs") == 0 || strcasecmp (cmd, "blockdev-flushbufs") == 0)
- return run_blockdev_flushbufs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "blockdev_rereadpt") == 0 || strcasecmp (cmd, "blockdev-rereadpt") == 0)
- return run_blockdev_rereadpt (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "upload") == 0)
- return run_upload (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "download") == 0)
- return run_download (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "checksum") == 0)
- return run_checksum (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "tar_in") == 0 || strcasecmp (cmd, "tar-in") == 0)
- return run_tar_in (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "tar_out") == 0 || strcasecmp (cmd, "tar-out") == 0)
- return run_tar_out (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "tgz_in") == 0 || strcasecmp (cmd, "tgz-in") == 0)
- return run_tgz_in (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "tgz_out") == 0 || strcasecmp (cmd, "tgz-out") == 0)
- return run_tgz_out (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mount_ro") == 0 || strcasecmp (cmd, "mount-ro") == 0)
- return run_mount_ro (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mount_options") == 0 || strcasecmp (cmd, "mount-options") == 0)
- return run_mount_options (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mount_vfs") == 0 || strcasecmp (cmd, "mount-vfs") == 0)
- return run_mount_vfs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "debug") == 0)
- return run_debug (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lvremove") == 0)
- return run_lvremove (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "vgremove") == 0)
- return run_vgremove (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "pvremove") == 0)
- return run_pvremove (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_e2label") == 0 || strcasecmp (cmd, "set-e2label") == 0)
- return run_set_e2label (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_e2label") == 0 || strcasecmp (cmd, "get-e2label") == 0)
- return run_get_e2label (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_e2uuid") == 0 || strcasecmp (cmd, "set-e2uuid") == 0)
- return run_set_e2uuid (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_e2uuid") == 0 || strcasecmp (cmd, "get-e2uuid") == 0)
- return run_get_e2uuid (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "fsck") == 0)
- return run_fsck (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "zero") == 0)
- return run_zero (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "grub_install") == 0 || strcasecmp (cmd, "grub-install") == 0)
- return run_grub_install (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "cp") == 0)
- return run_cp (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "cp_a") == 0 || strcasecmp (cmd, "cp-a") == 0)
- return run_cp_a (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mv") == 0)
- return run_mv (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "drop_caches") == 0 || strcasecmp (cmd, "drop-caches") == 0)
- return run_drop_caches (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "dmesg") == 0)
- return run_dmesg (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "ping_daemon") == 0 || strcasecmp (cmd, "ping-daemon") == 0)
- return run_ping_daemon (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "equal") == 0)
- return run_equal (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "strings") == 0)
- return run_strings (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "strings_e") == 0 || strcasecmp (cmd, "strings-e") == 0)
- return run_strings_e (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "hexdump") == 0)
- return run_hexdump (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "zerofree") == 0)
- return run_zerofree (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "pvresize") == 0)
- return run_pvresize (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sfdisk_N") == 0 || strcasecmp (cmd, "sfdisk-N") == 0)
- return run_sfdisk_N (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sfdisk_l") == 0 || strcasecmp (cmd, "sfdisk-l") == 0)
- return run_sfdisk_l (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sfdisk_kernel_geometry") == 0 || strcasecmp (cmd, "sfdisk-kernel-geometry") == 0)
- return run_sfdisk_kernel_geometry (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sfdisk_disk_geometry") == 0 || strcasecmp (cmd, "sfdisk-disk-geometry") == 0)
- return run_sfdisk_disk_geometry (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "vg_activate_all") == 0 || strcasecmp (cmd, "vg-activate-all") == 0)
- return run_vg_activate_all (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "vg_activate") == 0 || strcasecmp (cmd, "vg-activate") == 0)
- return run_vg_activate (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lvresize") == 0)
- return run_lvresize (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "resize2fs") == 0)
- return run_resize2fs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "find") == 0)
- return run_find (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "e2fsck_f") == 0 || strcasecmp (cmd, "e2fsck-f") == 0)
- return run_e2fsck_f (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sleep") == 0)
- return run_sleep (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "ntfs_3g_probe") == 0 || strcasecmp (cmd, "ntfs-3g-probe") == 0)
- return run_ntfs_3g_probe (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sh") == 0)
- return run_sh (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sh_lines") == 0 || strcasecmp (cmd, "sh-lines") == 0)
- return run_sh_lines (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "glob_expand") == 0 || strcasecmp (cmd, "glob-expand") == 0)
- return run_glob_expand (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "scrub_device") == 0 || strcasecmp (cmd, "scrub-device") == 0)
- return run_scrub_device (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "scrub_file") == 0 || strcasecmp (cmd, "scrub-file") == 0)
- return run_scrub_file (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "scrub_freespace") == 0 || strcasecmp (cmd, "scrub-freespace") == 0)
- return run_scrub_freespace (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkdtemp") == 0)
- return run_mkdtemp (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "wc_l") == 0 || strcasecmp (cmd, "wc-l") == 0)
- return run_wc_l (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "wc_w") == 0 || strcasecmp (cmd, "wc-w") == 0)
- return run_wc_w (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "wc_c") == 0 || strcasecmp (cmd, "wc-c") == 0)
- return run_wc_c (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "head") == 0)
- return run_head (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "head_n") == 0 || strcasecmp (cmd, "head-n") == 0)
- return run_head_n (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "tail") == 0)
- return run_tail (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "tail_n") == 0 || strcasecmp (cmd, "tail-n") == 0)
- return run_tail_n (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "df") == 0)
- return run_df (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "df_h") == 0 || strcasecmp (cmd, "df-h") == 0)
- return run_df_h (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "du") == 0)
- return run_du (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "initrd_list") == 0 || strcasecmp (cmd, "initrd-list") == 0)
- return run_initrd_list (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mount_loop") == 0 || strcasecmp (cmd, "mount-loop") == 0)
- return run_mount_loop (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkswap") == 0)
- return run_mkswap (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkswap_L") == 0 || strcasecmp (cmd, "mkswap-L") == 0)
- return run_mkswap_L (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkswap_U") == 0 || strcasecmp (cmd, "mkswap-U") == 0)
- return run_mkswap_U (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mknod") == 0)
- return run_mknod (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkfifo") == 0)
- return run_mkfifo (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mknod_b") == 0 || strcasecmp (cmd, "mknod-b") == 0)
- return run_mknod_b (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mknod_c") == 0 || strcasecmp (cmd, "mknod-c") == 0)
- return run_mknod_c (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "umask") == 0)
- return run_umask (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "readdir") == 0)
- return run_readdir (cmd, argc, argv);
- else
- {
- fprintf (stderr, "%s: unknown command\n", cmd);
- return -1;
- }
- return 0;
-}
-
+++ /dev/null
-/* 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 program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_LIBREADLINE
-#include <readline/readline.h>
-#endif
-
-#include "fish.h"
-
-#ifdef HAVE_LIBREADLINE
-
-static const char *const commands[] = {
- BUILTIN_COMMANDS_FOR_COMPLETION,
- "launch",
- "run",
- "kill-subprocess",
- "add-drive",
- "add",
- "add-cdrom",
- "cdrom",
- "add-drive-ro",
- "add-ro",
- "config",
- "set-qemu",
- "qemu",
- "get-qemu",
- "set-path",
- "path",
- "get-path",
- "set-append",
- "append",
- "get-append",
- "set-autosync",
- "autosync",
- "get-autosync",
- "set-verbose",
- "verbose",
- "get-verbose",
- "is-ready",
- "is-config",
- "is-launching",
- "is-busy",
- "get-state",
- "set-memsize",
- "memsize",
- "get-memsize",
- "mount",
- "sync",
- "touch",
- "cat",
- "ll",
- "ls",
- "list-devices",
- "list-partitions",
- "pvs",
- "vgs",
- "lvs",
- "pvs-full",
- "vgs-full",
- "lvs-full",
- "read-lines",
- "aug-init",
- "aug-close",
- "aug-defvar",
- "aug-defnode",
- "aug-get",
- "aug-set",
- "aug-insert",
- "aug-rm",
- "aug-mv",
- "aug-match",
- "aug-save",
- "aug-load",
- "aug-ls",
- "rm",
- "rmdir",
- "rm-rf",
- "mkdir",
- "mkdir-p",
- "chmod",
- "chown",
- "exists",
- "is-file",
- "is-dir",
- "pvcreate",
- "vgcreate",
- "lvcreate",
- "mkfs",
- "sfdisk",
- "write-file",
- "umount",
- "unmount",
- "mounts",
- "umount-all",
- "unmount-all",
- "lvm-remove-all",
- "file",
- "command",
- "command-lines",
- "stat",
- "lstat",
- "statvfs",
- "tune2fs-l",
- "blockdev-setro",
- "blockdev-setrw",
- "blockdev-getro",
- "blockdev-getss",
- "blockdev-getbsz",
- "blockdev-setbsz",
- "blockdev-getsz",
- "blockdev-getsize64",
- "blockdev-flushbufs",
- "blockdev-rereadpt",
- "upload",
- "download",
- "checksum",
- "tar-in",
- "tar-out",
- "tgz-in",
- "tgz-out",
- "mount-ro",
- "mount-options",
- "mount-vfs",
- "debug",
- "lvremove",
- "vgremove",
- "pvremove",
- "set-e2label",
- "get-e2label",
- "set-e2uuid",
- "get-e2uuid",
- "fsck",
- "zero",
- "grub-install",
- "cp",
- "cp-a",
- "mv",
- "drop-caches",
- "dmesg",
- "ping-daemon",
- "equal",
- "strings",
- "strings-e",
- "hexdump",
- "zerofree",
- "pvresize",
- "sfdisk-N",
- "sfdisk-l",
- "sfdisk-kernel-geometry",
- "sfdisk-disk-geometry",
- "vg-activate-all",
- "vg-activate",
- "lvresize",
- "resize2fs",
- "find",
- "e2fsck-f",
- "sleep",
- "ntfs-3g-probe",
- "sh",
- "sh-lines",
- "glob-expand",
- "scrub-device",
- "scrub-file",
- "scrub-freespace",
- "mkdtemp",
- "wc-l",
- "wc-w",
- "wc-c",
- "head",
- "head-n",
- "tail",
- "tail-n",
- "df",
- "df-h",
- "du",
- "initrd-list",
- "mount-loop",
- "mkswap",
- "mkswap-L",
- "mkswap-U",
- "mknod",
- "mkfifo",
- "mknod-b",
- "mknod-c",
- "umask",
- "readdir",
- NULL
-};
-
-static char *
-generator (const char *text, int state)
-{
- static int index, len;
- const char *name;
-
- if (!state) {
- index = 0;
- len = strlen (text);
- }
-
- rl_attempted_completion_over = 1;
-
- while ((name = commands[index]) != NULL) {
- index++;
- if (strncasecmp (name, text, len) == 0)
- return strdup (name);
- }
-
- return NULL;
-}
-
-#endif /* HAVE_LIBREADLINE */
-
-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;
-}
+++ /dev/null
-=head2 add-cdrom | cdrom
-
- add-cdrom filename
-
-This function adds a virtual CD-ROM disk image to the guest.
-
-This is equivalent to the qemu parameter C<-cdrom filename>.
-
-Note that this call checks for the existence of C<filename>. This
-stops you from specifying other types of drive which are supported
-by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
-the general C<config> call instead.
-
-=head2 add-drive | add
-
- add-drive filename
-
-This function adds a virtual machine disk image C<filename> to the
-guest. The first time you call this function, the disk appears as IDE
-disk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and
-so on.
-
-You don't necessarily need to be root when using libguestfs. However
-you obviously do need sufficient permissions to access the filename
-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,cache=off,if=virtio>.
-
-Note that this call checks for the existence of C<filename>. This
-stops you from specifying other types of drive which are supported
-by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
-the general C<config> call instead.
-
-=head2 add-drive-ro | add-ro
-
- add-drive-ro filename
-
-This adds a drive in snapshot mode, making it effectively
-read-only.
-
-Note that writes to the device are allowed, and will be seen for
-the duration of the guestfs handle, but they are written
-to a temporary file which is discarded as soon as the guestfs
-handle is closed. We don't currently have any method to enable
-changes to be committed, although qemu can support this.
-
-This is equivalent to the qemu parameter
-C<-drive file=filename,snapshot=on,if=virtio>.
-
-Note that this call checks for the existence of C<filename>. This
-stops you from specifying other types of drive which are supported
-by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
-the general C<config> call instead.
-
-=head2 aug-close
-
- aug-close
-
-Close the current Augeas handle and free up any resources
-used by it. After calling this, you have to call
-C<aug-init> again before you can use any other
-Augeas functions.
-
-=head2 aug-defnode
-
- aug-defnode name expr val
-
-Defines a variable C<name> whose value is the result of
-evaluating C<expr>.
-
-If C<expr> evaluates to an empty nodeset, a node is created,
-equivalent to calling C<aug-set> C<expr>, C<value>.
-C<name> will be the nodeset containing that single node.
-
-On success this returns a pair containing the
-number of nodes in the nodeset, and a boolean flag
-if a node was created.
-
-=head2 aug-defvar
-
- aug-defvar name expr
-
-Defines an Augeas variable C<name> whose value is the result
-of evaluating C<expr>. If C<expr> is NULL, then C<name> is
-undefined.
-
-On success this returns the number of nodes in C<expr>, or
-C<0> if C<expr> evaluates to something which is not a nodeset.
-
-=head2 aug-get
-
- aug-get path
-
-Look up the value associated with C<path>. If C<path>
-matches exactly one node, the C<value> is returned.
-
-=head2 aug-init
-
- aug-init root flags
-
-Create a new Augeas handle for editing configuration files.
-If there was any previous Augeas handle associated with this
-guestfs session, then it is closed.
-
-You must call this before using any other C<aug-*>
-commands.
-
-C<root> is the filesystem root. C<root> must not be NULL,
-use C</> instead.
-
-The flags are the same as the flags defined in
-E<lt>augeas.hE<gt>, the logical I<or> of the following
-integers:
-
-=over 4
-
-=item C<AUG_SAVE_BACKUP> = 1
-
-Keep the original file with a C<.augsave> extension.
-
-=item C<AUG_SAVE_NEWFILE> = 2
-
-Save changes into a file with extension C<.augnew>, and
-do not overwrite original. Overrides C<AUG_SAVE_BACKUP>.
-
-=item C<AUG_TYPE_CHECK> = 4
-
-Typecheck lenses (can be expensive).
-
-=item C<AUG_NO_STDINC> = 8
-
-Do not use standard load path for modules.
-
-=item C<AUG_SAVE_NOOP> = 16
-
-Make save a no-op, just record what would have been changed.
-
-=item C<AUG_NO_LOAD> = 32
-
-Do not load the tree in C<aug-init>.
-
-=back
-
-To close the handle, you can call C<aug-close>.
-
-To find out more about Augeas, see L<http://augeas.net/>.
-
-=head2 aug-insert
-
- aug-insert path label true|false
-
-Create a new sibling C<label> for C<path>, inserting it into
-the tree before or after C<path> (depending on the boolean
-flag C<before>).
-
-C<path> must match exactly one existing node in the tree, and
-C<label> must be a label, ie. not contain C</>, C<*> or end
-with a bracketed index C<[N]>.
-
-=head2 aug-load
-
- aug-load
-
-Load files into the tree.
-
-See C<aug_load> in the Augeas documentation for the full gory
-details.
-
-=head2 aug-ls
-
- aug-ls path
-
-This is just a shortcut for listing C<aug-match>
-C<path/*> and sorting the resulting nodes into alphabetical order.
-
-=head2 aug-match
-
- aug-match path
-
-Returns a list of paths which match the path expression C<path>.
-The returned paths are sufficiently qualified so that they match
-exactly one node in the current tree.
-
-=head2 aug-mv
-
- aug-mv src dest
-
-Move the node C<src> to C<dest>. C<src> must match exactly
-one node. C<dest> is overwritten if it exists.
-
-=head2 aug-rm
-
- aug-rm path
-
-Remove C<path> and all of its children.
-
-On success this returns the number of entries which were removed.
-
-=head2 aug-save
-
- aug-save
-
-This writes all pending changes to disk.
-
-The flags which were passed to C<aug-init> affect exactly
-how files are saved.
-
-=head2 aug-set
-
- aug-set path val
-
-Set the value associated with C<path> to C<value>.
-
-=head2 blockdev-flushbufs
-
- blockdev-flushbufs device
-
-This tells the kernel to flush internal buffers associated
-with C<device>.
-
-This uses the L<blockdev(8)> command.
-
-=head2 blockdev-getbsz
-
- blockdev-getbsz device
-
-This returns the block size of a device.
-
-(Note this is different from both I<size in blocks> and
-I<filesystem block size>).
-
-This uses the L<blockdev(8)> command.
-
-=head2 blockdev-getro
-
- blockdev-getro device
-
-Returns a boolean indicating if the block device is read-only
-(true if read-only, false if not).
-
-This uses the L<blockdev(8)> command.
-
-=head2 blockdev-getsize64
-
- blockdev-getsize64 device
-
-This returns the size of the device in bytes.
-
-See also C<blockdev-getsz>.
-
-This uses the L<blockdev(8)> command.
-
-=head2 blockdev-getss
-
- blockdev-getss device
-
-This returns the size of sectors on a block device.
-Usually 512, but can be larger for modern devices.
-
-(Note, this is not the size in sectors, use C<blockdev-getsz>
-for that).
-
-This uses the L<blockdev(8)> command.
-
-=head2 blockdev-getsz
-
- blockdev-getsz device
-
-This returns the size of the device in units of 512-byte sectors
-(even if the sectorsize isn't 512 bytes ... weird).
-
-See also C<blockdev-getss> for the real sector size of
-the device, and C<blockdev-getsize64> for the more
-useful I<size in bytes>.
-
-This uses the L<blockdev(8)> command.
-
-=head2 blockdev-rereadpt
-
- blockdev-rereadpt device
-
-Reread the partition table on C<device>.
-
-This uses the L<blockdev(8)> command.
-
-=head2 blockdev-setbsz
-
- blockdev-setbsz device blocksize
-
-This sets the block size of a device.
-
-(Note this is different from both I<size in blocks> and
-I<filesystem block size>).
-
-This uses the L<blockdev(8)> command.
-
-=head2 blockdev-setro
-
- blockdev-setro device
-
-Sets the block device named C<device> to read-only.
-
-This uses the L<blockdev(8)> command.
-
-=head2 blockdev-setrw
-
- blockdev-setrw device
-
-Sets the block device named C<device> to read-write.
-
-This uses the L<blockdev(8)> command.
-
-=head2 cat
-
- cat path
-
-Return the contents of the file named C<path>.
-
-Note that this function cannot correctly handle binary files
-(specifically, files containing C<\0> character which is treated
-as end of string). For those you need to use the C<download>
-function which has a more complex interface.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 checksum
-
- checksum csumtype path
-
-This call computes the MD5, SHAx or CRC checksum of the
-file named C<path>.
-
-The type of checksum to compute is given by the C<csumtype>
-parameter which must have one of the following values:
-
-=over 4
-
-=item C<crc>
-
-Compute the cyclic redundancy check (CRC) specified by POSIX
-for the C<cksum> command.
-
-=item C<md5>
-
-Compute the MD5 hash (using the C<md5sum> program).
-
-=item C<sha1>
-
-Compute the SHA1 hash (using the C<sha1sum> program).
-
-=item C<sha224>
-
-Compute the SHA224 hash (using the C<sha224sum> program).
-
-=item C<sha256>
-
-Compute the SHA256 hash (using the C<sha256sum> program).
-
-=item C<sha384>
-
-Compute the SHA384 hash (using the C<sha384sum> program).
-
-=item C<sha512>
-
-Compute the SHA512 hash (using the C<sha512sum> program).
-
-=back
-
-The checksum is returned as a printable string.
-
-=head2 chmod
-
- chmod mode path
-
-Change the mode (permissions) of C<path> to C<mode>. Only
-numeric modes are supported.
-
-=head2 chown
-
- chown owner group path
-
-Change the file owner to C<owner> and group to C<group>.
-
-Only numeric uid and gid are supported. If you want to use
-names, you will need to locate and parse the password file
-yourself (Augeas support makes this relatively easy).
-
-=head2 command
-
- command 'arguments ...'
-
-This call runs a command from the guest filesystem. The
-filesystem must be mounted, and must contain a compatible
-operating system (ie. something Linux, with the same
-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). Note that
-the command runs directly, and is I<not> invoked via
-the shell (see C<sh>).
-
-The return value is anything printed to I<stdout> by
-the command.
-
-If the command returns a non-zero exit status, then
-this function returns an error message. The error message
-string is the content of I<stderr> from the command.
-
-The C<$PATH> environment variable will contain at least
-C</usr/bin> and C</bin>. If you require a program from
-another location, you should provide the full path in the
-first parameter.
-
-Shared libraries and data files required by the program
-must be available on filesystems which are mounted in the
-correct places. It is the caller's responsibility to ensure
-all filesystems that are needed are mounted at the right
-locations.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 command-lines
-
- command-lines 'arguments ...'
-
-This is the same as C<command>, but splits the
-result into a list of lines.
-
-See also: C<sh-lines>
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 config
-
- config qemuparam qemuvalue
-
-This can be used to add arbitrary qemu command line parameters
-of the form C<-param value>. Actually it's not quite arbitrary - we
-prevent you from setting some parameters which would interfere with
-parameters that we use.
-
-The first character of C<param> string must be a C<-> (dash).
-
-C<value> can be NULL.
-
-=head2 cp
-
- cp src dest
-
-This copies a file from C<src> to C<dest> where C<dest> is
-either a destination filename or destination directory.
-
-=head2 cp-a
-
- cp-a src dest
-
-This copies a file or directory from C<src> to C<dest>
-recursively using the C<cp -a> command.
-
-=head2 debug
-
- debug subcmd 'extraargs ...'
-
-The C<debug> command exposes some internals of
-C<guestfsd> (the guestfs daemon) that runs inside the
-qemu subprocess.
-
-There is no comprehensive help for this command. You have
-to look at the file C<daemon/debug.c> in the libguestfs source
-to find out what you can do.
-
-=head2 df
-
- df
-
-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.
-
-=head2 df-h
-
- df-h
-
-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.
-
-=head2 dmesg
-
- dmesg
-
-This returns the kernel messages (C<dmesg> output) from
-the guest kernel. This is sometimes useful for extended
-debugging of problems.
-
-Another way to get the same information is to enable
-verbose messages with C<set-verbose> or by setting
-the environment variable C<LIBGUESTFS_DEBUG=1> before
-running the program.
-
-=head2 download
-
- download remotefilename (filename|-)
-
-Download file C<remotefilename> and save it as C<filename>
-on the local machine.
-
-C<filename> can also be a named pipe.
-
-See also C<upload>, C<cat>.
-
-Use C<-> instead of a filename to read/write from stdin/stdout.
-
-=head2 drop-caches
-
- drop-caches whattodrop
-
-This instructs the guest kernel to drop its page cache,
-and/or dentries and inode caches. The parameter C<whattodrop>
-tells the kernel what precisely to drop, see
-L<http://linux-mm.org/Drop_Caches>
-
-Setting C<whattodrop> to 3 should drop everything.
-
-This automatically calls L<sync(2)> before the operation,
-so that the maximum guest memory is freed.
-
-=head2 du
-
- du path
-
-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).
-
-=head2 e2fsck-f
-
- e2fsck-f device
-
-This runs C<e2fsck -p -f device>, ie. runs the ext2/ext3
-filesystem checker on C<device>, noninteractively (C<-p>),
-even if the filesystem appears to be clean (C<-f>).
-
-This command is only needed because of C<resize2fs>
-(q.v.). Normally you should use C<fsck>.
-
-=head2 equal
-
- equal file1 file2
-
-This compares the two files C<file1> and C<file2> and returns
-true if their content is exactly equal, or false otherwise.
-
-The external L<cmp(1)> program is used for the comparison.
-
-=head2 exists
-
- exists path
-
-This returns C<true> if and only if there is a file, directory
-(or anything) with the given C<path> name.
-
-See also C<is-file>, C<is-dir>, C<stat>.
-
-=head2 file
-
- file path
-
-This call uses the standard L<file(1)> command to determine
-the type or contents of the file. This also works on devices,
-for example to find out whether a partition contains a filesystem.
-
-The exact command which runs is C<file -bsL path>. Note in
-particular that the filename is not prepended to the output
-(the C<-b> option).
-
-=head2 find
-
- find directory
-
-This command lists out all files and directories, recursively,
-starting at C<directory>. It is essentially equivalent to
-running the shell command C<find directory -print> but some
-post-processing happens on the output, described below.
-
-This returns a list of strings I<without any prefix>. Thus
-if the directory structure was:
-
- /tmp/a
- /tmp/b
- /tmp/c/d
-
-then the returned list from C<find> C</tmp> would be
-4 elements:
-
- a
- b
- c
- c/d
-
-If C<directory> is not a directory, then this command returns
-an error.
-
-The returned list is sorted.
-
-=head2 fsck
-
- fsck fstype device
-
-This runs the filesystem checker (fsck) on C<device> which
-should have filesystem type C<fstype>.
-
-The returned integer is the status. See L<fsck(8)> for the
-list of status codes from C<fsck>.
-
-Notes:
-
-=over 4
-
-=item *
-
-Multiple status codes can be summed together.
-
-=item *
-
-A non-zero return code can mean "success", for example if
-errors have been corrected on the filesystem.
-
-=item *
-
-Checking or repairing NTFS volumes is not supported
-(by linux-ntfs).
-
-=back
-
-This command is entirely equivalent to running C<fsck -a -t fstype device>.
-
-=head2 get-append
-
- get-append
-
-Return the additional kernel options which are added to the
-guest kernel command line.
-
-If C<NULL> then no options are added.
-
-=head2 get-autosync
-
- get-autosync
-
-Get the autosync flag.
-
-=head2 get-e2label
-
- get-e2label device
-
-This returns the ext2/3/4 filesystem label of the filesystem on
-C<device>.
-
-=head2 get-e2uuid
-
- get-e2uuid device
-
-This returns the ext2/3/4 filesystem UUID of the filesystem on
-C<device>.
-
-=head2 get-memsize
-
- get-memsize
-
-This gets the memory size in megabytes allocated to the
-qemu subprocess.
-
-If C<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)>.
-
-=head2 get-path
-
- get-path
-
-Return the current search path.
-
-This is always non-NULL. If it wasn't set already, then this will
-return the default path.
-
-=head2 get-qemu
-
- get-qemu
-
-Return the current qemu binary.
-
-This is always non-NULL. If it wasn't set already, then this will
-return the default qemu binary name.
-
-=head2 get-state
-
- get-state
-
-This returns the current state as an opaque integer. This is
-only useful for printing debug and internal error messages.
-
-For more information on states, see L<guestfs(3)>.
-
-=head2 get-verbose
-
- get-verbose
-
-This returns the verbose messages flag.
-
-=head2 glob-expand
-
- glob-expand pattern
-
-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.
-
-=head2 grub-install
-
- grub-install root device
-
-This command installs GRUB (the Grand Unified Bootloader) on
-C<device>, with the root directory being C<root>.
-
-=head2 head
-
- head path
-
-This command returns up to the first 10 lines of a file as
-a list of strings.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 head-n
-
- head-n nrlines path
-
-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.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 hexdump
-
- hexdump path
-
-This runs C<hexdump -C> on the given C<path>. The result is
-the human-readable, canonical hex dump of the file.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 initrd-list
-
- initrd-list path
-
-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).
-
-=head2 is-busy
-
- is-busy
-
-This returns true iff this handle is busy processing a command
-(in the C<BUSY> state).
-
-For more information on states, see L<guestfs(3)>.
-
-=head2 is-config
-
- is-config
-
-This returns true iff this handle is being configured
-(in the C<CONFIG> state).
-
-For more information on states, see L<guestfs(3)>.
-
-=head2 is-dir
-
- is-dir path
-
-This returns C<true> if and only if there is a directory
-with the given C<path> name. Note that it returns false for
-other objects like files.
-
-See also C<stat>.
-
-=head2 is-file
-
- is-file path
-
-This returns C<true> if and only if there is a file
-with the given C<path> name. Note that it returns false for
-other objects like directories.
-
-See also C<stat>.
-
-=head2 is-launching
-
- is-launching
-
-This returns true iff this handle is launching the subprocess
-(in the C<LAUNCHING> state).
-
-For more information on states, see L<guestfs(3)>.
-
-=head2 is-ready
-
- is-ready
-
-This returns true iff this handle is ready to accept commands
-(in the C<READY> state).
-
-For more information on states, see L<guestfs(3)>.
-
-=head2 kill-subprocess
-
- kill-subprocess
-
-This kills the qemu subprocess. You should never need to call this.
-
-=head2 launch | run
-
- launch
-
-Internally libguestfs is implemented by running a virtual machine
-using L<qemu(1)>.
-
-You should call this after configuring the handle
-(eg. adding drives) but before performing any actions.
-
-=head2 list-devices
-
- list-devices
-
-List all the block devices.
-
-The full block device names are returned, eg. C</dev/sda>
-
-=head2 list-partitions
-
- list-partitions
-
-List all the partitions detected on all block devices.
-
-The full partition device names are returned, eg. C</dev/sda1>
-
-This does not return logical volumes. For that you will need to
-call C<lvs>.
-
-=head2 ll
-
- ll directory
-
-List the files in C<directory> (relative to the root directory,
-there is no cwd) in the format of 'ls -la'.
-
-This command is mostly useful for interactive sessions. It
-is I<not> intended that you try to parse the output string.
-
-=head2 ls
-
- ls directory
-
-List the files in C<directory> (relative to the root directory,
-there is no cwd). The '.' and '..' entries are not returned, but
-hidden files are shown.
-
-This command is mostly useful for interactive sessions. Programs
-should probably use C<readdir> instead.
-
-=head2 lstat
-
- lstat path
-
-Returns file information for the given C<path>.
-
-This is the same as C<stat> except that if C<path>
-is a symbolic link, then the link is stat-ed, not the file it
-refers to.
-
-This is the same as the C<lstat(2)> system call.
-
-=head2 lvcreate
-
- lvcreate logvol volgroup mbytes
-
-This creates an LVM volume group called C<logvol>
-on the volume group C<volgroup>, with C<size> megabytes.
-
-=head2 lvm-remove-all
-
- lvm-remove-all
-
-This command removes all LVM logical volumes, volume groups
-and physical volumes.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=head2 lvremove
-
- lvremove device
-
-Remove an LVM logical volume C<device>, where C<device> is
-the path to the LV, such as C</dev/VG/LV>.
-
-You can also remove all LVs in a volume group by specifying
-the VG name, C</dev/VG>.
-
-=head2 lvresize
-
- lvresize device mbytes
-
-This resizes (expands or shrinks) an existing LVM logical
-volume to C<mbytes>. When reducing, data in the reduced part
-is lost.
-
-=head2 lvs
-
- lvs
-
-List all the logical volumes detected. This is the equivalent
-of the L<lvs(8)> command.
-
-This returns a list of the logical volume device names
-(eg. C</dev/VolGroup00/LogVol00>).
-
-See also C<lvs-full>.
-
-=head2 lvs-full
-
- lvs-full
-
-List all the logical volumes detected. This is the equivalent
-of the L<lvs(8)> command. The "full" version includes all fields.
-
-=head2 mkdir
-
- mkdir path
-
-Create a directory named C<path>.
-
-=head2 mkdir-p
-
- mkdir-p path
-
-Create a directory named C<path>, creating any parent directories
-as necessary. This is like the C<mkdir -p> shell command.
-
-=head2 mkdtemp
-
- mkdtemp template
-
-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)>
-
-=head2 mkfifo
-
- mkfifo mode path
-
-This call creates a FIFO (named pipe) called C<path> with
-mode C<mode>. It is just a convenient wrapper around
-C<mknod>.
-
-=head2 mkfs
-
- mkfs fstype device
-
-This creates a filesystem on C<device> (usually a partition
-or LVM logical volume). The filesystem type is C<fstype>, for
-example C<ext3>.
-
-=head2 mknod
-
- mknod mode devmajor devminor path
-
-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.
-
-=head2 mknod-b
-
- mknod-b mode devmajor devminor path
-
-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<mknod>.
-
-=head2 mknod-c
-
- mknod-c mode devmajor devminor path
-
-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<mknod>.
-
-=head2 mkswap
-
- mkswap device
-
-Create a swap partition on C<device>.
-
-=head2 mkswap-L
-
- mkswap-L label device
-
-Create a swap partition on C<device> with label C<label>.
-
-=head2 mkswap-U
-
- mkswap-U uuid device
-
-Create a swap partition on C<device> with UUID C<uuid>.
-
-=head2 mount
-
- mount device mountpoint
-
-Mount a guest disk at a position in the filesystem. Block devices
-are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
-the guest. If those block devices contain partitions, they will have
-the usual names (eg. C</dev/sda1>). Also LVM C</dev/VG/LV>-style
-names can be used.
-
-The rules are the same as for L<mount(2)>: A filesystem must
-first be mounted on C</> before others can be mounted. Other
-filesystems can only be mounted on directories which already
-exist.
-
-The mounted filesystem is writable, if we have sufficient permissions
-on the underlying device.
-
-The filesystem options C<sync> and C<noatime> are set with this
-call, in order to improve reliability.
-
-=head2 mount-loop
-
- mount-loop file mountpoint
-
-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>.
-
-=head2 mount-options
-
- mount-options options device mountpoint
-
-This is the same as the C<mount> command, but it
-allows you to set the mount options as for the
-L<mount(8)> I<-o> flag.
-
-=head2 mount-ro
-
- mount-ro device mountpoint
-
-This is the same as the C<mount> command, but it
-mounts the filesystem with the read-only (I<-o ro>) flag.
-
-=head2 mount-vfs
-
- mount-vfs options vfstype device mountpoint
-
-This is the same as the C<mount> command, but it
-allows you to set both the mount options and the vfstype
-as for the L<mount(8)> I<-o> and I<-t> flags.
-
-=head2 mounts
-
- mounts
-
-This returns the list of currently mounted filesystems. It returns
-the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
-
-Some internal mounts are not shown.
-
-=head2 mv
-
- mv src dest
-
-This moves a file from C<src> to C<dest> where C<dest> is
-either a destination filename or destination directory.
-
-=head2 ntfs-3g-probe
-
- ntfs-3g-probe true|false device
-
-This command runs the L<ntfs-3g.probe(8)> command which probes
-an NTFS C<device> for mountability. (Not all NTFS volumes can
-be mounted read-write, and some cannot be mounted at all).
-
-C<rw> is a boolean flag. Set it to true if you want to test
-if the volume can be mounted read-write. Set it to false if
-you want to test if the volume can be mounted read-only.
-
-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.
-
-=head2 ping-daemon
-
- ping-daemon
-
-This is a test probe into the guestfs daemon running inside
-the qemu subprocess. Calling this function checks that the
-daemon responds to the ping message, without affecting the daemon
-or attached block device(s) in any other way.
-
-=head2 pvcreate
-
- pvcreate device
-
-This creates an LVM physical volume on the named C<device>,
-where C<device> should usually be a partition name such
-as C</dev/sda1>.
-
-=head2 pvremove
-
- pvremove device
-
-This wipes a physical volume C<device> so that LVM will no longer
-recognise it.
-
-The implementation uses the C<pvremove> command which refuses to
-wipe physical volumes that contain any volume groups, so you have
-to remove those first.
-
-=head2 pvresize
-
- pvresize device
-
-This resizes (expands or shrinks) an existing LVM physical
-volume to match the new size of the underlying device.
-
-=head2 pvs
-
- pvs
-
-List all the physical volumes detected. This is the equivalent
-of the L<pvs(8)> command.
-
-This returns a list of just the device names that contain
-PVs (eg. C</dev/sda2>).
-
-See also C<pvs-full>.
-
-=head2 pvs-full
-
- pvs-full
-
-List all the physical volumes detected. This is the equivalent
-of the L<pvs(8)> command. The "full" version includes all fields.
-
-=head2 read-lines
-
- read-lines path
-
-Return the contents of the file named C<path>.
-
-The file contents are returned as a list of lines. Trailing
-C<LF> and C<CRLF> character sequences are I<not> returned.
-
-Note that this function cannot correctly handle binary files
-(specifically, files containing C<\0> character which is treated
-as end of line). For those you need to use the C<read-file>
-function which has a more complex interface.
-
-=head2 readdir
-
- readdir dir
-
-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<ls>. To get a printable
-directory for human consumption, use C<ll>.
-
-=head2 resize2fs
-
- resize2fs device
-
-This resizes an ext2 or ext3 filesystem to match the size of
-the underlying device.
-
-I<Note:> It is sometimes required that you run C<e2fsck-f>
-on the C<device> before calling this command. For unknown reasons
-C<resize2fs> sometimes gives an error about this and sometimes not.
-In any case, it is always safe to call C<e2fsck-f> before
-calling this function.
-
-=head2 rm
-
- rm path
-
-Remove the single file C<path>.
-
-=head2 rm-rf
-
- rm-rf path
-
-Remove the file or directory C<path>, recursively removing the
-contents if its a directory. This is like the C<rm -rf> shell
-command.
-
-=head2 rmdir
-
- rmdir path
-
-Remove the single directory C<path>.
-
-=head2 scrub-device
-
- scrub-device 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.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=head2 scrub-file
-
- scrub-file 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.
-
-=head2 scrub-freespace
-
- scrub-freespace dir
-
-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<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.
-
-=head2 set-append | append
-
- set-append append
-
-This function is used to add additional options to the
-guest kernel command line.
-
-The default is C<NULL> unless overridden by setting
-C<LIBGUESTFS_APPEND> environment variable.
-
-Setting C<append> to C<NULL> means I<no> additional options
-are passed (libguestfs always adds a few of its own).
-
-=head2 set-autosync | autosync
-
- set-autosync true|false
-
-If C<autosync> is true, this enables autosync. Libguestfs will make a
-best effort attempt to run C<umount-all> followed by
-C<sync> when the handle is closed
-(also if the program exits without closing handles).
-
-This is disabled by default (except in guestfish where it is
-enabled by default).
-
-=head2 set-e2label
-
- set-e2label device label
-
-This sets the ext2/3/4 filesystem label of the filesystem on
-C<device> to C<label>. Filesystem labels are limited to
-16 characters.
-
-You can use either C<tune2fs-l> or C<get-e2label>
-to return the existing label on a filesystem.
-
-=head2 set-e2uuid
-
- set-e2uuid device uuid
-
-This sets the ext2/3/4 filesystem UUID of the filesystem on
-C<device> to C<uuid>. The format of the UUID and alternatives
-such as C<clear>, C<random> and C<time> are described in the
-L<tune2fs(8)> manpage.
-
-You can use either C<tune2fs-l> or C<get-e2uuid>
-to return the existing UUID of a filesystem.
-
-=head2 set-memsize | memsize
-
- set-memsize memsize
-
-This sets the memory size in megabytes allocated to the
-qemu subprocess. This only has any effect if called before
-C<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)>.
-
-=head2 set-path | path
-
- set-path path
-
-Set the path that libguestfs searches for kernel and initrd.img.
-
-The default is C<$libdir/guestfs> unless overridden by setting
-C<LIBGUESTFS_PATH> environment variable.
-
-Setting C<path> to C<NULL> restores the default path.
-
-=head2 set-qemu | qemu
-
- set-qemu qemu
-
-Set the qemu binary that we will use.
-
-The default is chosen when the library was compiled by the
-configure script.
-
-You can also override this by setting the C<LIBGUESTFS_QEMU>
-environment variable.
-
-Setting C<qemu> to C<NULL> restores the default qemu binary.
-
-=head2 set-verbose | verbose
-
- set-verbose true|false
-
-If C<verbose> is true, this turns on verbose messages (to C<stderr>).
-
-Verbose messages are disabled unless the environment variable
-C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
-
-=head2 sfdisk
-
- sfdisk device cyls heads sectors 'lines ...'
-
-This is a direct interface to the L<sfdisk(8)> program for creating
-partitions on block devices.
-
-C<device> should be a block device, for example C</dev/sda>.
-
-C<cyls>, C<heads> and C<sectors> are the number of cylinders, heads
-and sectors on the device, which are passed directly to sfdisk as
-the I<-C>, I<-H> and I<-S> parameters. If you pass C<0> for any
-of these, then the corresponding parameter is omitted. Usually for
-'large' disks, you can just pass C<0> for these, but for small
-(floppy-sized) disks, sfdisk (or rather, the kernel) cannot work
-out the right geometry and you will need to tell it.
-
-C<lines> is a list of lines that we feed to C<sfdisk>. For more
-information refer to the L<sfdisk(8)> manpage.
-
-To create a single partition occupying the whole disk, you would
-pass C<lines> as a single element list, when the single element being
-the string C<,> (comma).
-
-See also: C<sfdisk-l>, C<sfdisk-N>
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=head2 sfdisk-N
-
- sfdisk-N device partnum cyls heads sectors line
-
-This runs L<sfdisk(8)> option to modify just the single
-partition C<n> (note: C<n> counts from 1).
-
-For other parameters, see C<sfdisk>. You should usually
-pass C<0> for the cyls/heads/sectors parameters.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=head2 sfdisk-disk-geometry
-
- sfdisk-disk-geometry device
-
-This displays the disk geometry of C<device> read from the
-partition table. Especially in the case where the underlying
-block device has been resized, this can be different from the
-kernel's idea of the geometry (see C<sfdisk-kernel-geometry>).
-
-The result is in human-readable format, and not designed to
-be parsed.
-
-=head2 sfdisk-kernel-geometry
-
- sfdisk-kernel-geometry device
-
-This displays the kernel's idea of the geometry of C<device>.
-
-The result is in human-readable format, and not designed to
-be parsed.
-
-=head2 sfdisk-l
-
- sfdisk-l device
-
-This displays the partition table on C<device>, in the
-human-readable output of the L<sfdisk(8)> command. It is
-not intended to be parsed.
-
-=head2 sh
-
- sh command
-
-This call runs a command from the guest filesystem via the
-guest's C</bin/sh>.
-
-This is like C<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<command> apply to this call.
-
-=head2 sh-lines
-
- sh-lines command
-
-This is the same as C<sh>, but splits the result
-into a list of lines.
-
-See also: C<command-lines>
-
-=head2 sleep
-
- sleep secs
-
-Sleep for C<secs> seconds.
-
-=head2 stat
-
- stat path
-
-Returns file information for the given C<path>.
-
-This is the same as the C<stat(2)> system call.
-
-=head2 statvfs
-
- statvfs path
-
-Returns file system statistics for any mounted file system.
-C<path> should be a file or directory in the mounted file system
-(typically it is the mount point itself, but it doesn't need to be).
-
-This is the same as the C<statvfs(2)> system call.
-
-=head2 strings
-
- strings path
-
-This runs the L<strings(1)> command on a file and returns
-the list of printable strings found.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 strings-e
-
- strings-e encoding path
-
-This is like the C<strings> command, but allows you to
-specify the encoding.
-
-See the L<strings(1)> manpage for the full list of encodings.
-
-Commonly useful encodings are C<l> (lower case L) which will
-show strings inside Windows/x86 files.
-
-The returned strings are transcoded to UTF-8.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 sync
-
- sync
-
-This syncs the disk, so that any writes are flushed through to the
-underlying disk image.
-
-You should always call this if you have modified a disk image, before
-closing the handle.
-
-=head2 tail
-
- tail path
-
-This command returns up to the last 10 lines of a file as
-a list of strings.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 tail-n
-
- tail-n nrlines path
-
-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.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 tar-in
-
- tar-in (tarfile|-) directory
-
-This command uploads and unpacks local file C<tarfile> (an
-I<uncompressed> tar file) into C<directory>.
-
-To upload a compressed tarball, use C<tgz-in>.
-
-Use C<-> instead of a filename to read/write from stdin/stdout.
-
-=head2 tar-out
-
- tar-out directory (tarfile|-)
-
-This command packs the contents of C<directory> and downloads
-it to local file C<tarfile>.
-
-To download a compressed tarball, use C<tgz-out>.
-
-Use C<-> instead of a filename to read/write from stdin/stdout.
-
-=head2 tgz-in
-
- tgz-in (tarball|-) directory
-
-This command uploads and unpacks local file C<tarball> (a
-I<gzip compressed> tar file) into C<directory>.
-
-To upload an uncompressed tarball, use C<tar-in>.
-
-Use C<-> instead of a filename to read/write from stdin/stdout.
-
-=head2 tgz-out
-
- tgz-out directory (tarball|-)
-
-This command packs the contents of C<directory> and downloads
-it to local file C<tarball>.
-
-To download an uncompressed tarball, use C<tar-out>.
-
-Use C<-> instead of a filename to read/write from stdin/stdout.
-
-=head2 touch
-
- touch path
-
-Touch acts like the L<touch(1)> command. It can be used to
-update the timestamps on a file, or, if the file does not exist,
-to create a new zero-length file.
-
-=head2 tune2fs-l
-
- tune2fs-l device
-
-This returns the contents of the ext2, ext3 or ext4 filesystem
-superblock on C<device>.
-
-It is the same as running C<tune2fs -l device>. See L<tune2fs(8)>
-manpage for more details. The list of fields returned isn't
-clearly defined, and depends on both the version of C<tune2fs>
-that libguestfs was built against, and the filesystem itself.
-
-=head2 umask
-
- umask mask
-
-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<mknod>, C<mkdir>.
-
-This call returns the previous umask.
-
-=head2 umount | unmount
-
- umount pathordevice
-
-This unmounts the given filesystem. The filesystem may be
-specified either by its mountpoint (path) or the device which
-contains the filesystem.
-
-=head2 umount-all | unmount-all
-
- umount-all
-
-This unmounts all mounted filesystems.
-
-Some internal mounts are not unmounted by this call.
-
-=head2 upload
-
- upload (filename|-) remotefilename
-
-Upload local file C<filename> to C<remotefilename> on the
-filesystem.
-
-C<filename> can also be a named pipe.
-
-See also C<download>.
-
-Use C<-> instead of a filename to read/write from stdin/stdout.
-
-=head2 vg-activate
-
- vg-activate true|false 'volgroups ...'
-
-This command activates or (if C<activate> is false) deactivates
-all logical volumes in the listed volume groups C<volgroups>.
-If activated, then they are made known to the
-kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
-then those devices disappear.
-
-This command is the same as running C<vgchange -a y|n volgroups...>
-
-Note that if C<volgroups> is an empty list then B<all> volume groups
-are activated or deactivated.
-
-=head2 vg-activate-all
-
- vg-activate-all true|false
-
-This command activates or (if C<activate> is false) deactivates
-all logical volumes in all volume groups.
-If activated, then they are made known to the
-kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
-then those devices disappear.
-
-This command is the same as running C<vgchange -a y|n>
-
-=head2 vgcreate
-
- vgcreate volgroup 'physvols ...'
-
-This creates an LVM volume group called C<volgroup>
-from the non-empty list of physical volumes C<physvols>.
-
-=head2 vgremove
-
- vgremove vgname
-
-Remove an LVM volume group C<vgname>, (for example C<VG>).
-
-This also forcibly removes all logical volumes in the volume
-group (if any).
-
-=head2 vgs
-
- vgs
-
-List all the volumes groups detected. This is the equivalent
-of the L<vgs(8)> command.
-
-This returns a list of just the volume group names that were
-detected (eg. C<VolGroup00>).
-
-See also C<vgs-full>.
-
-=head2 vgs-full
-
- vgs-full
-
-List all the volumes groups detected. This is the equivalent
-of the L<vgs(8)> command. The "full" version includes all fields.
-
-=head2 wc-c
-
- wc-c path
-
-This command counts the characters in a file, using the
-C<wc -c> external command.
-
-=head2 wc-l
-
- wc-l path
-
-This command counts the lines in a file, using the
-C<wc -l> external command.
-
-=head2 wc-w
-
- wc-w path
-
-This command counts the words in a file, using the
-C<wc -w> external command.
-
-=head2 write-file
-
- write-file path content size
-
-This call creates a file called C<path>. The contents of the
-file is the string C<content> (which can contain any 8 bit data),
-with length C<size>.
-
-As a special case, if C<size> is C<0>
-then the length is calculated using C<strlen> (so in this case
-the content cannot contain embedded ASCII NULs).
-
-I<NB.> Owing to a bug, writing content containing ASCII NUL
-characters does I<not> work, even if the length is specified.
-We hope to resolve this bug in a future version. In the meantime
-use C<upload>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 zero
-
- zero device
-
-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.
-
-See also: C<scrub-device>.
-
-=head2 zerofree
-
- zerofree device
-
-This runs the I<zerofree> program on C<device>. This program
-claims to zero unused inodes and disk blocks on an ext2/3
-filesystem, thus making it possible to compress the filesystem
-more effectively.
-
-You should B<not> run this program if the filesystem is
-mounted.
-
-It is possible that using this program can damage the filesystem
-or data on the filesystem.
-
+++ /dev/null
-=head2 guestfs_add_cdrom
-
- int guestfs_add_cdrom (guestfs_h *handle,
- const char *filename);
-
-This function adds a virtual CD-ROM disk image to the guest.
-
-This is equivalent to the qemu parameter C<-cdrom filename>.
-
-Note that this call checks for the existence of C<filename>. This
-stops you from specifying other types of drive which are supported
-by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
-the general C<guestfs_config> call instead.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_add_drive
-
- int guestfs_add_drive (guestfs_h *handle,
- const char *filename);
-
-This function adds a virtual machine disk image C<filename> to the
-guest. The first time you call this function, the disk appears as IDE
-disk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and
-so on.
-
-You don't necessarily need to be root when using libguestfs. However
-you obviously do need sufficient permissions to access the filename
-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,cache=off,if=virtio>.
-
-Note that this call checks for the existence of C<filename>. This
-stops you from specifying other types of drive which are supported
-by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
-the general C<guestfs_config> call instead.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_add_drive_ro
-
- int guestfs_add_drive_ro (guestfs_h *handle,
- const char *filename);
-
-This adds a drive in snapshot mode, making it effectively
-read-only.
-
-Note that writes to the device are allowed, and will be seen for
-the duration of the guestfs handle, but they are written
-to a temporary file which is discarded as soon as the guestfs
-handle is closed. We don't currently have any method to enable
-changes to be committed, although qemu can support this.
-
-This is equivalent to the qemu parameter
-C<-drive file=filename,snapshot=on,if=virtio>.
-
-Note that this call checks for the existence of C<filename>. This
-stops you from specifying other types of drive which are supported
-by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
-the general C<guestfs_config> call instead.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_aug_close
-
- int guestfs_aug_close (guestfs_h *handle);
-
-Close the current Augeas handle and free up any resources
-used by it. After calling this, you have to call
-C<guestfs_aug_init> again before you can use any other
-Augeas functions.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_aug_defnode
-
- struct guestfs_int_bool *guestfs_aug_defnode (guestfs_h *handle,
- const char *name,
- const char *expr,
- const char *val);
-
-Defines a variable C<name> whose value is the result of
-evaluating C<expr>.
-
-If C<expr> evaluates to an empty nodeset, a node is created,
-equivalent to calling C<guestfs_aug_set> C<expr>, C<value>.
-C<name> will be the nodeset containing that single node.
-
-On success this returns a pair containing the
-number of nodes in the nodeset, and a boolean flag
-if a node was created.
-
-This function returns a C<struct guestfs_int_bool *>,
-or NULL if there was an error.
-I<The caller must call C<guestfs_free_int_bool> after use>.
-
-=head2 guestfs_aug_defvar
-
- int guestfs_aug_defvar (guestfs_h *handle,
- const char *name,
- const char *expr);
-
-Defines an Augeas variable C<name> whose value is the result
-of evaluating C<expr>. If C<expr> is NULL, then C<name> is
-undefined.
-
-On success this returns the number of nodes in C<expr>, or
-C<0> if C<expr> evaluates to something which is not a nodeset.
-
-On error this function returns -1.
-
-=head2 guestfs_aug_get
-
- char *guestfs_aug_get (guestfs_h *handle,
- const char *path);
-
-Look up the value associated with C<path>. If C<path>
-matches exactly one node, the C<value> is returned.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_aug_init
-
- int guestfs_aug_init (guestfs_h *handle,
- const char *root,
- int flags);
-
-Create a new Augeas handle for editing configuration files.
-If there was any previous Augeas handle associated with this
-guestfs session, then it is closed.
-
-You must call this before using any other C<guestfs_aug_*>
-commands.
-
-C<root> is the filesystem root. C<root> must not be NULL,
-use C</> instead.
-
-The flags are the same as the flags defined in
-E<lt>augeas.hE<gt>, the logical I<or> of the following
-integers:
-
-=over 4
-
-=item C<AUG_SAVE_BACKUP> = 1
-
-Keep the original file with a C<.augsave> extension.
-
-=item C<AUG_SAVE_NEWFILE> = 2
-
-Save changes into a file with extension C<.augnew>, and
-do not overwrite original. Overrides C<AUG_SAVE_BACKUP>.
-
-=item C<AUG_TYPE_CHECK> = 4
-
-Typecheck lenses (can be expensive).
-
-=item C<AUG_NO_STDINC> = 8
-
-Do not use standard load path for modules.
-
-=item C<AUG_SAVE_NOOP> = 16
-
-Make save a no-op, just record what would have been changed.
-
-=item C<AUG_NO_LOAD> = 32
-
-Do not load the tree in C<guestfs_aug_init>.
-
-=back
-
-To close the handle, you can call C<guestfs_aug_close>.
-
-To find out more about Augeas, see L<http://augeas.net/>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_aug_insert
-
- int guestfs_aug_insert (guestfs_h *handle,
- const char *path,
- const char *label,
- int before);
-
-Create a new sibling C<label> for C<path>, inserting it into
-the tree before or after C<path> (depending on the boolean
-flag C<before>).
-
-C<path> must match exactly one existing node in the tree, and
-C<label> must be a label, ie. not contain C</>, C<*> or end
-with a bracketed index C<[N]>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_aug_load
-
- int guestfs_aug_load (guestfs_h *handle);
-
-Load files into the tree.
-
-See C<aug_load> in the Augeas documentation for the full gory
-details.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_aug_ls
-
- char **guestfs_aug_ls (guestfs_h *handle,
- const char *path);
-
-This is just a shortcut for listing C<guestfs_aug_match>
-C<path/*> and sorting the resulting nodes into alphabetical order.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_aug_match
-
- char **guestfs_aug_match (guestfs_h *handle,
- const char *path);
-
-Returns a list of paths which match the path expression C<path>.
-The returned paths are sufficiently qualified so that they match
-exactly one node in the current tree.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_aug_mv
-
- int guestfs_aug_mv (guestfs_h *handle,
- const char *src,
- const char *dest);
-
-Move the node C<src> to C<dest>. C<src> must match exactly
-one node. C<dest> is overwritten if it exists.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_aug_rm
-
- int guestfs_aug_rm (guestfs_h *handle,
- const char *path);
-
-Remove C<path> and all of its children.
-
-On success this returns the number of entries which were removed.
-
-On error this function returns -1.
-
-=head2 guestfs_aug_save
-
- int guestfs_aug_save (guestfs_h *handle);
-
-This writes all pending changes to disk.
-
-The flags which were passed to C<guestfs_aug_init> affect exactly
-how files are saved.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_aug_set
-
- int guestfs_aug_set (guestfs_h *handle,
- const char *path,
- const char *val);
-
-Set the value associated with C<path> to C<value>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_blockdev_flushbufs
-
- int guestfs_blockdev_flushbufs (guestfs_h *handle,
- const char *device);
-
-This tells the kernel to flush internal buffers associated
-with C<device>.
-
-This uses the L<blockdev(8)> command.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_blockdev_getbsz
-
- int guestfs_blockdev_getbsz (guestfs_h *handle,
- const char *device);
-
-This returns the block size of a device.
-
-(Note this is different from both I<size in blocks> and
-I<filesystem block size>).
-
-This uses the L<blockdev(8)> command.
-
-On error this function returns -1.
-
-=head2 guestfs_blockdev_getro
-
- int guestfs_blockdev_getro (guestfs_h *handle,
- const char *device);
-
-Returns a boolean indicating if the block device is read-only
-(true if read-only, false if not).
-
-This uses the L<blockdev(8)> command.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_blockdev_getsize64
-
- int64_t guestfs_blockdev_getsize64 (guestfs_h *handle,
- const char *device);
-
-This returns the size of the device in bytes.
-
-See also C<guestfs_blockdev_getsz>.
-
-This uses the L<blockdev(8)> command.
-
-On error this function returns -1.
-
-=head2 guestfs_blockdev_getss
-
- int guestfs_blockdev_getss (guestfs_h *handle,
- const char *device);
-
-This returns the size of sectors on a block device.
-Usually 512, but can be larger for modern devices.
-
-(Note, this is not the size in sectors, use C<guestfs_blockdev_getsz>
-for that).
-
-This uses the L<blockdev(8)> command.
-
-On error this function returns -1.
-
-=head2 guestfs_blockdev_getsz
-
- int64_t guestfs_blockdev_getsz (guestfs_h *handle,
- const char *device);
-
-This returns the size of the device in units of 512-byte sectors
-(even if the sectorsize isn't 512 bytes ... weird).
-
-See also C<guestfs_blockdev_getss> for the real sector size of
-the device, and C<guestfs_blockdev_getsize64> for the more
-useful I<size in bytes>.
-
-This uses the L<blockdev(8)> command.
-
-On error this function returns -1.
-
-=head2 guestfs_blockdev_rereadpt
-
- int guestfs_blockdev_rereadpt (guestfs_h *handle,
- const char *device);
-
-Reread the partition table on C<device>.
-
-This uses the L<blockdev(8)> command.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_blockdev_setbsz
-
- int guestfs_blockdev_setbsz (guestfs_h *handle,
- const char *device,
- int blocksize);
-
-This sets the block size of a device.
-
-(Note this is different from both I<size in blocks> and
-I<filesystem block size>).
-
-This uses the L<blockdev(8)> command.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_blockdev_setro
-
- int guestfs_blockdev_setro (guestfs_h *handle,
- const char *device);
-
-Sets the block device named C<device> to read-only.
-
-This uses the L<blockdev(8)> command.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_blockdev_setrw
-
- int guestfs_blockdev_setrw (guestfs_h *handle,
- const char *device);
-
-Sets the block device named C<device> to read-write.
-
-This uses the L<blockdev(8)> command.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_cat
-
- char *guestfs_cat (guestfs_h *handle,
- const char *path);
-
-Return the contents of the file named C<path>.
-
-Note that this function cannot correctly handle binary files
-(specifically, files containing C<\0> character which is treated
-as end of string). For those you need to use the C<guestfs_download>
-function which has a more complex interface.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_checksum
-
- char *guestfs_checksum (guestfs_h *handle,
- const char *csumtype,
- const char *path);
-
-This call computes the MD5, SHAx or CRC checksum of the
-file named C<path>.
-
-The type of checksum to compute is given by the C<csumtype>
-parameter which must have one of the following values:
-
-=over 4
-
-=item C<crc>
-
-Compute the cyclic redundancy check (CRC) specified by POSIX
-for the C<cksum> command.
-
-=item C<md5>
-
-Compute the MD5 hash (using the C<md5sum> program).
-
-=item C<sha1>
-
-Compute the SHA1 hash (using the C<sha1sum> program).
-
-=item C<sha224>
-
-Compute the SHA224 hash (using the C<sha224sum> program).
-
-=item C<sha256>
-
-Compute the SHA256 hash (using the C<sha256sum> program).
-
-=item C<sha384>
-
-Compute the SHA384 hash (using the C<sha384sum> program).
-
-=item C<sha512>
-
-Compute the SHA512 hash (using the C<sha512sum> program).
-
-=back
-
-The checksum is returned as a printable string.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_chmod
-
- int guestfs_chmod (guestfs_h *handle,
- int mode,
- const char *path);
-
-Change the mode (permissions) of C<path> to C<mode>. Only
-numeric modes are supported.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_chown
-
- int guestfs_chown (guestfs_h *handle,
- int owner,
- int group,
- const char *path);
-
-Change the file owner to C<owner> and group to C<group>.
-
-Only numeric uid and gid are supported. If you want to use
-names, you will need to locate and parse the password file
-yourself (Augeas support makes this relatively easy).
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_command
-
- char *guestfs_command (guestfs_h *handle,
- char * const* const arguments);
-
-This call runs a command from the guest filesystem. The
-filesystem must be mounted, and must contain a compatible
-operating system (ie. something Linux, with the same
-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). 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.
-
-If the command returns a non-zero exit status, then
-this function returns an error message. The error message
-string is the content of I<stderr> from the command.
-
-The C<$PATH> environment variable will contain at least
-C</usr/bin> and C</bin>. If you require a program from
-another location, you should provide the full path in the
-first parameter.
-
-Shared libraries and data files required by the program
-must be available on filesystems which are mounted in the
-correct places. It is the caller's responsibility to ensure
-all filesystems that are needed are mounted at the right
-locations.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_command_lines
-
- char **guestfs_command_lines (guestfs_h *handle,
- char * const* const arguments);
-
-This is the same as C<guestfs_command>, but splits the
-result into a list of lines.
-
-See also: C<guestfs_sh_lines>
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_config
-
- int guestfs_config (guestfs_h *handle,
- const char *qemuparam,
- const char *qemuvalue);
-
-This can be used to add arbitrary qemu command line parameters
-of the form C<-param value>. Actually it's not quite arbitrary - we
-prevent you from setting some parameters which would interfere with
-parameters that we use.
-
-The first character of C<param> string must be a C<-> (dash).
-
-C<value> can be NULL.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_cp
-
- int guestfs_cp (guestfs_h *handle,
- const char *src,
- const char *dest);
-
-This copies a file from C<src> to C<dest> where C<dest> is
-either a destination filename or destination directory.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_cp_a
-
- int guestfs_cp_a (guestfs_h *handle,
- const char *src,
- const char *dest);
-
-This copies a file or directory from C<src> to C<dest>
-recursively using the C<cp -a> command.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_debug
-
- char *guestfs_debug (guestfs_h *handle,
- const char *subcmd,
- char * const* const extraargs);
-
-The C<guestfs_debug> command exposes some internals of
-C<guestfsd> (the guestfs daemon) that runs inside the
-qemu subprocess.
-
-There is no comprehensive help for this command. You have
-to look at the file C<daemon/debug.c> in the libguestfs source
-to find out what you can do.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_df
-
- char *guestfs_df (guestfs_h *handle);
-
-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.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_df_h
-
- char *guestfs_df_h (guestfs_h *handle);
-
-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.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_dmesg
-
- char *guestfs_dmesg (guestfs_h *handle);
-
-This returns the kernel messages (C<dmesg> output) from
-the guest kernel. This is sometimes useful for extended
-debugging of problems.
-
-Another way to get the same information is to enable
-verbose messages with C<guestfs_set_verbose> or by setting
-the environment variable C<LIBGUESTFS_DEBUG=1> before
-running the program.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_download
-
- int guestfs_download (guestfs_h *handle,
- const char *remotefilename,
- const char *filename);
-
-Download file C<remotefilename> and save it as C<filename>
-on the local machine.
-
-C<filename> can also be a named pipe.
-
-See also C<guestfs_upload>, C<guestfs_cat>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_drop_caches
-
- int guestfs_drop_caches (guestfs_h *handle,
- int whattodrop);
-
-This instructs the guest kernel to drop its page cache,
-and/or dentries and inode caches. The parameter C<whattodrop>
-tells the kernel what precisely to drop, see
-L<http://linux-mm.org/Drop_Caches>
-
-Setting C<whattodrop> to 3 should drop everything.
-
-This automatically calls L<sync(2)> before the operation,
-so that the maximum guest memory is freed.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_du
-
- int64_t guestfs_du (guestfs_h *handle,
- const char *path);
-
-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).
-
-On error this function returns -1.
-
-=head2 guestfs_e2fsck_f
-
- int guestfs_e2fsck_f (guestfs_h *handle,
- const char *device);
-
-This runs C<e2fsck -p -f device>, ie. runs the ext2/ext3
-filesystem checker on C<device>, noninteractively (C<-p>),
-even if the filesystem appears to be clean (C<-f>).
-
-This command is only needed because of C<guestfs_resize2fs>
-(q.v.). Normally you should use C<guestfs_fsck>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_end_busy
-
- int guestfs_end_busy (guestfs_h *handle);
-
-This sets the state to C<READY>, or if in C<CONFIG> then it leaves the
-state as is. This is only used when implementing
-actions using the low-level API.
-
-For more information on states, see L<guestfs(3)>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_equal
-
- int guestfs_equal (guestfs_h *handle,
- const char *file1,
- const char *file2);
-
-This compares the two files C<file1> and C<file2> and returns
-true if their content is exactly equal, or false otherwise.
-
-The external L<cmp(1)> program is used for the comparison.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_exists
-
- int guestfs_exists (guestfs_h *handle,
- const char *path);
-
-This returns C<true> if and only if there is a file, directory
-(or anything) with the given C<path> name.
-
-See also C<guestfs_is_file>, C<guestfs_is_dir>, C<guestfs_stat>.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_file
-
- char *guestfs_file (guestfs_h *handle,
- const char *path);
-
-This call uses the standard L<file(1)> command to determine
-the type or contents of the file. This also works on devices,
-for example to find out whether a partition contains a filesystem.
-
-The exact command which runs is C<file -bsL path>. Note in
-particular that the filename is not prepended to the output
-(the C<-b> option).
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_find
-
- char **guestfs_find (guestfs_h *handle,
- const char *directory);
-
-This command lists out all files and directories, recursively,
-starting at C<directory>. It is essentially equivalent to
-running the shell command C<find directory -print> but some
-post-processing happens on the output, described below.
-
-This returns a list of strings I<without any prefix>. Thus
-if the directory structure was:
-
- /tmp/a
- /tmp/b
- /tmp/c/d
-
-then the returned list from C<guestfs_find> C</tmp> would be
-4 elements:
-
- a
- b
- c
- c/d
-
-If C<directory> is not a directory, then this command returns
-an error.
-
-The returned list is sorted.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_fsck
-
- int guestfs_fsck (guestfs_h *handle,
- const char *fstype,
- const char *device);
-
-This runs the filesystem checker (fsck) on C<device> which
-should have filesystem type C<fstype>.
-
-The returned integer is the status. See L<fsck(8)> for the
-list of status codes from C<fsck>.
-
-Notes:
-
-=over 4
-
-=item *
-
-Multiple status codes can be summed together.
-
-=item *
-
-A non-zero return code can mean "success", for example if
-errors have been corrected on the filesystem.
-
-=item *
-
-Checking or repairing NTFS volumes is not supported
-(by linux-ntfs).
-
-=back
-
-This command is entirely equivalent to running C<fsck -a -t fstype device>.
-
-On error this function returns -1.
-
-=head2 guestfs_get_append
-
- const char *guestfs_get_append (guestfs_h *handle);
-
-Return the additional kernel options which are added to the
-guest kernel command line.
-
-If C<NULL> then no options are added.
-
-This function returns a string, or NULL on error.
-The string is owned by the guest handle and must I<not> be freed.
-
-=head2 guestfs_get_autosync
-
- int guestfs_get_autosync (guestfs_h *handle);
-
-Get the autosync flag.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_get_e2label
-
- char *guestfs_get_e2label (guestfs_h *handle,
- const char *device);
-
-This returns the ext2/3/4 filesystem label of the filesystem on
-C<device>.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_get_e2uuid
-
- char *guestfs_get_e2uuid (guestfs_h *handle,
- const char *device);
-
-This returns the ext2/3/4 filesystem UUID of the filesystem on
-C<device>.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_get_memsize
-
- int guestfs_get_memsize (guestfs_h *handle);
-
-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)>.
-
-On error this function returns -1.
-
-=head2 guestfs_get_path
-
- const char *guestfs_get_path (guestfs_h *handle);
-
-Return the current search path.
-
-This is always non-NULL. If it wasn't set already, then this will
-return the default path.
-
-This function returns a string, or NULL on error.
-The string is owned by the guest handle and must I<not> be freed.
-
-=head2 guestfs_get_qemu
-
- const char *guestfs_get_qemu (guestfs_h *handle);
-
-Return the current qemu binary.
-
-This is always non-NULL. If it wasn't set already, then this will
-return the default qemu binary name.
-
-This function returns a string, or NULL on error.
-The string is owned by the guest handle and must I<not> be freed.
-
-=head2 guestfs_get_state
-
- int guestfs_get_state (guestfs_h *handle);
-
-This returns the current state as an opaque integer. This is
-only useful for printing debug and internal error messages.
-
-For more information on states, see L<guestfs(3)>.
-
-On error this function returns -1.
-
-=head2 guestfs_get_verbose
-
- int guestfs_get_verbose (guestfs_h *handle);
-
-This returns the verbose messages flag.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_glob_expand
-
- char **guestfs_glob_expand (guestfs_h *handle,
- const char *pattern);
-
-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.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_grub_install
-
- int guestfs_grub_install (guestfs_h *handle,
- const char *root,
- const char *device);
-
-This command installs GRUB (the Grand Unified Bootloader) on
-C<device>, with the root directory being C<root>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_head
-
- char **guestfs_head (guestfs_h *handle,
- const char *path);
-
-This command returns up to the first 10 lines of a file as
-a list of strings.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_head_n
-
- char **guestfs_head_n (guestfs_h *handle,
- int nrlines,
- const char *path);
-
-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.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_hexdump
-
- char *guestfs_hexdump (guestfs_h *handle,
- const char *path);
-
-This runs C<hexdump -C> on the given C<path>. The result is
-the human-readable, canonical hex dump of the file.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_initrd_list
-
- char **guestfs_initrd_list (guestfs_h *handle,
- const char *path);
-
-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).
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_is_busy
-
- int guestfs_is_busy (guestfs_h *handle);
-
-This returns true iff this handle is busy processing a command
-(in the C<BUSY> state).
-
-For more information on states, see L<guestfs(3)>.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_is_config
-
- int guestfs_is_config (guestfs_h *handle);
-
-This returns true iff this handle is being configured
-(in the C<CONFIG> state).
-
-For more information on states, see L<guestfs(3)>.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_is_dir
-
- int guestfs_is_dir (guestfs_h *handle,
- const char *path);
-
-This returns C<true> if and only if there is a directory
-with the given C<path> name. Note that it returns false for
-other objects like files.
-
-See also C<guestfs_stat>.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_is_file
-
- int guestfs_is_file (guestfs_h *handle,
- const char *path);
-
-This returns C<true> if and only if there is a file
-with the given C<path> name. Note that it returns false for
-other objects like directories.
-
-See also C<guestfs_stat>.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_is_launching
-
- int guestfs_is_launching (guestfs_h *handle);
-
-This returns true iff this handle is launching the subprocess
-(in the C<LAUNCHING> state).
-
-For more information on states, see L<guestfs(3)>.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_is_ready
-
- int guestfs_is_ready (guestfs_h *handle);
-
-This returns true iff this handle is ready to accept commands
-(in the C<READY> state).
-
-For more information on states, see L<guestfs(3)>.
-
-This function returns a C truth value on success or -1 on error.
-
-=head2 guestfs_kill_subprocess
-
- int guestfs_kill_subprocess (guestfs_h *handle);
-
-This kills the qemu subprocess. You should never need to call this.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_launch
-
- int guestfs_launch (guestfs_h *handle);
-
-Internally libguestfs is implemented by running a virtual machine
-using L<qemu(1)>.
-
-You should call this after configuring the handle
-(eg. adding drives) but before performing any actions.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_list_devices
-
- char **guestfs_list_devices (guestfs_h *handle);
-
-List all the block devices.
-
-The full block device names are returned, eg. C</dev/sda>
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_list_partitions
-
- char **guestfs_list_partitions (guestfs_h *handle);
-
-List all the partitions detected on all block devices.
-
-The full partition device names are returned, eg. C</dev/sda1>
-
-This does not return logical volumes. For that you will need to
-call C<guestfs_lvs>.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_ll
-
- char *guestfs_ll (guestfs_h *handle,
- const char *directory);
-
-List the files in C<directory> (relative to the root directory,
-there is no cwd) in the format of 'ls -la'.
-
-This command is mostly useful for interactive sessions. It
-is I<not> intended that you try to parse the output string.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_ls
-
- char **guestfs_ls (guestfs_h *handle,
- const char *directory);
-
-List the files in C<directory> (relative to the root directory,
-there is no cwd). The '.' and '..' entries are not returned, but
-hidden files are shown.
-
-This command is mostly useful for interactive sessions. Programs
-should probably use C<guestfs_readdir> instead.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_lstat
-
- struct guestfs_stat *guestfs_lstat (guestfs_h *handle,
- const char *path);
-
-Returns file information for the given C<path>.
-
-This is the same as C<guestfs_stat> except that if C<path>
-is a symbolic link, then the link is stat-ed, not the file it
-refers to.
-
-This is the same as the C<lstat(2)> system call.
-
-This function returns a C<struct guestfs_stat *>
-(see L<stat(2)> and E<lt>guestfs-structs.hE<gt>),
-or NULL if there was an error.
-I<The caller must call C<free> after use>.
-
-=head2 guestfs_lvcreate
-
- int guestfs_lvcreate (guestfs_h *handle,
- const char *logvol,
- const char *volgroup,
- int mbytes);
-
-This creates an LVM volume group called C<logvol>
-on the volume group C<volgroup>, with C<size> megabytes.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_lvm_remove_all
-
- int guestfs_lvm_remove_all (guestfs_h *handle);
-
-This command removes all LVM logical volumes, volume groups
-and physical volumes.
-
-This function returns 0 on success or -1 on error.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=head2 guestfs_lvremove
-
- int guestfs_lvremove (guestfs_h *handle,
- const char *device);
-
-Remove an LVM logical volume C<device>, where C<device> is
-the path to the LV, such as C</dev/VG/LV>.
-
-You can also remove all LVs in a volume group by specifying
-the VG name, C</dev/VG>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_lvresize
-
- int guestfs_lvresize (guestfs_h *handle,
- const char *device,
- int mbytes);
-
-This resizes (expands or shrinks) an existing LVM logical
-volume to C<mbytes>. When reducing, data in the reduced part
-is lost.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_lvs
-
- char **guestfs_lvs (guestfs_h *handle);
-
-List all the logical volumes detected. This is the equivalent
-of the L<lvs(8)> command.
-
-This returns a list of the logical volume device names
-(eg. C</dev/VolGroup00/LogVol00>).
-
-See also C<guestfs_lvs_full>.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_lvs_full
-
- struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *handle);
-
-List all the logical volumes detected. This is the equivalent
-of the L<lvs(8)> command. The "full" version includes all fields.
-
-This function returns a C<struct guestfs_lvm_lv_list *>
-(see E<lt>guestfs-structs.hE<gt>),
-or NULL if there was an error.
-I<The caller must call C<guestfs_free_lvm_lv_list> after use>.
-
-=head2 guestfs_mkdir
-
- int guestfs_mkdir (guestfs_h *handle,
- const char *path);
-
-Create a directory named C<path>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mkdir_p
-
- int guestfs_mkdir_p (guestfs_h *handle,
- const char *path);
-
-Create a directory named C<path>, creating any parent directories
-as necessary. This is like the C<mkdir -p> shell command.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mkdtemp
-
- char *guestfs_mkdtemp (guestfs_h *handle,
- const char *template);
-
-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)>
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_mkfifo
-
- int guestfs_mkfifo (guestfs_h *handle,
- int mode,
- const char *path);
-
-This call creates a FIFO (named pipe) called C<path> with
-mode C<mode>. It is just a convenient wrapper around
-C<guestfs_mknod>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mkfs
-
- int guestfs_mkfs (guestfs_h *handle,
- const char *fstype,
- const char *device);
-
-This creates a filesystem on C<device> (usually a partition
-or LVM logical volume). The filesystem type is C<fstype>, for
-example C<ext3>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mknod
-
- int guestfs_mknod (guestfs_h *handle,
- int mode,
- int devmajor,
- int devminor,
- const char *path);
-
-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.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mknod_b
-
- int guestfs_mknod_b (guestfs_h *handle,
- int mode,
- int devmajor,
- int devminor,
- const char *path);
-
-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>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mknod_c
-
- int guestfs_mknod_c (guestfs_h *handle,
- int mode,
- int devmajor,
- int devminor,
- const char *path);
-
-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>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mkswap
-
- int guestfs_mkswap (guestfs_h *handle,
- const char *device);
-
-Create a swap partition on C<device>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mkswap_L
-
- int guestfs_mkswap_L (guestfs_h *handle,
- const char *label,
- const char *device);
-
-Create a swap partition on C<device> with label C<label>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mkswap_U
-
- int guestfs_mkswap_U (guestfs_h *handle,
- const char *uuid,
- const char *device);
-
-Create a swap partition on C<device> with UUID C<uuid>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mount
-
- int guestfs_mount (guestfs_h *handle,
- const char *device,
- const char *mountpoint);
-
-Mount a guest disk at a position in the filesystem. Block devices
-are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
-the guest. If those block devices contain partitions, they will have
-the usual names (eg. C</dev/sda1>). Also LVM C</dev/VG/LV>-style
-names can be used.
-
-The rules are the same as for L<mount(2)>: A filesystem must
-first be mounted on C</> before others can be mounted. Other
-filesystems can only be mounted on directories which already
-exist.
-
-The mounted filesystem is writable, if we have sufficient permissions
-on the underlying device.
-
-The filesystem options C<sync> and C<noatime> are set with this
-call, in order to improve reliability.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mount_loop
-
- int guestfs_mount_loop (guestfs_h *handle,
- const char *file,
- const char *mountpoint);
-
-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>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mount_options
-
- int guestfs_mount_options (guestfs_h *handle,
- const char *options,
- const char *device,
- const char *mountpoint);
-
-This is the same as the C<guestfs_mount> command, but it
-allows you to set the mount options as for the
-L<mount(8)> I<-o> flag.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mount_ro
-
- int guestfs_mount_ro (guestfs_h *handle,
- const char *device,
- const char *mountpoint);
-
-This is the same as the C<guestfs_mount> command, but it
-mounts the filesystem with the read-only (I<-o ro>) flag.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mount_vfs
-
- int guestfs_mount_vfs (guestfs_h *handle,
- const char *options,
- const char *vfstype,
- const char *device,
- const char *mountpoint);
-
-This is the same as the C<guestfs_mount> command, but it
-allows you to set both the mount options and the vfstype
-as for the L<mount(8)> I<-o> and I<-t> flags.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_mounts
-
- char **guestfs_mounts (guestfs_h *handle);
-
-This returns the list of currently mounted filesystems. It returns
-the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
-
-Some internal mounts are not shown.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_mv
-
- int guestfs_mv (guestfs_h *handle,
- const char *src,
- const char *dest);
-
-This moves a file from C<src> to C<dest> where C<dest> is
-either a destination filename or destination directory.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_ntfs_3g_probe
-
- int guestfs_ntfs_3g_probe (guestfs_h *handle,
- int rw,
- const char *device);
-
-This command runs the L<ntfs-3g.probe(8)> command which probes
-an NTFS C<device> for mountability. (Not all NTFS volumes can
-be mounted read-write, and some cannot be mounted at all).
-
-C<rw> is a boolean flag. Set it to true if you want to test
-if the volume can be mounted read-write. Set it to false if
-you want to test if the volume can be mounted read-only.
-
-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.
-
-On error this function returns -1.
-
-=head2 guestfs_ping_daemon
-
- int guestfs_ping_daemon (guestfs_h *handle);
-
-This is a test probe into the guestfs daemon running inside
-the qemu subprocess. Calling this function checks that the
-daemon responds to the ping message, without affecting the daemon
-or attached block device(s) in any other way.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_pvcreate
-
- int guestfs_pvcreate (guestfs_h *handle,
- const char *device);
-
-This creates an LVM physical volume on the named C<device>,
-where C<device> should usually be a partition name such
-as C</dev/sda1>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_pvremove
-
- int guestfs_pvremove (guestfs_h *handle,
- const char *device);
-
-This wipes a physical volume C<device> so that LVM will no longer
-recognise it.
-
-The implementation uses the C<pvremove> command which refuses to
-wipe physical volumes that contain any volume groups, so you have
-to remove those first.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_pvresize
-
- int guestfs_pvresize (guestfs_h *handle,
- const char *device);
-
-This resizes (expands or shrinks) an existing LVM physical
-volume to match the new size of the underlying device.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_pvs
-
- char **guestfs_pvs (guestfs_h *handle);
-
-List all the physical volumes detected. This is the equivalent
-of the L<pvs(8)> command.
-
-This returns a list of just the device names that contain
-PVs (eg. C</dev/sda2>).
-
-See also C<guestfs_pvs_full>.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_pvs_full
-
- struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *handle);
-
-List all the physical volumes detected. This is the equivalent
-of the L<pvs(8)> command. The "full" version includes all fields.
-
-This function returns a C<struct guestfs_lvm_pv_list *>
-(see E<lt>guestfs-structs.hE<gt>),
-or NULL if there was an error.
-I<The caller must call C<guestfs_free_lvm_pv_list> after use>.
-
-=head2 guestfs_read_lines
-
- char **guestfs_read_lines (guestfs_h *handle,
- const char *path);
-
-Return the contents of the file named C<path>.
-
-The file contents are returned as a list of lines. Trailing
-C<LF> and C<CRLF> character sequences are I<not> returned.
-
-Note that this function cannot correctly handle binary files
-(specifically, files containing C<\0> character which is treated
-as end of line). For those you need to use the C<guestfs_read_file>
-function which has a more complex interface.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_readdir
-
- struct guestfs_dirent_list *guestfs_readdir (guestfs_h *handle,
- const char *dir);
-
-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>.
-
-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>.
-
-=head2 guestfs_resize2fs
-
- int guestfs_resize2fs (guestfs_h *handle,
- const char *device);
-
-This resizes an ext2 or ext3 filesystem to match the size of
-the underlying device.
-
-I<Note:> It is sometimes required that you run C<guestfs_e2fsck_f>
-on the C<device> before calling this command. For unknown reasons
-C<resize2fs> sometimes gives an error about this and sometimes not.
-In any case, it is always safe to call C<guestfs_e2fsck_f> before
-calling this function.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_rm
-
- int guestfs_rm (guestfs_h *handle,
- const char *path);
-
-Remove the single file C<path>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_rm_rf
-
- int guestfs_rm_rf (guestfs_h *handle,
- const char *path);
-
-Remove the file or directory C<path>, recursively removing the
-contents if its a directory. This is like the C<rm -rf> shell
-command.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_rmdir
-
- int guestfs_rmdir (guestfs_h *handle,
- const char *path);
-
-Remove the single directory C<path>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_scrub_device
-
- int guestfs_scrub_device (guestfs_h *handle,
- const char *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.
-
-This function returns 0 on success or -1 on error.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=head2 guestfs_scrub_file
-
- int guestfs_scrub_file (guestfs_h *handle,
- const char *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.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_scrub_freespace
-
- int guestfs_scrub_freespace (guestfs_h *handle,
- const char *dir);
-
-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.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_append
-
- int guestfs_set_append (guestfs_h *handle,
- const char *append);
-
-This function is used to add additional options to the
-guest kernel command line.
-
-The default is C<NULL> unless overridden by setting
-C<LIBGUESTFS_APPEND> environment variable.
-
-Setting C<append> to C<NULL> means I<no> additional options
-are passed (libguestfs always adds a few of its own).
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_autosync
-
- int guestfs_set_autosync (guestfs_h *handle,
- int autosync);
-
-If C<autosync> is true, this enables autosync. Libguestfs will make a
-best effort attempt to run C<guestfs_umount_all> followed by
-C<guestfs_sync> when the handle is closed
-(also if the program exits without closing handles).
-
-This is disabled by default (except in guestfish where it is
-enabled by default).
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_busy
-
- int guestfs_set_busy (guestfs_h *handle);
-
-This sets the state to C<BUSY>. This is only used when implementing
-actions using the low-level API.
-
-For more information on states, see L<guestfs(3)>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_e2label
-
- int guestfs_set_e2label (guestfs_h *handle,
- const char *device,
- const char *label);
-
-This sets the ext2/3/4 filesystem label of the filesystem on
-C<device> to C<label>. Filesystem labels are limited to
-16 characters.
-
-You can use either C<guestfs_tune2fs_l> or C<guestfs_get_e2label>
-to return the existing label on a filesystem.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_e2uuid
-
- int guestfs_set_e2uuid (guestfs_h *handle,
- const char *device,
- const char *uuid);
-
-This sets the ext2/3/4 filesystem UUID of the filesystem on
-C<device> to C<uuid>. The format of the UUID and alternatives
-such as C<clear>, C<random> and C<time> are described in the
-L<tune2fs(8)> manpage.
-
-You can use either C<guestfs_tune2fs_l> or C<guestfs_get_e2uuid>
-to return the existing UUID of a filesystem.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_memsize
-
- int guestfs_set_memsize (guestfs_h *handle,
- int memsize);
-
-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)>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_path
-
- int guestfs_set_path (guestfs_h *handle,
- const char *path);
-
-Set the path that libguestfs searches for kernel and initrd.img.
-
-The default is C<$libdir/guestfs> unless overridden by setting
-C<LIBGUESTFS_PATH> environment variable.
-
-Setting C<path> to C<NULL> restores the default path.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_qemu
-
- int guestfs_set_qemu (guestfs_h *handle,
- const char *qemu);
-
-Set the qemu binary that we will use.
-
-The default is chosen when the library was compiled by the
-configure script.
-
-You can also override this by setting the C<LIBGUESTFS_QEMU>
-environment variable.
-
-Setting C<qemu> to C<NULL> restores the default qemu binary.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_ready
-
- int guestfs_set_ready (guestfs_h *handle);
-
-This sets the state to C<READY>. This is only used when implementing
-actions using the low-level API.
-
-For more information on states, see L<guestfs(3)>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_set_verbose
-
- int guestfs_set_verbose (guestfs_h *handle,
- int verbose);
-
-If C<verbose> is true, this turns on verbose messages (to C<stderr>).
-
-Verbose messages are disabled unless the environment variable
-C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_sfdisk
-
- int guestfs_sfdisk (guestfs_h *handle,
- const char *device,
- int cyls,
- int heads,
- int sectors,
- char * const* const lines);
-
-This is a direct interface to the L<sfdisk(8)> program for creating
-partitions on block devices.
-
-C<device> should be a block device, for example C</dev/sda>.
-
-C<cyls>, C<heads> and C<sectors> are the number of cylinders, heads
-and sectors on the device, which are passed directly to sfdisk as
-the I<-C>, I<-H> and I<-S> parameters. If you pass C<0> for any
-of these, then the corresponding parameter is omitted. Usually for
-'large' disks, you can just pass C<0> for these, but for small
-(floppy-sized) disks, sfdisk (or rather, the kernel) cannot work
-out the right geometry and you will need to tell it.
-
-C<lines> is a list of lines that we feed to C<sfdisk>. For more
-information refer to the L<sfdisk(8)> manpage.
-
-To create a single partition occupying the whole disk, you would
-pass C<lines> as a single element list, when the single element being
-the string C<,> (comma).
-
-See also: C<guestfs_sfdisk_l>, C<guestfs_sfdisk_N>
-
-This function returns 0 on success or -1 on error.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=head2 guestfs_sfdisk_N
-
- int guestfs_sfdisk_N (guestfs_h *handle,
- const char *device,
- int partnum,
- int cyls,
- int heads,
- int sectors,
- const char *line);
-
-This runs L<sfdisk(8)> option to modify just the single
-partition C<n> (note: C<n> counts from 1).
-
-For other parameters, see C<guestfs_sfdisk>. You should usually
-pass C<0> for the cyls/heads/sectors parameters.
-
-This function returns 0 on success or -1 on error.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=head2 guestfs_sfdisk_disk_geometry
-
- char *guestfs_sfdisk_disk_geometry (guestfs_h *handle,
- const char *device);
-
-This displays the disk geometry of C<device> read from the
-partition table. Especially in the case where the underlying
-block device has been resized, this can be different from the
-kernel's idea of the geometry (see C<guestfs_sfdisk_kernel_geometry>).
-
-The result is in human-readable format, and not designed to
-be parsed.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_sfdisk_kernel_geometry
-
- char *guestfs_sfdisk_kernel_geometry (guestfs_h *handle,
- const char *device);
-
-This displays the kernel's idea of the geometry of C<device>.
-
-The result is in human-readable format, and not designed to
-be parsed.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_sfdisk_l
-
- char *guestfs_sfdisk_l (guestfs_h *handle,
- const char *device);
-
-This displays the partition table on C<device>, in the
-human-readable output of the L<sfdisk(8)> command. It is
-not intended to be parsed.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_sh
-
- char *guestfs_sh (guestfs_h *handle,
- const char *command);
-
-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.
-
-This function returns a string, or NULL on error.
-I<The caller must free the returned string after use>.
-
-=head2 guestfs_sh_lines
-
- char **guestfs_sh_lines (guestfs_h *handle,
- const char *command);
-
-This is the same as C<guestfs_sh>, but splits the result
-into a list of lines.
-
-See also: C<guestfs_command_lines>
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_sleep
-
- int guestfs_sleep (guestfs_h *handle,
- int secs);
-
-Sleep for C<secs> seconds.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_stat
-
- struct guestfs_stat *guestfs_stat (guestfs_h *handle,
- const char *path);
-
-Returns file information for the given C<path>.
-
-This is the same as the C<stat(2)> system call.
-
-This function returns a C<struct guestfs_stat *>
-(see L<stat(2)> and E<lt>guestfs-structs.hE<gt>),
-or NULL if there was an error.
-I<The caller must call C<free> after use>.
-
-=head2 guestfs_statvfs
-
- struct guestfs_statvfs *guestfs_statvfs (guestfs_h *handle,
- const char *path);
-
-Returns file system statistics for any mounted file system.
-C<path> should be a file or directory in the mounted file system
-(typically it is the mount point itself, but it doesn't need to be).
-
-This is the same as the C<statvfs(2)> system call.
-
-This function returns a C<struct guestfs_statvfs *>
-(see L<statvfs(2)> and E<lt>guestfs-structs.hE<gt>),
-or NULL if there was an error.
-I<The caller must call C<free> after use>.
-
-=head2 guestfs_strings
-
- char **guestfs_strings (guestfs_h *handle,
- const char *path);
-
-This runs the L<strings(1)> command on a file and returns
-the list of printable strings found.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_strings_e
-
- char **guestfs_strings_e (guestfs_h *handle,
- const char *encoding,
- const char *path);
-
-This is like the C<guestfs_strings> command, but allows you to
-specify the encoding.
-
-See the L<strings(1)> manpage for the full list of encodings.
-
-Commonly useful encodings are C<l> (lower case L) which will
-show strings inside Windows/x86 files.
-
-The returned strings are transcoded to UTF-8.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_sync
-
- int guestfs_sync (guestfs_h *handle);
-
-This syncs the disk, so that any writes are flushed through to the
-underlying disk image.
-
-You should always call this if you have modified a disk image, before
-closing the handle.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_tail
-
- char **guestfs_tail (guestfs_h *handle,
- const char *path);
-
-This command returns up to the last 10 lines of a file as
-a list of strings.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_tail_n
-
- char **guestfs_tail_n (guestfs_h *handle,
- int nrlines,
- const char *path);
-
-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.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_tar_in
-
- int guestfs_tar_in (guestfs_h *handle,
- const char *tarfile,
- const char *directory);
-
-This command uploads and unpacks local file C<tarfile> (an
-I<uncompressed> tar file) into C<directory>.
-
-To upload a compressed tarball, use C<guestfs_tgz_in>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_tar_out
-
- int guestfs_tar_out (guestfs_h *handle,
- const char *directory,
- const char *tarfile);
-
-This command packs the contents of C<directory> and downloads
-it to local file C<tarfile>.
-
-To download a compressed tarball, use C<guestfs_tgz_out>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_tgz_in
-
- int guestfs_tgz_in (guestfs_h *handle,
- const char *tarball,
- const char *directory);
-
-This command uploads and unpacks local file C<tarball> (a
-I<gzip compressed> tar file) into C<directory>.
-
-To upload an uncompressed tarball, use C<guestfs_tar_in>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_tgz_out
-
- int guestfs_tgz_out (guestfs_h *handle,
- const char *directory,
- const char *tarball);
-
-This command packs the contents of C<directory> and downloads
-it to local file C<tarball>.
-
-To download an uncompressed tarball, use C<guestfs_tar_out>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_touch
-
- int guestfs_touch (guestfs_h *handle,
- const char *path);
-
-Touch acts like the L<touch(1)> command. It can be used to
-update the timestamps on a file, or, if the file does not exist,
-to create a new zero-length file.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_tune2fs_l
-
- char **guestfs_tune2fs_l (guestfs_h *handle,
- const char *device);
-
-This returns the contents of the ext2, ext3 or ext4 filesystem
-superblock on C<device>.
-
-It is the same as running C<tune2fs -l device>. See L<tune2fs(8)>
-manpage for more details. The list of fields returned isn't
-clearly defined, and depends on both the version of C<tune2fs>
-that libguestfs was built against, and the filesystem itself.
-
-This function returns a NULL-terminated array of
-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>.
-
-=head2 guestfs_umask
-
- int guestfs_umask (guestfs_h *handle,
- int mask);
-
-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.
-
-On error this function returns -1.
-
-=head2 guestfs_umount
-
- int guestfs_umount (guestfs_h *handle,
- const char *pathordevice);
-
-This unmounts the given filesystem. The filesystem may be
-specified either by its mountpoint (path) or the device which
-contains the filesystem.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_umount_all
-
- int guestfs_umount_all (guestfs_h *handle);
-
-This unmounts all mounted filesystems.
-
-Some internal mounts are not unmounted by this call.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_upload
-
- int guestfs_upload (guestfs_h *handle,
- const char *filename,
- const char *remotefilename);
-
-Upload local file C<filename> to C<remotefilename> on the
-filesystem.
-
-C<filename> can also be a named pipe.
-
-See also C<guestfs_download>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_vg_activate
-
- int guestfs_vg_activate (guestfs_h *handle,
- int activate,
- char * const* const volgroups);
-
-This command activates or (if C<activate> is false) deactivates
-all logical volumes in the listed volume groups C<volgroups>.
-If activated, then they are made known to the
-kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
-then those devices disappear.
-
-This command is the same as running C<vgchange -a y|n volgroups...>
-
-Note that if C<volgroups> is an empty list then B<all> volume groups
-are activated or deactivated.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_vg_activate_all
-
- int guestfs_vg_activate_all (guestfs_h *handle,
- int activate);
-
-This command activates or (if C<activate> is false) deactivates
-all logical volumes in all volume groups.
-If activated, then they are made known to the
-kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
-then those devices disappear.
-
-This command is the same as running C<vgchange -a y|n>
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_vgcreate
-
- int guestfs_vgcreate (guestfs_h *handle,
- const char *volgroup,
- char * const* const physvols);
-
-This creates an LVM volume group called C<volgroup>
-from the non-empty list of physical volumes C<physvols>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_vgremove
-
- int guestfs_vgremove (guestfs_h *handle,
- const char *vgname);
-
-Remove an LVM volume group C<vgname>, (for example C<VG>).
-
-This also forcibly removes all logical volumes in the volume
-group (if any).
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_vgs
-
- char **guestfs_vgs (guestfs_h *handle);
-
-List all the volumes groups detected. This is the equivalent
-of the L<vgs(8)> command.
-
-This returns a list of just the volume group names that were
-detected (eg. C<VolGroup00>).
-
-See also C<guestfs_vgs_full>.
-
-This function returns a NULL-terminated array of strings
-(like L<environ(3)>), or NULL if there was an error.
-I<The caller must free the strings and the array after use>.
-
-=head2 guestfs_vgs_full
-
- struct guestfs_lvm_vg_list *guestfs_vgs_full (guestfs_h *handle);
-
-List all the volumes groups detected. This is the equivalent
-of the L<vgs(8)> command. The "full" version includes all fields.
-
-This function returns a C<struct guestfs_lvm_vg_list *>
-(see E<lt>guestfs-structs.hE<gt>),
-or NULL if there was an error.
-I<The caller must call C<guestfs_free_lvm_vg_list> after use>.
-
-=head2 guestfs_wait_ready
-
- int guestfs_wait_ready (guestfs_h *handle);
-
-Internally libguestfs is implemented by running a virtual machine
-using L<qemu(1)>.
-
-You should call this after C<guestfs_launch> to wait for the launch
-to complete.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_wc_c
-
- int guestfs_wc_c (guestfs_h *handle,
- const char *path);
-
-This command counts the characters in a file, using the
-C<wc -c> external command.
-
-On error this function returns -1.
-
-=head2 guestfs_wc_l
-
- int guestfs_wc_l (guestfs_h *handle,
- const char *path);
-
-This command counts the lines in a file, using the
-C<wc -l> external command.
-
-On error this function returns -1.
-
-=head2 guestfs_wc_w
-
- int guestfs_wc_w (guestfs_h *handle,
- const char *path);
-
-This command counts the words in a file, using the
-C<wc -w> external command.
-
-On error this function returns -1.
-
-=head2 guestfs_write_file
-
- int guestfs_write_file (guestfs_h *handle,
- const char *path,
- const char *content,
- int size);
-
-This call creates a file called C<path>. The contents of the
-file is the string C<content> (which can contain any 8 bit data),
-with length C<size>.
-
-As a special case, if C<size> is C<0>
-then the length is calculated using C<strlen> (so in this case
-the content cannot contain embedded ASCII NULs).
-
-I<NB.> Owing to a bug, writing content containing ASCII NUL
-characters does I<not> work, even if the length is specified.
-We hope to resolve this bug in a future version. In the meantime
-use C<guestfs_upload>.
-
-This function returns 0 on success or -1 on error.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=head2 guestfs_zero
-
- int guestfs_zero (guestfs_h *handle,
- const char *device);
-
-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.
-
-See also: C<guestfs_scrub_device>.
-
-This function returns 0 on success or -1 on error.
-
-=head2 guestfs_zerofree
-
- int guestfs_zerofree (guestfs_h *handle,
- const char *device);
-
-This runs the I<zerofree> program on C<device>. This program
-claims to zero unused inodes and disk blocks on an ext2/3
-filesystem, thus making it possible to compress the filesystem
-more effectively.
-
-You should B<not> run this program if the filesystem is
-mounted.
-
-It is possible that using this program can damage the filesystem
-or data on the filesystem.
-
-This function returns 0 on success or -1 on error.
-
+++ /dev/null
-=head2 guestfs_lvm_pv
-
- struct guestfs_lvm_pv {
- char *pv_name;
- /* The next field is NOT nul-terminated, be careful when printing it: */
- char pv_uuid[32];
- 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; /* Number of elements in list. */
- struct guestfs_lvm_pv *val; /* Elements. */
- };
-
- void guestfs_free_lvm_pv_list (struct guestfs_free_lvm_pv_list *);
-
-=head2 guestfs_lvm_vg
-
- struct guestfs_lvm_vg {
- char *vg_name;
- /* The next field is NOT nul-terminated, be careful when printing it: */
- char vg_uuid[32];
- 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; /* Number of elements in list. */
- struct guestfs_lvm_vg *val; /* Elements. */
- };
-
- void guestfs_free_lvm_vg_list (struct guestfs_free_lvm_vg_list *);
-
-=head2 guestfs_lvm_lv
-
- struct guestfs_lvm_lv {
- char *lv_name;
- /* The next field is NOT nul-terminated, be careful when printing it: */
- char lv_uuid[32];
- 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;
- /* The next field is [0..100] or -1 meaning 'not present': */
- float snap_percent;
- /* The next field is [0..100] or -1 meaning 'not present': */
- float copy_percent;
- char *move_pv;
- char *lv_tags;
- char *mirror_log;
- char *modules;
-
- struct guestfs_lvm_lv_list {
- uint32_t len; /* Number of elements in list. */
- struct guestfs_lvm_lv *val; /* Elements. */
- };
-
- void guestfs_free_lvm_lv_list (struct guestfs_free_lvm_lv_list *);
-
-=head2 guestfs_stat
-
- 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;
- };
-
-=head2 guestfs_statvfs
-
- 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;
- };
-
-=head2 guestfs_dirent
-
- struct guestfs_dirent {
- int64_t ino;
- char ftyp;
- char *name;
- };
-
- struct guestfs_dirent_list {
- uint32_t len; /* Number of elements in list. */
- struct guestfs_dirent *val; /* Elements. */
- };
-
- void guestfs_free_dirent_list (struct guestfs_free_dirent_list *);
-
+++ /dev/null
-{- 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 program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--}
-
-module Bindtests where
-import qualified Guestfs
-
-main = do
- g <- Guestfs.create
- Guestfs.test0 g "abc" (Just "def") [] False 0 "123" "456"
- Guestfs.test0 g "abc" Nothing [] False 0 "123" "456"
- Guestfs.test0 g "" (Just "def") [] False 0 "123" "456"
- Guestfs.test0 g "" (Just "") [] False 0 "123" "456"
- Guestfs.test0 g "abc" (Just "def") ["1"] False 0 "123" "456"
- Guestfs.test0 g "abc" (Just "def") ["1","2"] False 0 "123" "456"
- Guestfs.test0 g "abc" (Just "def") ["1"] True 0 "123" "456"
- Guestfs.test0 g "abc" (Just "def") ["1"] False (-1) "123" "456"
- Guestfs.test0 g "abc" (Just "def") ["1"] False (-2) "123" "456"
- Guestfs.test0 g "abc" (Just "def") ["1"] False 1 "123" "456"
- Guestfs.test0 g "abc" (Just "def") ["1"] False 2 "123" "456"
- Guestfs.test0 g "abc" (Just "def") ["1"] False 4095 "123" "456"
- Guestfs.test0 g "abc" (Just "def") ["1"] False 0 "" ""
- putStrLn "EOF"
+++ /dev/null
-{- 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 <guestfs.h> #-}
-{-# LANGUAGE ForeignFunctionInterface #-}
-
-module Guestfs (
- create,
- test0,
- test0rint,
- test0rinterr,
- test0rint64,
- test0rint64err,
- launch,
- wait_ready,
- kill_subprocess,
- add_drive,
- add_cdrom,
- add_drive_ro,
- config,
- set_qemu,
- set_path,
- set_append,
- set_autosync,
- set_verbose,
- get_state,
- set_busy,
- set_ready,
- end_busy,
- set_memsize,
- get_memsize,
- mount,
- sync,
- touch,
- aug_init,
- aug_close,
- aug_defvar,
- aug_set,
- aug_insert,
- aug_rm,
- aug_mv,
- aug_save,
- aug_load,
- rm,
- rmdir,
- rm_rf,
- mkdir,
- mkdir_p,
- chmod,
- chown,
- pvcreate,
- vgcreate,
- lvcreate,
- mkfs,
- sfdisk,
- write_file,
- umount,
- umount_all,
- lvm_remove_all,
- blockdev_setro,
- blockdev_setrw,
- blockdev_getss,
- blockdev_getbsz,
- blockdev_setbsz,
- blockdev_getsz,
- blockdev_getsize64,
- blockdev_flushbufs,
- blockdev_rereadpt,
- upload,
- download,
- tar_in,
- tar_out,
- tgz_in,
- tgz_out,
- mount_ro,
- mount_options,
- mount_vfs,
- lvremove,
- vgremove,
- pvremove,
- set_e2label,
- set_e2uuid,
- fsck,
- zero,
- grub_install,
- cp,
- cp_a,
- mv,
- drop_caches,
- ping_daemon,
- zerofree,
- pvresize,
- sfdisk_N,
- vg_activate_all,
- vg_activate,
- lvresize,
- resize2fs,
- e2fsck_f,
- sleep,
- ntfs_3g_probe,
- scrub_device,
- scrub_file,
- scrub_freespace,
- wc_l,
- wc_w,
- wc_c,
- du,
- mount_loop,
- mkswap,
- mkswap_L,
- mkswap_U,
- mknod,
- mkfifo,
- mknod_b,
- mknod_c,
- umask
- ) where
-import Foreign
-import Foreign.C
-import Foreign.C.Types
-import IO
-import Control.Exception
-import Data.Typeable
-
-data GuestfsS = GuestfsS -- represents the opaque C struct
-type GuestfsP = Ptr GuestfsS -- guestfs_h *
-type GuestfsH = ForeignPtr GuestfsS -- guestfs_h * with attached finalizer
-
--- XXX define properly later XXX
-data PV = PV
-data VG = VG
-data LV = LV
-data IntBool = IntBool
-data Stat = Stat
-data StatVFS = StatVFS
-data Hashtable = Hashtable
-
-foreign import ccall unsafe "guestfs_create" c_create
- :: IO GuestfsP
-foreign import ccall unsafe "&guestfs_close" c_close
- :: FunPtr (GuestfsP -> IO ())
-foreign import ccall unsafe "guestfs_set_error_handler" c_set_error_handler
- :: GuestfsP -> Ptr CInt -> Ptr CInt -> IO ()
-
-create :: IO GuestfsH
-create = do
- p <- c_create
- c_set_error_handler p nullPtr nullPtr
- h <- newForeignPtr c_close p
- return h
-
-foreign import ccall unsafe "guestfs_last_error" c_last_error
- :: GuestfsP -> IO CString
-
--- last_error :: GuestfsH -> IO (Maybe String)
--- last_error h = do
--- str <- withForeignPtr h (\p -> c_last_error p)
--- maybePeek peekCString str
-
-last_error :: GuestfsH -> IO (String)
-last_error h = do
- str <- withForeignPtr h (\p -> c_last_error p)
- if (str == nullPtr)
- then return "no error"
- else peekCString str
-
-foreign import ccall unsafe "guestfs_test0" c_test0
- :: GuestfsP -> CString -> CString -> Ptr CString -> CInt -> CInt -> CString -> CString -> IO (CInt)
-
-test0 :: GuestfsH -> String -> Maybe String -> [String] -> Bool -> Int -> String -> String -> IO ()
-test0 h str optstr strlist b integer filein fileout = do
- r <- withCString str $ \str -> maybeWith withCString optstr $ \optstr -> withMany withCString strlist $ \strlist -> withArray0 nullPtr strlist $ \strlist -> withCString filein $ \filein -> withCString fileout $ \fileout -> withForeignPtr h (\p -> c_test0 p str optstr strlist (fromBool b) (fromIntegral integer) filein fileout)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_test0rint" c_test0rint
- :: GuestfsP -> CString -> IO (CInt)
-
-test0rint :: GuestfsH -> String -> IO (Int)
-test0rint h val = do
- r <- withCString val $ \val -> withForeignPtr h (\p -> c_test0rint p val)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_test0rinterr" c_test0rinterr
- :: GuestfsP -> IO (CInt)
-
-test0rinterr :: GuestfsH -> IO (Int)
-test0rinterr h = do
- r <- withForeignPtr h (\p -> c_test0rinterr p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_test0rint64" c_test0rint64
- :: GuestfsP -> CString -> IO (Int64)
-
-test0rint64 :: GuestfsH -> String -> IO (Integer)
-test0rint64 h val = do
- r <- withCString val $ \val -> withForeignPtr h (\p -> c_test0rint64 p val)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_test0rint64err" c_test0rint64err
- :: GuestfsP -> IO (Int64)
-
-test0rint64err :: GuestfsH -> IO (Integer)
-test0rint64err h = do
- r <- withForeignPtr h (\p -> c_test0rint64err p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_launch" c_launch
- :: GuestfsP -> IO (CInt)
-
-launch :: GuestfsH -> IO ()
-launch h = do
- r <- withForeignPtr h (\p -> c_launch p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
- :: GuestfsP -> IO (CInt)
-
-wait_ready :: GuestfsH -> IO ()
-wait_ready h = do
- r <- withForeignPtr h (\p -> c_wait_ready p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
- :: GuestfsP -> IO (CInt)
-
-kill_subprocess :: GuestfsH -> IO ()
-kill_subprocess h = do
- r <- withForeignPtr h (\p -> c_kill_subprocess p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_add_drive" c_add_drive
- :: GuestfsP -> CString -> IO (CInt)
-
-add_drive :: GuestfsH -> String -> IO ()
-add_drive h filename = do
- r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive p filename)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
- :: GuestfsP -> CString -> IO (CInt)
-
-add_cdrom :: GuestfsH -> String -> IO ()
-add_cdrom h filename = do
- r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_cdrom p filename)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_add_drive_ro" c_add_drive_ro
- :: GuestfsP -> CString -> IO (CInt)
-
-add_drive_ro :: GuestfsH -> String -> IO ()
-add_drive_ro h filename = do
- r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive_ro p filename)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_config" c_config
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-config :: GuestfsH -> String -> Maybe String -> IO ()
-config h qemuparam qemuvalue = do
- r <- withCString qemuparam $ \qemuparam -> maybeWith withCString qemuvalue $ \qemuvalue -> withForeignPtr h (\p -> c_config p qemuparam qemuvalue)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
- :: GuestfsP -> CString -> IO (CInt)
-
-set_qemu :: GuestfsH -> String -> IO ()
-set_qemu h qemu = do
- r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_set_path" c_set_path
- :: GuestfsP -> CString -> IO (CInt)
-
-set_path :: GuestfsH -> String -> IO ()
-set_path h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_set_append" c_set_append
- :: GuestfsP -> CString -> IO (CInt)
-
-set_append :: GuestfsH -> String -> IO ()
-set_append h append = do
- r <- withCString append $ \append -> withForeignPtr h (\p -> c_set_append p append)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_set_autosync" c_set_autosync
- :: GuestfsP -> CInt -> IO (CInt)
-
-set_autosync :: GuestfsH -> Bool -> IO ()
-set_autosync h autosync = do
- r <- withForeignPtr h (\p -> c_set_autosync p (fromBool autosync))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_set_verbose" c_set_verbose
- :: GuestfsP -> CInt -> IO (CInt)
-
-set_verbose :: GuestfsH -> Bool -> IO ()
-set_verbose h verbose = do
- r <- withForeignPtr h (\p -> c_set_verbose p (fromBool verbose))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_get_state" c_get_state
- :: GuestfsP -> IO (CInt)
-
-get_state :: GuestfsH -> IO (Int)
-get_state h = do
- r <- withForeignPtr h (\p -> c_get_state p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_set_busy" c_set_busy
- :: GuestfsP -> IO (CInt)
-
-set_busy :: GuestfsH -> IO ()
-set_busy h = do
- r <- withForeignPtr h (\p -> c_set_busy p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_set_ready" c_set_ready
- :: GuestfsP -> IO (CInt)
-
-set_ready :: GuestfsH -> IO ()
-set_ready h = do
- r <- withForeignPtr h (\p -> c_set_ready p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_end_busy" c_end_busy
- :: GuestfsP -> IO (CInt)
-
-end_busy :: GuestfsH -> IO ()
-end_busy h = do
- r <- withForeignPtr h (\p -> c_end_busy p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_set_memsize" c_set_memsize
- :: GuestfsP -> CInt -> IO (CInt)
-
-set_memsize :: GuestfsH -> Int -> IO ()
-set_memsize h memsize = do
- r <- withForeignPtr h (\p -> c_set_memsize p (fromIntegral memsize))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_get_memsize" c_get_memsize
- :: GuestfsP -> IO (CInt)
-
-get_memsize :: GuestfsH -> IO (Int)
-get_memsize h = do
- r <- withForeignPtr h (\p -> c_get_memsize p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_mount" c_mount
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-mount :: GuestfsH -> String -> String -> IO ()
-mount h device mountpoint = do
- r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount p device mountpoint)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_sync" c_sync
- :: GuestfsP -> IO (CInt)
-
-sync :: GuestfsH -> IO ()
-sync h = do
- r <- withForeignPtr h (\p -> c_sync p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_touch" c_touch
- :: GuestfsP -> CString -> IO (CInt)
-
-touch :: GuestfsH -> String -> IO ()
-touch h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_aug_init" c_aug_init
- :: GuestfsP -> CString -> CInt -> IO (CInt)
-
-aug_init :: GuestfsH -> String -> Int -> IO ()
-aug_init h root flags = do
- r <- withCString root $ \root -> withForeignPtr h (\p -> c_aug_init p root (fromIntegral flags))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_aug_close" c_aug_close
- :: GuestfsP -> IO (CInt)
-
-aug_close :: GuestfsH -> IO ()
-aug_close h = do
- r <- withForeignPtr h (\p -> c_aug_close p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_aug_defvar" c_aug_defvar
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-aug_defvar :: GuestfsH -> String -> Maybe String -> IO (Int)
-aug_defvar h name expr = do
- r <- withCString name $ \name -> maybeWith withCString expr $ \expr -> withForeignPtr h (\p -> c_aug_defvar p name expr)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_aug_set" c_aug_set
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-aug_set :: GuestfsH -> String -> String -> IO ()
-aug_set h path val = do
- r <- withCString path $ \path -> withCString val $ \val -> withForeignPtr h (\p -> c_aug_set p path val)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_aug_insert" c_aug_insert
- :: GuestfsP -> CString -> CString -> CInt -> IO (CInt)
-
-aug_insert :: GuestfsH -> String -> String -> Bool -> IO ()
-aug_insert h path label before = do
- r <- withCString path $ \path -> withCString label $ \label -> withForeignPtr h (\p -> c_aug_insert p path label (fromBool before))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_aug_rm" c_aug_rm
- :: GuestfsP -> CString -> IO (CInt)
-
-aug_rm :: GuestfsH -> String -> IO (Int)
-aug_rm h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_aug_rm p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-aug_mv :: GuestfsH -> String -> String -> IO ()
-aug_mv h src dest = do
- r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_aug_mv p src dest)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_aug_save" c_aug_save
- :: GuestfsP -> IO (CInt)
-
-aug_save :: GuestfsH -> IO ()
-aug_save h = do
- r <- withForeignPtr h (\p -> c_aug_save p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_aug_load" c_aug_load
- :: GuestfsP -> IO (CInt)
-
-aug_load :: GuestfsH -> IO ()
-aug_load h = do
- r <- withForeignPtr h (\p -> c_aug_load p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_rm" c_rm
- :: GuestfsP -> CString -> IO (CInt)
-
-rm :: GuestfsH -> String -> IO ()
-rm h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_rmdir" c_rmdir
- :: GuestfsP -> CString -> IO (CInt)
-
-rmdir :: GuestfsH -> String -> IO ()
-rmdir h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
- :: GuestfsP -> CString -> IO (CInt)
-
-rm_rf :: GuestfsH -> String -> IO ()
-rm_rf h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mkdir" c_mkdir
- :: GuestfsP -> CString -> IO (CInt)
-
-mkdir :: GuestfsH -> String -> IO ()
-mkdir h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
- :: GuestfsP -> CString -> IO (CInt)
-
-mkdir_p :: GuestfsH -> String -> IO ()
-mkdir_p h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_chmod" c_chmod
- :: GuestfsP -> CInt -> CString -> IO (CInt)
-
-chmod :: GuestfsH -> Int -> String -> IO ()
-chmod h mode path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_chmod p (fromIntegral mode) path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_chown" c_chown
- :: GuestfsP -> CInt -> CInt -> CString -> IO (CInt)
-
-chown :: GuestfsH -> Int -> Int -> String -> IO ()
-chown h owner group path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_chown p (fromIntegral owner) (fromIntegral group) path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
- :: GuestfsP -> CString -> IO (CInt)
-
-pvcreate :: GuestfsH -> String -> IO ()
-pvcreate h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
- :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
-
-vgcreate :: GuestfsH -> String -> [String] -> IO ()
-vgcreate h volgroup physvols = do
- r <- withCString volgroup $ \volgroup -> withMany withCString physvols $ \physvols -> withArray0 nullPtr physvols $ \physvols -> withForeignPtr h (\p -> c_vgcreate p volgroup physvols)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_lvcreate" c_lvcreate
- :: GuestfsP -> CString -> CString -> CInt -> IO (CInt)
-
-lvcreate :: GuestfsH -> String -> String -> Int -> IO ()
-lvcreate h logvol volgroup mbytes = do
- r <- withCString logvol $ \logvol -> withCString volgroup $ \volgroup -> withForeignPtr h (\p -> c_lvcreate p logvol volgroup (fromIntegral mbytes))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mkfs" c_mkfs
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-mkfs :: GuestfsH -> String -> String -> IO ()
-mkfs h fstype device = do
- r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_mkfs p fstype device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_sfdisk" c_sfdisk
- :: GuestfsP -> CString -> CInt -> CInt -> CInt -> Ptr CString -> IO (CInt)
-
-sfdisk :: GuestfsH -> String -> Int -> Int -> Int -> [String] -> IO ()
-sfdisk h device cyls heads sectors lines = do
- r <- withCString device $ \device -> withMany withCString lines $ \lines -> withArray0 nullPtr lines $ \lines -> withForeignPtr h (\p -> c_sfdisk p device (fromIntegral cyls) (fromIntegral heads) (fromIntegral sectors) lines)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_write_file" c_write_file
- :: GuestfsP -> CString -> CString -> CInt -> IO (CInt)
-
-write_file :: GuestfsH -> String -> String -> Int -> IO ()
-write_file h path content size = do
- r <- withCString path $ \path -> withCString content $ \content -> withForeignPtr h (\p -> c_write_file p path content (fromIntegral size))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_umount" c_umount
- :: GuestfsP -> CString -> IO (CInt)
-
-umount :: GuestfsH -> String -> IO ()
-umount h pathordevice = do
- r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_umount_all" c_umount_all
- :: GuestfsP -> IO (CInt)
-
-umount_all :: GuestfsH -> IO ()
-umount_all h = do
- r <- withForeignPtr h (\p -> c_umount_all p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
- :: GuestfsP -> IO (CInt)
-
-lvm_remove_all :: GuestfsH -> IO ()
-lvm_remove_all h = do
- r <- withForeignPtr h (\p -> c_lvm_remove_all p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
- :: GuestfsP -> CString -> IO (CInt)
-
-blockdev_setro :: GuestfsH -> String -> IO ()
-blockdev_setro h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setro p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
- :: GuestfsP -> CString -> IO (CInt)
-
-blockdev_setrw :: GuestfsH -> String -> IO ()
-blockdev_setrw h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setrw p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_blockdev_getss" c_blockdev_getss
- :: GuestfsP -> CString -> IO (CInt)
-
-blockdev_getss :: GuestfsH -> String -> IO (Int)
-blockdev_getss h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_getss p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_blockdev_getbsz" c_blockdev_getbsz
- :: GuestfsP -> CString -> IO (CInt)
-
-blockdev_getbsz :: GuestfsH -> String -> IO (Int)
-blockdev_getbsz h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_getbsz p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_blockdev_setbsz" c_blockdev_setbsz
- :: GuestfsP -> CString -> CInt -> IO (CInt)
-
-blockdev_setbsz :: GuestfsH -> String -> Int -> IO ()
-blockdev_setbsz h device blocksize = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setbsz p device (fromIntegral blocksize))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_blockdev_getsz" c_blockdev_getsz
- :: GuestfsP -> CString -> IO (Int64)
-
-blockdev_getsz :: GuestfsH -> String -> IO (Integer)
-blockdev_getsz h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_getsz p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_blockdev_getsize64" c_blockdev_getsize64
- :: GuestfsP -> CString -> IO (Int64)
-
-blockdev_getsize64 :: GuestfsH -> String -> IO (Integer)
-blockdev_getsize64 h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_getsize64 p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
- :: GuestfsP -> CString -> IO (CInt)
-
-blockdev_flushbufs :: GuestfsH -> String -> IO ()
-blockdev_flushbufs h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_flushbufs p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
- :: GuestfsP -> CString -> IO (CInt)
-
-blockdev_rereadpt :: GuestfsH -> String -> IO ()
-blockdev_rereadpt h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_rereadpt p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_upload" c_upload
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-upload :: GuestfsH -> String -> String -> IO ()
-upload h filename remotefilename = do
- r <- withCString filename $ \filename -> withCString remotefilename $ \remotefilename -> withForeignPtr h (\p -> c_upload p filename remotefilename)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_download" c_download
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-download :: GuestfsH -> String -> String -> IO ()
-download h remotefilename filename = do
- r <- withCString remotefilename $ \remotefilename -> withCString filename $ \filename -> withForeignPtr h (\p -> c_download p remotefilename filename)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_tar_in" c_tar_in
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-tar_in :: GuestfsH -> String -> String -> IO ()
-tar_in h tarfile directory = do
- r <- withCString tarfile $ \tarfile -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tar_in p tarfile directory)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_tar_out" c_tar_out
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-tar_out :: GuestfsH -> String -> String -> IO ()
-tar_out h directory tarfile = do
- r <- withCString directory $ \directory -> withCString tarfile $ \tarfile -> withForeignPtr h (\p -> c_tar_out p directory tarfile)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-tgz_in :: GuestfsH -> String -> String -> IO ()
-tgz_in h tarball directory = do
- r <- withCString tarball $ \tarball -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tgz_in p tarball directory)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-tgz_out :: GuestfsH -> String -> String -> IO ()
-tgz_out h directory tarball = do
- r <- withCString directory $ \directory -> withCString tarball $ \tarball -> withForeignPtr h (\p -> c_tgz_out p directory tarball)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-mount_ro :: GuestfsH -> String -> String -> IO ()
-mount_ro h device mountpoint = do
- r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_ro p device mountpoint)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mount_options" c_mount_options
- :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
-
-mount_options :: GuestfsH -> String -> String -> String -> IO ()
-mount_options h options device mountpoint = do
- r <- withCString options $ \options -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_options p options device mountpoint)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
- :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
-
-mount_vfs :: GuestfsH -> String -> String -> String -> String -> IO ()
-mount_vfs h options vfstype device mountpoint = do
- r <- withCString options $ \options -> withCString vfstype $ \vfstype -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_vfs p options vfstype device mountpoint)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_lvremove" c_lvremove
- :: GuestfsP -> CString -> IO (CInt)
-
-lvremove :: GuestfsH -> String -> IO ()
-lvremove h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_vgremove" c_vgremove
- :: GuestfsP -> CString -> IO (CInt)
-
-vgremove :: GuestfsH -> String -> IO ()
-vgremove h vgname = do
- r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_pvremove" c_pvremove
- :: GuestfsP -> CString -> IO (CInt)
-
-pvremove :: GuestfsH -> String -> IO ()
-pvremove h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-set_e2label :: GuestfsH -> String -> String -> IO ()
-set_e2label h device label = do
- r <- withCString device $ \device -> withCString label $ \label -> withForeignPtr h (\p -> c_set_e2label p device label)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-set_e2uuid :: GuestfsH -> String -> String -> IO ()
-set_e2uuid h device uuid = do
- r <- withCString device $ \device -> withCString uuid $ \uuid -> withForeignPtr h (\p -> c_set_e2uuid p device uuid)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_fsck" c_fsck
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-fsck :: GuestfsH -> String -> String -> IO (Int)
-fsck h fstype device = do
- r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_fsck p fstype device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_zero" c_zero
- :: GuestfsP -> CString -> IO (CInt)
-
-zero :: GuestfsH -> String -> IO ()
-zero h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_grub_install" c_grub_install
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-grub_install :: GuestfsH -> String -> String -> IO ()
-grub_install h root device = do
- r <- withCString root $ \root -> withCString device $ \device -> withForeignPtr h (\p -> c_grub_install p root device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_cp" c_cp
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-cp :: GuestfsH -> String -> String -> IO ()
-cp h src dest = do
- r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_cp_a" c_cp_a
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-cp_a :: GuestfsH -> String -> String -> IO ()
-cp_a h src dest = do
- r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mv" c_mv
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-mv :: GuestfsH -> String -> String -> IO ()
-mv h src dest = do
- r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_drop_caches" c_drop_caches
- :: GuestfsP -> CInt -> IO (CInt)
-
-drop_caches :: GuestfsH -> Int -> IO ()
-drop_caches h whattodrop = do
- r <- withForeignPtr h (\p -> c_drop_caches p (fromIntegral whattodrop))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
- :: GuestfsP -> IO (CInt)
-
-ping_daemon :: GuestfsH -> IO ()
-ping_daemon h = do
- r <- withForeignPtr h (\p -> c_ping_daemon p)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_zerofree" c_zerofree
- :: GuestfsP -> CString -> IO (CInt)
-
-zerofree :: GuestfsH -> String -> IO ()
-zerofree h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_zerofree p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_pvresize" c_pvresize
- :: GuestfsP -> CString -> IO (CInt)
-
-pvresize :: GuestfsH -> String -> IO ()
-pvresize h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvresize p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_sfdisk_N" c_sfdisk_N
- :: GuestfsP -> CString -> CInt -> CInt -> CInt -> CInt -> CString -> IO (CInt)
-
-sfdisk_N :: GuestfsH -> String -> Int -> Int -> Int -> Int -> String -> IO ()
-sfdisk_N h device partnum cyls heads sectors line = do
- r <- withCString device $ \device -> withCString line $ \line -> withForeignPtr h (\p -> c_sfdisk_N p device (fromIntegral partnum) (fromIntegral cyls) (fromIntegral heads) (fromIntegral sectors) line)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_vg_activate_all" c_vg_activate_all
- :: GuestfsP -> CInt -> IO (CInt)
-
-vg_activate_all :: GuestfsH -> Bool -> IO ()
-vg_activate_all h activate = do
- r <- withForeignPtr h (\p -> c_vg_activate_all p (fromBool activate))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_vg_activate" c_vg_activate
- :: GuestfsP -> CInt -> Ptr CString -> IO (CInt)
-
-vg_activate :: GuestfsH -> Bool -> [String] -> IO ()
-vg_activate h activate volgroups = do
- r <- withMany withCString volgroups $ \volgroups -> withArray0 nullPtr volgroups $ \volgroups -> withForeignPtr h (\p -> c_vg_activate p (fromBool activate) volgroups)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_lvresize" c_lvresize
- :: GuestfsP -> CString -> CInt -> IO (CInt)
-
-lvresize :: GuestfsH -> String -> Int -> IO ()
-lvresize h device mbytes = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvresize p device (fromIntegral mbytes))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_resize2fs" c_resize2fs
- :: GuestfsP -> CString -> IO (CInt)
-
-resize2fs :: GuestfsH -> String -> IO ()
-resize2fs h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_resize2fs p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_e2fsck_f" c_e2fsck_f
- :: GuestfsP -> CString -> IO (CInt)
-
-e2fsck_f :: GuestfsH -> String -> IO ()
-e2fsck_f h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_e2fsck_f p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_sleep" c_sleep
- :: GuestfsP -> CInt -> IO (CInt)
-
-sleep :: GuestfsH -> Int -> IO ()
-sleep h secs = do
- r <- withForeignPtr h (\p -> c_sleep p (fromIntegral secs))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_ntfs_3g_probe" c_ntfs_3g_probe
- :: GuestfsP -> CInt -> CString -> IO (CInt)
-
-ntfs_3g_probe :: GuestfsH -> Bool -> String -> IO (Int)
-ntfs_3g_probe h rw device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_ntfs_3g_probe p (fromBool rw) device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_scrub_device" c_scrub_device
- :: GuestfsP -> CString -> IO (CInt)
-
-scrub_device :: GuestfsH -> String -> IO ()
-scrub_device h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_scrub_device p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_scrub_file" c_scrub_file
- :: GuestfsP -> CString -> IO (CInt)
-
-scrub_file :: GuestfsH -> String -> IO ()
-scrub_file h file = do
- r <- withCString file $ \file -> withForeignPtr h (\p -> c_scrub_file p file)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_scrub_freespace" c_scrub_freespace
- :: GuestfsP -> CString -> IO (CInt)
-
-scrub_freespace :: GuestfsH -> String -> IO ()
-scrub_freespace h dir = do
- r <- withCString dir $ \dir -> withForeignPtr h (\p -> c_scrub_freespace p dir)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_wc_l" c_wc_l
- :: GuestfsP -> CString -> IO (CInt)
-
-wc_l :: GuestfsH -> String -> IO (Int)
-wc_l h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_wc_l p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_wc_w" c_wc_w
- :: GuestfsP -> CString -> IO (CInt)
-
-wc_w :: GuestfsH -> String -> IO (Int)
-wc_w h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_wc_w p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_wc_c" c_wc_c
- :: GuestfsP -> CString -> IO (CInt)
-
-wc_c :: GuestfsH -> String -> IO (Int)
-wc_c h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_wc_c p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_du" c_du
- :: GuestfsP -> CString -> IO (Int64)
-
-du :: GuestfsH -> String -> IO (Integer)
-du h path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_du p path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
-foreign import ccall unsafe "guestfs_mount_loop" c_mount_loop
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-mount_loop :: GuestfsH -> String -> String -> IO ()
-mount_loop h file mountpoint = do
- r <- withCString file $ \file -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_loop p file mountpoint)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mkswap" c_mkswap
- :: GuestfsP -> CString -> IO (CInt)
-
-mkswap :: GuestfsH -> String -> IO ()
-mkswap h device = do
- r <- withCString device $ \device -> withForeignPtr h (\p -> c_mkswap p device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mkswap_L" c_mkswap_L
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-mkswap_L :: GuestfsH -> String -> String -> IO ()
-mkswap_L h label device = do
- r <- withCString label $ \label -> withCString device $ \device -> withForeignPtr h (\p -> c_mkswap_L p label device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mkswap_U" c_mkswap_U
- :: GuestfsP -> CString -> CString -> IO (CInt)
-
-mkswap_U :: GuestfsH -> String -> String -> IO ()
-mkswap_U h uuid device = do
- r <- withCString uuid $ \uuid -> withCString device $ \device -> withForeignPtr h (\p -> c_mkswap_U p uuid device)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mknod" c_mknod
- :: GuestfsP -> CInt -> CInt -> CInt -> CString -> IO (CInt)
-
-mknod :: GuestfsH -> Int -> Int -> Int -> String -> IO ()
-mknod h mode devmajor devminor path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_mknod p (fromIntegral mode) (fromIntegral devmajor) (fromIntegral devminor) path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mkfifo" c_mkfifo
- :: GuestfsP -> CInt -> CString -> IO (CInt)
-
-mkfifo :: GuestfsH -> Int -> String -> IO ()
-mkfifo h mode path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkfifo p (fromIntegral mode) path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mknod_b" c_mknod_b
- :: GuestfsP -> CInt -> CInt -> CInt -> CString -> IO (CInt)
-
-mknod_b :: GuestfsH -> Int -> Int -> Int -> String -> IO ()
-mknod_b h mode devmajor devminor path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_mknod_b p (fromIntegral mode) (fromIntegral devmajor) (fromIntegral devminor) path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_mknod_c" c_mknod_c
- :: GuestfsP -> CInt -> CInt -> CInt -> CString -> IO (CInt)
-
-mknod_c :: GuestfsH -> Int -> Int -> Int -> String -> IO ()
-mknod_c h mode devmajor devminor path = do
- r <- withCString path $ \path -> withForeignPtr h (\p -> c_mknod_c p (fromIntegral mode) (fromIntegral devmajor) (fromIntegral devminor) path)
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return ()
-
-foreign import ccall unsafe "guestfs_umask" c_umask
- :: GuestfsP -> CInt -> IO (CInt)
-
-umask :: GuestfsH -> Int -> IO (Int)
-umask h mask = do
- r <- withForeignPtr h (\p -> c_umask p (fromIntegral mask))
- if (r == -1)
- then do
- err <- last_error h
- fail err
- else return (fromIntegral r)
-
+++ /dev/null
-/* 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 program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-import com.redhat.et.libguestfs.*;
-
-public class Bindtests {
- public static void main (String[] argv)
- {
- try {
- GuestFS g = new GuestFS ();
- g.test0 ("abc", "def", new String[]{}, false, 0, "123", "456");
- g.test0 ("abc", null, new String[]{}, false, 0, "123", "456");
- g.test0 ("", "def", new String[]{}, false, 0, "123", "456");
- g.test0 ("", "", new String[]{}, false, 0, "123", "456");
- g.test0 ("abc", "def", new String[]{"1"}, false, 0, "123", "456");
- g.test0 ("abc", "def", new String[]{"1","2"}, false, 0, "123", "456");
- g.test0 ("abc", "def", new String[]{"1"}, true, 0, "123", "456");
- g.test0 ("abc", "def", new String[]{"1"}, false, -1, "123", "456");
- g.test0 ("abc", "def", new String[]{"1"}, false, -2, "123", "456");
- g.test0 ("abc", "def", new String[]{"1"}, false, 1, "123", "456");
- g.test0 ("abc", "def", new String[]{"1"}, false, 2, "123", "456");
- g.test0 ("abc", "def", new String[]{"1"}, false, 4095, "123", "456");
- g.test0 ("abc", "def", new String[]{"1"}, false, 0, "", "");
-
- System.out.println ("EOF");
- }
- catch (Exception exn) {
- System.err.println (exn);
- System.exit (1);
- }
- }
-}
+++ /dev/null
-/* 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
- */
-
-package com.redhat.et.libguestfs;
-
-/**
- * Libguestfs Dirent structure.
- *
- * @author rjones
- * @see GuestFS
- */
-public class Dirent {
- public long ino;
- public char ftyp;
- public String name;
-}
+++ /dev/null
-/* 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
- */
-
-package com.redhat.et.libguestfs;
-
-import java.util.HashMap;
-import com.redhat.et.libguestfs.LibGuestFSException;
-import com.redhat.et.libguestfs.PV;
-import com.redhat.et.libguestfs.VG;
-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.
- *
- * @author rjones
- */
-public class GuestFS {
- // Load the native code.
- static {
- System.loadLibrary ("guestfs_jni");
- }
-
- /**
- * The native guestfs_h pointer.
- */
- long g;
-
- /**
- * Create a libguestfs handle.
- *
- * @throws LibGuestFSException
- */
- public GuestFS () throws LibGuestFSException
- {
- g = _create ();
- }
- private native long _create () throws LibGuestFSException;
-
- /**
- * Close a libguestfs handle.
- *
- * You can also leave handles to be collected by the garbage
- * collector, but this method ensures that the resources used
- * by the handle are freed up immediately. If you call any
- * other methods after closing the handle, you will get an
- * exception.
- *
- * @throws LibGuestFSException
- */
- public void close () throws LibGuestFSException
- {
- if (g != 0)
- _close (g);
- g = 0;
- }
- private native void _close (long g) throws LibGuestFSException;
-
- public void finalize () throws LibGuestFSException
- {
- close ();
- }
-
-public void test0 (String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0: handle is closed");
- _test0 (g, str, optstr, strlist, b, integer, filein, fileout);
- }
- private native void _test0 (long g, String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
- throws LibGuestFSException;
-
-public int test0rint (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rint: handle is closed");
- return _test0rint (g, val);
- }
- private native int _test0rint (long g, String val)
- throws LibGuestFSException;
-
-public int test0rinterr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rinterr: handle is closed");
- return _test0rinterr (g);
- }
- private native int _test0rinterr (long g)
- throws LibGuestFSException;
-
-public long test0rint64 (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rint64: handle is closed");
- return _test0rint64 (g, val);
- }
- private native long _test0rint64 (long g, String val)
- throws LibGuestFSException;
-
-public long test0rint64err ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rint64err: handle is closed");
- return _test0rint64err (g);
- }
- private native long _test0rint64err (long g)
- throws LibGuestFSException;
-
-public boolean test0rbool (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rbool: handle is closed");
- return _test0rbool (g, val);
- }
- private native boolean _test0rbool (long g, String val)
- throws LibGuestFSException;
-
-public boolean test0rboolerr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rboolerr: handle is closed");
- return _test0rboolerr (g);
- }
- private native boolean _test0rboolerr (long g)
- throws LibGuestFSException;
-
-public String test0rconststring (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rconststring: handle is closed");
- return _test0rconststring (g, val);
- }
- private native String _test0rconststring (long g, String val)
- throws LibGuestFSException;
-
-public String test0rconststringerr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rconststringerr: handle is closed");
- return _test0rconststringerr (g);
- }
- private native String _test0rconststringerr (long g)
- throws LibGuestFSException;
-
-public String test0rstring (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rstring: handle is closed");
- return _test0rstring (g, val);
- }
- private native String _test0rstring (long g, String val)
- throws LibGuestFSException;
-
-public String test0rstringerr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rstringerr: handle is closed");
- return _test0rstringerr (g);
- }
- private native String _test0rstringerr (long g)
- throws LibGuestFSException;
-
-public String[] test0rstringlist (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rstringlist: handle is closed");
- return _test0rstringlist (g, val);
- }
- private native String[] _test0rstringlist (long g, String val)
- throws LibGuestFSException;
-
-public String[] test0rstringlisterr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rstringlisterr: handle is closed");
- return _test0rstringlisterr (g);
- }
- private native String[] _test0rstringlisterr (long g)
- throws LibGuestFSException;
-
-public IntBool test0rintbool (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rintbool: handle is closed");
- return _test0rintbool (g, val);
- }
- private native IntBool _test0rintbool (long g, String val)
- throws LibGuestFSException;
-
-public IntBool test0rintboolerr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rintboolerr: handle is closed");
- return _test0rintboolerr (g);
- }
- private native IntBool _test0rintboolerr (long g)
- throws LibGuestFSException;
-
-public PV[] test0rpvlist (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rpvlist: handle is closed");
- return _test0rpvlist (g, val);
- }
- private native PV[] _test0rpvlist (long g, String val)
- throws LibGuestFSException;
-
-public PV[] test0rpvlisterr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rpvlisterr: handle is closed");
- return _test0rpvlisterr (g);
- }
- private native PV[] _test0rpvlisterr (long g)
- throws LibGuestFSException;
-
-public VG[] test0rvglist (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rvglist: handle is closed");
- return _test0rvglist (g, val);
- }
- private native VG[] _test0rvglist (long g, String val)
- throws LibGuestFSException;
-
-public VG[] test0rvglisterr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rvglisterr: handle is closed");
- return _test0rvglisterr (g);
- }
- private native VG[] _test0rvglisterr (long g)
- throws LibGuestFSException;
-
-public LV[] test0rlvlist (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rlvlist: handle is closed");
- return _test0rlvlist (g, val);
- }
- private native LV[] _test0rlvlist (long g, String val)
- throws LibGuestFSException;
-
-public LV[] test0rlvlisterr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rlvlisterr: handle is closed");
- return _test0rlvlisterr (g);
- }
- private native LV[] _test0rlvlisterr (long g)
- throws LibGuestFSException;
-
-public Stat test0rstat (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rstat: handle is closed");
- return _test0rstat (g, val);
- }
- private native Stat _test0rstat (long g, String val)
- throws LibGuestFSException;
-
-public Stat test0rstaterr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rstaterr: handle is closed");
- return _test0rstaterr (g);
- }
- private native Stat _test0rstaterr (long g)
- throws LibGuestFSException;
-
-public StatVFS test0rstatvfs (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rstatvfs: handle is closed");
- return _test0rstatvfs (g, val);
- }
- private native StatVFS _test0rstatvfs (long g, String val)
- throws LibGuestFSException;
-
-public StatVFS test0rstatvfserr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rstatvfserr: handle is closed");
- return _test0rstatvfserr (g);
- }
- private native StatVFS _test0rstatvfserr (long g)
- throws LibGuestFSException;
-
-public HashMap<String,String> test0rhashtable (String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rhashtable: handle is closed");
- return _test0rhashtable (g, val);
- }
- private native HashMap<String,String> _test0rhashtable (long g, String val)
- throws LibGuestFSException;
-
-public HashMap<String,String> test0rhashtableerr ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("test0rhashtableerr: handle is closed");
- return _test0rhashtableerr (g);
- }
- private native HashMap<String,String> _test0rhashtableerr (long g)
- throws LibGuestFSException;
-
- /**
- * launch the qemu subprocess
- * <p>
- * Internally libguestfs is implemented by running a
- * virtual machine using qemu(1).
- * <p>
- * You should call this after configuring the handle (eg.
- * adding drives) but before performing any actions.
- * <p>
- * @throws LibGuestFSException
- */
- public void launch ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("launch: handle is closed");
- _launch (g);
- }
- private native void _launch (long g)
- throws LibGuestFSException;
-
- /**
- * wait until the qemu subprocess launches
- * <p>
- * Internally libguestfs is implemented by running a
- * virtual machine using qemu(1).
- * <p>
- * You should call this after "g.launch" to wait for the
- * launch to complete.
- * <p>
- * @throws LibGuestFSException
- */
- public void wait_ready ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("wait_ready: handle is closed");
- _wait_ready (g);
- }
- private native void _wait_ready (long g)
- throws LibGuestFSException;
-
- /**
- * kill the qemu subprocess
- * <p>
- * This kills the qemu subprocess. You should never need to
- * call this.
- * <p>
- * @throws LibGuestFSException
- */
- public void kill_subprocess ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("kill_subprocess: handle is closed");
- _kill_subprocess (g);
- }
- private native void _kill_subprocess (long g)
- throws LibGuestFSException;
-
- /**
- * add an image to examine or modify
- * <p>
- * This function adds a virtual machine disk image
- * "filename" to the guest. The first time you call this
- * function, the disk appears as IDE disk 0 ("/dev/sda") in
- * the guest, the second time as "/dev/sdb", and so on.
- * <p>
- * You don't necessarily need to be root when using
- * libguestfs. However you obviously do need sufficient
- * permissions to access the filename 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).
- * <p>
- * This is equivalent to the qemu parameter "-drive
- * file=filename,cache=off,if=virtio".
- * <p>
- * Note that this call checks for the existence of
- * "filename". This stops you from specifying other types
- * of drive which are supported by qemu such as "nbd:" and
- * "http:" URLs. To specify those, use the general
- * "g.config" call instead.
- * <p>
- * @throws LibGuestFSException
- */
- public void add_drive (String filename)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("add_drive: handle is closed");
- _add_drive (g, filename);
- }
- private native void _add_drive (long g, String filename)
- throws LibGuestFSException;
-
- /**
- * add a CD-ROM disk image to examine
- * <p>
- * This function adds a virtual CD-ROM disk image to the
- * guest.
- * <p>
- * This is equivalent to the qemu parameter "-cdrom
- * filename".
- * <p>
- * Note that this call checks for the existence of
- * "filename". This stops you from specifying other types
- * of drive which are supported by qemu such as "nbd:" and
- * "http:" URLs. To specify those, use the general
- * "g.config" call instead.
- * <p>
- * @throws LibGuestFSException
- */
- public void add_cdrom (String filename)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("add_cdrom: handle is closed");
- _add_cdrom (g, filename);
- }
- private native void _add_cdrom (long g, String filename)
- throws LibGuestFSException;
-
- /**
- * add a drive in snapshot mode (read-only)
- * <p>
- * This adds a drive in snapshot mode, making it
- * effectively read-only.
- * <p>
- * Note that writes to the device are allowed, and will be
- * seen for the duration of the guestfs handle, but they
- * are written to a temporary file which is discarded as
- * soon as the guestfs handle is closed. We don't currently
- * have any method to enable changes to be committed,
- * although qemu can support this.
- * <p>
- * This is equivalent to the qemu parameter "-drive
- * file=filename,snapshot=on,if=virtio".
- * <p>
- * Note that this call checks for the existence of
- * "filename". This stops you from specifying other types
- * of drive which are supported by qemu such as "nbd:" and
- * "http:" URLs. To specify those, use the general
- * "g.config" call instead.
- * <p>
- * @throws LibGuestFSException
- */
- public void add_drive_ro (String filename)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("add_drive_ro: handle is closed");
- _add_drive_ro (g, filename);
- }
- private native void _add_drive_ro (long g, String filename)
- throws LibGuestFSException;
-
- /**
- * add qemu parameters
- * <p>
- * This can be used to add arbitrary qemu command line
- * parameters of the form "-param value". Actually it's not
- * quite arbitrary - we prevent you from setting some
- * parameters which would interfere with parameters that we
- * use.
- * <p>
- * The first character of "param" string must be a "-"
- * (dash).
- * <p>
- * "value" can be NULL.
- * <p>
- * @throws LibGuestFSException
- */
- public void config (String qemuparam, String qemuvalue)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("config: handle is closed");
- _config (g, qemuparam, qemuvalue);
- }
- private native void _config (long g, String qemuparam, String qemuvalue)
- throws LibGuestFSException;
-
- /**
- * set the qemu binary
- * <p>
- * Set the qemu binary that we will use.
- * <p>
- * The default is chosen when the library was compiled by
- * the configure script.
- * <p>
- * You can also override this by setting the
- * "LIBGUESTFS_QEMU" environment variable.
- * <p>
- * Setting "qemu" to "NULL" restores the default qemu
- * binary.
- * <p>
- * @throws LibGuestFSException
- */
- public void set_qemu (String qemu)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_qemu: handle is closed");
- _set_qemu (g, qemu);
- }
- private native void _set_qemu (long g, String qemu)
- throws LibGuestFSException;
-
- /**
- * get the qemu binary
- * <p>
- * Return the current qemu binary.
- * <p>
- * This is always non-NULL. If it wasn't set already, then
- * this will return the default qemu binary name.
- * <p>
- * @throws LibGuestFSException
- */
- public String get_qemu ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("get_qemu: handle is closed");
- return _get_qemu (g);
- }
- private native String _get_qemu (long g)
- throws LibGuestFSException;
-
- /**
- * set the search path
- * <p>
- * Set the path that libguestfs searches for kernel and
- * initrd.img.
- * <p>
- * The default is "$libdir/guestfs" unless overridden by
- * setting "LIBGUESTFS_PATH" environment variable.
- * <p>
- * Setting "path" to "NULL" restores the default path.
- * <p>
- * @throws LibGuestFSException
- */
- public void set_path (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_path: handle is closed");
- _set_path (g, path);
- }
- private native void _set_path (long g, String path)
- throws LibGuestFSException;
-
- /**
- * get the search path
- * <p>
- * Return the current search path.
- * <p>
- * This is always non-NULL. If it wasn't set already, then
- * this will return the default path.
- * <p>
- * @throws LibGuestFSException
- */
- public String get_path ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("get_path: handle is closed");
- return _get_path (g);
- }
- private native String _get_path (long g)
- throws LibGuestFSException;
-
- /**
- * add options to kernel command line
- * <p>
- * This function is used to add additional options to the
- * guest kernel command line.
- * <p>
- * The default is "NULL" unless overridden by setting
- * "LIBGUESTFS_APPEND" environment variable.
- * <p>
- * Setting "append" to "NULL" means *no* additional options
- * are passed (libguestfs always adds a few of its own).
- * <p>
- * @throws LibGuestFSException
- */
- public void set_append (String append)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_append: handle is closed");
- _set_append (g, append);
- }
- private native void _set_append (long g, String append)
- throws LibGuestFSException;
-
- /**
- * get the additional kernel options
- * <p>
- * Return the additional kernel options which are added to
- * the guest kernel command line.
- * <p>
- * If "NULL" then no options are added.
- * <p>
- * @throws LibGuestFSException
- */
- public String get_append ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("get_append: handle is closed");
- return _get_append (g);
- }
- private native String _get_append (long g)
- throws LibGuestFSException;
-
- /**
- * set autosync mode
- * <p>
- * If "autosync" is true, this enables autosync. Libguestfs
- * will make a best effort attempt to run "g.umount_all"
- * followed by "g.sync" when the handle is closed (also if
- * the program exits without closing handles).
- * <p>
- * This is disabled by default (except in guestfish where
- * it is enabled by default).
- * <p>
- * @throws LibGuestFSException
- */
- public void set_autosync (boolean autosync)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_autosync: handle is closed");
- _set_autosync (g, autosync);
- }
- private native void _set_autosync (long g, boolean autosync)
- throws LibGuestFSException;
-
- /**
- * get autosync mode
- * <p>
- * Get the autosync flag.
- * <p>
- * @throws LibGuestFSException
- */
- public boolean get_autosync ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("get_autosync: handle is closed");
- return _get_autosync (g);
- }
- private native boolean _get_autosync (long g)
- throws LibGuestFSException;
-
- /**
- * set verbose mode
- * <p>
- * If "verbose" is true, this turns on verbose messages (to
- * "stderr").
- * <p>
- * Verbose messages are disabled unless the environment
- * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
- * <p>
- * @throws LibGuestFSException
- */
- public void set_verbose (boolean verbose)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_verbose: handle is closed");
- _set_verbose (g, verbose);
- }
- private native void _set_verbose (long g, boolean verbose)
- throws LibGuestFSException;
-
- /**
- * get verbose mode
- * <p>
- * This returns the verbose messages flag.
- * <p>
- * @throws LibGuestFSException
- */
- public boolean get_verbose ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("get_verbose: handle is closed");
- return _get_verbose (g);
- }
- private native boolean _get_verbose (long g)
- throws LibGuestFSException;
-
- /**
- * is ready to accept commands
- * <p>
- * This returns true iff this handle is ready to accept
- * commands (in the "READY" state).
- * <p>
- * For more information on states, see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public boolean is_ready ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("is_ready: handle is closed");
- return _is_ready (g);
- }
- private native boolean _is_ready (long g)
- throws LibGuestFSException;
-
- /**
- * is in configuration state
- * <p>
- * This returns true iff this handle is being configured
- * (in the "CONFIG" state).
- * <p>
- * For more information on states, see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public boolean is_config ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("is_config: handle is closed");
- return _is_config (g);
- }
- private native boolean _is_config (long g)
- throws LibGuestFSException;
-
- /**
- * is launching subprocess
- * <p>
- * This returns true iff this handle is launching the
- * subprocess (in the "LAUNCHING" state).
- * <p>
- * For more information on states, see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public boolean is_launching ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("is_launching: handle is closed");
- return _is_launching (g);
- }
- private native boolean _is_launching (long g)
- throws LibGuestFSException;
-
- /**
- * is busy processing a command
- * <p>
- * This returns true iff this handle is busy processing a
- * command (in the "BUSY" state).
- * <p>
- * For more information on states, see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public boolean is_busy ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("is_busy: handle is closed");
- return _is_busy (g);
- }
- private native boolean _is_busy (long g)
- throws LibGuestFSException;
-
- /**
- * get the current state
- * <p>
- * This returns the current state as an opaque integer.
- * This is only useful for printing debug and internal
- * error messages.
- * <p>
- * For more information on states, see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public int get_state ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("get_state: handle is closed");
- return _get_state (g);
- }
- private native int _get_state (long g)
- throws LibGuestFSException;
-
- /**
- * set state to busy
- * <p>
- * This sets the state to "BUSY". This is only used when
- * implementing actions using the low-level API.
- * <p>
- * For more information on states, see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public void set_busy ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_busy: handle is closed");
- _set_busy (g);
- }
- private native void _set_busy (long g)
- throws LibGuestFSException;
-
- /**
- * set state to ready
- * <p>
- * This sets the state to "READY". This is only used when
- * implementing actions using the low-level API.
- * <p>
- * For more information on states, see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public void set_ready ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_ready: handle is closed");
- _set_ready (g);
- }
- private native void _set_ready (long g)
- throws LibGuestFSException;
-
- /**
- * leave the busy state
- * <p>
- * This sets the state to "READY", or if in "CONFIG" then
- * it leaves the state as is. This is only used when
- * implementing actions using the low-level API.
- * <p>
- * For more information on states, see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public void end_busy ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("end_busy: handle is closed");
- _end_busy (g);
- }
- private native void _end_busy (long g)
- throws LibGuestFSException;
-
- /**
- * set memory allocated to the qemu subprocess
- * <p>
- * This sets the memory size in megabytes allocated to the
- * qemu subprocess. This only has any effect if called
- * before "g.launch".
- * <p>
- * You can also change this by setting the environment
- * variable "LIBGUESTFS_MEMSIZE" before the handle is
- * created.
- * <p>
- * For more information on the architecture of libguestfs,
- * see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public void set_memsize (int memsize)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_memsize: handle is closed");
- _set_memsize (g, memsize);
- }
- private native void _set_memsize (long g, int memsize)
- throws LibGuestFSException;
-
- /**
- * get memory allocated to the qemu subprocess
- * <p>
- * This gets the memory size in megabytes allocated to the
- * qemu subprocess.
- * <p>
- * If "g.set_memsize" was not called on this handle, and if
- * "LIBGUESTFS_MEMSIZE" was not set, then this returns the
- * compiled-in default value for memsize.
- * <p>
- * For more information on the architecture of libguestfs,
- * see guestfs(3).
- * <p>
- * @throws LibGuestFSException
- */
- public int get_memsize ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("get_memsize: handle is closed");
- return _get_memsize (g);
- }
- private native int _get_memsize (long g)
- throws LibGuestFSException;
-
- /**
- * mount a guest disk at a position in the filesystem
- * <p>
- * Mount a guest disk at a position in the filesystem.
- * Block devices are named "/dev/sda", "/dev/sdb" and so
- * on, as they were added to the guest. If those block
- * devices contain partitions, they will have the usual
- * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
- * names can be used.
- * <p>
- * The rules are the same as for mount(2): A filesystem
- * must first be mounted on "/" before others can be
- * mounted. Other filesystems can only be mounted on
- * directories which already exist.
- * <p>
- * The mounted filesystem is writable, if we have
- * sufficient permissions on the underlying device.
- * <p>
- * The filesystem options "sync" and "noatime" are set with
- * this call, in order to improve reliability.
- * <p>
- * @throws LibGuestFSException
- */
- public void mount (String device, String mountpoint)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mount: handle is closed");
- _mount (g, device, mountpoint);
- }
- private native void _mount (long g, String device, String mountpoint)
- throws LibGuestFSException;
-
- /**
- * sync disks, writes are flushed through to the disk image
- * <p>
- * This syncs the disk, so that any writes are flushed
- * through to the underlying disk image.
- * <p>
- * You should always call this if you have modified a disk
- * image, before closing the handle.
- * <p>
- * @throws LibGuestFSException
- */
- public void sync ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("sync: handle is closed");
- _sync (g);
- }
- private native void _sync (long g)
- throws LibGuestFSException;
-
- /**
- * update file timestamps or create a new file
- * <p>
- * Touch acts like the touch(1) command. It can be used to
- * update the timestamps on a file, or, if the file does
- * not exist, to create a new zero-length file.
- * <p>
- * @throws LibGuestFSException
- */
- public void touch (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("touch: handle is closed");
- _touch (g, path);
- }
- private native void _touch (long g, String path)
- throws LibGuestFSException;
-
- /**
- * list the contents of a file
- * <p>
- * Return the contents of the file named "path".
- * <p>
- * Note that this function cannot correctly handle binary
- * files (specifically, files containing "\0" character
- * which is treated as end of string). For those you need
- * to use the "g.download" function which has a more
- * complex interface.
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String cat (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("cat: handle is closed");
- return _cat (g, path);
- }
- private native String _cat (long g, String path)
- throws LibGuestFSException;
-
- /**
- * list the files in a directory (long format)
- * <p>
- * List the files in "directory" (relative to the root
- * directory, there is no cwd) in the format of 'ls -la'.
- * <p>
- * This command is mostly useful for interactive sessions.
- * It is *not* intended that you try to parse the output
- * string.
- * <p>
- * @throws LibGuestFSException
- */
- public String ll (String directory)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("ll: handle is closed");
- return _ll (g, directory);
- }
- private native String _ll (long g, String directory)
- throws LibGuestFSException;
-
- /**
- * list the files in a directory
- * <p>
- * List the files in "directory" (relative to the root
- * directory, there is no cwd). The '.' and '..' entries
- * are not returned, but hidden files are shown.
- * <p>
- * This command is mostly useful for interactive sessions.
- * Programs should probably use "g.readdir" instead.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] ls (String directory)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("ls: handle is closed");
- return _ls (g, directory);
- }
- private native String[] _ls (long g, String directory)
- throws LibGuestFSException;
-
- /**
- * list the block devices
- * <p>
- * List all the block devices.
- * <p>
- * The full block device names are returned, eg. "/dev/sda"
- * <p>
- * @throws LibGuestFSException
- */
- public String[] list_devices ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("list_devices: handle is closed");
- return _list_devices (g);
- }
- private native String[] _list_devices (long g)
- throws LibGuestFSException;
-
- /**
- * list the partitions
- * <p>
- * List all the partitions detected on all block devices.
- * <p>
- * The full partition device names are returned, eg.
- * "/dev/sda1"
- * <p>
- * This does not return logical volumes. For that you will
- * need to call "g.lvs".
- * <p>
- * @throws LibGuestFSException
- */
- public String[] list_partitions ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("list_partitions: handle is closed");
- return _list_partitions (g);
- }
- private native String[] _list_partitions (long g)
- throws LibGuestFSException;
-
- /**
- * list the LVM physical volumes (PVs)
- * <p>
- * List all the physical volumes detected. This is the
- * equivalent of the pvs(8) command.
- * <p>
- * This returns a list of just the device names that
- * contain PVs (eg. "/dev/sda2").
- * <p>
- * See also "g.pvs_full".
- * <p>
- * @throws LibGuestFSException
- */
- public String[] pvs ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("pvs: handle is closed");
- return _pvs (g);
- }
- private native String[] _pvs (long g)
- throws LibGuestFSException;
-
- /**
- * list the LVM volume groups (VGs)
- * <p>
- * List all the volumes groups detected. This is the
- * equivalent of the vgs(8) command.
- * <p>
- * This returns a list of just the volume group names that
- * were detected (eg. "VolGroup00").
- * <p>
- * See also "g.vgs_full".
- * <p>
- * @throws LibGuestFSException
- */
- public String[] vgs ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("vgs: handle is closed");
- return _vgs (g);
- }
- private native String[] _vgs (long g)
- throws LibGuestFSException;
-
- /**
- * list the LVM logical volumes (LVs)
- * <p>
- * List all the logical volumes detected. This is the
- * equivalent of the lvs(8) command.
- * <p>
- * This returns a list of the logical volume device names
- * (eg. "/dev/VolGroup00/LogVol00").
- * <p>
- * See also "g.lvs_full".
- * <p>
- * @throws LibGuestFSException
- */
- public String[] lvs ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("lvs: handle is closed");
- return _lvs (g);
- }
- private native String[] _lvs (long g)
- throws LibGuestFSException;
-
- /**
- * list the LVM physical volumes (PVs)
- * <p>
- * List all the physical volumes detected. This is the
- * equivalent of the pvs(8) command. The "full" version
- * includes all fields.
- * <p>
- * @throws LibGuestFSException
- */
- public PV[] pvs_full ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("pvs_full: handle is closed");
- return _pvs_full (g);
- }
- private native PV[] _pvs_full (long g)
- throws LibGuestFSException;
-
- /**
- * list the LVM volume groups (VGs)
- * <p>
- * List all the volumes groups detected. This is the
- * equivalent of the vgs(8) command. The "full" version
- * includes all fields.
- * <p>
- * @throws LibGuestFSException
- */
- public VG[] vgs_full ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("vgs_full: handle is closed");
- return _vgs_full (g);
- }
- private native VG[] _vgs_full (long g)
- throws LibGuestFSException;
-
- /**
- * list the LVM logical volumes (LVs)
- * <p>
- * List all the logical volumes detected. This is the
- * equivalent of the lvs(8) command. The "full" version
- * includes all fields.
- * <p>
- * @throws LibGuestFSException
- */
- public LV[] lvs_full ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("lvs_full: handle is closed");
- return _lvs_full (g);
- }
- private native LV[] _lvs_full (long g)
- throws LibGuestFSException;
-
- /**
- * read file as lines
- * <p>
- * Return the contents of the file named "path".
- * <p>
- * The file contents are returned as a list of lines.
- * Trailing "LF" and "CRLF" character sequences are *not*
- * returned.
- * <p>
- * Note that this function cannot correctly handle binary
- * files (specifically, files containing "\0" character
- * which is treated as end of line). For those you need to
- * use the "g.read_file" function which has a more complex
- * interface.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] read_lines (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("read_lines: handle is closed");
- return _read_lines (g, path);
- }
- private native String[] _read_lines (long g, String path)
- throws LibGuestFSException;
-
- /**
- * create a new Augeas handle
- * <p>
- * Create a new Augeas handle for editing configuration
- * files. If there was any previous Augeas handle
- * associated with this guestfs session, then it is closed.
- * <p>
- * You must call this before using any other "g.aug_*"
- * commands.
- * <p>
- * "root" is the filesystem root. "root" must not be NULL,
- * use "/" instead.
- * <p>
- * The flags are the same as the flags defined in
- * <augeas.h>, the logical *or* of the following integers:
- * <p>
- * "AUG_SAVE_BACKUP" = 1
- * Keep the original file with a ".augsave" extension.
- * <p>
- * "AUG_SAVE_NEWFILE" = 2
- * Save changes into a file with extension ".augnew",
- * and do not overwrite original. Overrides
- * "AUG_SAVE_BACKUP".
- * <p>
- * "AUG_TYPE_CHECK" = 4
- * Typecheck lenses (can be expensive).
- * <p>
- * "AUG_NO_STDINC" = 8
- * Do not use standard load path for modules.
- * <p>
- * "AUG_SAVE_NOOP" = 16
- * Make save a no-op, just record what would have been
- * changed.
- * <p>
- * "AUG_NO_LOAD" = 32
- * Do not load the tree in "g.aug_init".
- * <p>
- * To close the handle, you can call "g.aug_close".
- * <p>
- * To find out more about Augeas, see <http://augeas.net/>.
- * <p>
- * @throws LibGuestFSException
- */
- public void aug_init (String root, int flags)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_init: handle is closed");
- _aug_init (g, root, flags);
- }
- private native void _aug_init (long g, String root, int flags)
- throws LibGuestFSException;
-
- /**
- * close the current Augeas handle
- * <p>
- * Close the current Augeas handle and free up any
- * resources used by it. After calling this, you have to
- * call "g.aug_init" again before you can use any other
- * Augeas functions.
- * <p>
- * @throws LibGuestFSException
- */
- public void aug_close ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_close: handle is closed");
- _aug_close (g);
- }
- private native void _aug_close (long g)
- throws LibGuestFSException;
-
- /**
- * define an Augeas variable
- * <p>
- * Defines an Augeas variable "name" whose value is the
- * result of evaluating "expr". If "expr" is NULL, then
- * "name" is undefined.
- * <p>
- * On success this returns the number of nodes in "expr",
- * or 0 if "expr" evaluates to something which is not a
- * nodeset.
- * <p>
- * @throws LibGuestFSException
- */
- public int aug_defvar (String name, String expr)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_defvar: handle is closed");
- return _aug_defvar (g, name, expr);
- }
- private native int _aug_defvar (long g, String name, String expr)
- throws LibGuestFSException;
-
- /**
- * define an Augeas node
- * <p>
- * Defines a variable "name" whose value is the result of
- * evaluating "expr".
- * <p>
- * If "expr" evaluates to an empty nodeset, a node is
- * created, equivalent to calling "g.aug_set" "expr",
- * "value". "name" will be the nodeset containing that
- * single node.
- * <p>
- * On success this returns a pair containing the number of
- * nodes in the nodeset, and a boolean flag if a node was
- * created.
- * <p>
- * @throws LibGuestFSException
- */
- public IntBool aug_defnode (String name, String expr, String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_defnode: handle is closed");
- return _aug_defnode (g, name, expr, val);
- }
- private native IntBool _aug_defnode (long g, String name, String expr, String val)
- throws LibGuestFSException;
-
- /**
- * look up the value of an Augeas path
- * <p>
- * Look up the value associated with "path". If "path"
- * matches exactly one node, the "value" is returned.
- * <p>
- * @throws LibGuestFSException
- */
- public String aug_get (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_get: handle is closed");
- return _aug_get (g, path);
- }
- private native String _aug_get (long g, String path)
- throws LibGuestFSException;
-
- /**
- * set Augeas path to value
- * <p>
- * Set the value associated with "path" to "value".
- * <p>
- * @throws LibGuestFSException
- */
- public void aug_set (String path, String val)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_set: handle is closed");
- _aug_set (g, path, val);
- }
- private native void _aug_set (long g, String path, String val)
- throws LibGuestFSException;
-
- /**
- * insert a sibling Augeas node
- * <p>
- * Create a new sibling "label" for "path", inserting it
- * into the tree before or after "path" (depending on the
- * boolean flag "before").
- * <p>
- * "path" must match exactly one existing node in the tree,
- * and "label" must be a label, ie. not contain "/", "*" or
- * end with a bracketed index "[N]".
- * <p>
- * @throws LibGuestFSException
- */
- public void aug_insert (String path, String label, boolean before)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_insert: handle is closed");
- _aug_insert (g, path, label, before);
- }
- private native void _aug_insert (long g, String path, String label, boolean before)
- throws LibGuestFSException;
-
- /**
- * remove an Augeas path
- * <p>
- * Remove "path" and all of its children.
- * <p>
- * On success this returns the number of entries which were
- * removed.
- * <p>
- * @throws LibGuestFSException
- */
- public int aug_rm (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_rm: handle is closed");
- return _aug_rm (g, path);
- }
- private native int _aug_rm (long g, String path)
- throws LibGuestFSException;
-
- /**
- * move Augeas node
- * <p>
- * Move the node "src" to "dest". "src" must match exactly
- * one node. "dest" is overwritten if it exists.
- * <p>
- * @throws LibGuestFSException
- */
- public void aug_mv (String src, String dest)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_mv: handle is closed");
- _aug_mv (g, src, dest);
- }
- private native void _aug_mv (long g, String src, String dest)
- throws LibGuestFSException;
-
- /**
- * return Augeas nodes which match path
- * <p>
- * Returns a list of paths which match the path expression
- * "path". The returned paths are sufficiently qualified so
- * that they match exactly one node in the current tree.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] aug_match (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_match: handle is closed");
- return _aug_match (g, path);
- }
- private native String[] _aug_match (long g, String path)
- throws LibGuestFSException;
-
- /**
- * write all pending Augeas changes to disk
- * <p>
- * This writes all pending changes to disk.
- * <p>
- * The flags which were passed to "g.aug_init" affect
- * exactly how files are saved.
- * <p>
- * @throws LibGuestFSException
- */
- public void aug_save ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_save: handle is closed");
- _aug_save (g);
- }
- private native void _aug_save (long g)
- throws LibGuestFSException;
-
- /**
- * load files into the tree
- * <p>
- * Load files into the tree.
- * <p>
- * See "aug_load" in the Augeas documentation for the full
- * gory details.
- * <p>
- * @throws LibGuestFSException
- */
- public void aug_load ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_load: handle is closed");
- _aug_load (g);
- }
- private native void _aug_load (long g)
- throws LibGuestFSException;
-
- /**
- * list Augeas nodes under a path
- * <p>
- * This is just a shortcut for listing "g.aug_match"
- * "path/*" and sorting the resulting nodes into
- * alphabetical order.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] aug_ls (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("aug_ls: handle is closed");
- return _aug_ls (g, path);
- }
- private native String[] _aug_ls (long g, String path)
- throws LibGuestFSException;
-
- /**
- * remove a file
- * <p>
- * Remove the single file "path".
- * <p>
- * @throws LibGuestFSException
- */
- public void rm (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("rm: handle is closed");
- _rm (g, path);
- }
- private native void _rm (long g, String path)
- throws LibGuestFSException;
-
- /**
- * remove a directory
- * <p>
- * Remove the single directory "path".
- * <p>
- * @throws LibGuestFSException
- */
- public void rmdir (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("rmdir: handle is closed");
- _rmdir (g, path);
- }
- private native void _rmdir (long g, String path)
- throws LibGuestFSException;
-
- /**
- * remove a file or directory recursively
- * <p>
- * Remove the file or directory "path", recursively
- * removing the contents if its a directory. This is like
- * the "rm -rf" shell command.
- * <p>
- * @throws LibGuestFSException
- */
- public void rm_rf (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("rm_rf: handle is closed");
- _rm_rf (g, path);
- }
- private native void _rm_rf (long g, String path)
- throws LibGuestFSException;
-
- /**
- * create a directory
- * <p>
- * Create a directory named "path".
- * <p>
- * @throws LibGuestFSException
- */
- public void mkdir (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mkdir: handle is closed");
- _mkdir (g, path);
- }
- private native void _mkdir (long g, String path)
- throws LibGuestFSException;
-
- /**
- * create a directory and parents
- * <p>
- * Create a directory named "path", creating any parent
- * directories as necessary. This is like the "mkdir -p"
- * shell command.
- * <p>
- * @throws LibGuestFSException
- */
- public void mkdir_p (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mkdir_p: handle is closed");
- _mkdir_p (g, path);
- }
- private native void _mkdir_p (long g, String path)
- throws LibGuestFSException;
-
- /**
- * change file mode
- * <p>
- * Change the mode (permissions) of "path" to "mode". Only
- * numeric modes are supported.
- * <p>
- * @throws LibGuestFSException
- */
- public void chmod (int mode, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("chmod: handle is closed");
- _chmod (g, mode, path);
- }
- private native void _chmod (long g, int mode, String path)
- throws LibGuestFSException;
-
- /**
- * change file owner and group
- * <p>
- * Change the file owner to "owner" and group to "group".
- * <p>
- * Only numeric uid and gid are supported. If you want to
- * use names, you will need to locate and parse the
- * password file yourself (Augeas support makes this
- * relatively easy).
- * <p>
- * @throws LibGuestFSException
- */
- public void chown (int owner, int group, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("chown: handle is closed");
- _chown (g, owner, group, path);
- }
- private native void _chown (long g, int owner, int group, String path)
- throws LibGuestFSException;
-
- /**
- * test if file or directory exists
- * <p>
- * This returns "true" if and only if there is a file,
- * directory (or anything) with the given "path" name.
- * <p>
- * See also "g.is_file", "g.is_dir", "g.stat".
- * <p>
- * @throws LibGuestFSException
- */
- public boolean exists (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("exists: handle is closed");
- return _exists (g, path);
- }
- private native boolean _exists (long g, String path)
- throws LibGuestFSException;
-
- /**
- * test if file exists
- * <p>
- * This returns "true" if and only if there is a file with
- * the given "path" name. Note that it returns false for
- * other objects like directories.
- * <p>
- * See also "g.stat".
- * <p>
- * @throws LibGuestFSException
- */
- public boolean is_file (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("is_file: handle is closed");
- return _is_file (g, path);
- }
- private native boolean _is_file (long g, String path)
- throws LibGuestFSException;
-
- /**
- * test if file exists
- * <p>
- * This returns "true" if and only if there is a directory
- * with the given "path" name. Note that it returns false
- * for other objects like files.
- * <p>
- * See also "g.stat".
- * <p>
- * @throws LibGuestFSException
- */
- public boolean is_dir (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("is_dir: handle is closed");
- return _is_dir (g, path);
- }
- private native boolean _is_dir (long g, String path)
- throws LibGuestFSException;
-
- /**
- * create an LVM physical volume
- * <p>
- * This creates an LVM physical volume on the named
- * "device", where "device" should usually be a partition
- * name such as "/dev/sda1".
- * <p>
- * @throws LibGuestFSException
- */
- public void pvcreate (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("pvcreate: handle is closed");
- _pvcreate (g, device);
- }
- private native void _pvcreate (long g, String device)
- throws LibGuestFSException;
-
- /**
- * create an LVM volume group
- * <p>
- * This creates an LVM volume group called "volgroup" from
- * the non-empty list of physical volumes "physvols".
- * <p>
- * @throws LibGuestFSException
- */
- public void vgcreate (String volgroup, String[] physvols)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("vgcreate: handle is closed");
- _vgcreate (g, volgroup, physvols);
- }
- private native void _vgcreate (long g, String volgroup, String[] physvols)
- throws LibGuestFSException;
-
- /**
- * create an LVM volume group
- * <p>
- * This creates an LVM volume group called "logvol" on the
- * volume group "volgroup", with "size" megabytes.
- * <p>
- * @throws LibGuestFSException
- */
- public void lvcreate (String logvol, String volgroup, int mbytes)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("lvcreate: handle is closed");
- _lvcreate (g, logvol, volgroup, mbytes);
- }
- private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
- throws LibGuestFSException;
-
- /**
- * make a filesystem
- * <p>
- * This creates a filesystem on "device" (usually a
- * partition or LVM logical volume). The filesystem type is
- * "fstype", for example "ext3".
- * <p>
- * @throws LibGuestFSException
- */
- public void mkfs (String fstype, String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mkfs: handle is closed");
- _mkfs (g, fstype, device);
- }
- private native void _mkfs (long g, String fstype, String device)
- throws LibGuestFSException;
-
- /**
- * create partitions on a block device
- * <p>
- * This is a direct interface to the sfdisk(8) program for
- * creating partitions on block devices.
- * <p>
- * "device" should be a block device, for example
- * "/dev/sda".
- * <p>
- * "cyls", "heads" and "sectors" are the number of
- * cylinders, heads and sectors on the device, which are
- * passed directly to sfdisk as the *-C*, *-H* and *-S*
- * parameters. If you pass 0 for any of these, then the
- * corresponding parameter is omitted. Usually for 'large'
- * disks, you can just pass 0 for these, but for small
- * (floppy-sized) disks, sfdisk (or rather, the kernel)
- * cannot work out the right geometry and you will need to
- * tell it.
- * <p>
- * "lines" is a list of lines that we feed to "sfdisk". For
- * more information refer to the sfdisk(8) manpage.
- * <p>
- * To create a single partition occupying the whole disk,
- * you would pass "lines" as a single element list, when
- * the single element being the string "," (comma).
- * <p>
- * See also: "g.sfdisk_l", "g.sfdisk_N"
- * <p>
- * This command is dangerous. Without careful use you can
- * easily destroy all your data.
- * <p>
- * @throws LibGuestFSException
- */
- public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("sfdisk: handle is closed");
- _sfdisk (g, device, cyls, heads, sectors, lines);
- }
- private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
- throws LibGuestFSException;
-
- /**
- * create a file
- * <p>
- * This call creates a file called "path". The contents of
- * the file is the string "content" (which can contain any
- * 8 bit data), with length "size".
- * <p>
- * As a special case, if "size" is 0 then the length is
- * calculated using "strlen" (so in this case the content
- * cannot contain embedded ASCII NULs).
- * <p>
- * *NB.* Owing to a bug, writing content containing ASCII
- * NUL characters does *not* work, even if the length is
- * specified. We hope to resolve this bug in a future
- * version. In the meantime use "g.upload".
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public void write_file (String path, String content, int size)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("write_file: handle is closed");
- _write_file (g, path, content, size);
- }
- private native void _write_file (long g, String path, String content, int size)
- throws LibGuestFSException;
-
- /**
- * unmount a filesystem
- * <p>
- * This unmounts the given filesystem. The filesystem may
- * be specified either by its mountpoint (path) or the
- * device which contains the filesystem.
- * <p>
- * @throws LibGuestFSException
- */
- public void umount (String pathordevice)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("umount: handle is closed");
- _umount (g, pathordevice);
- }
- private native void _umount (long g, String pathordevice)
- throws LibGuestFSException;
-
- /**
- * show mounted filesystems
- * <p>
- * This returns the list of currently mounted filesystems.
- * It returns the list of devices (eg. "/dev/sda1",
- * "/dev/VG/LV").
- * <p>
- * Some internal mounts are not shown.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] mounts ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mounts: handle is closed");
- return _mounts (g);
- }
- private native String[] _mounts (long g)
- throws LibGuestFSException;
-
- /**
- * unmount all filesystems
- * <p>
- * This unmounts all mounted filesystems.
- * <p>
- * Some internal mounts are not unmounted by this call.
- * <p>
- * @throws LibGuestFSException
- */
- public void umount_all ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("umount_all: handle is closed");
- _umount_all (g);
- }
- private native void _umount_all (long g)
- throws LibGuestFSException;
-
- /**
- * remove all LVM LVs, VGs and PVs
- * <p>
- * This command removes all LVM logical volumes, volume
- * groups and physical volumes.
- * <p>
- * This command is dangerous. Without careful use you can
- * easily destroy all your data.
- * <p>
- * @throws LibGuestFSException
- */
- public void lvm_remove_all ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("lvm_remove_all: handle is closed");
- _lvm_remove_all (g);
- }
- private native void _lvm_remove_all (long g)
- throws LibGuestFSException;
-
- /**
- * determine file type
- * <p>
- * This call uses the standard file(1) command to determine
- * the type or contents of the file. This also works on
- * devices, for example to find out whether a partition
- * contains a filesystem.
- * <p>
- * The exact command which runs is "file -bsL path". Note
- * in particular that the filename is not prepended to the
- * output (the "-b" option).
- * <p>
- * @throws LibGuestFSException
- */
- public String file (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("file: handle is closed");
- return _file (g, path);
- }
- private native String _file (long g, String path)
- throws LibGuestFSException;
-
- /**
- * run a command from the guest filesystem
- * <p>
- * This call runs a command from the guest filesystem. The
- * filesystem must be mounted, and must contain a
- * compatible operating system (ie. something Linux, with
- * the same or compatible processor architecture).
- * <p>
- * 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). Note that
- * the command runs directly, and is *not* invoked via the
- * shell (see "g.sh").
- * <p>
- * The return value is anything printed to *stdout* by the
- * command.
- * <p>
- * If the command returns a non-zero exit status, then this
- * function returns an error message. The error message
- * string is the content of *stderr* from the command.
- * <p>
- * The $PATH environment variable will contain at least
- * "/usr/bin" and "/bin". If you require a program from
- * another location, you should provide the full path in
- * the first parameter.
- * <p>
- * Shared libraries and data files required by the program
- * must be available on filesystems which are mounted in
- * the correct places. It is the caller's responsibility to
- * ensure all filesystems that are needed are mounted at
- * the right locations.
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String command (String[] arguments)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("command: handle is closed");
- return _command (g, arguments);
- }
- private native String _command (long g, String[] arguments)
- throws LibGuestFSException;
-
- /**
- * run a command, returning lines
- * <p>
- * This is the same as "g.command", but splits the result
- * into a list of lines.
- * <p>
- * See also: "g.sh_lines"
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] command_lines (String[] arguments)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("command_lines: handle is closed");
- return _command_lines (g, arguments);
- }
- private native String[] _command_lines (long g, String[] arguments)
- throws LibGuestFSException;
-
- /**
- * get file information
- * <p>
- * Returns file information for the given "path".
- * <p>
- * This is the same as the stat(2) system call.
- * <p>
- * @throws LibGuestFSException
- */
- public Stat stat (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("stat: handle is closed");
- return _stat (g, path);
- }
- private native Stat _stat (long g, String path)
- throws LibGuestFSException;
-
- /**
- * get file information for a symbolic link
- * <p>
- * Returns file information for the given "path".
- * <p>
- * This is the same as "g.stat" except that if "path" is a
- * symbolic link, then the link is stat-ed, not the file it
- * refers to.
- * <p>
- * This is the same as the lstat(2) system call.
- * <p>
- * @throws LibGuestFSException
- */
- public Stat lstat (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("lstat: handle is closed");
- return _lstat (g, path);
- }
- private native Stat _lstat (long g, String path)
- throws LibGuestFSException;
-
- /**
- * get file system statistics
- * <p>
- * Returns file system statistics for any mounted file
- * system. "path" should be a file or directory in the
- * mounted file system (typically it is the mount point
- * itself, but it doesn't need to be).
- * <p>
- * This is the same as the statvfs(2) system call.
- * <p>
- * @throws LibGuestFSException
- */
- public StatVFS statvfs (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("statvfs: handle is closed");
- return _statvfs (g, path);
- }
- private native StatVFS _statvfs (long g, String path)
- throws LibGuestFSException;
-
- /**
- * get ext2/ext3/ext4 superblock details
- * <p>
- * This returns the contents of the ext2, ext3 or ext4
- * filesystem superblock on "device".
- * <p>
- * It is the same as running "tune2fs -l device". See
- * tune2fs(8) manpage for more details. The list of fields
- * returned isn't clearly defined, and depends on both the
- * version of "tune2fs" that libguestfs was built against,
- * and the filesystem itself.
- * <p>
- * @throws LibGuestFSException
- */
- public HashMap<String,String> tune2fs_l (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("tune2fs_l: handle is closed");
- return _tune2fs_l (g, device);
- }
- private native HashMap<String,String> _tune2fs_l (long g, String device)
- throws LibGuestFSException;
-
- /**
- * set block device to read-only
- * <p>
- * Sets the block device named "device" to read-only.
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public void blockdev_setro (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_setro: handle is closed");
- _blockdev_setro (g, device);
- }
- private native void _blockdev_setro (long g, String device)
- throws LibGuestFSException;
-
- /**
- * set block device to read-write
- * <p>
- * Sets the block device named "device" to read-write.
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public void blockdev_setrw (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_setrw: handle is closed");
- _blockdev_setrw (g, device);
- }
- private native void _blockdev_setrw (long g, String device)
- throws LibGuestFSException;
-
- /**
- * is block device set to read-only
- * <p>
- * Returns a boolean indicating if the block device is
- * read-only (true if read-only, false if not).
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public boolean blockdev_getro (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_getro: handle is closed");
- return _blockdev_getro (g, device);
- }
- private native boolean _blockdev_getro (long g, String device)
- throws LibGuestFSException;
-
- /**
- * get sectorsize of block device
- * <p>
- * This returns the size of sectors on a block device.
- * Usually 512, but can be larger for modern devices.
- * <p>
- * (Note, this is not the size in sectors, use
- * "g.blockdev_getsz" for that).
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public int blockdev_getss (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_getss: handle is closed");
- return _blockdev_getss (g, device);
- }
- private native int _blockdev_getss (long g, String device)
- throws LibGuestFSException;
-
- /**
- * get blocksize of block device
- * <p>
- * This returns the block size of a device.
- * <p>
- * (Note this is different from both *size in blocks* and
- * *filesystem block size*).
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public int blockdev_getbsz (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
- return _blockdev_getbsz (g, device);
- }
- private native int _blockdev_getbsz (long g, String device)
- throws LibGuestFSException;
-
- /**
- * set blocksize of block device
- * <p>
- * This sets the block size of a device.
- * <p>
- * (Note this is different from both *size in blocks* and
- * *filesystem block size*).
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public void blockdev_setbsz (String device, int blocksize)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
- _blockdev_setbsz (g, device, blocksize);
- }
- private native void _blockdev_setbsz (long g, String device, int blocksize)
- throws LibGuestFSException;
-
- /**
- * get total size of device in 512-byte sectors
- * <p>
- * This returns the size of the device in units of 512-byte
- * sectors (even if the sectorsize isn't 512 bytes ...
- * weird).
- * <p>
- * See also "g.blockdev_getss" for the real sector size of
- * the device, and "g.blockdev_getsize64" for the more
- * useful *size in bytes*.
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public long blockdev_getsz (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_getsz: handle is closed");
- return _blockdev_getsz (g, device);
- }
- private native long _blockdev_getsz (long g, String device)
- throws LibGuestFSException;
-
- /**
- * get total size of device in bytes
- * <p>
- * This returns the size of the device in bytes.
- * <p>
- * See also "g.blockdev_getsz".
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public long blockdev_getsize64 (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
- return _blockdev_getsize64 (g, device);
- }
- private native long _blockdev_getsize64 (long g, String device)
- throws LibGuestFSException;
-
- /**
- * flush device buffers
- * <p>
- * This tells the kernel to flush internal buffers
- * associated with "device".
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public void blockdev_flushbufs (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
- _blockdev_flushbufs (g, device);
- }
- private native void _blockdev_flushbufs (long g, String device)
- throws LibGuestFSException;
-
- /**
- * reread partition table
- * <p>
- * Reread the partition table on "device".
- * <p>
- * This uses the blockdev(8) command.
- * <p>
- * @throws LibGuestFSException
- */
- public void blockdev_rereadpt (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
- _blockdev_rereadpt (g, device);
- }
- private native void _blockdev_rereadpt (long g, String device)
- throws LibGuestFSException;
-
- /**
- * upload a file from the local machine
- * <p>
- * Upload local file "filename" to "remotefilename" on the
- * filesystem.
- * <p>
- * "filename" can also be a named pipe.
- * <p>
- * See also "g.download".
- * <p>
- * @throws LibGuestFSException
- */
- public void upload (String filename, String remotefilename)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("upload: handle is closed");
- _upload (g, filename, remotefilename);
- }
- private native void _upload (long g, String filename, String remotefilename)
- throws LibGuestFSException;
-
- /**
- * download a file to the local machine
- * <p>
- * Download file "remotefilename" and save it as "filename"
- * on the local machine.
- * <p>
- * "filename" can also be a named pipe.
- * <p>
- * See also "g.upload", "g.cat".
- * <p>
- * @throws LibGuestFSException
- */
- public void download (String remotefilename, String filename)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("download: handle is closed");
- _download (g, remotefilename, filename);
- }
- private native void _download (long g, String remotefilename, String filename)
- throws LibGuestFSException;
-
- /**
- * compute MD5, SHAx or CRC checksum of file
- * <p>
- * This call computes the MD5, SHAx or CRC checksum of the
- * file named "path".
- * <p>
- * The type of checksum to compute is given by the
- * "csumtype" parameter which must have one of the
- * following values:
- * <p>
- * "crc"
- * Compute the cyclic redundancy check (CRC) specified
- * by POSIX for the "cksum" command.
- * <p>
- * "md5"
- * Compute the MD5 hash (using the "md5sum" program).
- * <p>
- * "sha1"
- * Compute the SHA1 hash (using the "sha1sum" program).
- * <p>
- * "sha224"
- * Compute the SHA224 hash (using the "sha224sum"
- * program).
- * <p>
- * "sha256"
- * Compute the SHA256 hash (using the "sha256sum"
- * program).
- * <p>
- * "sha384"
- * Compute the SHA384 hash (using the "sha384sum"
- * program).
- * <p>
- * "sha512"
- * Compute the SHA512 hash (using the "sha512sum"
- * program).
- * <p>
- * The checksum is returned as a printable string.
- * <p>
- * @throws LibGuestFSException
- */
- public String checksum (String csumtype, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("checksum: handle is closed");
- return _checksum (g, csumtype, path);
- }
- private native String _checksum (long g, String csumtype, String path)
- throws LibGuestFSException;
-
- /**
- * unpack tarfile to directory
- * <p>
- * This command uploads and unpacks local file "tarfile"
- * (an *uncompressed* tar file) into "directory".
- * <p>
- * To upload a compressed tarball, use "g.tgz_in".
- * <p>
- * @throws LibGuestFSException
- */
- public void tar_in (String tarfile, String directory)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("tar_in: handle is closed");
- _tar_in (g, tarfile, directory);
- }
- private native void _tar_in (long g, String tarfile, String directory)
- throws LibGuestFSException;
-
- /**
- * pack directory into tarfile
- * <p>
- * This command packs the contents of "directory" and
- * downloads it to local file "tarfile".
- * <p>
- * To download a compressed tarball, use "g.tgz_out".
- * <p>
- * @throws LibGuestFSException
- */
- public void tar_out (String directory, String tarfile)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("tar_out: handle is closed");
- _tar_out (g, directory, tarfile);
- }
- private native void _tar_out (long g, String directory, String tarfile)
- throws LibGuestFSException;
-
- /**
- * unpack compressed tarball to directory
- * <p>
- * This command uploads and unpacks local file "tarball" (a
- * *gzip compressed* tar file) into "directory".
- * <p>
- * To upload an uncompressed tarball, use "g.tar_in".
- * <p>
- * @throws LibGuestFSException
- */
- public void tgz_in (String tarball, String directory)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("tgz_in: handle is closed");
- _tgz_in (g, tarball, directory);
- }
- private native void _tgz_in (long g, String tarball, String directory)
- throws LibGuestFSException;
-
- /**
- * pack directory into compressed tarball
- * <p>
- * This command packs the contents of "directory" and
- * downloads it to local file "tarball".
- * <p>
- * To download an uncompressed tarball, use "g.tar_out".
- * <p>
- * @throws LibGuestFSException
- */
- public void tgz_out (String directory, String tarball)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("tgz_out: handle is closed");
- _tgz_out (g, directory, tarball);
- }
- private native void _tgz_out (long g, String directory, String tarball)
- throws LibGuestFSException;
-
- /**
- * mount a guest disk, read-only
- * <p>
- * This is the same as the "g.mount" command, but it mounts
- * the filesystem with the read-only (*-o ro*) flag.
- * <p>
- * @throws LibGuestFSException
- */
- public void mount_ro (String device, String mountpoint)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mount_ro: handle is closed");
- _mount_ro (g, device, mountpoint);
- }
- private native void _mount_ro (long g, String device, String mountpoint)
- throws LibGuestFSException;
-
- /**
- * mount a guest disk with mount options
- * <p>
- * This is the same as the "g.mount" command, but it allows
- * you to set the mount options as for the mount(8) *-o*
- * flag.
- * <p>
- * @throws LibGuestFSException
- */
- public void mount_options (String options, String device, String mountpoint)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mount_options: handle is closed");
- _mount_options (g, options, device, mountpoint);
- }
- private native void _mount_options (long g, String options, String device, String mountpoint)
- throws LibGuestFSException;
-
- /**
- * mount a guest disk with mount options and vfstype
- * <p>
- * This is the same as the "g.mount" command, but it allows
- * you to set both the mount options and the vfstype as for
- * the mount(8) *-o* and *-t* flags.
- * <p>
- * @throws LibGuestFSException
- */
- public void mount_vfs (String options, String vfstype, String device, String mountpoint)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mount_vfs: handle is closed");
- _mount_vfs (g, options, vfstype, device, mountpoint);
- }
- private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
- throws LibGuestFSException;
-
- /**
- * debugging and internals
- * <p>
- * The "g.debug" command exposes some internals of
- * "guestfsd" (the guestfs daemon) that runs inside the
- * qemu subprocess.
- * <p>
- * There is no comprehensive help for this command. You
- * have to look at the file "daemon/debug.c" in the
- * libguestfs source to find out what you can do.
- * <p>
- * @throws LibGuestFSException
- */
- public String debug (String subcmd, String[] extraargs)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("debug: handle is closed");
- return _debug (g, subcmd, extraargs);
- }
- private native String _debug (long g, String subcmd, String[] extraargs)
- throws LibGuestFSException;
-
- /**
- * remove an LVM logical volume
- * <p>
- * Remove an LVM logical volume "device", where "device" is
- * the path to the LV, such as "/dev/VG/LV".
- * <p>
- * You can also remove all LVs in a volume group by
- * specifying the VG name, "/dev/VG".
- * <p>
- * @throws LibGuestFSException
- */
- public void lvremove (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("lvremove: handle is closed");
- _lvremove (g, device);
- }
- private native void _lvremove (long g, String device)
- throws LibGuestFSException;
-
- /**
- * remove an LVM volume group
- * <p>
- * Remove an LVM volume group "vgname", (for example "VG").
- * <p>
- * This also forcibly removes all logical volumes in the
- * volume group (if any).
- * <p>
- * @throws LibGuestFSException
- */
- public void vgremove (String vgname)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("vgremove: handle is closed");
- _vgremove (g, vgname);
- }
- private native void _vgremove (long g, String vgname)
- throws LibGuestFSException;
-
- /**
- * remove an LVM physical volume
- * <p>
- * This wipes a physical volume "device" so that LVM will
- * no longer recognise it.
- * <p>
- * The implementation uses the "pvremove" command which
- * refuses to wipe physical volumes that contain any volume
- * groups, so you have to remove those first.
- * <p>
- * @throws LibGuestFSException
- */
- public void pvremove (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("pvremove: handle is closed");
- _pvremove (g, device);
- }
- private native void _pvremove (long g, String device)
- throws LibGuestFSException;
-
- /**
- * set the ext2/3/4 filesystem label
- * <p>
- * This sets the ext2/3/4 filesystem label of the
- * filesystem on "device" to "label". Filesystem labels are
- * limited to 16 characters.
- * <p>
- * You can use either "g.tune2fs_l" or "g.get_e2label" to
- * return the existing label on a filesystem.
- * <p>
- * @throws LibGuestFSException
- */
- public void set_e2label (String device, String label)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_e2label: handle is closed");
- _set_e2label (g, device, label);
- }
- private native void _set_e2label (long g, String device, String label)
- throws LibGuestFSException;
-
- /**
- * get the ext2/3/4 filesystem label
- * <p>
- * This returns the ext2/3/4 filesystem label of the
- * filesystem on "device".
- * <p>
- * @throws LibGuestFSException
- */
- public String get_e2label (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("get_e2label: handle is closed");
- return _get_e2label (g, device);
- }
- private native String _get_e2label (long g, String device)
- throws LibGuestFSException;
-
- /**
- * set the ext2/3/4 filesystem UUID
- * <p>
- * This sets the ext2/3/4 filesystem UUID of the filesystem
- * on "device" to "uuid". The format of the UUID and
- * alternatives such as "clear", "random" and "time" are
- * described in the tune2fs(8) manpage.
- * <p>
- * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
- * return the existing UUID of a filesystem.
- * <p>
- * @throws LibGuestFSException
- */
- public void set_e2uuid (String device, String uuid)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("set_e2uuid: handle is closed");
- _set_e2uuid (g, device, uuid);
- }
- private native void _set_e2uuid (long g, String device, String uuid)
- throws LibGuestFSException;
-
- /**
- * get the ext2/3/4 filesystem UUID
- * <p>
- * This returns the ext2/3/4 filesystem UUID of the
- * filesystem on "device".
- * <p>
- * @throws LibGuestFSException
- */
- public String get_e2uuid (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("get_e2uuid: handle is closed");
- return _get_e2uuid (g, device);
- }
- private native String _get_e2uuid (long g, String device)
- throws LibGuestFSException;
-
- /**
- * run the filesystem checker
- * <p>
- * This runs the filesystem checker (fsck) on "device"
- * which should have filesystem type "fstype".
- * <p>
- * The returned integer is the status. See fsck(8) for the
- * list of status codes from "fsck".
- * <p>
- * Notes:
- * <p>
- * * Multiple status codes can be summed together.
- * <p>
- * * A non-zero return code can mean "success", for
- * example if errors have been corrected on the
- * filesystem.
- * <p>
- * * Checking or repairing NTFS volumes is not supported
- * (by linux-ntfs).
- * <p>
- * This command is entirely equivalent to running "fsck -a
- * -t fstype device".
- * <p>
- * @throws LibGuestFSException
- */
- public int fsck (String fstype, String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("fsck: handle is closed");
- return _fsck (g, fstype, device);
- }
- private native int _fsck (long g, String fstype, String device)
- throws LibGuestFSException;
-
- /**
- * write zeroes to the device
- * <p>
- * This command writes zeroes over the first few blocks of
- * "device".
- * <p>
- * How many blocks are zeroed isn't specified (but it's
- * *not* enough to securely wipe the device). It should be
- * sufficient to remove any partition tables, filesystem
- * superblocks and so on.
- * <p>
- * See also: "g.scrub_device".
- * <p>
- * @throws LibGuestFSException
- */
- public void zero (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("zero: handle is closed");
- _zero (g, device);
- }
- private native void _zero (long g, String device)
- throws LibGuestFSException;
-
- /**
- * install GRUB
- * <p>
- * This command installs GRUB (the Grand Unified
- * Bootloader) on "device", with the root directory being
- * "root".
- * <p>
- * @throws LibGuestFSException
- */
- public void grub_install (String root, String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("grub_install: handle is closed");
- _grub_install (g, root, device);
- }
- private native void _grub_install (long g, String root, String device)
- throws LibGuestFSException;
-
- /**
- * copy a file
- * <p>
- * This copies a file from "src" to "dest" where "dest" is
- * either a destination filename or destination directory.
- * <p>
- * @throws LibGuestFSException
- */
- public void cp (String src, String dest)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("cp: handle is closed");
- _cp (g, src, dest);
- }
- private native void _cp (long g, String src, String dest)
- throws LibGuestFSException;
-
- /**
- * copy a file or directory recursively
- * <p>
- * This copies a file or directory from "src" to "dest"
- * recursively using the "cp -a" command.
- * <p>
- * @throws LibGuestFSException
- */
- public void cp_a (String src, String dest)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("cp_a: handle is closed");
- _cp_a (g, src, dest);
- }
- private native void _cp_a (long g, String src, String dest)
- throws LibGuestFSException;
-
- /**
- * move a file
- * <p>
- * This moves a file from "src" to "dest" where "dest" is
- * either a destination filename or destination directory.
- * <p>
- * @throws LibGuestFSException
- */
- public void mv (String src, String dest)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mv: handle is closed");
- _mv (g, src, dest);
- }
- private native void _mv (long g, String src, String dest)
- throws LibGuestFSException;
-
- /**
- * drop kernel page cache, dentries and inodes
- * <p>
- * This instructs the guest kernel to drop its page cache,
- * and/or dentries and inode caches. The parameter
- * "whattodrop" tells the kernel what precisely to drop,
- * see <http://linux-mm.org/Drop_Caches>
- * <p>
- * Setting "whattodrop" to 3 should drop everything.
- * <p>
- * This automatically calls sync(2) before the operation,
- * so that the maximum guest memory is freed.
- * <p>
- * @throws LibGuestFSException
- */
- public void drop_caches (int whattodrop)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("drop_caches: handle is closed");
- _drop_caches (g, whattodrop);
- }
- private native void _drop_caches (long g, int whattodrop)
- throws LibGuestFSException;
-
- /**
- * return kernel messages
- * <p>
- * This returns the kernel messages ("dmesg" output) from
- * the guest kernel. This is sometimes useful for extended
- * debugging of problems.
- * <p>
- * Another way to get the same information is to enable
- * verbose messages with "g.set_verbose" or by setting the
- * environment variable "LIBGUESTFS_DEBUG=1" before running
- * the program.
- * <p>
- * @throws LibGuestFSException
- */
- public String dmesg ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("dmesg: handle is closed");
- return _dmesg (g);
- }
- private native String _dmesg (long g)
- throws LibGuestFSException;
-
- /**
- * ping the guest daemon
- * <p>
- * This is a test probe into the guestfs daemon running
- * inside the qemu subprocess. Calling this function checks
- * that the daemon responds to the ping message, without
- * affecting the daemon or attached block device(s) in any
- * other way.
- * <p>
- * @throws LibGuestFSException
- */
- public void ping_daemon ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("ping_daemon: handle is closed");
- _ping_daemon (g);
- }
- private native void _ping_daemon (long g)
- throws LibGuestFSException;
-
- /**
- * test if two files have equal contents
- * <p>
- * This compares the two files "file1" and "file2" and
- * returns true if their content is exactly equal, or false
- * otherwise.
- * <p>
- * The external cmp(1) program is used for the comparison.
- * <p>
- * @throws LibGuestFSException
- */
- public boolean equal (String file1, String file2)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("equal: handle is closed");
- return _equal (g, file1, file2);
- }
- private native boolean _equal (long g, String file1, String file2)
- throws LibGuestFSException;
-
- /**
- * print the printable strings in a file
- * <p>
- * This runs the strings(1) command on a file and returns
- * the list of printable strings found.
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] strings (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("strings: handle is closed");
- return _strings (g, path);
- }
- private native String[] _strings (long g, String path)
- throws LibGuestFSException;
-
- /**
- * print the printable strings in a file
- * <p>
- * This is like the "g.strings" command, but allows you to
- * specify the encoding.
- * <p>
- * See the strings(1) manpage for the full list of
- * encodings.
- * <p>
- * Commonly useful encodings are "l" (lower case L) which
- * will show strings inside Windows/x86 files.
- * <p>
- * The returned strings are transcoded to UTF-8.
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] strings_e (String encoding, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("strings_e: handle is closed");
- return _strings_e (g, encoding, path);
- }
- private native String[] _strings_e (long g, String encoding, String path)
- throws LibGuestFSException;
-
- /**
- * dump a file in hexadecimal
- * <p>
- * This runs "hexdump -C" on the given "path". The result
- * is the human-readable, canonical hex dump of the file.
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String hexdump (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("hexdump: handle is closed");
- return _hexdump (g, path);
- }
- private native String _hexdump (long g, String path)
- throws LibGuestFSException;
-
- /**
- * zero unused inodes and disk blocks on ext2/3 filesystem
- * <p>
- * This runs the *zerofree* program on "device". This
- * program claims to zero unused inodes and disk blocks on
- * an ext2/3 filesystem, thus making it possible to
- * compress the filesystem more effectively.
- * <p>
- * You should not run this program if the filesystem is
- * mounted.
- * <p>
- * It is possible that using this program can damage the
- * filesystem or data on the filesystem.
- * <p>
- * @throws LibGuestFSException
- */
- public void zerofree (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("zerofree: handle is closed");
- _zerofree (g, device);
- }
- private native void _zerofree (long g, String device)
- throws LibGuestFSException;
-
- /**
- * resize an LVM physical volume
- * <p>
- * This resizes (expands or shrinks) an existing LVM
- * physical volume to match the new size of the underlying
- * device.
- * <p>
- * @throws LibGuestFSException
- */
- public void pvresize (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("pvresize: handle is closed");
- _pvresize (g, device);
- }
- private native void _pvresize (long g, String device)
- throws LibGuestFSException;
-
- /**
- * modify a single partition on a block device
- * <p>
- * This runs sfdisk(8) option to modify just the single
- * partition "n" (note: "n" counts from 1).
- * <p>
- * For other parameters, see "g.sfdisk". You should usually
- * pass 0 for the cyls/heads/sectors parameters.
- * <p>
- * This command is dangerous. Without careful use you can
- * easily destroy all your data.
- * <p>
- * @throws LibGuestFSException
- */
- public void sfdisk_N (String device, int partnum, int cyls, int heads, int sectors, String line)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("sfdisk_N: handle is closed");
- _sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
- }
- private native void _sfdisk_N (long g, String device, int partnum, int cyls, int heads, int sectors, String line)
- throws LibGuestFSException;
-
- /**
- * display the partition table
- * <p>
- * This displays the partition table on "device", in the
- * human-readable output of the sfdisk(8) command. It is
- * not intended to be parsed.
- * <p>
- * @throws LibGuestFSException
- */
- public String sfdisk_l (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("sfdisk_l: handle is closed");
- return _sfdisk_l (g, device);
- }
- private native String _sfdisk_l (long g, String device)
- throws LibGuestFSException;
-
- /**
- * display the kernel geometry
- * <p>
- * This displays the kernel's idea of the geometry of
- * "device".
- * <p>
- * The result is in human-readable format, and not designed
- * to be parsed.
- * <p>
- * @throws LibGuestFSException
- */
- public String sfdisk_kernel_geometry (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("sfdisk_kernel_geometry: handle is closed");
- return _sfdisk_kernel_geometry (g, device);
- }
- private native String _sfdisk_kernel_geometry (long g, String device)
- throws LibGuestFSException;
-
- /**
- * display the disk geometry from the partition table
- * <p>
- * This displays the disk geometry of "device" read from
- * the partition table. Especially in the case where the
- * underlying block device has been resized, this can be
- * different from the kernel's idea of the geometry (see
- * "g.sfdisk_kernel_geometry").
- * <p>
- * The result is in human-readable format, and not designed
- * to be parsed.
- * <p>
- * @throws LibGuestFSException
- */
- public String sfdisk_disk_geometry (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("sfdisk_disk_geometry: handle is closed");
- return _sfdisk_disk_geometry (g, device);
- }
- private native String _sfdisk_disk_geometry (long g, String device)
- throws LibGuestFSException;
-
- /**
- * activate or deactivate all volume groups
- * <p>
- * This command activates or (if "activate" is false)
- * deactivates all logical volumes in all volume groups. If
- * activated, then they are made known to the kernel, ie.
- * they appear as "/dev/mapper" devices. If deactivated,
- * then those devices disappear.
- * <p>
- * This command is the same as running "vgchange -a y|n"
- * <p>
- * @throws LibGuestFSException
- */
- public void vg_activate_all (boolean activate)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("vg_activate_all: handle is closed");
- _vg_activate_all (g, activate);
- }
- private native void _vg_activate_all (long g, boolean activate)
- throws LibGuestFSException;
-
- /**
- * activate or deactivate some volume groups
- * <p>
- * This command activates or (if "activate" is false)
- * deactivates all logical volumes in the listed volume
- * groups "volgroups". If activated, then they are made
- * known to the kernel, ie. they appear as "/dev/mapper"
- * devices. If deactivated, then those devices disappear.
- * <p>
- * This command is the same as running "vgchange -a y|n
- * volgroups..."
- * <p>
- * Note that if "volgroups" is an empty list then all
- * volume groups are activated or deactivated.
- * <p>
- * @throws LibGuestFSException
- */
- public void vg_activate (boolean activate, String[] volgroups)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("vg_activate: handle is closed");
- _vg_activate (g, activate, volgroups);
- }
- private native void _vg_activate (long g, boolean activate, String[] volgroups)
- throws LibGuestFSException;
-
- /**
- * resize an LVM logical volume
- * <p>
- * This resizes (expands or shrinks) an existing LVM
- * logical volume to "mbytes". When reducing, data in the
- * reduced part is lost.
- * <p>
- * @throws LibGuestFSException
- */
- public void lvresize (String device, int mbytes)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("lvresize: handle is closed");
- _lvresize (g, device, mbytes);
- }
- private native void _lvresize (long g, String device, int mbytes)
- throws LibGuestFSException;
-
- /**
- * resize an ext2/ext3 filesystem
- * <p>
- * This resizes an ext2 or ext3 filesystem to match the
- * size of the underlying device.
- * <p>
- * *Note:* It is sometimes required that you run
- * "g.e2fsck_f" on the "device" before calling this
- * command. For unknown reasons "resize2fs" sometimes gives
- * an error about this and sometimes not. In any case, it
- * is always safe to call "g.e2fsck_f" before calling this
- * function.
- * <p>
- * @throws LibGuestFSException
- */
- public void resize2fs (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("resize2fs: handle is closed");
- _resize2fs (g, device);
- }
- private native void _resize2fs (long g, String device)
- throws LibGuestFSException;
-
- /**
- * find all files and directories
- * <p>
- * This command lists out all files and directories,
- * recursively, starting at "directory". It is essentially
- * equivalent to running the shell command "find directory
- * -print" but some post-processing happens on the output,
- * described below.
- * <p>
- * This returns a list of strings *without any prefix*.
- * Thus if the directory structure was:
- * <p>
- * /tmp/a
- * /tmp/b
- * /tmp/c/d
- * <p>
- * then the returned list from "g.find" "/tmp" would be 4
- * elements:
- * <p>
- * a
- * b
- * c
- * c/d
- * <p>
- * If "directory" is not a directory, then this command
- * returns an error.
- * <p>
- * The returned list is sorted.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] find (String directory)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("find: handle is closed");
- return _find (g, directory);
- }
- private native String[] _find (long g, String directory)
- throws LibGuestFSException;
-
- /**
- * check an ext2/ext3 filesystem
- * <p>
- * This runs "e2fsck -p -f device", ie. runs the ext2/ext3
- * filesystem checker on "device", noninteractively ("-p"),
- * even if the filesystem appears to be clean ("-f").
- * <p>
- * This command is only needed because of "g.resize2fs"
- * (q.v.). Normally you should use "g.fsck".
- * <p>
- * @throws LibGuestFSException
- */
- public void e2fsck_f (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("e2fsck_f: handle is closed");
- _e2fsck_f (g, device);
- }
- private native void _e2fsck_f (long g, String device)
- throws LibGuestFSException;
-
- /**
- * sleep for some seconds
- * <p>
- * Sleep for "secs" seconds.
- * <p>
- * @throws LibGuestFSException
- */
- public void sleep (int secs)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("sleep: handle is closed");
- _sleep (g, secs);
- }
- private native void _sleep (long g, int secs)
- throws LibGuestFSException;
-
- /**
- * probe NTFS volume
- * <p>
- * This command runs the ntfs-3g.probe(8) command which
- * probes an NTFS "device" for mountability. (Not all NTFS
- * volumes can be mounted read-write, and some cannot be
- * mounted at all).
- * <p>
- * "rw" is a boolean flag. Set it to true if you want to
- * test if the volume can be mounted read-write. Set it to
- * false if you want to test if the volume can be mounted
- * read-only.
- * <p>
- * The return value is an integer which 0 if the operation
- * would succeed, or some non-zero value documented in the
- * ntfs-3g.probe(8) manual page.
- * <p>
- * @throws LibGuestFSException
- */
- public int ntfs_3g_probe (boolean rw, String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("ntfs_3g_probe: handle is closed");
- return _ntfs_3g_probe (g, rw, device);
- }
- private native int _ntfs_3g_probe (long g, boolean rw, String device)
- throws LibGuestFSException;
-
- /**
- * run a command via the shell
- * <p>
- * This call runs a command from the guest filesystem via
- * the guest's "/bin/sh".
- * <p>
- * This is like "g.command", but passes the command to:
- * <p>
- * /bin/sh -c "command"
- * <p>
- * Depending on the guest's shell, this usually results in
- * wildcards being expanded, shell expressions being
- * interpolated and so on.
- * <p>
- * All the provisos about "g.command" apply to this call.
- * <p>
- * @throws LibGuestFSException
- */
- public String sh (String command)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("sh: handle is closed");
- return _sh (g, command);
- }
- private native String _sh (long g, String command)
- throws LibGuestFSException;
-
- /**
- * run a command via the shell returning lines
- * <p>
- * This is the same as "g.sh", but splits the result into a
- * list of lines.
- * <p>
- * See also: "g.command_lines"
- * <p>
- * @throws LibGuestFSException
- */
- public String[] sh_lines (String command)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("sh_lines: handle is closed");
- return _sh_lines (g, command);
- }
- private native String[] _sh_lines (long g, String command)
- throws LibGuestFSException;
-
- /**
- * expand a wildcard path
- * <p>
- * This command searches for all the pathnames matching
- * "pattern" according to the wildcard expansion rules used
- * by the shell.
- * <p>
- * If no paths match, then this returns an empty list
- * (note: not an error).
- * <p>
- * It is just a wrapper around the C glob(3) function with
- * flags "GLOB_MARK|GLOB_BRACE". See that manual page for
- * more details.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] glob_expand (String pattern)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("glob_expand: handle is closed");
- return _glob_expand (g, pattern);
- }
- private native String[] _glob_expand (long g, String pattern)
- throws LibGuestFSException;
-
- /**
- * scrub (securely wipe) a device
- * <p>
- * This command writes patterns over "device" to make data
- * retrieval more difficult.
- * <p>
- * It is an interface to the scrub(1) program. See that
- * manual page for more details.
- * <p>
- * This command is dangerous. Without careful use you can
- * easily destroy all your data.
- * <p>
- * @throws LibGuestFSException
- */
- public void scrub_device (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("scrub_device: handle is closed");
- _scrub_device (g, device);
- }
- private native void _scrub_device (long g, String device)
- throws LibGuestFSException;
-
- /**
- * scrub (securely wipe) a file
- * <p>
- * This command writes patterns over a file to make data
- * retrieval more difficult.
- * <p>
- * The file is *removed* after scrubbing.
- * <p>
- * It is an interface to the scrub(1) program. See that
- * manual page for more details.
- * <p>
- * @throws LibGuestFSException
- */
- public void scrub_file (String file)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("scrub_file: handle is closed");
- _scrub_file (g, file);
- }
- private native void _scrub_file (long g, String file)
- throws LibGuestFSException;
-
- /**
- * scrub (securely wipe) free space
- * <p>
- * This command creates the directory "dir" and then fills
- * it with files until the filesystem is full, and scrubs
- * the files as for "g.scrub_file", and deletes them. The
- * intention is to scrub any free space on the partition
- * containing "dir".
- * <p>
- * It is an interface to the scrub(1) program. See that
- * manual page for more details.
- * <p>
- * @throws LibGuestFSException
- */
- public void scrub_freespace (String dir)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("scrub_freespace: handle is closed");
- _scrub_freespace (g, dir);
- }
- private native void _scrub_freespace (long g, String dir)
- throws LibGuestFSException;
-
- /**
- * create a temporary directory
- * <p>
- * This command creates a temporary directory. The
- * "template" parameter should be a full pathname for the
- * temporary directory name with the final six characters
- * being "XXXXXX".
- * <p>
- * For example: "/tmp/myprogXXXXXX" or
- * "/Temp/myprogXXXXXX", the second one being suitable for
- * Windows filesystems.
- * <p>
- * The name of the temporary directory that was created is
- * returned.
- * <p>
- * The temporary directory is created with mode 0700 and is
- * owned by root.
- * <p>
- * The caller is responsible for deleting the temporary
- * directory and its contents after use.
- * <p>
- * See also: mkdtemp(3)
- * <p>
- * @throws LibGuestFSException
- */
- public String mkdtemp (String template)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mkdtemp: handle is closed");
- return _mkdtemp (g, template);
- }
- private native String _mkdtemp (long g, String template)
- throws LibGuestFSException;
-
- /**
- * count lines in a file
- * <p>
- * This command counts the lines in a file, using the "wc
- * -l" external command.
- * <p>
- * @throws LibGuestFSException
- */
- public int wc_l (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("wc_l: handle is closed");
- return _wc_l (g, path);
- }
- private native int _wc_l (long g, String path)
- throws LibGuestFSException;
-
- /**
- * count words in a file
- * <p>
- * This command counts the words in a file, using the "wc
- * -w" external command.
- * <p>
- * @throws LibGuestFSException
- */
- public int wc_w (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("wc_w: handle is closed");
- return _wc_w (g, path);
- }
- private native int _wc_w (long g, String path)
- throws LibGuestFSException;
-
- /**
- * count characters in a file
- * <p>
- * This command counts the characters in a file, using the
- * "wc -c" external command.
- * <p>
- * @throws LibGuestFSException
- */
- public int wc_c (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("wc_c: handle is closed");
- return _wc_c (g, path);
- }
- private native int _wc_c (long g, String path)
- throws LibGuestFSException;
-
- /**
- * return first 10 lines of a file
- * <p>
- * This command returns up to the first 10 lines of a file
- * as a list of strings.
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] head (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("head: handle is closed");
- return _head (g, path);
- }
- private native String[] _head (long g, String path)
- throws LibGuestFSException;
-
- /**
- * return first N lines of a file
- * <p>
- * If the parameter "nrlines" is a positive number, this
- * returns the first "nrlines" lines of the file "path".
- * <p>
- * If the parameter "nrlines" is a negative number, this
- * returns lines from the file "path", excluding the last
- * "nrlines" lines.
- * <p>
- * If the parameter "nrlines" is zero, this returns an
- * empty list.
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] head_n (int nrlines, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("head_n: handle is closed");
- return _head_n (g, nrlines, path);
- }
- private native String[] _head_n (long g, int nrlines, String path)
- throws LibGuestFSException;
-
- /**
- * return last 10 lines of a file
- * <p>
- * This command returns up to the last 10 lines of a file
- * as a list of strings.
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] tail (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("tail: handle is closed");
- return _tail (g, path);
- }
- private native String[] _tail (long g, String path)
- throws LibGuestFSException;
-
- /**
- * return last N lines of a file
- * <p>
- * If the parameter "nrlines" is a positive number, this
- * returns the last "nrlines" lines of the file "path".
- * <p>
- * If the parameter "nrlines" is a negative number, this
- * returns lines from the file "path", starting with the
- * "-nrlines"th line.
- * <p>
- * If the parameter "nrlines" is zero, this returns an
- * empty list.
- * <p>
- * Because of the message protocol, there is a transfer
- * limit of somewhere between 2MB and 4MB. To transfer
- * large files you should use FTP.
- * <p>
- * @throws LibGuestFSException
- */
- public String[] tail_n (int nrlines, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("tail_n: handle is closed");
- return _tail_n (g, nrlines, path);
- }
- private native String[] _tail_n (long g, int nrlines, String path)
- throws LibGuestFSException;
-
- /**
- * report file system disk space usage
- * <p>
- * This command runs the "df" command to report disk space
- * used.
- * <p>
- * This command is mostly useful for interactive sessions.
- * It is *not* intended that you try to parse the output
- * string. Use "statvfs" from programs.
- * <p>
- * @throws LibGuestFSException
- */
- public String df ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("df: handle is closed");
- return _df (g);
- }
- private native String _df (long g)
- throws LibGuestFSException;
-
- /**
- * report file system disk space usage (human readable)
- * <p>
- * This command runs the "df -h" command to report disk
- * space used in human-readable format.
- * <p>
- * This command is mostly useful for interactive sessions.
- * It is *not* intended that you try to parse the output
- * string. Use "statvfs" from programs.
- * <p>
- * @throws LibGuestFSException
- */
- public String df_h ()
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("df_h: handle is closed");
- return _df_h (g);
- }
- private native String _df_h (long g)
- throws LibGuestFSException;
-
- /**
- * estimate file space usage
- * <p>
- * This command runs the "du -s" command to estimate file
- * space usage for "path".
- * <p>
- * "path" can be a file or a directory. If "path" is a
- * directory then the estimate includes the contents of the
- * directory and all subdirectories (recursively).
- * <p>
- * The result is the estimated size in *kilobytes* (ie.
- * units of 1024 bytes).
- * <p>
- * @throws LibGuestFSException
- */
- public long du (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("du: handle is closed");
- return _du (g, path);
- }
- private native long _du (long g, String path)
- throws LibGuestFSException;
-
- /**
- * list files in an initrd
- * <p>
- * This command lists out files contained in an initrd.
- * <p>
- * The files are listed without any initial "/" character.
- * The files are listed in the order they appear (not
- * necessarily alphabetical). Directory names are listed as
- * separate items.
- * <p>
- * Old Linux kernels (2.4 and earlier) used a compressed
- * ext2 filesystem as initrd. We *only* support the newer
- * initramfs format (compressed cpio files).
- * <p>
- * @throws LibGuestFSException
- */
- public String[] initrd_list (String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("initrd_list: handle is closed");
- return _initrd_list (g, path);
- }
- private native String[] _initrd_list (long g, String path)
- throws LibGuestFSException;
-
- /**
- * mount a file using the loop device
- * <p>
- * This command lets you mount "file" (a filesystem image
- * in a file) on a mount point. It is entirely equivalent
- * to the command "mount -o loop file mountpoint".
- * <p>
- * @throws LibGuestFSException
- */
- public void mount_loop (String file, String mountpoint)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mount_loop: handle is closed");
- _mount_loop (g, file, mountpoint);
- }
- private native void _mount_loop (long g, String file, String mountpoint)
- throws LibGuestFSException;
-
- /**
- * create a swap partition
- * <p>
- * Create a swap partition on "device".
- * <p>
- * @throws LibGuestFSException
- */
- public void mkswap (String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mkswap: handle is closed");
- _mkswap (g, device);
- }
- private native void _mkswap (long g, String device)
- throws LibGuestFSException;
-
- /**
- * create a swap partition with a label
- * <p>
- * Create a swap partition on "device" with label "label".
- * <p>
- * @throws LibGuestFSException
- */
- public void mkswap_L (String label, String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mkswap_L: handle is closed");
- _mkswap_L (g, label, device);
- }
- private native void _mkswap_L (long g, String label, String device)
- throws LibGuestFSException;
-
- /**
- * create a swap partition with an explicit UUID
- * <p>
- * Create a swap partition on "device" with UUID "uuid".
- * <p>
- * @throws LibGuestFSException
- */
- public void mkswap_U (String uuid, String device)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mkswap_U: handle is closed");
- _mkswap_U (g, uuid, device);
- }
- private native void _mkswap_U (long g, String uuid, String device)
- throws LibGuestFSException;
-
- /**
- * make block, character or FIFO devices
- * <p>
- * This call creates block or character special devices, or
- * named pipes (FIFOs).
- * <p>
- * The "mode" parameter should be the mode, using the
- * standard constants. "devmajor" and "devminor" are the
- * device major and minor numbers, only used when creating
- * block and character special devices.
- * <p>
- * @throws LibGuestFSException
- */
- public void mknod (int mode, int devmajor, int devminor, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mknod: handle is closed");
- _mknod (g, mode, devmajor, devminor, path);
- }
- private native void _mknod (long g, int mode, int devmajor, int devminor, String path)
- throws LibGuestFSException;
-
- /**
- * make FIFO (named pipe)
- * <p>
- * This call creates a FIFO (named pipe) called "path" with
- * mode "mode". It is just a convenient wrapper around
- * "g.mknod".
- * <p>
- * @throws LibGuestFSException
- */
- public void mkfifo (int mode, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mkfifo: handle is closed");
- _mkfifo (g, mode, path);
- }
- private native void _mkfifo (long g, int mode, String path)
- throws LibGuestFSException;
-
- /**
- * make block device node
- * <p>
- * This call creates a block device node called "path" with
- * mode "mode" and device major/minor "devmajor" and
- * "devminor". It is just a convenient wrapper around
- * "g.mknod".
- * <p>
- * @throws LibGuestFSException
- */
- public void mknod_b (int mode, int devmajor, int devminor, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mknod_b: handle is closed");
- _mknod_b (g, mode, devmajor, devminor, path);
- }
- private native void _mknod_b (long g, int mode, int devmajor, int devminor, String path)
- throws LibGuestFSException;
-
- /**
- * make char device node
- * <p>
- * This call creates a char device node called "path" with
- * mode "mode" and device major/minor "devmajor" and
- * "devminor". It is just a convenient wrapper around
- * "g.mknod".
- * <p>
- * @throws LibGuestFSException
- */
- public void mknod_c (int mode, int devmajor, int devminor, String path)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("mknod_c: handle is closed");
- _mknod_c (g, mode, devmajor, devminor, path);
- }
- private native void _mknod_c (long g, int mode, int devmajor, int devminor, String path)
- throws LibGuestFSException;
-
- /**
- * set file mode creation mask (umask)
- * <p>
- * This function sets the mask used for creating new files
- * and device nodes to "mask & 0777".
- * <p>
- * Typical umask values would be 022 which creates new
- * files with permissions like "-rw-r--r--" or
- * "-rwxr-xr-x", and 002 which creates new files with
- * permissions like "-rw-rw-r--" or "-rwxrwxr-x".
- * <p>
- * The default umask is 022. This is important because it
- * means that directories and device nodes will be created
- * with 0644 or 0755 mode even if you specify 0777.
- * <p>
- * See also umask(2), "g.mknod", "g.mkdir".
- * <p>
- * This call returns the previous umask.
- * <p>
- * @throws LibGuestFSException
- */
- public int umask (int mask)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("umask: handle is closed");
- return _umask (g, mask);
- }
- private native int _umask (long g, int mask)
- throws LibGuestFSException;
-
- /**
- * read directories entries
- * <p>
- * This returns the list of directory entries in directory
- * "dir".
- * <p>
- * All entries in the directory are returned, including "."
- * and "..". The entries are *not* sorted, but returned in
- * the same order as the underlying filesystem.
- * <p>
- * This function is primarily intended for use by programs.
- * To get a simple list of names, use "g.ls". To get a
- * printable directory for human consumption, use "g.ll".
- * <p>
- * @throws LibGuestFSException
- */
- public Dirent[] readdir (String dir)
- throws LibGuestFSException
- {
- if (g == 0)
- throw new LibGuestFSException ("readdir: handle is closed");
- return _readdir (g, dir);
- }
- private native Dirent[] _readdir (long g, String dir)
- throws LibGuestFSException;
-
-}
+++ /dev/null
-/* 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
- */
-
-package com.redhat.et.libguestfs;
-
-/**
- * Libguestfs LV structure.
- *
- * @author rjones
- * @see GuestFS
- */
-public class LV {
- public String lv_name;
- public String lv_uuid;
- public String lv_attr;
- public long lv_major;
- public long lv_minor;
- public long lv_kernel_major;
- public long lv_kernel_minor;
- public long lv_size;
- public long seg_count;
- public String origin;
- /* The next field is [0..100] or -1 meaning 'not present': */
- public float snap_percent;
- /* The next field is [0..100] or -1 meaning 'not present': */
- public float copy_percent;
- public String move_pv;
- public String lv_tags;
- public String mirror_log;
- public String modules;
-}
+++ /dev/null
-/* 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
- */
-
-package com.redhat.et.libguestfs;
-
-/**
- * Libguestfs PV structure.
- *
- * @author rjones
- * @see GuestFS
- */
-public class PV {
- public String pv_name;
- public String pv_uuid;
- public String pv_fmt;
- public long pv_size;
- public long dev_size;
- public long pv_free;
- public long pv_used;
- public String pv_attr;
- public long pv_pe_count;
- public long pv_pe_alloc_count;
- public String pv_tags;
- public long pe_start;
- public long pv_mda_count;
- public long pv_mda_free;
-}
+++ /dev/null
-/* 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
- */
-
-package com.redhat.et.libguestfs;
-
-/**
- * Libguestfs Stat structure.
- *
- * @author rjones
- * @see GuestFS
- */
-public class Stat {
- public long dev;
- public long ino;
- public long mode;
- public long nlink;
- public long uid;
- public long gid;
- public long rdev;
- public long size;
- public long blksize;
- public long blocks;
- public long atime;
- public long mtime;
- public long ctime;
-}
+++ /dev/null
-/* 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
- */
-
-package com.redhat.et.libguestfs;
-
-/**
- * Libguestfs StatVFS structure.
- *
- * @author rjones
- * @see GuestFS
- */
-public class StatVFS {
- public long bsize;
- public long frsize;
- public long blocks;
- public long bfree;
- public long bavail;
- public long files;
- public long ffree;
- public long favail;
- public long fsid;
- public long flag;
- public long namemax;
-}
+++ /dev/null
-/* 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
- */
-
-package com.redhat.et.libguestfs;
-
-/**
- * Libguestfs VG structure.
- *
- * @author rjones
- * @see GuestFS
- */
-public class VG {
- public String vg_name;
- public String vg_uuid;
- public String vg_fmt;
- public String vg_attr;
- public long vg_size;
- public long vg_free;
- public String vg_sysid;
- public long vg_extent_size;
- public long vg_extent_count;
- public long vg_free_count;
- public long max_lv;
- public long max_pv;
- public long pv_count;
- public long lv_count;
- public long snap_count;
- public long vg_seqno;
- public String vg_tags;
- public long vg_mda_count;
- public long vg_mda_free;
-}
+++ /dev/null
-/* 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 <string.h>
-
-#include "com_redhat_et_libguestfs_GuestFS.h"
-#include "guestfs.h"
-
-/* Note that this function returns. The exception is not thrown
- * until after the wrapper function returns.
- */
-static void
-throw_exception (JNIEnv *env, const char *msg)
-{
- jclass cl;
- cl = (*env)->FindClass (env,
- "com/redhat/et/libguestfs/LibGuestFSException");
- (*env)->ThrowNew (env, cl, msg);
-}
-
-JNIEXPORT jlong JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1create
- (JNIEnv *env, jobject obj)
-{
- guestfs_h *g;
-
- g = guestfs_create ();
- if (g == NULL) {
- throw_exception (env, "GuestFS.create: failed to allocate handle");
- return 0;
- }
- guestfs_set_error_handler (g, NULL, NULL);
- return (jlong) (long) g;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1close
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- guestfs_close (g);
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0
- (JNIEnv *env, jobject obj, jlong jg, jstring jstr, jstring joptstr, jobjectArray jstrlist, jboolean jb, jint jinteger, jstring jfilein, jstring jfileout)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *str;
- const char *optstr;
- int strlist_len;
- const char **strlist;
- int b;
- int integer;
- const char *filein;
- const char *fileout;
- int i;
-
- str = (*env)->GetStringUTFChars (env, jstr, NULL);
- optstr = joptstr ? (*env)->GetStringUTFChars (env, joptstr, NULL) : NULL;
- strlist_len = (*env)->GetArrayLength (env, jstrlist);
- strlist = guestfs_safe_malloc (g, sizeof (char *) * (strlist_len+1));
- for (i = 0; i < strlist_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jstrlist, i);
- strlist[i] = (*env)->GetStringUTFChars (env, o, NULL);
- }
- strlist[strlist_len] = NULL;
- b = jb;
- integer = jinteger;
- filein = (*env)->GetStringUTFChars (env, jfilein, NULL);
- fileout = (*env)->GetStringUTFChars (env, jfileout, NULL);
- r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout);
- (*env)->ReleaseStringUTFChars (env, jstr, str);
- if (joptstr)
- (*env)->ReleaseStringUTFChars (env, joptstr, optstr);
- for (i = 0; i < strlist_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jstrlist, i);
- (*env)->ReleaseStringUTFChars (env, o, strlist[i]);
- }
- free (strlist);
- (*env)->ReleaseStringUTFChars (env, jfilein, filein);
- (*env)->ReleaseStringUTFChars (env, jfileout, fileout);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rint
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *val;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rint (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rinterr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_test0rinterr (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT jlong JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rint64
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int64_t r;
- const char *val;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rint64 (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jlong) r;
-}
-
-JNIEXPORT jlong JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rint64err
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int64_t r;
-
- r = guestfs_test0rint64err (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jlong) r;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rbool
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *val;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rbool (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rboolerr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_test0rboolerr (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rconststring
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- const char *r;
- const char *val;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rconststring (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- return (*env)->NewStringUTF (env, r);
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rconststringerr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- const char *r;
-
- r = guestfs_test0rconststringerr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- return (*env)->NewStringUTF (env, r);
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rstring
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *val;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rstring (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rstringerr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
-
- r = guestfs_test0rstringerr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rstringlist
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *val;
- int i;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rstringlist (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rstringlisterr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int i;
-
- r = guestfs_test0rstringlisterr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rintbool
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_int_bool *r;
- const char *val;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rintbool (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/IntBool");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "i", "I");
- (*env)->SetIntField (env, jr, fl, r->i);
- fl = (*env)->GetFieldID (env, cl, "i", "Z");
- (*env)->SetBooleanField (env, jr, fl, r->b);
- guestfs_free_int_bool (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rintboolerr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_int_bool *r;
-
- r = guestfs_test0rintboolerr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/IntBool");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "i", "I");
- (*env)->SetIntField (env, jr, fl, r->i);
- fl = (*env)->GetFieldID (env, cl, "i", "Z");
- (*env)->SetBooleanField (env, jr, fl, r->b);
- guestfs_free_int_bool (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rpvlist
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_lvm_pv_list *r;
- const char *val;
- int i;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rpvlist (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/PV");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "pv_name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_name));
- {
- char s[33];
- memcpy (s, r->val[i].pv_uuid, 32);
- s[32] = 0;
- fl = (*env)->GetFieldID (env, cl, "pv_uuid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s));
- }
- fl = (*env)->GetFieldID (env, cl, "pv_fmt", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_fmt));
- fl = (*env)->GetFieldID (env, cl, "pv_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_size);
- fl = (*env)->GetFieldID (env, cl, "dev_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].dev_size);
- fl = (*env)->GetFieldID (env, cl, "pv_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_free);
- fl = (*env)->GetFieldID (env, cl, "pv_used", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_used);
- fl = (*env)->GetFieldID (env, cl, "pv_attr", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_attr));
- fl = (*env)->GetFieldID (env, cl, "pv_pe_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_count);
- fl = (*env)->GetFieldID (env, cl, "pv_pe_alloc_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_alloc_count);
- fl = (*env)->GetFieldID (env, cl, "pv_tags", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_tags));
- fl = (*env)->GetFieldID (env, cl, "pe_start", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pe_start);
- fl = (*env)->GetFieldID (env, cl, "pv_mda_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_count);
- fl = (*env)->GetFieldID (env, cl, "pv_mda_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_free);
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_lvm_pv_list (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rpvlisterr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_lvm_pv_list *r;
- int i;
-
- r = guestfs_test0rpvlisterr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/PV");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "pv_name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_name));
- {
- char s[33];
- memcpy (s, r->val[i].pv_uuid, 32);
- s[32] = 0;
- fl = (*env)->GetFieldID (env, cl, "pv_uuid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s));
- }
- fl = (*env)->GetFieldID (env, cl, "pv_fmt", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_fmt));
- fl = (*env)->GetFieldID (env, cl, "pv_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_size);
- fl = (*env)->GetFieldID (env, cl, "dev_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].dev_size);
- fl = (*env)->GetFieldID (env, cl, "pv_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_free);
- fl = (*env)->GetFieldID (env, cl, "pv_used", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_used);
- fl = (*env)->GetFieldID (env, cl, "pv_attr", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_attr));
- fl = (*env)->GetFieldID (env, cl, "pv_pe_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_count);
- fl = (*env)->GetFieldID (env, cl, "pv_pe_alloc_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_alloc_count);
- fl = (*env)->GetFieldID (env, cl, "pv_tags", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_tags));
- fl = (*env)->GetFieldID (env, cl, "pe_start", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pe_start);
- fl = (*env)->GetFieldID (env, cl, "pv_mda_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_count);
- fl = (*env)->GetFieldID (env, cl, "pv_mda_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_free);
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_lvm_pv_list (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rvglist
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_lvm_vg_list *r;
- const char *val;
- int i;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rvglist (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/VG");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "vg_name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_name));
- {
- char s[33];
- memcpy (s, r->val[i].vg_uuid, 32);
- s[32] = 0;
- fl = (*env)->GetFieldID (env, cl, "vg_uuid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s));
- }
- fl = (*env)->GetFieldID (env, cl, "vg_fmt", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_fmt));
- fl = (*env)->GetFieldID (env, cl, "vg_attr", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_attr));
- fl = (*env)->GetFieldID (env, cl, "vg_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_size);
- fl = (*env)->GetFieldID (env, cl, "vg_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free);
- fl = (*env)->GetFieldID (env, cl, "vg_sysid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_sysid));
- fl = (*env)->GetFieldID (env, cl, "vg_extent_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_size);
- fl = (*env)->GetFieldID (env, cl, "vg_extent_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_count);
- fl = (*env)->GetFieldID (env, cl, "vg_free_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free_count);
- fl = (*env)->GetFieldID (env, cl, "max_lv", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].max_lv);
- fl = (*env)->GetFieldID (env, cl, "max_pv", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].max_pv);
- fl = (*env)->GetFieldID (env, cl, "pv_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_count);
- fl = (*env)->GetFieldID (env, cl, "lv_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_count);
- fl = (*env)->GetFieldID (env, cl, "snap_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].snap_count);
- fl = (*env)->GetFieldID (env, cl, "vg_seqno", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_seqno);
- fl = (*env)->GetFieldID (env, cl, "vg_tags", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_tags));
- fl = (*env)->GetFieldID (env, cl, "vg_mda_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_count);
- fl = (*env)->GetFieldID (env, cl, "vg_mda_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_free);
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_lvm_vg_list (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rvglisterr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_lvm_vg_list *r;
- int i;
-
- r = guestfs_test0rvglisterr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/VG");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "vg_name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_name));
- {
- char s[33];
- memcpy (s, r->val[i].vg_uuid, 32);
- s[32] = 0;
- fl = (*env)->GetFieldID (env, cl, "vg_uuid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s));
- }
- fl = (*env)->GetFieldID (env, cl, "vg_fmt", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_fmt));
- fl = (*env)->GetFieldID (env, cl, "vg_attr", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_attr));
- fl = (*env)->GetFieldID (env, cl, "vg_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_size);
- fl = (*env)->GetFieldID (env, cl, "vg_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free);
- fl = (*env)->GetFieldID (env, cl, "vg_sysid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_sysid));
- fl = (*env)->GetFieldID (env, cl, "vg_extent_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_size);
- fl = (*env)->GetFieldID (env, cl, "vg_extent_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_count);
- fl = (*env)->GetFieldID (env, cl, "vg_free_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free_count);
- fl = (*env)->GetFieldID (env, cl, "max_lv", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].max_lv);
- fl = (*env)->GetFieldID (env, cl, "max_pv", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].max_pv);
- fl = (*env)->GetFieldID (env, cl, "pv_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_count);
- fl = (*env)->GetFieldID (env, cl, "lv_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_count);
- fl = (*env)->GetFieldID (env, cl, "snap_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].snap_count);
- fl = (*env)->GetFieldID (env, cl, "vg_seqno", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_seqno);
- fl = (*env)->GetFieldID (env, cl, "vg_tags", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_tags));
- fl = (*env)->GetFieldID (env, cl, "vg_mda_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_count);
- fl = (*env)->GetFieldID (env, cl, "vg_mda_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_free);
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_lvm_vg_list (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rlvlist
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_lvm_lv_list *r;
- const char *val;
- int i;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rlvlist (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/LV");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "lv_name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_name));
- {
- char s[33];
- memcpy (s, r->val[i].lv_uuid, 32);
- s[32] = 0;
- fl = (*env)->GetFieldID (env, cl, "lv_uuid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s));
- }
- fl = (*env)->GetFieldID (env, cl, "lv_attr", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_attr));
- fl = (*env)->GetFieldID (env, cl, "lv_major", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_major);
- fl = (*env)->GetFieldID (env, cl, "lv_minor", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_minor);
- fl = (*env)->GetFieldID (env, cl, "lv_kernel_major", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_major);
- fl = (*env)->GetFieldID (env, cl, "lv_kernel_minor", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_minor);
- fl = (*env)->GetFieldID (env, cl, "lv_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_size);
- fl = (*env)->GetFieldID (env, cl, "seg_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].seg_count);
- fl = (*env)->GetFieldID (env, cl, "origin", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].origin));
- fl = (*env)->GetFieldID (env, cl, "snap_percent", "F");
- (*env)->SetFloatField (env, jfl, fl, r->val[i].snap_percent);
- fl = (*env)->GetFieldID (env, cl, "copy_percent", "F");
- (*env)->SetFloatField (env, jfl, fl, r->val[i].copy_percent);
- fl = (*env)->GetFieldID (env, cl, "move_pv", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].move_pv));
- fl = (*env)->GetFieldID (env, cl, "lv_tags", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_tags));
- fl = (*env)->GetFieldID (env, cl, "mirror_log", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].mirror_log));
- fl = (*env)->GetFieldID (env, cl, "modules", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].modules));
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_lvm_lv_list (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rlvlisterr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_lvm_lv_list *r;
- int i;
-
- r = guestfs_test0rlvlisterr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/LV");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "lv_name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_name));
- {
- char s[33];
- memcpy (s, r->val[i].lv_uuid, 32);
- s[32] = 0;
- fl = (*env)->GetFieldID (env, cl, "lv_uuid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s));
- }
- fl = (*env)->GetFieldID (env, cl, "lv_attr", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_attr));
- fl = (*env)->GetFieldID (env, cl, "lv_major", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_major);
- fl = (*env)->GetFieldID (env, cl, "lv_minor", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_minor);
- fl = (*env)->GetFieldID (env, cl, "lv_kernel_major", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_major);
- fl = (*env)->GetFieldID (env, cl, "lv_kernel_minor", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_minor);
- fl = (*env)->GetFieldID (env, cl, "lv_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_size);
- fl = (*env)->GetFieldID (env, cl, "seg_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].seg_count);
- fl = (*env)->GetFieldID (env, cl, "origin", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].origin));
- fl = (*env)->GetFieldID (env, cl, "snap_percent", "F");
- (*env)->SetFloatField (env, jfl, fl, r->val[i].snap_percent);
- fl = (*env)->GetFieldID (env, cl, "copy_percent", "F");
- (*env)->SetFloatField (env, jfl, fl, r->val[i].copy_percent);
- fl = (*env)->GetFieldID (env, cl, "move_pv", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].move_pv));
- fl = (*env)->GetFieldID (env, cl, "lv_tags", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_tags));
- fl = (*env)->GetFieldID (env, cl, "mirror_log", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].mirror_log));
- fl = (*env)->GetFieldID (env, cl, "modules", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].modules));
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_lvm_lv_list (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rstat
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_stat *r;
- const char *val;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rstat (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/Stat");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "dev", "J");
- (*env)->SetLongField (env, jr, fl, r->dev);
- fl = (*env)->GetFieldID (env, cl, "ino", "J");
- (*env)->SetLongField (env, jr, fl, r->ino);
- fl = (*env)->GetFieldID (env, cl, "mode", "J");
- (*env)->SetLongField (env, jr, fl, r->mode);
- fl = (*env)->GetFieldID (env, cl, "nlink", "J");
- (*env)->SetLongField (env, jr, fl, r->nlink);
- fl = (*env)->GetFieldID (env, cl, "uid", "J");
- (*env)->SetLongField (env, jr, fl, r->uid);
- fl = (*env)->GetFieldID (env, cl, "gid", "J");
- (*env)->SetLongField (env, jr, fl, r->gid);
- fl = (*env)->GetFieldID (env, cl, "rdev", "J");
- (*env)->SetLongField (env, jr, fl, r->rdev);
- fl = (*env)->GetFieldID (env, cl, "size", "J");
- (*env)->SetLongField (env, jr, fl, r->size);
- fl = (*env)->GetFieldID (env, cl, "blksize", "J");
- (*env)->SetLongField (env, jr, fl, r->blksize);
- fl = (*env)->GetFieldID (env, cl, "blocks", "J");
- (*env)->SetLongField (env, jr, fl, r->blocks);
- fl = (*env)->GetFieldID (env, cl, "atime", "J");
- (*env)->SetLongField (env, jr, fl, r->atime);
- fl = (*env)->GetFieldID (env, cl, "mtime", "J");
- (*env)->SetLongField (env, jr, fl, r->mtime);
- fl = (*env)->GetFieldID (env, cl, "ctime", "J");
- (*env)->SetLongField (env, jr, fl, r->ctime);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rstaterr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_stat *r;
-
- r = guestfs_test0rstaterr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/Stat");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "dev", "J");
- (*env)->SetLongField (env, jr, fl, r->dev);
- fl = (*env)->GetFieldID (env, cl, "ino", "J");
- (*env)->SetLongField (env, jr, fl, r->ino);
- fl = (*env)->GetFieldID (env, cl, "mode", "J");
- (*env)->SetLongField (env, jr, fl, r->mode);
- fl = (*env)->GetFieldID (env, cl, "nlink", "J");
- (*env)->SetLongField (env, jr, fl, r->nlink);
- fl = (*env)->GetFieldID (env, cl, "uid", "J");
- (*env)->SetLongField (env, jr, fl, r->uid);
- fl = (*env)->GetFieldID (env, cl, "gid", "J");
- (*env)->SetLongField (env, jr, fl, r->gid);
- fl = (*env)->GetFieldID (env, cl, "rdev", "J");
- (*env)->SetLongField (env, jr, fl, r->rdev);
- fl = (*env)->GetFieldID (env, cl, "size", "J");
- (*env)->SetLongField (env, jr, fl, r->size);
- fl = (*env)->GetFieldID (env, cl, "blksize", "J");
- (*env)->SetLongField (env, jr, fl, r->blksize);
- fl = (*env)->GetFieldID (env, cl, "blocks", "J");
- (*env)->SetLongField (env, jr, fl, r->blocks);
- fl = (*env)->GetFieldID (env, cl, "atime", "J");
- (*env)->SetLongField (env, jr, fl, r->atime);
- fl = (*env)->GetFieldID (env, cl, "mtime", "J");
- (*env)->SetLongField (env, jr, fl, r->mtime);
- fl = (*env)->GetFieldID (env, cl, "ctime", "J");
- (*env)->SetLongField (env, jr, fl, r->ctime);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rstatvfs
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_statvfs *r;
- const char *val;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rstatvfs (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/StatVFS");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "bsize", "J");
- (*env)->SetLongField (env, jr, fl, r->bsize);
- fl = (*env)->GetFieldID (env, cl, "frsize", "J");
- (*env)->SetLongField (env, jr, fl, r->frsize);
- fl = (*env)->GetFieldID (env, cl, "blocks", "J");
- (*env)->SetLongField (env, jr, fl, r->blocks);
- fl = (*env)->GetFieldID (env, cl, "bfree", "J");
- (*env)->SetLongField (env, jr, fl, r->bfree);
- fl = (*env)->GetFieldID (env, cl, "bavail", "J");
- (*env)->SetLongField (env, jr, fl, r->bavail);
- fl = (*env)->GetFieldID (env, cl, "files", "J");
- (*env)->SetLongField (env, jr, fl, r->files);
- fl = (*env)->GetFieldID (env, cl, "ffree", "J");
- (*env)->SetLongField (env, jr, fl, r->ffree);
- fl = (*env)->GetFieldID (env, cl, "favail", "J");
- (*env)->SetLongField (env, jr, fl, r->favail);
- fl = (*env)->GetFieldID (env, cl, "fsid", "J");
- (*env)->SetLongField (env, jr, fl, r->fsid);
- fl = (*env)->GetFieldID (env, cl, "flag", "J");
- (*env)->SetLongField (env, jr, fl, r->flag);
- fl = (*env)->GetFieldID (env, cl, "namemax", "J");
- (*env)->SetLongField (env, jr, fl, r->namemax);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rstatvfserr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_statvfs *r;
-
- r = guestfs_test0rstatvfserr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/StatVFS");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "bsize", "J");
- (*env)->SetLongField (env, jr, fl, r->bsize);
- fl = (*env)->GetFieldID (env, cl, "frsize", "J");
- (*env)->SetLongField (env, jr, fl, r->frsize);
- fl = (*env)->GetFieldID (env, cl, "blocks", "J");
- (*env)->SetLongField (env, jr, fl, r->blocks);
- fl = (*env)->GetFieldID (env, cl, "bfree", "J");
- (*env)->SetLongField (env, jr, fl, r->bfree);
- fl = (*env)->GetFieldID (env, cl, "bavail", "J");
- (*env)->SetLongField (env, jr, fl, r->bavail);
- fl = (*env)->GetFieldID (env, cl, "files", "J");
- (*env)->SetLongField (env, jr, fl, r->files);
- fl = (*env)->GetFieldID (env, cl, "ffree", "J");
- (*env)->SetLongField (env, jr, fl, r->ffree);
- fl = (*env)->GetFieldID (env, cl, "favail", "J");
- (*env)->SetLongField (env, jr, fl, r->favail);
- fl = (*env)->GetFieldID (env, cl, "fsid", "J");
- (*env)->SetLongField (env, jr, fl, r->fsid);
- fl = (*env)->GetFieldID (env, cl, "flag", "J");
- (*env)->SetLongField (env, jr, fl, r->flag);
- fl = (*env)->GetFieldID (env, cl, "namemax", "J");
- (*env)->SetLongField (env, jr, fl, r->namemax);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rhashtable
- (JNIEnv *env, jobject obj, jlong jg, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- char **r;
- const char *val;
-
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_test0rhashtable (g, val);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- throw_exception (env, "test0rhashtable: internal error: please let us know how to make a Java HashMap from JNI bindings!");
- return NULL;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1test0rhashtableerr
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- char **r;
-
- r = guestfs_test0rhashtableerr (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- throw_exception (env, "test0rhashtableerr: internal error: please let us know how to make a Java HashMap from JNI bindings!");
- return NULL;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1launch
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_launch (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1wait_1ready
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_wait_ready (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1kill_1subprocess
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_kill_subprocess (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1add_1drive
- (JNIEnv *env, jobject obj, jlong jg, jstring jfilename)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *filename;
-
- filename = (*env)->GetStringUTFChars (env, jfilename, NULL);
- r = guestfs_add_drive (g, filename);
- (*env)->ReleaseStringUTFChars (env, jfilename, filename);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1add_1cdrom
- (JNIEnv *env, jobject obj, jlong jg, jstring jfilename)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *filename;
-
- filename = (*env)->GetStringUTFChars (env, jfilename, NULL);
- r = guestfs_add_cdrom (g, filename);
- (*env)->ReleaseStringUTFChars (env, jfilename, filename);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1add_1drive_1ro
- (JNIEnv *env, jobject obj, jlong jg, jstring jfilename)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *filename;
-
- filename = (*env)->GetStringUTFChars (env, jfilename, NULL);
- r = guestfs_add_drive_ro (g, filename);
- (*env)->ReleaseStringUTFChars (env, jfilename, filename);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1config
- (JNIEnv *env, jobject obj, jlong jg, jstring jqemuparam, jstring jqemuvalue)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *qemuparam;
- const char *qemuvalue;
-
- qemuparam = (*env)->GetStringUTFChars (env, jqemuparam, NULL);
- qemuvalue = jqemuvalue ? (*env)->GetStringUTFChars (env, jqemuvalue, NULL) : NULL;
- r = guestfs_config (g, qemuparam, qemuvalue);
- (*env)->ReleaseStringUTFChars (env, jqemuparam, qemuparam);
- if (jqemuvalue)
- (*env)->ReleaseStringUTFChars (env, jqemuvalue, qemuvalue);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1qemu
- (JNIEnv *env, jobject obj, jlong jg, jstring jqemu)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *qemu;
-
- qemu = (*env)->GetStringUTFChars (env, jqemu, NULL);
- r = guestfs_set_qemu (g, qemu);
- (*env)->ReleaseStringUTFChars (env, jqemu, qemu);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1get_1qemu
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- const char *r;
-
- r = guestfs_get_qemu (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- return (*env)->NewStringUTF (env, r);
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1path
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_set_path (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1get_1path
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- const char *r;
-
- r = guestfs_get_path (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- return (*env)->NewStringUTF (env, r);
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1append
- (JNIEnv *env, jobject obj, jlong jg, jstring jappend)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *append;
-
- append = (*env)->GetStringUTFChars (env, jappend, NULL);
- r = guestfs_set_append (g, append);
- (*env)->ReleaseStringUTFChars (env, jappend, append);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1get_1append
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- const char *r;
-
- r = guestfs_get_append (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- return (*env)->NewStringUTF (env, r);
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1autosync
- (JNIEnv *env, jobject obj, jlong jg, jboolean jautosync)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int autosync;
-
- autosync = jautosync;
- r = guestfs_set_autosync (g, autosync);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1get_1autosync
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_get_autosync (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1verbose
- (JNIEnv *env, jobject obj, jlong jg, jboolean jverbose)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int verbose;
-
- verbose = jverbose;
- r = guestfs_set_verbose (g, verbose);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1get_1verbose
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_get_verbose (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1is_1ready
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_is_ready (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1is_1config
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_is_config (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1is_1launching
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_is_launching (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1is_1busy
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_is_busy (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1get_1state
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_get_state (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1busy
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_set_busy (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1ready
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_set_ready (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1end_1busy
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_end_busy (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1memsize
- (JNIEnv *env, jobject obj, jlong jg, jint jmemsize)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int memsize;
-
- memsize = jmemsize;
- r = guestfs_set_memsize (g, memsize);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1get_1memsize
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_get_memsize (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mount
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jstring jmountpoint)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
- const char *mountpoint;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- mountpoint = (*env)->GetStringUTFChars (env, jmountpoint, NULL);
- r = guestfs_mount (g, device, mountpoint);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- (*env)->ReleaseStringUTFChars (env, jmountpoint, mountpoint);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1sync
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_sync (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1touch
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_touch (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1cat
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_cat (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1ll
- (JNIEnv *env, jobject obj, jlong jg, jstring jdirectory)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *directory;
-
- directory = (*env)->GetStringUTFChars (env, jdirectory, NULL);
- r = guestfs_ll (g, directory);
- (*env)->ReleaseStringUTFChars (env, jdirectory, directory);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1ls
- (JNIEnv *env, jobject obj, jlong jg, jstring jdirectory)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *directory;
- int i;
-
- directory = (*env)->GetStringUTFChars (env, jdirectory, NULL);
- r = guestfs_ls (g, directory);
- (*env)->ReleaseStringUTFChars (env, jdirectory, directory);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1list_1devices
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int i;
-
- r = guestfs_list_devices (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1list_1partitions
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int i;
-
- r = guestfs_list_partitions (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1pvs
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int i;
-
- r = guestfs_pvs (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1vgs
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int i;
-
- r = guestfs_vgs (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1lvs
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int i;
-
- r = guestfs_lvs (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1pvs_1full
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_lvm_pv_list *r;
- int i;
-
- r = guestfs_pvs_full (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/PV");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "pv_name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_name));
- {
- char s[33];
- memcpy (s, r->val[i].pv_uuid, 32);
- s[32] = 0;
- fl = (*env)->GetFieldID (env, cl, "pv_uuid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s));
- }
- fl = (*env)->GetFieldID (env, cl, "pv_fmt", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_fmt));
- fl = (*env)->GetFieldID (env, cl, "pv_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_size);
- fl = (*env)->GetFieldID (env, cl, "dev_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].dev_size);
- fl = (*env)->GetFieldID (env, cl, "pv_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_free);
- fl = (*env)->GetFieldID (env, cl, "pv_used", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_used);
- fl = (*env)->GetFieldID (env, cl, "pv_attr", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_attr));
- fl = (*env)->GetFieldID (env, cl, "pv_pe_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_count);
- fl = (*env)->GetFieldID (env, cl, "pv_pe_alloc_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_alloc_count);
- fl = (*env)->GetFieldID (env, cl, "pv_tags", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_tags));
- fl = (*env)->GetFieldID (env, cl, "pe_start", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pe_start);
- fl = (*env)->GetFieldID (env, cl, "pv_mda_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_count);
- fl = (*env)->GetFieldID (env, cl, "pv_mda_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_free);
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_lvm_pv_list (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1vgs_1full
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_lvm_vg_list *r;
- int i;
-
- r = guestfs_vgs_full (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/VG");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "vg_name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_name));
- {
- char s[33];
- memcpy (s, r->val[i].vg_uuid, 32);
- s[32] = 0;
- fl = (*env)->GetFieldID (env, cl, "vg_uuid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s));
- }
- fl = (*env)->GetFieldID (env, cl, "vg_fmt", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_fmt));
- fl = (*env)->GetFieldID (env, cl, "vg_attr", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_attr));
- fl = (*env)->GetFieldID (env, cl, "vg_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_size);
- fl = (*env)->GetFieldID (env, cl, "vg_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free);
- fl = (*env)->GetFieldID (env, cl, "vg_sysid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_sysid));
- fl = (*env)->GetFieldID (env, cl, "vg_extent_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_size);
- fl = (*env)->GetFieldID (env, cl, "vg_extent_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_count);
- fl = (*env)->GetFieldID (env, cl, "vg_free_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free_count);
- fl = (*env)->GetFieldID (env, cl, "max_lv", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].max_lv);
- fl = (*env)->GetFieldID (env, cl, "max_pv", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].max_pv);
- fl = (*env)->GetFieldID (env, cl, "pv_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].pv_count);
- fl = (*env)->GetFieldID (env, cl, "lv_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_count);
- fl = (*env)->GetFieldID (env, cl, "snap_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].snap_count);
- fl = (*env)->GetFieldID (env, cl, "vg_seqno", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_seqno);
- fl = (*env)->GetFieldID (env, cl, "vg_tags", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_tags));
- fl = (*env)->GetFieldID (env, cl, "vg_mda_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_count);
- fl = (*env)->GetFieldID (env, cl, "vg_mda_free", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_free);
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_lvm_vg_list (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1lvs_1full
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_lvm_lv_list *r;
- int i;
-
- r = guestfs_lvs_full (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/LV");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "lv_name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_name));
- {
- char s[33];
- memcpy (s, r->val[i].lv_uuid, 32);
- s[32] = 0;
- fl = (*env)->GetFieldID (env, cl, "lv_uuid", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s));
- }
- fl = (*env)->GetFieldID (env, cl, "lv_attr", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_attr));
- fl = (*env)->GetFieldID (env, cl, "lv_major", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_major);
- fl = (*env)->GetFieldID (env, cl, "lv_minor", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_minor);
- fl = (*env)->GetFieldID (env, cl, "lv_kernel_major", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_major);
- fl = (*env)->GetFieldID (env, cl, "lv_kernel_minor", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_minor);
- fl = (*env)->GetFieldID (env, cl, "lv_size", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].lv_size);
- fl = (*env)->GetFieldID (env, cl, "seg_count", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].seg_count);
- fl = (*env)->GetFieldID (env, cl, "origin", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].origin));
- fl = (*env)->GetFieldID (env, cl, "snap_percent", "F");
- (*env)->SetFloatField (env, jfl, fl, r->val[i].snap_percent);
- fl = (*env)->GetFieldID (env, cl, "copy_percent", "F");
- (*env)->SetFloatField (env, jfl, fl, r->val[i].copy_percent);
- fl = (*env)->GetFieldID (env, cl, "move_pv", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].move_pv));
- fl = (*env)->GetFieldID (env, cl, "lv_tags", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_tags));
- fl = (*env)->GetFieldID (env, cl, "mirror_log", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].mirror_log));
- fl = (*env)->GetFieldID (env, cl, "modules", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].modules));
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_lvm_lv_list (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1read_1lines
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *path;
- int i;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_read_lines (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1init
- (JNIEnv *env, jobject obj, jlong jg, jstring jroot, jint jflags)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *root;
- int flags;
-
- root = (*env)->GetStringUTFChars (env, jroot, NULL);
- flags = jflags;
- r = guestfs_aug_init (g, root, flags);
- (*env)->ReleaseStringUTFChars (env, jroot, root);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1close
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_aug_close (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1defvar
- (JNIEnv *env, jobject obj, jlong jg, jstring jname, jstring jexpr)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *name;
- const char *expr;
-
- name = (*env)->GetStringUTFChars (env, jname, NULL);
- expr = jexpr ? (*env)->GetStringUTFChars (env, jexpr, NULL) : NULL;
- r = guestfs_aug_defvar (g, name, expr);
- (*env)->ReleaseStringUTFChars (env, jname, name);
- if (jexpr)
- (*env)->ReleaseStringUTFChars (env, jexpr, expr);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1defnode
- (JNIEnv *env, jobject obj, jlong jg, jstring jname, jstring jexpr, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_int_bool *r;
- const char *name;
- const char *expr;
- const char *val;
-
- name = (*env)->GetStringUTFChars (env, jname, NULL);
- expr = (*env)->GetStringUTFChars (env, jexpr, NULL);
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_aug_defnode (g, name, expr, val);
- (*env)->ReleaseStringUTFChars (env, jname, name);
- (*env)->ReleaseStringUTFChars (env, jexpr, expr);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/IntBool");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "i", "I");
- (*env)->SetIntField (env, jr, fl, r->i);
- fl = (*env)->GetFieldID (env, cl, "i", "Z");
- (*env)->SetBooleanField (env, jr, fl, r->b);
- guestfs_free_int_bool (r);
- return jr;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1get
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_aug_get (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1set
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath, jstring jval)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
- const char *val;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- val = (*env)->GetStringUTFChars (env, jval, NULL);
- r = guestfs_aug_set (g, path, val);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- (*env)->ReleaseStringUTFChars (env, jval, val);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1insert
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath, jstring jlabel, jboolean jbefore)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
- const char *label;
- int before;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- label = (*env)->GetStringUTFChars (env, jlabel, NULL);
- before = jbefore;
- r = guestfs_aug_insert (g, path, label, before);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- (*env)->ReleaseStringUTFChars (env, jlabel, label);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1rm
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_aug_rm (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1mv
- (JNIEnv *env, jobject obj, jlong jg, jstring jsrc, jstring jdest)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *src;
- const char *dest;
-
- src = (*env)->GetStringUTFChars (env, jsrc, NULL);
- dest = (*env)->GetStringUTFChars (env, jdest, NULL);
- r = guestfs_aug_mv (g, src, dest);
- (*env)->ReleaseStringUTFChars (env, jsrc, src);
- (*env)->ReleaseStringUTFChars (env, jdest, dest);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1match
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *path;
- int i;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_aug_match (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1save
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_aug_save (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1load
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_aug_load (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1aug_1ls
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *path;
- int i;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_aug_ls (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1rm
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_rm (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1rmdir
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_rmdir (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1rm_1rf
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_rm_rf (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mkdir
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_mkdir (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mkdir_1p
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_mkdir_p (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1chmod
- (JNIEnv *env, jobject obj, jlong jg, jint jmode, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int mode;
- const char *path;
-
- mode = jmode;
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_chmod (g, mode, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1chown
- (JNIEnv *env, jobject obj, jlong jg, jint jowner, jint jgroup, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int owner;
- int group;
- const char *path;
-
- owner = jowner;
- group = jgroup;
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_chown (g, owner, group, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1exists
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_exists (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1is_1file
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_is_file (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1is_1dir
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_is_dir (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1pvcreate
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_pvcreate (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1vgcreate
- (JNIEnv *env, jobject obj, jlong jg, jstring jvolgroup, jobjectArray jphysvols)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *volgroup;
- int physvols_len;
- const char **physvols;
- int i;
-
- volgroup = (*env)->GetStringUTFChars (env, jvolgroup, NULL);
- physvols_len = (*env)->GetArrayLength (env, jphysvols);
- physvols = guestfs_safe_malloc (g, sizeof (char *) * (physvols_len+1));
- for (i = 0; i < physvols_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jphysvols, i);
- physvols[i] = (*env)->GetStringUTFChars (env, o, NULL);
- }
- physvols[physvols_len] = NULL;
- r = guestfs_vgcreate (g, volgroup, physvols);
- (*env)->ReleaseStringUTFChars (env, jvolgroup, volgroup);
- for (i = 0; i < physvols_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jphysvols, i);
- (*env)->ReleaseStringUTFChars (env, o, physvols[i]);
- }
- free (physvols);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1lvcreate
- (JNIEnv *env, jobject obj, jlong jg, jstring jlogvol, jstring jvolgroup, jint jmbytes)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *logvol;
- const char *volgroup;
- int mbytes;
-
- logvol = (*env)->GetStringUTFChars (env, jlogvol, NULL);
- volgroup = (*env)->GetStringUTFChars (env, jvolgroup, NULL);
- mbytes = jmbytes;
- r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
- (*env)->ReleaseStringUTFChars (env, jlogvol, logvol);
- (*env)->ReleaseStringUTFChars (env, jvolgroup, volgroup);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mkfs
- (JNIEnv *env, jobject obj, jlong jg, jstring jfstype, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *fstype;
- const char *device;
-
- fstype = (*env)->GetStringUTFChars (env, jfstype, NULL);
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_mkfs (g, fstype, device);
- (*env)->ReleaseStringUTFChars (env, jfstype, fstype);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1sfdisk
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jint jcyls, jint jheads, jint jsectors, jobjectArray jlines)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
- int cyls;
- int heads;
- int sectors;
- int lines_len;
- const char **lines;
- int i;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- cyls = jcyls;
- heads = jheads;
- sectors = jsectors;
- lines_len = (*env)->GetArrayLength (env, jlines);
- lines = guestfs_safe_malloc (g, sizeof (char *) * (lines_len+1));
- for (i = 0; i < lines_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jlines, i);
- lines[i] = (*env)->GetStringUTFChars (env, o, NULL);
- }
- lines[lines_len] = NULL;
- r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- for (i = 0; i < lines_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jlines, i);
- (*env)->ReleaseStringUTFChars (env, o, lines[i]);
- }
- free (lines);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1write_1file
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath, jstring jcontent, jint jsize)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
- const char *content;
- int size;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- content = (*env)->GetStringUTFChars (env, jcontent, NULL);
- size = jsize;
- r = guestfs_write_file (g, path, content, size);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- (*env)->ReleaseStringUTFChars (env, jcontent, content);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1umount
- (JNIEnv *env, jobject obj, jlong jg, jstring jpathordevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *pathordevice;
-
- pathordevice = (*env)->GetStringUTFChars (env, jpathordevice, NULL);
- r = guestfs_umount (g, pathordevice);
- (*env)->ReleaseStringUTFChars (env, jpathordevice, pathordevice);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mounts
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int i;
-
- r = guestfs_mounts (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1umount_1all
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_umount_all (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1lvm_1remove_1all
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_lvm_remove_all (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1file
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_file (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1command
- (JNIEnv *env, jobject obj, jlong jg, jobjectArray jarguments)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- int arguments_len;
- const char **arguments;
- int i;
-
- arguments_len = (*env)->GetArrayLength (env, jarguments);
- arguments = guestfs_safe_malloc (g, sizeof (char *) * (arguments_len+1));
- for (i = 0; i < arguments_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jarguments, i);
- arguments[i] = (*env)->GetStringUTFChars (env, o, NULL);
- }
- arguments[arguments_len] = NULL;
- r = guestfs_command (g, arguments);
- for (i = 0; i < arguments_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jarguments, i);
- (*env)->ReleaseStringUTFChars (env, o, arguments[i]);
- }
- free (arguments);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1command_1lines
- (JNIEnv *env, jobject obj, jlong jg, jobjectArray jarguments)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int arguments_len;
- const char **arguments;
- int i;
-
- arguments_len = (*env)->GetArrayLength (env, jarguments);
- arguments = guestfs_safe_malloc (g, sizeof (char *) * (arguments_len+1));
- for (i = 0; i < arguments_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jarguments, i);
- arguments[i] = (*env)->GetStringUTFChars (env, o, NULL);
- }
- arguments[arguments_len] = NULL;
- r = guestfs_command_lines (g, arguments);
- for (i = 0; i < arguments_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jarguments, i);
- (*env)->ReleaseStringUTFChars (env, o, arguments[i]);
- }
- free (arguments);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1stat
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_stat *r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_stat (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/Stat");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "dev", "J");
- (*env)->SetLongField (env, jr, fl, r->dev);
- fl = (*env)->GetFieldID (env, cl, "ino", "J");
- (*env)->SetLongField (env, jr, fl, r->ino);
- fl = (*env)->GetFieldID (env, cl, "mode", "J");
- (*env)->SetLongField (env, jr, fl, r->mode);
- fl = (*env)->GetFieldID (env, cl, "nlink", "J");
- (*env)->SetLongField (env, jr, fl, r->nlink);
- fl = (*env)->GetFieldID (env, cl, "uid", "J");
- (*env)->SetLongField (env, jr, fl, r->uid);
- fl = (*env)->GetFieldID (env, cl, "gid", "J");
- (*env)->SetLongField (env, jr, fl, r->gid);
- fl = (*env)->GetFieldID (env, cl, "rdev", "J");
- (*env)->SetLongField (env, jr, fl, r->rdev);
- fl = (*env)->GetFieldID (env, cl, "size", "J");
- (*env)->SetLongField (env, jr, fl, r->size);
- fl = (*env)->GetFieldID (env, cl, "blksize", "J");
- (*env)->SetLongField (env, jr, fl, r->blksize);
- fl = (*env)->GetFieldID (env, cl, "blocks", "J");
- (*env)->SetLongField (env, jr, fl, r->blocks);
- fl = (*env)->GetFieldID (env, cl, "atime", "J");
- (*env)->SetLongField (env, jr, fl, r->atime);
- fl = (*env)->GetFieldID (env, cl, "mtime", "J");
- (*env)->SetLongField (env, jr, fl, r->mtime);
- fl = (*env)->GetFieldID (env, cl, "ctime", "J");
- (*env)->SetLongField (env, jr, fl, r->ctime);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1lstat
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_stat *r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_lstat (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/Stat");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "dev", "J");
- (*env)->SetLongField (env, jr, fl, r->dev);
- fl = (*env)->GetFieldID (env, cl, "ino", "J");
- (*env)->SetLongField (env, jr, fl, r->ino);
- fl = (*env)->GetFieldID (env, cl, "mode", "J");
- (*env)->SetLongField (env, jr, fl, r->mode);
- fl = (*env)->GetFieldID (env, cl, "nlink", "J");
- (*env)->SetLongField (env, jr, fl, r->nlink);
- fl = (*env)->GetFieldID (env, cl, "uid", "J");
- (*env)->SetLongField (env, jr, fl, r->uid);
- fl = (*env)->GetFieldID (env, cl, "gid", "J");
- (*env)->SetLongField (env, jr, fl, r->gid);
- fl = (*env)->GetFieldID (env, cl, "rdev", "J");
- (*env)->SetLongField (env, jr, fl, r->rdev);
- fl = (*env)->GetFieldID (env, cl, "size", "J");
- (*env)->SetLongField (env, jr, fl, r->size);
- fl = (*env)->GetFieldID (env, cl, "blksize", "J");
- (*env)->SetLongField (env, jr, fl, r->blksize);
- fl = (*env)->GetFieldID (env, cl, "blocks", "J");
- (*env)->SetLongField (env, jr, fl, r->blocks);
- fl = (*env)->GetFieldID (env, cl, "atime", "J");
- (*env)->SetLongField (env, jr, fl, r->atime);
- fl = (*env)->GetFieldID (env, cl, "mtime", "J");
- (*env)->SetLongField (env, jr, fl, r->mtime);
- fl = (*env)->GetFieldID (env, cl, "ctime", "J");
- (*env)->SetLongField (env, jr, fl, r->ctime);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1statvfs
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobject jr;
- jclass cl;
- jfieldID fl;
- struct guestfs_statvfs *r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_statvfs (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/StatVFS");
- jr = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "bsize", "J");
- (*env)->SetLongField (env, jr, fl, r->bsize);
- fl = (*env)->GetFieldID (env, cl, "frsize", "J");
- (*env)->SetLongField (env, jr, fl, r->frsize);
- fl = (*env)->GetFieldID (env, cl, "blocks", "J");
- (*env)->SetLongField (env, jr, fl, r->blocks);
- fl = (*env)->GetFieldID (env, cl, "bfree", "J");
- (*env)->SetLongField (env, jr, fl, r->bfree);
- fl = (*env)->GetFieldID (env, cl, "bavail", "J");
- (*env)->SetLongField (env, jr, fl, r->bavail);
- fl = (*env)->GetFieldID (env, cl, "files", "J");
- (*env)->SetLongField (env, jr, fl, r->files);
- fl = (*env)->GetFieldID (env, cl, "ffree", "J");
- (*env)->SetLongField (env, jr, fl, r->ffree);
- fl = (*env)->GetFieldID (env, cl, "favail", "J");
- (*env)->SetLongField (env, jr, fl, r->favail);
- fl = (*env)->GetFieldID (env, cl, "fsid", "J");
- (*env)->SetLongField (env, jr, fl, r->fsid);
- fl = (*env)->GetFieldID (env, cl, "flag", "J");
- (*env)->SetLongField (env, jr, fl, r->flag);
- fl = (*env)->GetFieldID (env, cl, "namemax", "J");
- (*env)->SetLongField (env, jr, fl, r->namemax);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1tune2fs_1l
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- char **r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_tune2fs_l (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- throw_exception (env, "tune2fs_l: internal error: please let us know how to make a Java HashMap from JNI bindings!");
- return NULL;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1setro
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_blockdev_setro (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1setrw
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_blockdev_setrw (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1getro
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_blockdev_getro (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1getss
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_blockdev_getss (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1getbsz
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_blockdev_getbsz (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1setbsz
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jint jblocksize)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
- int blocksize;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- blocksize = jblocksize;
- r = guestfs_blockdev_setbsz (g, device, blocksize);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jlong JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1getsz
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int64_t r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_blockdev_getsz (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jlong) r;
-}
-
-JNIEXPORT jlong JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1getsize64
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int64_t r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_blockdev_getsize64 (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jlong) r;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1flushbufs
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_blockdev_flushbufs (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1blockdev_1rereadpt
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_blockdev_rereadpt (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1upload
- (JNIEnv *env, jobject obj, jlong jg, jstring jfilename, jstring jremotefilename)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *filename;
- const char *remotefilename;
-
- filename = (*env)->GetStringUTFChars (env, jfilename, NULL);
- remotefilename = (*env)->GetStringUTFChars (env, jremotefilename, NULL);
- r = guestfs_upload (g, filename, remotefilename);
- (*env)->ReleaseStringUTFChars (env, jfilename, filename);
- (*env)->ReleaseStringUTFChars (env, jremotefilename, remotefilename);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1download
- (JNIEnv *env, jobject obj, jlong jg, jstring jremotefilename, jstring jfilename)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *remotefilename;
- const char *filename;
-
- remotefilename = (*env)->GetStringUTFChars (env, jremotefilename, NULL);
- filename = (*env)->GetStringUTFChars (env, jfilename, NULL);
- r = guestfs_download (g, remotefilename, filename);
- (*env)->ReleaseStringUTFChars (env, jremotefilename, remotefilename);
- (*env)->ReleaseStringUTFChars (env, jfilename, filename);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1checksum
- (JNIEnv *env, jobject obj, jlong jg, jstring jcsumtype, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *csumtype;
- const char *path;
-
- csumtype = (*env)->GetStringUTFChars (env, jcsumtype, NULL);
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_checksum (g, csumtype, path);
- (*env)->ReleaseStringUTFChars (env, jcsumtype, csumtype);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1tar_1in
- (JNIEnv *env, jobject obj, jlong jg, jstring jtarfile, jstring jdirectory)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *tarfile;
- const char *directory;
-
- tarfile = (*env)->GetStringUTFChars (env, jtarfile, NULL);
- directory = (*env)->GetStringUTFChars (env, jdirectory, NULL);
- r = guestfs_tar_in (g, tarfile, directory);
- (*env)->ReleaseStringUTFChars (env, jtarfile, tarfile);
- (*env)->ReleaseStringUTFChars (env, jdirectory, directory);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1tar_1out
- (JNIEnv *env, jobject obj, jlong jg, jstring jdirectory, jstring jtarfile)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *directory;
- const char *tarfile;
-
- directory = (*env)->GetStringUTFChars (env, jdirectory, NULL);
- tarfile = (*env)->GetStringUTFChars (env, jtarfile, NULL);
- r = guestfs_tar_out (g, directory, tarfile);
- (*env)->ReleaseStringUTFChars (env, jdirectory, directory);
- (*env)->ReleaseStringUTFChars (env, jtarfile, tarfile);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1tgz_1in
- (JNIEnv *env, jobject obj, jlong jg, jstring jtarball, jstring jdirectory)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *tarball;
- const char *directory;
-
- tarball = (*env)->GetStringUTFChars (env, jtarball, NULL);
- directory = (*env)->GetStringUTFChars (env, jdirectory, NULL);
- r = guestfs_tgz_in (g, tarball, directory);
- (*env)->ReleaseStringUTFChars (env, jtarball, tarball);
- (*env)->ReleaseStringUTFChars (env, jdirectory, directory);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1tgz_1out
- (JNIEnv *env, jobject obj, jlong jg, jstring jdirectory, jstring jtarball)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *directory;
- const char *tarball;
-
- directory = (*env)->GetStringUTFChars (env, jdirectory, NULL);
- tarball = (*env)->GetStringUTFChars (env, jtarball, NULL);
- r = guestfs_tgz_out (g, directory, tarball);
- (*env)->ReleaseStringUTFChars (env, jdirectory, directory);
- (*env)->ReleaseStringUTFChars (env, jtarball, tarball);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mount_1ro
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jstring jmountpoint)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
- const char *mountpoint;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- mountpoint = (*env)->GetStringUTFChars (env, jmountpoint, NULL);
- r = guestfs_mount_ro (g, device, mountpoint);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- (*env)->ReleaseStringUTFChars (env, jmountpoint, mountpoint);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mount_1options
- (JNIEnv *env, jobject obj, jlong jg, jstring joptions, jstring jdevice, jstring jmountpoint)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *options;
- const char *device;
- const char *mountpoint;
-
- options = (*env)->GetStringUTFChars (env, joptions, NULL);
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- mountpoint = (*env)->GetStringUTFChars (env, jmountpoint, NULL);
- r = guestfs_mount_options (g, options, device, mountpoint);
- (*env)->ReleaseStringUTFChars (env, joptions, options);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- (*env)->ReleaseStringUTFChars (env, jmountpoint, mountpoint);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mount_1vfs
- (JNIEnv *env, jobject obj, jlong jg, jstring joptions, jstring jvfstype, jstring jdevice, jstring jmountpoint)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *options;
- const char *vfstype;
- const char *device;
- const char *mountpoint;
-
- options = (*env)->GetStringUTFChars (env, joptions, NULL);
- vfstype = (*env)->GetStringUTFChars (env, jvfstype, NULL);
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- mountpoint = (*env)->GetStringUTFChars (env, jmountpoint, NULL);
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- (*env)->ReleaseStringUTFChars (env, joptions, options);
- (*env)->ReleaseStringUTFChars (env, jvfstype, vfstype);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- (*env)->ReleaseStringUTFChars (env, jmountpoint, mountpoint);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1debug
- (JNIEnv *env, jobject obj, jlong jg, jstring jsubcmd, jobjectArray jextraargs)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *subcmd;
- int extraargs_len;
- const char **extraargs;
- int i;
-
- subcmd = (*env)->GetStringUTFChars (env, jsubcmd, NULL);
- extraargs_len = (*env)->GetArrayLength (env, jextraargs);
- extraargs = guestfs_safe_malloc (g, sizeof (char *) * (extraargs_len+1));
- for (i = 0; i < extraargs_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jextraargs, i);
- extraargs[i] = (*env)->GetStringUTFChars (env, o, NULL);
- }
- extraargs[extraargs_len] = NULL;
- r = guestfs_debug (g, subcmd, extraargs);
- (*env)->ReleaseStringUTFChars (env, jsubcmd, subcmd);
- for (i = 0; i < extraargs_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jextraargs, i);
- (*env)->ReleaseStringUTFChars (env, o, extraargs[i]);
- }
- free (extraargs);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1lvremove
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_lvremove (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1vgremove
- (JNIEnv *env, jobject obj, jlong jg, jstring jvgname)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *vgname;
-
- vgname = (*env)->GetStringUTFChars (env, jvgname, NULL);
- r = guestfs_vgremove (g, vgname);
- (*env)->ReleaseStringUTFChars (env, jvgname, vgname);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1pvremove
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_pvremove (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1e2label
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jstring jlabel)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
- const char *label;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- label = (*env)->GetStringUTFChars (env, jlabel, NULL);
- r = guestfs_set_e2label (g, device, label);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- (*env)->ReleaseStringUTFChars (env, jlabel, label);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1get_1e2label
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_get_e2label (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1set_1e2uuid
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jstring juuid)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
- const char *uuid;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- uuid = (*env)->GetStringUTFChars (env, juuid, NULL);
- r = guestfs_set_e2uuid (g, device, uuid);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- (*env)->ReleaseStringUTFChars (env, juuid, uuid);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1get_1e2uuid
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_get_e2uuid (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1fsck
- (JNIEnv *env, jobject obj, jlong jg, jstring jfstype, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *fstype;
- const char *device;
-
- fstype = (*env)->GetStringUTFChars (env, jfstype, NULL);
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_fsck (g, fstype, device);
- (*env)->ReleaseStringUTFChars (env, jfstype, fstype);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1zero
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_zero (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1grub_1install
- (JNIEnv *env, jobject obj, jlong jg, jstring jroot, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *root;
- const char *device;
-
- root = (*env)->GetStringUTFChars (env, jroot, NULL);
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_grub_install (g, root, device);
- (*env)->ReleaseStringUTFChars (env, jroot, root);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1cp
- (JNIEnv *env, jobject obj, jlong jg, jstring jsrc, jstring jdest)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *src;
- const char *dest;
-
- src = (*env)->GetStringUTFChars (env, jsrc, NULL);
- dest = (*env)->GetStringUTFChars (env, jdest, NULL);
- r = guestfs_cp (g, src, dest);
- (*env)->ReleaseStringUTFChars (env, jsrc, src);
- (*env)->ReleaseStringUTFChars (env, jdest, dest);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1cp_1a
- (JNIEnv *env, jobject obj, jlong jg, jstring jsrc, jstring jdest)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *src;
- const char *dest;
-
- src = (*env)->GetStringUTFChars (env, jsrc, NULL);
- dest = (*env)->GetStringUTFChars (env, jdest, NULL);
- r = guestfs_cp_a (g, src, dest);
- (*env)->ReleaseStringUTFChars (env, jsrc, src);
- (*env)->ReleaseStringUTFChars (env, jdest, dest);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mv
- (JNIEnv *env, jobject obj, jlong jg, jstring jsrc, jstring jdest)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *src;
- const char *dest;
-
- src = (*env)->GetStringUTFChars (env, jsrc, NULL);
- dest = (*env)->GetStringUTFChars (env, jdest, NULL);
- r = guestfs_mv (g, src, dest);
- (*env)->ReleaseStringUTFChars (env, jsrc, src);
- (*env)->ReleaseStringUTFChars (env, jdest, dest);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1drop_1caches
- (JNIEnv *env, jobject obj, jlong jg, jint jwhattodrop)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int whattodrop;
-
- whattodrop = jwhattodrop;
- r = guestfs_drop_caches (g, whattodrop);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1dmesg
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
-
- r = guestfs_dmesg (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1ping_1daemon
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
-
- r = guestfs_ping_daemon (g);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1equal
- (JNIEnv *env, jobject obj, jlong jg, jstring jfile1, jstring jfile2)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *file1;
- const char *file2;
-
- file1 = (*env)->GetStringUTFChars (env, jfile1, NULL);
- file2 = (*env)->GetStringUTFChars (env, jfile2, NULL);
- r = guestfs_equal (g, file1, file2);
- (*env)->ReleaseStringUTFChars (env, jfile1, file1);
- (*env)->ReleaseStringUTFChars (env, jfile2, file2);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jboolean) r;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1strings
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *path;
- int i;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_strings (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1strings_1e
- (JNIEnv *env, jobject obj, jlong jg, jstring jencoding, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *encoding;
- const char *path;
- int i;
-
- encoding = (*env)->GetStringUTFChars (env, jencoding, NULL);
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_strings_e (g, encoding, path);
- (*env)->ReleaseStringUTFChars (env, jencoding, encoding);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1hexdump
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_hexdump (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1zerofree
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_zerofree (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1pvresize
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_pvresize (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1sfdisk_1N
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jint jpartnum, jint jcyls, jint jheads, jint jsectors, jstring jline)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
- int partnum;
- int cyls;
- int heads;
- int sectors;
- const char *line;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- partnum = jpartnum;
- cyls = jcyls;
- heads = jheads;
- sectors = jsectors;
- line = (*env)->GetStringUTFChars (env, jline, NULL);
- r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- (*env)->ReleaseStringUTFChars (env, jline, line);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1sfdisk_1l
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_sfdisk_l (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1sfdisk_1kernel_1geometry
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_sfdisk_kernel_geometry (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1sfdisk_1disk_1geometry
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_sfdisk_disk_geometry (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1vg_1activate_1all
- (JNIEnv *env, jobject obj, jlong jg, jboolean jactivate)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int activate;
-
- activate = jactivate;
- r = guestfs_vg_activate_all (g, activate);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1vg_1activate
- (JNIEnv *env, jobject obj, jlong jg, jboolean jactivate, jobjectArray jvolgroups)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int activate;
- int volgroups_len;
- const char **volgroups;
- int i;
-
- activate = jactivate;
- volgroups_len = (*env)->GetArrayLength (env, jvolgroups);
- volgroups = guestfs_safe_malloc (g, sizeof (char *) * (volgroups_len+1));
- for (i = 0; i < volgroups_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jvolgroups, i);
- volgroups[i] = (*env)->GetStringUTFChars (env, o, NULL);
- }
- volgroups[volgroups_len] = NULL;
- r = guestfs_vg_activate (g, activate, volgroups);
- for (i = 0; i < volgroups_len; ++i) {
- jobject o = (*env)->GetObjectArrayElement (env, jvolgroups, i);
- (*env)->ReleaseStringUTFChars (env, o, volgroups[i]);
- }
- free (volgroups);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1lvresize
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jint jmbytes)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
- int mbytes;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- mbytes = jmbytes;
- r = guestfs_lvresize (g, device, mbytes);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1resize2fs
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_resize2fs (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1find
- (JNIEnv *env, jobject obj, jlong jg, jstring jdirectory)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *directory;
- int i;
-
- directory = (*env)->GetStringUTFChars (env, jdirectory, NULL);
- r = guestfs_find (g, directory);
- (*env)->ReleaseStringUTFChars (env, jdirectory, directory);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1e2fsck_1f
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_e2fsck_f (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1sleep
- (JNIEnv *env, jobject obj, jlong jg, jint jsecs)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int secs;
-
- secs = jsecs;
- r = guestfs_sleep (g, secs);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1ntfs_13g_1probe
- (JNIEnv *env, jobject obj, jlong jg, jboolean jrw, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int rw;
- const char *device;
-
- rw = jrw;
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_ntfs_3g_probe (g, rw, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1sh
- (JNIEnv *env, jobject obj, jlong jg, jstring jcommand)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *command;
-
- command = (*env)->GetStringUTFChars (env, jcommand, NULL);
- r = guestfs_sh (g, command);
- (*env)->ReleaseStringUTFChars (env, jcommand, command);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1sh_1lines
- (JNIEnv *env, jobject obj, jlong jg, jstring jcommand)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *command;
- int i;
-
- command = (*env)->GetStringUTFChars (env, jcommand, NULL);
- r = guestfs_sh_lines (g, command);
- (*env)->ReleaseStringUTFChars (env, jcommand, command);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1glob_1expand
- (JNIEnv *env, jobject obj, jlong jg, jstring jpattern)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *pattern;
- int i;
-
- pattern = (*env)->GetStringUTFChars (env, jpattern, NULL);
- r = guestfs_glob_expand (g, pattern);
- (*env)->ReleaseStringUTFChars (env, jpattern, pattern);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1scrub_1device
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_scrub_device (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1scrub_1file
- (JNIEnv *env, jobject obj, jlong jg, jstring jfile)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *file;
-
- file = (*env)->GetStringUTFChars (env, jfile, NULL);
- r = guestfs_scrub_file (g, file);
- (*env)->ReleaseStringUTFChars (env, jfile, file);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1scrub_1freespace
- (JNIEnv *env, jobject obj, jlong jg, jstring jdir)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *dir;
-
- dir = (*env)->GetStringUTFChars (env, jdir, NULL);
- r = guestfs_scrub_freespace (g, dir);
- (*env)->ReleaseStringUTFChars (env, jdir, dir);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mkdtemp
- (JNIEnv *env, jobject obj, jlong jg, jstring jtemplate)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
- const char *template;
-
- template = (*env)->GetStringUTFChars (env, jtemplate, NULL);
- r = guestfs_mkdtemp (g, template);
- (*env)->ReleaseStringUTFChars (env, jtemplate, template);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1wc_1l
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_wc_l (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1wc_1w
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_wc_w (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1wc_1c
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_wc_c (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1head
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *path;
- int i;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_head (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1head_1n
- (JNIEnv *env, jobject obj, jlong jg, jint jnrlines, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int nrlines;
- const char *path;
- int i;
-
- nrlines = jnrlines;
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_head_n (g, nrlines, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1tail
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *path;
- int i;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_tail (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1tail_1n
- (JNIEnv *env, jobject obj, jlong jg, jint jnrlines, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- int nrlines;
- const char *path;
- int i;
-
- nrlines = jnrlines;
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_tail_n (g, nrlines, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1df
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
-
- r = guestfs_df (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1df_1h
- (JNIEnv *env, jobject obj, jlong jg)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jstring jr;
- char *r;
-
- r = guestfs_df_h (g);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- jr = (*env)->NewStringUTF (env, r);
- free (r);
- return jr;
-}
-
-JNIEXPORT jlong JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1du
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int64_t r;
- const char *path;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_du (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jlong) r;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1initrd_1list
- (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- int r_len;
- jclass cl;
- jstring jstr;
- char **r;
- const char *path;
- int i;
-
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_initrd_list (g, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- for (r_len = 0; r[r_len] != NULL; ++r_len) ;
- cl = (*env)->FindClass (env, "java/lang/String");
- jstr = (*env)->NewStringUTF (env, "");
- jr = (*env)->NewObjectArray (env, r_len, cl, jstr);
- for (i = 0; i < r_len; ++i) {
- jstr = (*env)->NewStringUTF (env, r[i]);
- (*env)->SetObjectArrayElement (env, jr, i, jstr);
- free (r[i]);
- }
- free (r);
- return jr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mount_1loop
- (JNIEnv *env, jobject obj, jlong jg, jstring jfile, jstring jmountpoint)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *file;
- const char *mountpoint;
-
- file = (*env)->GetStringUTFChars (env, jfile, NULL);
- mountpoint = (*env)->GetStringUTFChars (env, jmountpoint, NULL);
- r = guestfs_mount_loop (g, file, mountpoint);
- (*env)->ReleaseStringUTFChars (env, jfile, file);
- (*env)->ReleaseStringUTFChars (env, jmountpoint, mountpoint);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mkswap
- (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *device;
-
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_mkswap (g, device);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mkswap_1L
- (JNIEnv *env, jobject obj, jlong jg, jstring jlabel, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *label;
- const char *device;
-
- label = (*env)->GetStringUTFChars (env, jlabel, NULL);
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_mkswap_L (g, label, device);
- (*env)->ReleaseStringUTFChars (env, jlabel, label);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mkswap_1U
- (JNIEnv *env, jobject obj, jlong jg, jstring juuid, jstring jdevice)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- const char *uuid;
- const char *device;
-
- uuid = (*env)->GetStringUTFChars (env, juuid, NULL);
- device = (*env)->GetStringUTFChars (env, jdevice, NULL);
- r = guestfs_mkswap_U (g, uuid, device);
- (*env)->ReleaseStringUTFChars (env, juuid, uuid);
- (*env)->ReleaseStringUTFChars (env, jdevice, device);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mknod
- (JNIEnv *env, jobject obj, jlong jg, jint jmode, jint jdevmajor, jint jdevminor, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int mode;
- int devmajor;
- int devminor;
- const char *path;
-
- mode = jmode;
- devmajor = jdevmajor;
- devminor = jdevminor;
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_mknod (g, mode, devmajor, devminor, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mkfifo
- (JNIEnv *env, jobject obj, jlong jg, jint jmode, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int mode;
- const char *path;
-
- mode = jmode;
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_mkfifo (g, mode, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mknod_1b
- (JNIEnv *env, jobject obj, jlong jg, jint jmode, jint jdevmajor, jint jdevminor, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int mode;
- int devmajor;
- int devminor;
- const char *path;
-
- mode = jmode;
- devmajor = jdevmajor;
- devminor = jdevminor;
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_mknod_b (g, mode, devmajor, devminor, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT void JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1mknod_1c
- (JNIEnv *env, jobject obj, jlong jg, jint jmode, jint jdevmajor, jint jdevminor, jstring jpath)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int mode;
- int devmajor;
- int devminor;
- const char *path;
-
- mode = jmode;
- devmajor = jdevmajor;
- devminor = jdevminor;
- path = (*env)->GetStringUTFChars (env, jpath, NULL);
- r = guestfs_mknod_c (g, mode, devmajor, devminor, path);
- (*env)->ReleaseStringUTFChars (env, jpath, path);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return ;
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1umask
- (JNIEnv *env, jobject obj, jlong jg, jint jmask)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- int r;
- int mask;
-
- mask = jmask;
- r = guestfs_umask (g, mask);
- if (r == -1) {
- throw_exception (env, guestfs_last_error (g));
- return 0;
- }
- return (jint) r;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_redhat_et_libguestfs_GuestFS__1readdir
- (JNIEnv *env, jobject obj, jlong jg, jstring jdir)
-{
- guestfs_h *g = (guestfs_h *) (long) jg;
- jobjectArray jr;
- jclass cl;
- jfieldID fl;
- jobject jfl;
- struct guestfs_dirent_list *r;
- const char *dir;
- int i;
-
- dir = (*env)->GetStringUTFChars (env, jdir, NULL);
- r = guestfs_readdir (g, dir);
- (*env)->ReleaseStringUTFChars (env, jdir, dir);
- if (r == NULL) {
- throw_exception (env, guestfs_last_error (g));
- return NULL;
- }
- cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/Dirent");
- jr = (*env)->NewObjectArray (env, r->len, cl, NULL);
- for (i = 0; i < r->len; ++i) {
- jfl = (*env)->AllocObject (env, cl);
- fl = (*env)->GetFieldID (env, cl, "ino", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].ino);
- fl = (*env)->GetFieldID (env, cl, "ftyp", "J");
- (*env)->SetLongField (env, jfl, fl, r->val[i].ftyp);
- fl = (*env)->GetFieldID (env, cl, "name", "Ljava/lang/String;");
- (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].name));
- (*env)->SetObjectArrayElement (env, jfl, i, jfl);
- }
- guestfs_free_dirent_list (r);
- return jr;
-}
-
+++ /dev/null
-(* 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 program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *)
-
-let () =
- let g = Guestfs.create () in
- Guestfs.test0 g "abc" (Some "def") [||] false 0 "123" "456";
- Guestfs.test0 g "abc" None [||] false 0 "123" "456";
- Guestfs.test0 g "" (Some "def") [||] false 0 "123" "456";
- Guestfs.test0 g "" (Some "") [||] false 0 "123" "456";
- Guestfs.test0 g "abc" (Some "def") [|"1"|] false 0 "123" "456";
- Guestfs.test0 g "abc" (Some "def") [|"1";"2"|] false 0 "123" "456";
- Guestfs.test0 g "abc" (Some "def") [|"1"|] true 0 "123" "456";
- Guestfs.test0 g "abc" (Some "def") [|"1"|] false (-1) "123" "456";
- Guestfs.test0 g "abc" (Some "def") [|"1"|] false (-2) "123" "456";
- Guestfs.test0 g "abc" (Some "def") [|"1"|] false 1 "123" "456";
- Guestfs.test0 g "abc" (Some "def") [|"1"|] false 2 "123" "456";
- Guestfs.test0 g "abc" (Some "def") [|"1"|] false 4095 "123" "456";
- Guestfs.test0 g "abc" (Some "def") [|"1"|] false 0 "" "";
-print_endline "EOF"
+++ /dev/null
-(* 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
- *)
-
-type t
-exception Error of string
-external create : unit -> t = "ocaml_guestfs_create"
-external close : t -> unit = "ocaml_guestfs_close"
-
-let () =
- Callback.register_exception "ocaml_guestfs_error" (Error "")
-
-type lvm_pv = {
- pv_name : string;
- pv_uuid : string;
- pv_fmt : string;
- pv_size : int64;
- dev_size : int64;
- pv_free : int64;
- pv_used : int64;
- pv_attr : string;
- pv_pe_count : int64;
- pv_pe_alloc_count : int64;
- pv_tags : string;
- pe_start : int64;
- pv_mda_count : int64;
- pv_mda_free : int64;
-}
-
-type lvm_vg = {
- vg_name : string;
- vg_uuid : string;
- vg_fmt : string;
- vg_attr : string;
- vg_size : int64;
- vg_free : int64;
- vg_sysid : string;
- vg_extent_size : int64;
- vg_extent_count : int64;
- vg_free_count : int64;
- max_lv : int64;
- max_pv : int64;
- pv_count : int64;
- lv_count : int64;
- snap_count : int64;
- vg_seqno : int64;
- vg_tags : string;
- vg_mda_count : int64;
- vg_mda_free : int64;
-}
-
-type lvm_lv = {
- lv_name : string;
- lv_uuid : string;
- lv_attr : string;
- lv_major : int64;
- lv_minor : int64;
- lv_kernel_major : int64;
- lv_kernel_minor : int64;
- lv_size : int64;
- seg_count : int64;
- origin : string;
- snap_percent : float option;
- copy_percent : float option;
- move_pv : string;
- lv_tags : string;
- mirror_log : string;
- modules : string;
-}
-
-type stat = {
- dev : int64;
- ino : int64;
- mode : int64;
- nlink : int64;
- uid : int64;
- gid : int64;
- rdev : int64;
- size : int64;
- blksize : int64;
- blocks : int64;
- atime : int64;
- mtime : int64;
- ctime : int64;
-}
-
-type statvfs = {
- bsize : int64;
- frsize : int64;
- blocks : int64;
- bfree : int64;
- bavail : int64;
- files : int64;
- ffree : int64;
- favail : int64;
- fsid : int64;
- flag : int64;
- namemax : int64;
-}
-
-type dirent = {
- ino : int64;
- ftyp : char;
- name : string;
-}
-
-external test0 : t -> string -> string option -> string array -> bool -> int -> string -> string -> unit = "ocaml_guestfs_test0_byte" "ocaml_guestfs_test0"
-external test0rint : t -> string -> int = "ocaml_guestfs_test0rint"
-external test0rinterr : t -> int = "ocaml_guestfs_test0rinterr"
-external test0rint64 : t -> string -> int64 = "ocaml_guestfs_test0rint64"
-external test0rint64err : t -> int64 = "ocaml_guestfs_test0rint64err"
-external test0rbool : t -> string -> bool = "ocaml_guestfs_test0rbool"
-external test0rboolerr : t -> bool = "ocaml_guestfs_test0rboolerr"
-external test0rconststring : t -> string -> string = "ocaml_guestfs_test0rconststring"
-external test0rconststringerr : t -> string = "ocaml_guestfs_test0rconststringerr"
-external test0rstring : t -> string -> string = "ocaml_guestfs_test0rstring"
-external test0rstringerr : t -> string = "ocaml_guestfs_test0rstringerr"
-external test0rstringlist : t -> string -> string array = "ocaml_guestfs_test0rstringlist"
-external test0rstringlisterr : t -> string array = "ocaml_guestfs_test0rstringlisterr"
-external test0rintbool : t -> string -> int * bool = "ocaml_guestfs_test0rintbool"
-external test0rintboolerr : t -> int * bool = "ocaml_guestfs_test0rintboolerr"
-external test0rpvlist : t -> string -> lvm_pv array = "ocaml_guestfs_test0rpvlist"
-external test0rpvlisterr : t -> lvm_pv array = "ocaml_guestfs_test0rpvlisterr"
-external test0rvglist : t -> string -> lvm_vg array = "ocaml_guestfs_test0rvglist"
-external test0rvglisterr : t -> lvm_vg array = "ocaml_guestfs_test0rvglisterr"
-external test0rlvlist : t -> string -> lvm_lv array = "ocaml_guestfs_test0rlvlist"
-external test0rlvlisterr : t -> lvm_lv array = "ocaml_guestfs_test0rlvlisterr"
-external test0rstat : t -> string -> stat = "ocaml_guestfs_test0rstat"
-external test0rstaterr : t -> stat = "ocaml_guestfs_test0rstaterr"
-external test0rstatvfs : t -> string -> statvfs = "ocaml_guestfs_test0rstatvfs"
-external test0rstatvfserr : t -> statvfs = "ocaml_guestfs_test0rstatvfserr"
-external test0rhashtable : t -> string -> (string * string) list = "ocaml_guestfs_test0rhashtable"
-external test0rhashtableerr : t -> (string * string) list = "ocaml_guestfs_test0rhashtableerr"
-external launch : t -> unit = "ocaml_guestfs_launch"
-external wait_ready : t -> unit = "ocaml_guestfs_wait_ready"
-external kill_subprocess : t -> unit = "ocaml_guestfs_kill_subprocess"
-external add_drive : t -> string -> unit = "ocaml_guestfs_add_drive"
-external add_cdrom : t -> string -> unit = "ocaml_guestfs_add_cdrom"
-external add_drive_ro : t -> string -> unit = "ocaml_guestfs_add_drive_ro"
-external config : t -> string -> string option -> unit = "ocaml_guestfs_config"
-external set_qemu : t -> string -> unit = "ocaml_guestfs_set_qemu"
-external get_qemu : t -> string = "ocaml_guestfs_get_qemu"
-external set_path : t -> string -> unit = "ocaml_guestfs_set_path"
-external get_path : t -> string = "ocaml_guestfs_get_path"
-external set_append : t -> string -> unit = "ocaml_guestfs_set_append"
-external get_append : t -> string = "ocaml_guestfs_get_append"
-external set_autosync : t -> bool -> unit = "ocaml_guestfs_set_autosync"
-external get_autosync : t -> bool = "ocaml_guestfs_get_autosync"
-external set_verbose : t -> bool -> unit = "ocaml_guestfs_set_verbose"
-external get_verbose : t -> bool = "ocaml_guestfs_get_verbose"
-external is_ready : t -> bool = "ocaml_guestfs_is_ready"
-external is_config : t -> bool = "ocaml_guestfs_is_config"
-external is_launching : t -> bool = "ocaml_guestfs_is_launching"
-external is_busy : t -> bool = "ocaml_guestfs_is_busy"
-external get_state : t -> int = "ocaml_guestfs_get_state"
-external set_busy : t -> unit = "ocaml_guestfs_set_busy"
-external set_ready : t -> unit = "ocaml_guestfs_set_ready"
-external end_busy : t -> unit = "ocaml_guestfs_end_busy"
-external set_memsize : t -> int -> unit = "ocaml_guestfs_set_memsize"
-external get_memsize : t -> int = "ocaml_guestfs_get_memsize"
-external mount : t -> string -> string -> unit = "ocaml_guestfs_mount"
-external sync : t -> unit = "ocaml_guestfs_sync"
-external touch : t -> string -> unit = "ocaml_guestfs_touch"
-external cat : t -> string -> string = "ocaml_guestfs_cat"
-external ll : t -> string -> string = "ocaml_guestfs_ll"
-external ls : t -> string -> string array = "ocaml_guestfs_ls"
-external list_devices : t -> string array = "ocaml_guestfs_list_devices"
-external list_partitions : t -> string array = "ocaml_guestfs_list_partitions"
-external pvs : t -> string array = "ocaml_guestfs_pvs"
-external vgs : t -> string array = "ocaml_guestfs_vgs"
-external lvs : t -> string array = "ocaml_guestfs_lvs"
-external pvs_full : t -> lvm_pv array = "ocaml_guestfs_pvs_full"
-external vgs_full : t -> lvm_vg array = "ocaml_guestfs_vgs_full"
-external lvs_full : t -> lvm_lv array = "ocaml_guestfs_lvs_full"
-external read_lines : t -> string -> string array = "ocaml_guestfs_read_lines"
-external aug_init : t -> string -> int -> unit = "ocaml_guestfs_aug_init"
-external aug_close : t -> unit = "ocaml_guestfs_aug_close"
-external aug_defvar : t -> string -> string option -> int = "ocaml_guestfs_aug_defvar"
-external aug_defnode : t -> string -> string -> string -> int * bool = "ocaml_guestfs_aug_defnode"
-external aug_get : t -> string -> string = "ocaml_guestfs_aug_get"
-external aug_set : t -> string -> string -> unit = "ocaml_guestfs_aug_set"
-external aug_insert : t -> string -> string -> bool -> unit = "ocaml_guestfs_aug_insert"
-external aug_rm : t -> string -> int = "ocaml_guestfs_aug_rm"
-external aug_mv : t -> string -> string -> unit = "ocaml_guestfs_aug_mv"
-external aug_match : t -> string -> string array = "ocaml_guestfs_aug_match"
-external aug_save : t -> unit = "ocaml_guestfs_aug_save"
-external aug_load : t -> unit = "ocaml_guestfs_aug_load"
-external aug_ls : t -> string -> string array = "ocaml_guestfs_aug_ls"
-external rm : t -> string -> unit = "ocaml_guestfs_rm"
-external rmdir : t -> string -> unit = "ocaml_guestfs_rmdir"
-external rm_rf : t -> string -> unit = "ocaml_guestfs_rm_rf"
-external mkdir : t -> string -> unit = "ocaml_guestfs_mkdir"
-external mkdir_p : t -> string -> unit = "ocaml_guestfs_mkdir_p"
-external chmod : t -> int -> string -> unit = "ocaml_guestfs_chmod"
-external chown : t -> int -> int -> string -> unit = "ocaml_guestfs_chown"
-external exists : t -> string -> bool = "ocaml_guestfs_exists"
-external is_file : t -> string -> bool = "ocaml_guestfs_is_file"
-external is_dir : t -> string -> bool = "ocaml_guestfs_is_dir"
-external pvcreate : t -> string -> unit = "ocaml_guestfs_pvcreate"
-external vgcreate : t -> string -> string array -> unit = "ocaml_guestfs_vgcreate"
-external lvcreate : t -> string -> string -> int -> unit = "ocaml_guestfs_lvcreate"
-external mkfs : t -> string -> string -> unit = "ocaml_guestfs_mkfs"
-external sfdisk : t -> string -> int -> int -> int -> string array -> unit = "ocaml_guestfs_sfdisk_byte" "ocaml_guestfs_sfdisk"
-external write_file : t -> string -> string -> int -> unit = "ocaml_guestfs_write_file"
-external umount : t -> string -> unit = "ocaml_guestfs_umount"
-external mounts : t -> string array = "ocaml_guestfs_mounts"
-external umount_all : t -> unit = "ocaml_guestfs_umount_all"
-external lvm_remove_all : t -> unit = "ocaml_guestfs_lvm_remove_all"
-external file : t -> string -> string = "ocaml_guestfs_file"
-external command : t -> string array -> string = "ocaml_guestfs_command"
-external command_lines : t -> string array -> string array = "ocaml_guestfs_command_lines"
-external stat : t -> string -> stat = "ocaml_guestfs_stat"
-external lstat : t -> string -> stat = "ocaml_guestfs_lstat"
-external statvfs : t -> string -> statvfs = "ocaml_guestfs_statvfs"
-external tune2fs_l : t -> string -> (string * string) list = "ocaml_guestfs_tune2fs_l"
-external blockdev_setro : t -> string -> unit = "ocaml_guestfs_blockdev_setro"
-external blockdev_setrw : t -> string -> unit = "ocaml_guestfs_blockdev_setrw"
-external blockdev_getro : t -> string -> bool = "ocaml_guestfs_blockdev_getro"
-external blockdev_getss : t -> string -> int = "ocaml_guestfs_blockdev_getss"
-external blockdev_getbsz : t -> string -> int = "ocaml_guestfs_blockdev_getbsz"
-external blockdev_setbsz : t -> string -> int -> unit = "ocaml_guestfs_blockdev_setbsz"
-external blockdev_getsz : t -> string -> int64 = "ocaml_guestfs_blockdev_getsz"
-external blockdev_getsize64 : t -> string -> int64 = "ocaml_guestfs_blockdev_getsize64"
-external blockdev_flushbufs : t -> string -> unit = "ocaml_guestfs_blockdev_flushbufs"
-external blockdev_rereadpt : t -> string -> unit = "ocaml_guestfs_blockdev_rereadpt"
-external upload : t -> string -> string -> unit = "ocaml_guestfs_upload"
-external download : t -> string -> string -> unit = "ocaml_guestfs_download"
-external checksum : t -> string -> string -> string = "ocaml_guestfs_checksum"
-external tar_in : t -> string -> string -> unit = "ocaml_guestfs_tar_in"
-external tar_out : t -> string -> string -> unit = "ocaml_guestfs_tar_out"
-external tgz_in : t -> string -> string -> unit = "ocaml_guestfs_tgz_in"
-external tgz_out : t -> string -> string -> unit = "ocaml_guestfs_tgz_out"
-external mount_ro : t -> string -> string -> unit = "ocaml_guestfs_mount_ro"
-external mount_options : t -> string -> string -> string -> unit = "ocaml_guestfs_mount_options"
-external mount_vfs : t -> string -> string -> string -> string -> unit = "ocaml_guestfs_mount_vfs"
-external debug : t -> string -> string array -> string = "ocaml_guestfs_debug"
-external lvremove : t -> string -> unit = "ocaml_guestfs_lvremove"
-external vgremove : t -> string -> unit = "ocaml_guestfs_vgremove"
-external pvremove : t -> string -> unit = "ocaml_guestfs_pvremove"
-external set_e2label : t -> string -> string -> unit = "ocaml_guestfs_set_e2label"
-external get_e2label : t -> string -> string = "ocaml_guestfs_get_e2label"
-external set_e2uuid : t -> string -> string -> unit = "ocaml_guestfs_set_e2uuid"
-external get_e2uuid : t -> string -> string = "ocaml_guestfs_get_e2uuid"
-external fsck : t -> string -> string -> int = "ocaml_guestfs_fsck"
-external zero : t -> string -> unit = "ocaml_guestfs_zero"
-external grub_install : t -> string -> string -> unit = "ocaml_guestfs_grub_install"
-external cp : t -> string -> string -> unit = "ocaml_guestfs_cp"
-external cp_a : t -> string -> string -> unit = "ocaml_guestfs_cp_a"
-external mv : t -> string -> string -> unit = "ocaml_guestfs_mv"
-external drop_caches : t -> int -> unit = "ocaml_guestfs_drop_caches"
-external dmesg : t -> string = "ocaml_guestfs_dmesg"
-external ping_daemon : t -> unit = "ocaml_guestfs_ping_daemon"
-external equal : t -> string -> string -> bool = "ocaml_guestfs_equal"
-external strings : t -> string -> string array = "ocaml_guestfs_strings"
-external strings_e : t -> string -> string -> string array = "ocaml_guestfs_strings_e"
-external hexdump : t -> string -> string = "ocaml_guestfs_hexdump"
-external zerofree : t -> string -> unit = "ocaml_guestfs_zerofree"
-external pvresize : t -> string -> unit = "ocaml_guestfs_pvresize"
-external sfdisk_N : t -> string -> int -> int -> int -> int -> string -> unit = "ocaml_guestfs_sfdisk_N_byte" "ocaml_guestfs_sfdisk_N"
-external sfdisk_l : t -> string -> string = "ocaml_guestfs_sfdisk_l"
-external sfdisk_kernel_geometry : t -> string -> string = "ocaml_guestfs_sfdisk_kernel_geometry"
-external sfdisk_disk_geometry : t -> string -> string = "ocaml_guestfs_sfdisk_disk_geometry"
-external vg_activate_all : t -> bool -> unit = "ocaml_guestfs_vg_activate_all"
-external vg_activate : t -> bool -> string array -> unit = "ocaml_guestfs_vg_activate"
-external lvresize : t -> string -> int -> unit = "ocaml_guestfs_lvresize"
-external resize2fs : t -> string -> unit = "ocaml_guestfs_resize2fs"
-external find : t -> string -> string array = "ocaml_guestfs_find"
-external e2fsck_f : t -> string -> unit = "ocaml_guestfs_e2fsck_f"
-external sleep : t -> int -> unit = "ocaml_guestfs_sleep"
-external ntfs_3g_probe : t -> bool -> string -> int = "ocaml_guestfs_ntfs_3g_probe"
-external sh : t -> string -> string = "ocaml_guestfs_sh"
-external sh_lines : t -> string -> string array = "ocaml_guestfs_sh_lines"
-external glob_expand : t -> string -> string array = "ocaml_guestfs_glob_expand"
-external scrub_device : t -> string -> unit = "ocaml_guestfs_scrub_device"
-external scrub_file : t -> string -> unit = "ocaml_guestfs_scrub_file"
-external scrub_freespace : t -> string -> unit = "ocaml_guestfs_scrub_freespace"
-external mkdtemp : t -> string -> string = "ocaml_guestfs_mkdtemp"
-external wc_l : t -> string -> int = "ocaml_guestfs_wc_l"
-external wc_w : t -> string -> int = "ocaml_guestfs_wc_w"
-external wc_c : t -> string -> int = "ocaml_guestfs_wc_c"
-external head : t -> string -> string array = "ocaml_guestfs_head"
-external head_n : t -> int -> string -> string array = "ocaml_guestfs_head_n"
-external tail : t -> string -> string array = "ocaml_guestfs_tail"
-external tail_n : t -> int -> string -> string array = "ocaml_guestfs_tail_n"
-external df : t -> string = "ocaml_guestfs_df"
-external df_h : t -> string = "ocaml_guestfs_df_h"
-external du : t -> string -> int64 = "ocaml_guestfs_du"
-external initrd_list : t -> string -> string array = "ocaml_guestfs_initrd_list"
-external mount_loop : t -> string -> string -> unit = "ocaml_guestfs_mount_loop"
-external mkswap : t -> string -> unit = "ocaml_guestfs_mkswap"
-external mkswap_L : t -> string -> string -> unit = "ocaml_guestfs_mkswap_L"
-external mkswap_U : t -> string -> string -> unit = "ocaml_guestfs_mkswap_U"
-external mknod : t -> int -> int -> int -> string -> unit = "ocaml_guestfs_mknod"
-external mkfifo : t -> int -> string -> unit = "ocaml_guestfs_mkfifo"
-external mknod_b : t -> int -> int -> int -> string -> unit = "ocaml_guestfs_mknod_b"
-external mknod_c : t -> int -> int -> int -> string -> unit = "ocaml_guestfs_mknod_c"
-external umask : t -> int -> int = "ocaml_guestfs_umask"
-external readdir : t -> string -> dirent array = "ocaml_guestfs_readdir"
+++ /dev/null
-(* 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
- *)
-
-(** For API documentation you should refer to the C API
- in the guestfs(3) manual page. The OCaml API uses almost
- exactly the same calls. *)
-
-type t
-(** A [guestfs_h] handle. *)
-
-exception Error of string
-(** This exception is raised when there is an error. *)
-
-val create : unit -> t
-
-val close : t -> unit
-(** Handles are closed by the garbage collector when they become
- unreferenced, but callers can also call this in order to
- provide predictable cleanup. *)
-
-type lvm_pv = {
- pv_name : string;
- pv_uuid : string;
- pv_fmt : string;
- pv_size : int64;
- dev_size : int64;
- pv_free : int64;
- pv_used : int64;
- pv_attr : string;
- pv_pe_count : int64;
- pv_pe_alloc_count : int64;
- pv_tags : string;
- pe_start : int64;
- pv_mda_count : int64;
- pv_mda_free : int64;
-}
-
-type lvm_vg = {
- vg_name : string;
- vg_uuid : string;
- vg_fmt : string;
- vg_attr : string;
- vg_size : int64;
- vg_free : int64;
- vg_sysid : string;
- vg_extent_size : int64;
- vg_extent_count : int64;
- vg_free_count : int64;
- max_lv : int64;
- max_pv : int64;
- pv_count : int64;
- lv_count : int64;
- snap_count : int64;
- vg_seqno : int64;
- vg_tags : string;
- vg_mda_count : int64;
- vg_mda_free : int64;
-}
-
-type lvm_lv = {
- lv_name : string;
- lv_uuid : string;
- lv_attr : string;
- lv_major : int64;
- lv_minor : int64;
- lv_kernel_major : int64;
- lv_kernel_minor : int64;
- lv_size : int64;
- seg_count : int64;
- origin : string;
- snap_percent : float option;
- copy_percent : float option;
- move_pv : string;
- lv_tags : string;
- mirror_log : string;
- modules : string;
-}
-
-type stat = {
- dev : int64;
- ino : int64;
- mode : int64;
- nlink : int64;
- uid : int64;
- gid : int64;
- rdev : int64;
- size : int64;
- blksize : int64;
- blocks : int64;
- atime : int64;
- mtime : int64;
- ctime : int64;
-}
-
-type statvfs = {
- bsize : int64;
- frsize : int64;
- blocks : int64;
- bfree : int64;
- bavail : int64;
- files : int64;
- ffree : int64;
- favail : int64;
- fsid : int64;
- flag : int64;
- namemax : int64;
-}
-
-type dirent = {
- ino : int64;
- ftyp : char;
- name : string;
-}
-
-val test0 : t -> string -> string option -> string array -> bool -> int -> string -> string -> unit
-(** internal test function - do not use *)
-
-val test0rint : t -> string -> int
-(** internal test function - do not use *)
-
-val test0rinterr : t -> int
-(** internal test function - do not use *)
-
-val test0rint64 : t -> string -> int64
-(** internal test function - do not use *)
-
-val test0rint64err : t -> int64
-(** internal test function - do not use *)
-
-val test0rbool : t -> string -> bool
-(** internal test function - do not use *)
-
-val test0rboolerr : t -> bool
-(** internal test function - do not use *)
-
-val test0rconststring : t -> string -> string
-(** internal test function - do not use *)
-
-val test0rconststringerr : t -> string
-(** internal test function - do not use *)
-
-val test0rstring : t -> string -> string
-(** internal test function - do not use *)
-
-val test0rstringerr : t -> string
-(** internal test function - do not use *)
-
-val test0rstringlist : t -> string -> string array
-(** internal test function - do not use *)
-
-val test0rstringlisterr : t -> string array
-(** internal test function - do not use *)
-
-val test0rintbool : t -> string -> int * bool
-(** internal test function - do not use *)
-
-val test0rintboolerr : t -> int * bool
-(** internal test function - do not use *)
-
-val test0rpvlist : t -> string -> lvm_pv array
-(** internal test function - do not use *)
-
-val test0rpvlisterr : t -> lvm_pv array
-(** internal test function - do not use *)
-
-val test0rvglist : t -> string -> lvm_vg array
-(** internal test function - do not use *)
-
-val test0rvglisterr : t -> lvm_vg array
-(** internal test function - do not use *)
-
-val test0rlvlist : t -> string -> lvm_lv array
-(** internal test function - do not use *)
-
-val test0rlvlisterr : t -> lvm_lv array
-(** internal test function - do not use *)
-
-val test0rstat : t -> string -> stat
-(** internal test function - do not use *)
-
-val test0rstaterr : t -> stat
-(** internal test function - do not use *)
-
-val test0rstatvfs : t -> string -> statvfs
-(** internal test function - do not use *)
-
-val test0rstatvfserr : t -> statvfs
-(** internal test function - do not use *)
-
-val test0rhashtable : t -> string -> (string * string) list
-(** internal test function - do not use *)
-
-val test0rhashtableerr : t -> (string * string) list
-(** internal test function - do not use *)
-
-val launch : t -> unit
-(** launch the qemu subprocess *)
-
-val wait_ready : t -> unit
-(** wait until the qemu subprocess launches *)
-
-val kill_subprocess : t -> unit
-(** kill the qemu subprocess *)
-
-val add_drive : t -> string -> unit
-(** add an image to examine or modify *)
-
-val add_cdrom : t -> string -> unit
-(** add a CD-ROM disk image to examine *)
-
-val add_drive_ro : t -> string -> unit
-(** add a drive in snapshot mode (read-only) *)
-
-val config : t -> string -> string option -> unit
-(** add qemu parameters *)
-
-val set_qemu : t -> string -> unit
-(** set the qemu binary *)
-
-val get_qemu : t -> string
-(** get the qemu binary *)
-
-val set_path : t -> string -> unit
-(** set the search path *)
-
-val get_path : t -> string
-(** get the search path *)
-
-val set_append : t -> string -> unit
-(** add options to kernel command line *)
-
-val get_append : t -> string
-(** get the additional kernel options *)
-
-val set_autosync : t -> bool -> unit
-(** set autosync mode *)
-
-val get_autosync : t -> bool
-(** get autosync mode *)
-
-val set_verbose : t -> bool -> unit
-(** set verbose mode *)
-
-val get_verbose : t -> bool
-(** get verbose mode *)
-
-val is_ready : t -> bool
-(** is ready to accept commands *)
-
-val is_config : t -> bool
-(** is in configuration state *)
-
-val is_launching : t -> bool
-(** is launching subprocess *)
-
-val is_busy : t -> bool
-(** is busy processing a command *)
-
-val get_state : t -> int
-(** get the current state *)
-
-val set_busy : t -> unit
-(** set state to busy *)
-
-val set_ready : t -> unit
-(** set state to ready *)
-
-val end_busy : t -> unit
-(** leave the busy state *)
-
-val set_memsize : t -> int -> unit
-(** set memory allocated to the qemu subprocess *)
-
-val get_memsize : t -> int
-(** get memory allocated to the qemu subprocess *)
-
-val mount : t -> string -> string -> unit
-(** mount a guest disk at a position in the filesystem *)
-
-val sync : t -> unit
-(** sync disks, writes are flushed through to the disk image *)
-
-val touch : t -> string -> unit
-(** update file timestamps or create a new file *)
-
-val cat : t -> string -> string
-(** list the contents of a file *)
-
-val ll : t -> string -> string
-(** list the files in a directory (long format) *)
-
-val ls : t -> string -> string array
-(** list the files in a directory *)
-
-val list_devices : t -> string array
-(** list the block devices *)
-
-val list_partitions : t -> string array
-(** list the partitions *)
-
-val pvs : t -> string array
-(** list the LVM physical volumes (PVs) *)
-
-val vgs : t -> string array
-(** list the LVM volume groups (VGs) *)
-
-val lvs : t -> string array
-(** list the LVM logical volumes (LVs) *)
-
-val pvs_full : t -> lvm_pv array
-(** list the LVM physical volumes (PVs) *)
-
-val vgs_full : t -> lvm_vg array
-(** list the LVM volume groups (VGs) *)
-
-val lvs_full : t -> lvm_lv array
-(** list the LVM logical volumes (LVs) *)
-
-val read_lines : t -> string -> string array
-(** read file as lines *)
-
-val aug_init : t -> string -> int -> unit
-(** create a new Augeas handle *)
-
-val aug_close : t -> unit
-(** close the current Augeas handle *)
-
-val aug_defvar : t -> string -> string option -> int
-(** define an Augeas variable *)
-
-val aug_defnode : t -> string -> string -> string -> int * bool
-(** define an Augeas node *)
-
-val aug_get : t -> string -> string
-(** look up the value of an Augeas path *)
-
-val aug_set : t -> string -> string -> unit
-(** set Augeas path to value *)
-
-val aug_insert : t -> string -> string -> bool -> unit
-(** insert a sibling Augeas node *)
-
-val aug_rm : t -> string -> int
-(** remove an Augeas path *)
-
-val aug_mv : t -> string -> string -> unit
-(** move Augeas node *)
-
-val aug_match : t -> string -> string array
-(** return Augeas nodes which match path *)
-
-val aug_save : t -> unit
-(** write all pending Augeas changes to disk *)
-
-val aug_load : t -> unit
-(** load files into the tree *)
-
-val aug_ls : t -> string -> string array
-(** list Augeas nodes under a path *)
-
-val rm : t -> string -> unit
-(** remove a file *)
-
-val rmdir : t -> string -> unit
-(** remove a directory *)
-
-val rm_rf : t -> string -> unit
-(** remove a file or directory recursively *)
-
-val mkdir : t -> string -> unit
-(** create a directory *)
-
-val mkdir_p : t -> string -> unit
-(** create a directory and parents *)
-
-val chmod : t -> int -> string -> unit
-(** change file mode *)
-
-val chown : t -> int -> int -> string -> unit
-(** change file owner and group *)
-
-val exists : t -> string -> bool
-(** test if file or directory exists *)
-
-val is_file : t -> string -> bool
-(** test if file exists *)
-
-val is_dir : t -> string -> bool
-(** test if file exists *)
-
-val pvcreate : t -> string -> unit
-(** create an LVM physical volume *)
-
-val vgcreate : t -> string -> string array -> unit
-(** create an LVM volume group *)
-
-val lvcreate : t -> string -> string -> int -> unit
-(** create an LVM volume group *)
-
-val mkfs : t -> string -> string -> unit
-(** make a filesystem *)
-
-val sfdisk : t -> string -> int -> int -> int -> string array -> unit
-(** create partitions on a block device *)
-
-val write_file : t -> string -> string -> int -> unit
-(** create a file *)
-
-val umount : t -> string -> unit
-(** unmount a filesystem *)
-
-val mounts : t -> string array
-(** show mounted filesystems *)
-
-val umount_all : t -> unit
-(** unmount all filesystems *)
-
-val lvm_remove_all : t -> unit
-(** remove all LVM LVs, VGs and PVs *)
-
-val file : t -> string -> string
-(** determine file type *)
-
-val command : t -> string array -> string
-(** run a command from the guest filesystem *)
-
-val command_lines : t -> string array -> string array
-(** run a command, returning lines *)
-
-val stat : t -> string -> stat
-(** get file information *)
-
-val lstat : t -> string -> stat
-(** get file information for a symbolic link *)
-
-val statvfs : t -> string -> statvfs
-(** get file system statistics *)
-
-val tune2fs_l : t -> string -> (string * string) list
-(** get ext2/ext3/ext4 superblock details *)
-
-val blockdev_setro : t -> string -> unit
-(** set block device to read-only *)
-
-val blockdev_setrw : t -> string -> unit
-(** set block device to read-write *)
-
-val blockdev_getro : t -> string -> bool
-(** is block device set to read-only *)
-
-val blockdev_getss : t -> string -> int
-(** get sectorsize of block device *)
-
-val blockdev_getbsz : t -> string -> int
-(** get blocksize of block device *)
-
-val blockdev_setbsz : t -> string -> int -> unit
-(** set blocksize of block device *)
-
-val blockdev_getsz : t -> string -> int64
-(** get total size of device in 512-byte sectors *)
-
-val blockdev_getsize64 : t -> string -> int64
-(** get total size of device in bytes *)
-
-val blockdev_flushbufs : t -> string -> unit
-(** flush device buffers *)
-
-val blockdev_rereadpt : t -> string -> unit
-(** reread partition table *)
-
-val upload : t -> string -> string -> unit
-(** upload a file from the local machine *)
-
-val download : t -> string -> string -> unit
-(** download a file to the local machine *)
-
-val checksum : t -> string -> string -> string
-(** compute MD5, SHAx or CRC checksum of file *)
-
-val tar_in : t -> string -> string -> unit
-(** unpack tarfile to directory *)
-
-val tar_out : t -> string -> string -> unit
-(** pack directory into tarfile *)
-
-val tgz_in : t -> string -> string -> unit
-(** unpack compressed tarball to directory *)
-
-val tgz_out : t -> string -> string -> unit
-(** pack directory into compressed tarball *)
-
-val mount_ro : t -> string -> string -> unit
-(** mount a guest disk, read-only *)
-
-val mount_options : t -> string -> string -> string -> unit
-(** mount a guest disk with mount options *)
-
-val mount_vfs : t -> string -> string -> string -> string -> unit
-(** mount a guest disk with mount options and vfstype *)
-
-val debug : t -> string -> string array -> string
-(** debugging and internals *)
-
-val lvremove : t -> string -> unit
-(** remove an LVM logical volume *)
-
-val vgremove : t -> string -> unit
-(** remove an LVM volume group *)
-
-val pvremove : t -> string -> unit
-(** remove an LVM physical volume *)
-
-val set_e2label : t -> string -> string -> unit
-(** set the ext2/3/4 filesystem label *)
-
-val get_e2label : t -> string -> string
-(** get the ext2/3/4 filesystem label *)
-
-val set_e2uuid : t -> string -> string -> unit
-(** set the ext2/3/4 filesystem UUID *)
-
-val get_e2uuid : t -> string -> string
-(** get the ext2/3/4 filesystem UUID *)
-
-val fsck : t -> string -> string -> int
-(** run the filesystem checker *)
-
-val zero : t -> string -> unit
-(** write zeroes to the device *)
-
-val grub_install : t -> string -> string -> unit
-(** install GRUB *)
-
-val cp : t -> string -> string -> unit
-(** copy a file *)
-
-val cp_a : t -> string -> string -> unit
-(** copy a file or directory recursively *)
-
-val mv : t -> string -> string -> unit
-(** move a file *)
-
-val drop_caches : t -> int -> unit
-(** drop kernel page cache, dentries and inodes *)
-
-val dmesg : t -> string
-(** return kernel messages *)
-
-val ping_daemon : t -> unit
-(** ping the guest daemon *)
-
-val equal : t -> string -> string -> bool
-(** test if two files have equal contents *)
-
-val strings : t -> string -> string array
-(** print the printable strings in a file *)
-
-val strings_e : t -> string -> string -> string array
-(** print the printable strings in a file *)
-
-val hexdump : t -> string -> string
-(** dump a file in hexadecimal *)
-
-val zerofree : t -> string -> unit
-(** zero unused inodes and disk blocks on ext2/3 filesystem *)
-
-val pvresize : t -> string -> unit
-(** resize an LVM physical volume *)
-
-val sfdisk_N : t -> string -> int -> int -> int -> int -> string -> unit
-(** modify a single partition on a block device *)
-
-val sfdisk_l : t -> string -> string
-(** display the partition table *)
-
-val sfdisk_kernel_geometry : t -> string -> string
-(** display the kernel geometry *)
-
-val sfdisk_disk_geometry : t -> string -> string
-(** display the disk geometry from the partition table *)
-
-val vg_activate_all : t -> bool -> unit
-(** activate or deactivate all volume groups *)
-
-val vg_activate : t -> bool -> string array -> unit
-(** activate or deactivate some volume groups *)
-
-val lvresize : t -> string -> int -> unit
-(** resize an LVM logical volume *)
-
-val resize2fs : t -> string -> unit
-(** resize an ext2/ext3 filesystem *)
-
-val find : t -> string -> string array
-(** find all files and directories *)
-
-val e2fsck_f : t -> string -> unit
-(** check an ext2/ext3 filesystem *)
-
-val sleep : t -> int -> unit
-(** sleep for some seconds *)
-
-val ntfs_3g_probe : t -> bool -> string -> int
-(** probe NTFS volume *)
-
-val sh : t -> string -> string
-(** run a command via the shell *)
-
-val sh_lines : t -> string -> string array
-(** run a command via the shell returning lines *)
-
-val glob_expand : t -> string -> string array
-(** expand a wildcard path *)
-
-val scrub_device : t -> string -> unit
-(** scrub (securely wipe) a device *)
-
-val scrub_file : t -> string -> unit
-(** scrub (securely wipe) a file *)
-
-val scrub_freespace : t -> string -> unit
-(** scrub (securely wipe) free space *)
-
-val mkdtemp : t -> string -> string
-(** create a temporary directory *)
-
-val wc_l : t -> string -> int
-(** count lines in a file *)
-
-val wc_w : t -> string -> int
-(** count words in a file *)
-
-val wc_c : t -> string -> int
-(** count characters in a file *)
-
-val head : t -> string -> string array
-(** return first 10 lines of a file *)
-
-val head_n : t -> int -> string -> string array
-(** return first N lines of a file *)
-
-val tail : t -> string -> string array
-(** return last 10 lines of a file *)
-
-val tail_n : t -> int -> string -> string array
-(** return last N lines of a file *)
-
-val df : t -> string
-(** report file system disk space usage *)
-
-val df_h : t -> string
-(** report file system disk space usage (human readable) *)
-
-val du : t -> string -> int64
-(** estimate file space usage *)
-
-val initrd_list : t -> string -> string array
-(** list files in an initrd *)
-
-val mount_loop : t -> string -> string -> unit
-(** mount a file using the loop device *)
-
-val mkswap : t -> string -> unit
-(** create a swap partition *)
-
-val mkswap_L : t -> string -> string -> unit
-(** create a swap partition with a label *)
-
-val mkswap_U : t -> string -> string -> unit
-(** create a swap partition with an explicit UUID *)
-
-val mknod : t -> int -> int -> int -> string -> unit
-(** make block, character or FIFO devices *)
-
-val mkfifo : t -> int -> string -> unit
-(** make FIFO (named pipe) *)
-
-val mknod_b : t -> int -> int -> int -> string -> unit
-(** make block device node *)
-
-val mknod_c : t -> int -> int -> int -> string -> unit
-(** make char device node *)
-
-val umask : t -> int -> int
-(** set file mode creation mask (umask) *)
-
-val readdir : t -> string -> dirent array
-(** read directories entries *)
-
+++ /dev/null
-/* 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 <string.h>
-
-#include <caml/config.h>
-#include <caml/alloc.h>
-#include <caml/callback.h>
-#include <caml/fail.h>
-#include <caml/memory.h>
-#include <caml/mlvalues.h>
-#include <caml/signals.h>
-
-#include <guestfs.h>
-
-#include "guestfs_c.h"
-
-/* Copy a hashtable of string pairs into an assoc-list. We return
- * the list in reverse order, but hashtables aren't supposed to be
- * ordered anyway.
- */
-static CAMLprim value
-copy_table (char * const * argv)
-{
- CAMLparam0 ();
- CAMLlocal5 (rv, pairv, kv, vv, cons);
- int i;
-
- rv = Val_int (0);
- for (i = 0; argv[i] != NULL; i += 2) {
- kv = caml_copy_string (argv[i]);
- vv = caml_copy_string (argv[i+1]);
- pairv = caml_alloc (2, 0);
- Store_field (pairv, 0, kv);
- Store_field (pairv, 1, vv);
- cons = caml_alloc (2, 0);
- Store_field (cons, 1, rv);
- rv = cons;
- Store_field (cons, 0, pairv);
- }
-
- CAMLreturn (rv);
-}
-
-static CAMLprim value
-copy_lvm_pv (const struct guestfs_lvm_pv *pv)
-{
- CAMLparam0 ();
- CAMLlocal2 (rv, v);
-
- rv = caml_alloc (14, 0);
- v = caml_copy_string (pv->pv_name);
- Store_field (rv, 0, v);
- v = caml_alloc_string (32);
- memcpy (String_val (v), pv->pv_uuid, 32);
- Store_field (rv, 1, v);
- v = caml_copy_string (pv->pv_fmt);
- Store_field (rv, 2, v);
- v = caml_copy_int64 (pv->pv_size);
- Store_field (rv, 3, v);
- v = caml_copy_int64 (pv->dev_size);
- Store_field (rv, 4, v);
- v = caml_copy_int64 (pv->pv_free);
- Store_field (rv, 5, v);
- v = caml_copy_int64 (pv->pv_used);
- Store_field (rv, 6, v);
- v = caml_copy_string (pv->pv_attr);
- Store_field (rv, 7, v);
- v = caml_copy_int64 (pv->pv_pe_count);
- Store_field (rv, 8, v);
- v = caml_copy_int64 (pv->pv_pe_alloc_count);
- Store_field (rv, 9, v);
- v = caml_copy_string (pv->pv_tags);
- Store_field (rv, 10, v);
- v = caml_copy_int64 (pv->pe_start);
- Store_field (rv, 11, v);
- v = caml_copy_int64 (pv->pv_mda_count);
- Store_field (rv, 12, v);
- v = caml_copy_int64 (pv->pv_mda_free);
- Store_field (rv, 13, v);
- CAMLreturn (rv);
-}
-
-static CAMLprim value
-copy_lvm_pv_list (const struct guestfs_lvm_pv_list *pvs)
-{
- CAMLparam0 ();
- CAMLlocal2 (rv, v);
- int i;
-
- if (pvs->len == 0)
- CAMLreturn (Atom (0));
- else {
- rv = caml_alloc (pvs->len, 0);
- for (i = 0; i < pvs->len; ++i) {
- v = copy_lvm_pv (&pvs->val[i]);
- caml_modify (&Field (rv, i), v);
- }
- CAMLreturn (rv);
- }
-}
-
-static CAMLprim value
-copy_lvm_vg (const struct guestfs_lvm_vg *vg)
-{
- CAMLparam0 ();
- CAMLlocal2 (rv, v);
-
- rv = caml_alloc (19, 0);
- v = caml_copy_string (vg->vg_name);
- Store_field (rv, 0, v);
- v = caml_alloc_string (32);
- memcpy (String_val (v), vg->vg_uuid, 32);
- Store_field (rv, 1, v);
- v = caml_copy_string (vg->vg_fmt);
- Store_field (rv, 2, v);
- v = caml_copy_string (vg->vg_attr);
- Store_field (rv, 3, v);
- v = caml_copy_int64 (vg->vg_size);
- Store_field (rv, 4, v);
- v = caml_copy_int64 (vg->vg_free);
- Store_field (rv, 5, v);
- v = caml_copy_string (vg->vg_sysid);
- Store_field (rv, 6, v);
- v = caml_copy_int64 (vg->vg_extent_size);
- Store_field (rv, 7, v);
- v = caml_copy_int64 (vg->vg_extent_count);
- Store_field (rv, 8, v);
- v = caml_copy_int64 (vg->vg_free_count);
- Store_field (rv, 9, v);
- v = caml_copy_int64 (vg->max_lv);
- Store_field (rv, 10, v);
- v = caml_copy_int64 (vg->max_pv);
- Store_field (rv, 11, v);
- v = caml_copy_int64 (vg->pv_count);
- Store_field (rv, 12, v);
- v = caml_copy_int64 (vg->lv_count);
- Store_field (rv, 13, v);
- v = caml_copy_int64 (vg->snap_count);
- Store_field (rv, 14, v);
- v = caml_copy_int64 (vg->vg_seqno);
- Store_field (rv, 15, v);
- v = caml_copy_string (vg->vg_tags);
- Store_field (rv, 16, v);
- v = caml_copy_int64 (vg->vg_mda_count);
- Store_field (rv, 17, v);
- v = caml_copy_int64 (vg->vg_mda_free);
- Store_field (rv, 18, v);
- CAMLreturn (rv);
-}
-
-static CAMLprim value
-copy_lvm_vg_list (const struct guestfs_lvm_vg_list *vgs)
-{
- CAMLparam0 ();
- CAMLlocal2 (rv, v);
- int i;
-
- if (vgs->len == 0)
- CAMLreturn (Atom (0));
- else {
- rv = caml_alloc (vgs->len, 0);
- for (i = 0; i < vgs->len; ++i) {
- v = copy_lvm_vg (&vgs->val[i]);
- caml_modify (&Field (rv, i), v);
- }
- CAMLreturn (rv);
- }
-}
-
-static CAMLprim value
-copy_lvm_lv (const struct guestfs_lvm_lv *lv)
-{
- CAMLparam0 ();
- CAMLlocal3 (rv, v, v2);
-
- rv = caml_alloc (16, 0);
- v = caml_copy_string (lv->lv_name);
- Store_field (rv, 0, v);
- v = caml_alloc_string (32);
- memcpy (String_val (v), lv->lv_uuid, 32);
- Store_field (rv, 1, v);
- v = caml_copy_string (lv->lv_attr);
- Store_field (rv, 2, v);
- v = caml_copy_int64 (lv->lv_major);
- Store_field (rv, 3, v);
- v = caml_copy_int64 (lv->lv_minor);
- Store_field (rv, 4, v);
- v = caml_copy_int64 (lv->lv_kernel_major);
- Store_field (rv, 5, v);
- v = caml_copy_int64 (lv->lv_kernel_minor);
- Store_field (rv, 6, v);
- v = caml_copy_int64 (lv->lv_size);
- Store_field (rv, 7, v);
- v = caml_copy_int64 (lv->seg_count);
- Store_field (rv, 8, v);
- v = caml_copy_string (lv->origin);
- Store_field (rv, 9, v);
- if (lv->snap_percent >= 0) { /* Some snap_percent */
- v2 = caml_copy_double (lv->snap_percent);
- v = caml_alloc (1, 0);
- Store_field (v, 0, v2);
- } else /* None */
- v = Val_int (0);
- Store_field (rv, 10, v);
- if (lv->copy_percent >= 0) { /* Some copy_percent */
- v2 = caml_copy_double (lv->copy_percent);
- v = caml_alloc (1, 0);
- Store_field (v, 0, v2);
- } else /* None */
- v = Val_int (0);
- Store_field (rv, 11, v);
- v = caml_copy_string (lv->move_pv);
- Store_field (rv, 12, v);
- v = caml_copy_string (lv->lv_tags);
- Store_field (rv, 13, v);
- v = caml_copy_string (lv->mirror_log);
- Store_field (rv, 14, v);
- v = caml_copy_string (lv->modules);
- Store_field (rv, 15, v);
- CAMLreturn (rv);
-}
-
-static CAMLprim value
-copy_lvm_lv_list (const struct guestfs_lvm_lv_list *lvs)
-{
- CAMLparam0 ();
- CAMLlocal2 (rv, v);
- int i;
-
- if (lvs->len == 0)
- CAMLreturn (Atom (0));
- else {
- rv = caml_alloc (lvs->len, 0);
- for (i = 0; i < lvs->len; ++i) {
- v = copy_lvm_lv (&lvs->val[i]);
- caml_modify (&Field (rv, i), v);
- }
- CAMLreturn (rv);
- }
-}
-
-static CAMLprim value
-copy_stat (const struct guestfs_stat *stat)
-{
- CAMLparam0 ();
- CAMLlocal2 (rv, v);
-
- rv = caml_alloc (13, 0);
- v = caml_copy_int64 (stat->dev);
- Store_field (rv, 0, v);
- v = caml_copy_int64 (stat->ino);
- Store_field (rv, 1, v);
- v = caml_copy_int64 (stat->mode);
- Store_field (rv, 2, v);
- v = caml_copy_int64 (stat->nlink);
- Store_field (rv, 3, v);
- v = caml_copy_int64 (stat->uid);
- Store_field (rv, 4, v);
- v = caml_copy_int64 (stat->gid);
- Store_field (rv, 5, v);
- v = caml_copy_int64 (stat->rdev);
- Store_field (rv, 6, v);
- v = caml_copy_int64 (stat->size);
- Store_field (rv, 7, v);
- v = caml_copy_int64 (stat->blksize);
- Store_field (rv, 8, v);
- v = caml_copy_int64 (stat->blocks);
- Store_field (rv, 9, v);
- v = caml_copy_int64 (stat->atime);
- Store_field (rv, 10, v);
- v = caml_copy_int64 (stat->mtime);
- Store_field (rv, 11, v);
- v = caml_copy_int64 (stat->ctime);
- Store_field (rv, 12, v);
- CAMLreturn (rv);
-}
-
-static CAMLprim value
-copy_statvfs (const struct guestfs_statvfs *statvfs)
-{
- CAMLparam0 ();
- CAMLlocal2 (rv, v);
-
- rv = caml_alloc (11, 0);
- v = caml_copy_int64 (statvfs->bsize);
- Store_field (rv, 0, v);
- v = caml_copy_int64 (statvfs->frsize);
- Store_field (rv, 1, v);
- v = caml_copy_int64 (statvfs->blocks);
- Store_field (rv, 2, v);
- v = caml_copy_int64 (statvfs->bfree);
- Store_field (rv, 3, v);
- v = caml_copy_int64 (statvfs->bavail);
- Store_field (rv, 4, v);
- v = caml_copy_int64 (statvfs->files);
- Store_field (rv, 5, v);
- v = caml_copy_int64 (statvfs->ffree);
- Store_field (rv, 6, v);
- v = caml_copy_int64 (statvfs->favail);
- Store_field (rv, 7, v);
- v = caml_copy_int64 (statvfs->fsid);
- Store_field (rv, 8, v);
- v = caml_copy_int64 (statvfs->flag);
- Store_field (rv, 9, v);
- v = caml_copy_int64 (statvfs->namemax);
- Store_field (rv, 10, v);
- CAMLreturn (rv);
-}
-
-static CAMLprim value
-copy_dirent (const struct guestfs_dirent *dirent)
-{
- CAMLparam0 ();
- CAMLlocal2 (rv, v);
-
- rv = caml_alloc (3, 0);
- v = caml_copy_int64 (dirent->ino);
- Store_field (rv, 0, v);
- v = Val_int (dirent->ftyp);
- Store_field (rv, 1, v);
- v = caml_copy_string (dirent->name);
- Store_field (rv, 2, v);
- CAMLreturn (rv);
-}
-
-static CAMLprim value
-copy_dirent_list (const struct guestfs_dirent_list *dirents)
-{
- CAMLparam0 ();
- CAMLlocal2 (rv, v);
- int i;
-
- if (dirents->len == 0)
- CAMLreturn (Atom (0));
- else {
- rv = caml_alloc (dirents->len, 0);
- for (i = 0; i < dirents->len; ++i) {
- v = copy_dirent (&dirents->val[i]);
- caml_modify (&Field (rv, i), v);
- }
- CAMLreturn (rv);
- }
-}
-
-CAMLprim value
-ocaml_guestfs_test0 (value gv, value strv, value optstrv, value strlistv, value bv, value integerv, value fileinv, value fileoutv)
-{
- CAMLparam5 (gv, strv, optstrv, strlistv, bv);
- CAMLxparam3 (integerv, fileinv, fileoutv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0: used handle after closing it");
-
- const char *str = String_val (strv);
- const char *optstr =
- optstrv != Val_int (0) ? String_val (Field (optstrv, 0)) : NULL;
- char **strlist = ocaml_guestfs_strings_val (g, strlistv);
- int b = Bool_val (bv);
- int integer = Int_val (integerv);
- const char *filein = String_val (fileinv);
- const char *fileout = String_val (fileoutv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout);
- caml_leave_blocking_section ();
- ocaml_guestfs_free_strings (strlist);
- if (r == -1)
- ocaml_guestfs_raise_error (g, "test0");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0_byte (value *argv, int argn)
-{
- return ocaml_guestfs_test0 (argv[0], argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rint (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rint: used handle after closing it");
-
- const char *val = String_val (valv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rint (g, val);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "test0rint");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rinterr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rinterr: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rinterr (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "test0rinterr");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rint64 (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rint64: used handle after closing it");
-
- const char *val = String_val (valv);
- int64_t r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rint64 (g, val);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "test0rint64");
-
- rv = caml_copy_int64 (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rint64err (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rint64err: used handle after closing it");
-
- int64_t r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rint64err (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "test0rint64err");
-
- rv = caml_copy_int64 (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rbool (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rbool: used handle after closing it");
-
- const char *val = String_val (valv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rbool (g, val);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "test0rbool");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rboolerr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rboolerr: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rboolerr (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "test0rboolerr");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rconststring (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rconststring: used handle after closing it");
-
- const char *val = String_val (valv);
- const char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rconststring (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rconststring");
-
- rv = caml_copy_string (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rconststringerr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rconststringerr: used handle after closing it");
-
- const char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rconststringerr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rconststringerr");
-
- rv = caml_copy_string (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rstring (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rstring: used handle after closing it");
-
- const char *val = String_val (valv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rstring (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rstring");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rstringerr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rstringerr: used handle after closing it");
-
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rstringerr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rstringerr");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rstringlist (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rstringlist: used handle after closing it");
-
- const char *val = String_val (valv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rstringlist (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rstringlist");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rstringlisterr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rstringlisterr: used handle after closing it");
-
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rstringlisterr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rstringlisterr");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rintbool (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rintbool: used handle after closing it");
-
- const char *val = String_val (valv);
- struct guestfs_int_bool *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rintbool (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rintbool");
-
- rv = caml_alloc (2, 0);
- Store_field (rv, 0, Val_int (r->i));
- Store_field (rv, 1, Val_bool (r->b));
- guestfs_free_int_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rintboolerr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rintboolerr: used handle after closing it");
-
- struct guestfs_int_bool *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rintboolerr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rintboolerr");
-
- rv = caml_alloc (2, 0);
- Store_field (rv, 0, Val_int (r->i));
- Store_field (rv, 1, Val_bool (r->b));
- guestfs_free_int_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rpvlist (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rpvlist: used handle after closing it");
-
- const char *val = String_val (valv);
- struct guestfs_lvm_pv_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rpvlist (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rpvlist");
-
- rv = copy_lvm_pv_list (r);
- guestfs_free_lvm_pv_list (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rpvlisterr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rpvlisterr: used handle after closing it");
-
- struct guestfs_lvm_pv_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rpvlisterr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rpvlisterr");
-
- rv = copy_lvm_pv_list (r);
- guestfs_free_lvm_pv_list (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rvglist (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rvglist: used handle after closing it");
-
- const char *val = String_val (valv);
- struct guestfs_lvm_vg_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rvglist (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rvglist");
-
- rv = copy_lvm_vg_list (r);
- guestfs_free_lvm_vg_list (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rvglisterr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rvglisterr: used handle after closing it");
-
- struct guestfs_lvm_vg_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rvglisterr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rvglisterr");
-
- rv = copy_lvm_vg_list (r);
- guestfs_free_lvm_vg_list (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rlvlist (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rlvlist: used handle after closing it");
-
- const char *val = String_val (valv);
- struct guestfs_lvm_lv_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rlvlist (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rlvlist");
-
- rv = copy_lvm_lv_list (r);
- guestfs_free_lvm_lv_list (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rlvlisterr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rlvlisterr: used handle after closing it");
-
- struct guestfs_lvm_lv_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rlvlisterr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rlvlisterr");
-
- rv = copy_lvm_lv_list (r);
- guestfs_free_lvm_lv_list (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rstat (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rstat: used handle after closing it");
-
- const char *val = String_val (valv);
- struct guestfs_stat *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rstat (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rstat");
-
- rv = copy_stat (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rstaterr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rstaterr: used handle after closing it");
-
- struct guestfs_stat *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rstaterr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rstaterr");
-
- rv = copy_stat (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rstatvfs (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rstatvfs: used handle after closing it");
-
- const char *val = String_val (valv);
- struct guestfs_statvfs *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rstatvfs (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rstatvfs");
-
- rv = copy_statvfs (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rstatvfserr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rstatvfserr: used handle after closing it");
-
- struct guestfs_statvfs *r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rstatvfserr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rstatvfserr");
-
- rv = copy_statvfs (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rhashtable (value gv, value valv)
-{
- CAMLparam2 (gv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rhashtable: used handle after closing it");
-
- const char *val = String_val (valv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rhashtable (g, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rhashtable");
-
- rv = copy_table (r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_test0rhashtableerr (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("test0rhashtableerr: used handle after closing it");
-
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_test0rhashtableerr (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "test0rhashtableerr");
-
- rv = copy_table (r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_launch (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("launch: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_launch (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "launch");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_wait_ready (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("wait_ready: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_wait_ready (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "wait_ready");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_kill_subprocess (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("kill_subprocess: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_kill_subprocess (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "kill_subprocess");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_add_drive (value gv, value filenamev)
-{
- CAMLparam2 (gv, filenamev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("add_drive: used handle after closing it");
-
- const char *filename = String_val (filenamev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_add_drive (g, filename);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "add_drive");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_add_cdrom (value gv, value filenamev)
-{
- CAMLparam2 (gv, filenamev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("add_cdrom: used handle after closing it");
-
- const char *filename = String_val (filenamev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_add_cdrom (g, filename);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "add_cdrom");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_add_drive_ro (value gv, value filenamev)
-{
- CAMLparam2 (gv, filenamev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("add_drive_ro: used handle after closing it");
-
- const char *filename = String_val (filenamev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_add_drive_ro (g, filename);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "add_drive_ro");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_config (value gv, value qemuparamv, value qemuvaluev)
-{
- CAMLparam3 (gv, qemuparamv, qemuvaluev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("config: used handle after closing it");
-
- const char *qemuparam = String_val (qemuparamv);
- const char *qemuvalue =
- qemuvaluev != Val_int (0) ? String_val (Field (qemuvaluev, 0)) : NULL;
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_config (g, qemuparam, qemuvalue);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "config");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_qemu (value gv, value qemuv)
-{
- CAMLparam2 (gv, qemuv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_qemu: used handle after closing it");
-
- const char *qemu = String_val (qemuv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_qemu (g, qemu);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_qemu");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_get_qemu (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("get_qemu: used handle after closing it");
-
- const char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_get_qemu (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "get_qemu");
-
- rv = caml_copy_string (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_path (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_path: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_path (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_path");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_get_path (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("get_path: used handle after closing it");
-
- const char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_get_path (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "get_path");
-
- rv = caml_copy_string (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_append (value gv, value appendv)
-{
- CAMLparam2 (gv, appendv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_append: used handle after closing it");
-
- const char *append = String_val (appendv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_append (g, append);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_append");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_get_append (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("get_append: used handle after closing it");
-
- const char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_get_append (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "get_append");
-
- rv = caml_copy_string (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_autosync (value gv, value autosyncv)
-{
- CAMLparam2 (gv, autosyncv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_autosync: used handle after closing it");
-
- int autosync = Bool_val (autosyncv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_autosync (g, autosync);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_autosync");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_get_autosync (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("get_autosync: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_get_autosync (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "get_autosync");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_verbose (value gv, value verbosev)
-{
- CAMLparam2 (gv, verbosev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_verbose: used handle after closing it");
-
- int verbose = Bool_val (verbosev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_verbose (g, verbose);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_verbose");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_get_verbose (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("get_verbose: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_get_verbose (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "get_verbose");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_is_ready (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("is_ready: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_is_ready (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "is_ready");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_is_config (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("is_config: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_is_config (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "is_config");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_is_launching (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("is_launching: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_is_launching (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "is_launching");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_is_busy (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("is_busy: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_is_busy (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "is_busy");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_get_state (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("get_state: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_get_state (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "get_state");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_busy (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_busy: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_busy (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_busy");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_ready (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_ready: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_ready (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_ready");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_end_busy (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("end_busy: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_end_busy (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "end_busy");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_memsize (value gv, value memsizev)
-{
- CAMLparam2 (gv, memsizev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_memsize: used handle after closing it");
-
- int memsize = Int_val (memsizev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_memsize (g, memsize);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_memsize");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_get_memsize (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("get_memsize: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_get_memsize (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "get_memsize");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mount (value gv, value devicev, value mountpointv)
-{
- CAMLparam3 (gv, devicev, mountpointv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mount: used handle after closing it");
-
- const char *device = String_val (devicev);
- const char *mountpoint = String_val (mountpointv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mount (g, device, mountpoint);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mount");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sync (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("sync: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_sync (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "sync");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_touch (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("touch: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_touch (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "touch");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_cat (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("cat: used handle after closing it");
-
- const char *path = String_val (pathv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_cat (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "cat");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_ll (value gv, value directoryv)
-{
- CAMLparam2 (gv, directoryv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("ll: used handle after closing it");
-
- const char *directory = String_val (directoryv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_ll (g, directory);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "ll");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_ls (value gv, value directoryv)
-{
- CAMLparam2 (gv, directoryv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("ls: used handle after closing it");
-
- const char *directory = String_val (directoryv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_ls (g, directory);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "ls");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_list_devices (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("list_devices: used handle after closing it");
-
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_list_devices (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "list_devices");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_list_partitions (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("list_partitions: used handle after closing it");
-
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_list_partitions (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "list_partitions");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_pvs (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("pvs: used handle after closing it");
-
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_pvs (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "pvs");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_vgs (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("vgs: used handle after closing it");
-
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_vgs (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "vgs");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_lvs (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("lvs: used handle after closing it");
-
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_lvs (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "lvs");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_pvs_full (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("pvs_full: used handle after closing it");
-
- struct guestfs_lvm_pv_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_pvs_full (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "pvs_full");
-
- rv = copy_lvm_pv_list (r);
- guestfs_free_lvm_pv_list (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_vgs_full (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("vgs_full: used handle after closing it");
-
- struct guestfs_lvm_vg_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_vgs_full (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "vgs_full");
-
- rv = copy_lvm_vg_list (r);
- guestfs_free_lvm_vg_list (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_lvs_full (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("lvs_full: used handle after closing it");
-
- struct guestfs_lvm_lv_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_lvs_full (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "lvs_full");
-
- rv = copy_lvm_lv_list (r);
- guestfs_free_lvm_lv_list (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_read_lines (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("read_lines: used handle after closing it");
-
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_read_lines (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "read_lines");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_init (value gv, value rootv, value flagsv)
-{
- CAMLparam3 (gv, rootv, flagsv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_init: used handle after closing it");
-
- const char *root = String_val (rootv);
- int flags = Int_val (flagsv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_init (g, root, flags);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "aug_init");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_close (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_close: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_close (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "aug_close");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_defvar (value gv, value namev, value exprv)
-{
- CAMLparam3 (gv, namev, exprv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_defvar: used handle after closing it");
-
- const char *name = String_val (namev);
- const char *expr =
- exprv != Val_int (0) ? String_val (Field (exprv, 0)) : NULL;
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_defvar (g, name, expr);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "aug_defvar");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_defnode (value gv, value namev, value exprv, value valv)
-{
- CAMLparam4 (gv, namev, exprv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_defnode: used handle after closing it");
-
- const char *name = String_val (namev);
- const char *expr = String_val (exprv);
- const char *val = String_val (valv);
- struct guestfs_int_bool *r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_defnode (g, name, expr, val);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "aug_defnode");
-
- rv = caml_alloc (2, 0);
- Store_field (rv, 0, Val_int (r->i));
- Store_field (rv, 1, Val_bool (r->b));
- guestfs_free_int_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_get (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_get: used handle after closing it");
-
- const char *path = String_val (pathv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_get (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "aug_get");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_set (value gv, value pathv, value valv)
-{
- CAMLparam3 (gv, pathv, valv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_set: used handle after closing it");
-
- const char *path = String_val (pathv);
- const char *val = String_val (valv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_set (g, path, val);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "aug_set");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_insert (value gv, value pathv, value labelv, value beforev)
-{
- CAMLparam4 (gv, pathv, labelv, beforev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_insert: used handle after closing it");
-
- const char *path = String_val (pathv);
- const char *label = String_val (labelv);
- int before = Bool_val (beforev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_insert (g, path, label, before);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "aug_insert");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_rm (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_rm: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_rm (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "aug_rm");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_mv (value gv, value srcv, value destv)
-{
- CAMLparam3 (gv, srcv, destv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_mv: used handle after closing it");
-
- const char *src = String_val (srcv);
- const char *dest = String_val (destv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_mv (g, src, dest);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "aug_mv");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_match (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_match: used handle after closing it");
-
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_match (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "aug_match");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_save (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_save: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_save (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "aug_save");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_load (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_load: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_load (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "aug_load");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_aug_ls (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("aug_ls: used handle after closing it");
-
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_aug_ls (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "aug_ls");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_rm (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("rm: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_rm (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "rm");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_rmdir (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("rmdir: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_rmdir (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "rmdir");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_rm_rf (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("rm_rf: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_rm_rf (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "rm_rf");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mkdir (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mkdir: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mkdir (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mkdir");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mkdir_p (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mkdir_p: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mkdir_p (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mkdir_p");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_chmod (value gv, value modev, value pathv)
-{
- CAMLparam3 (gv, modev, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("chmod: used handle after closing it");
-
- int mode = Int_val (modev);
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_chmod (g, mode, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "chmod");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_chown (value gv, value ownerv, value groupv, value pathv)
-{
- CAMLparam4 (gv, ownerv, groupv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("chown: used handle after closing it");
-
- int owner = Int_val (ownerv);
- int group = Int_val (groupv);
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_chown (g, owner, group, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "chown");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_exists (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("exists: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_exists (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "exists");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_is_file (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("is_file: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_is_file (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "is_file");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_is_dir (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("is_dir: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_is_dir (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "is_dir");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_pvcreate (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("pvcreate: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_pvcreate (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "pvcreate");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_vgcreate (value gv, value volgroupv, value physvolsv)
-{
- CAMLparam3 (gv, volgroupv, physvolsv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("vgcreate: used handle after closing it");
-
- const char *volgroup = String_val (volgroupv);
- char **physvols = ocaml_guestfs_strings_val (g, physvolsv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_vgcreate (g, volgroup, physvols);
- caml_leave_blocking_section ();
- ocaml_guestfs_free_strings (physvols);
- if (r == -1)
- ocaml_guestfs_raise_error (g, "vgcreate");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_lvcreate (value gv, value logvolv, value volgroupv, value mbytesv)
-{
- CAMLparam4 (gv, logvolv, volgroupv, mbytesv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("lvcreate: used handle after closing it");
-
- const char *logvol = String_val (logvolv);
- const char *volgroup = String_val (volgroupv);
- int mbytes = Int_val (mbytesv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "lvcreate");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mkfs (value gv, value fstypev, value devicev)
-{
- CAMLparam3 (gv, fstypev, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mkfs: used handle after closing it");
-
- const char *fstype = String_val (fstypev);
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mkfs (g, fstype, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mkfs");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sfdisk (value gv, value devicev, value cylsv, value headsv, value sectorsv, value linesv)
-{
- CAMLparam5 (gv, devicev, cylsv, headsv, sectorsv);
- CAMLxparam1 (linesv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("sfdisk: used handle after closing it");
-
- const char *device = String_val (devicev);
- int cyls = Int_val (cylsv);
- int heads = Int_val (headsv);
- int sectors = Int_val (sectorsv);
- char **lines = ocaml_guestfs_strings_val (g, linesv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
- caml_leave_blocking_section ();
- ocaml_guestfs_free_strings (lines);
- if (r == -1)
- ocaml_guestfs_raise_error (g, "sfdisk");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sfdisk_byte (value *argv, int argn)
-{
- return ocaml_guestfs_sfdisk (argv[0], argv[0], argv[1], argv[2], argv[3], argv[4]);
-}
-
-CAMLprim value
-ocaml_guestfs_write_file (value gv, value pathv, value contentv, value sizev)
-{
- CAMLparam4 (gv, pathv, contentv, sizev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("write_file: used handle after closing it");
-
- const char *path = String_val (pathv);
- const char *content = String_val (contentv);
- int size = Int_val (sizev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_write_file (g, path, content, size);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "write_file");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_umount (value gv, value pathordevicev)
-{
- CAMLparam2 (gv, pathordevicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("umount: used handle after closing it");
-
- const char *pathordevice = String_val (pathordevicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_umount (g, pathordevice);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "umount");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mounts (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mounts: used handle after closing it");
-
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_mounts (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "mounts");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_umount_all (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("umount_all: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_umount_all (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "umount_all");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_lvm_remove_all (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("lvm_remove_all: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_lvm_remove_all (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "lvm_remove_all");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_file (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("file: used handle after closing it");
-
- const char *path = String_val (pathv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_file (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "file");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_command (value gv, value argumentsv)
-{
- CAMLparam2 (gv, argumentsv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("command: used handle after closing it");
-
- char **arguments = ocaml_guestfs_strings_val (g, argumentsv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_command (g, arguments);
- caml_leave_blocking_section ();
- ocaml_guestfs_free_strings (arguments);
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "command");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_command_lines (value gv, value argumentsv)
-{
- CAMLparam2 (gv, argumentsv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("command_lines: used handle after closing it");
-
- char **arguments = ocaml_guestfs_strings_val (g, argumentsv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_command_lines (g, arguments);
- caml_leave_blocking_section ();
- ocaml_guestfs_free_strings (arguments);
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "command_lines");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_stat (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("stat: used handle after closing it");
-
- const char *path = String_val (pathv);
- struct guestfs_stat *r;
-
- caml_enter_blocking_section ();
- r = guestfs_stat (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "stat");
-
- rv = copy_stat (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_lstat (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("lstat: used handle after closing it");
-
- const char *path = String_val (pathv);
- struct guestfs_stat *r;
-
- caml_enter_blocking_section ();
- r = guestfs_lstat (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "lstat");
-
- rv = copy_stat (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_statvfs (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("statvfs: used handle after closing it");
-
- const char *path = String_val (pathv);
- struct guestfs_statvfs *r;
-
- caml_enter_blocking_section ();
- r = guestfs_statvfs (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "statvfs");
-
- rv = copy_statvfs (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_tune2fs_l (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("tune2fs_l: used handle after closing it");
-
- const char *device = String_val (devicev);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_tune2fs_l (g, device);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "tune2fs_l");
-
- rv = copy_table (r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_setro (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_setro: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_setro (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_setro");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_setrw (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_setrw: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_setrw (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_setrw");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_getro (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_getro: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_getro (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_getro");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_getss (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_getss: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_getss (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_getss");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_getbsz (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_getbsz: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_getbsz (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_getbsz");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_setbsz (value gv, value devicev, value blocksizev)
-{
- CAMLparam3 (gv, devicev, blocksizev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_setbsz: used handle after closing it");
-
- const char *device = String_val (devicev);
- int blocksize = Int_val (blocksizev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_setbsz (g, device, blocksize);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_setbsz");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_getsz (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_getsz: used handle after closing it");
-
- const char *device = String_val (devicev);
- int64_t r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_getsz (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_getsz");
-
- rv = caml_copy_int64 (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_getsize64 (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_getsize64: used handle after closing it");
-
- const char *device = String_val (devicev);
- int64_t r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_getsize64 (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_getsize64");
-
- rv = caml_copy_int64 (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_flushbufs (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_flushbufs: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_flushbufs (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_flushbufs");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_blockdev_rereadpt (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("blockdev_rereadpt: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_blockdev_rereadpt (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "blockdev_rereadpt");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_upload (value gv, value filenamev, value remotefilenamev)
-{
- CAMLparam3 (gv, filenamev, remotefilenamev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("upload: used handle after closing it");
-
- const char *filename = String_val (filenamev);
- const char *remotefilename = String_val (remotefilenamev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_upload (g, filename, remotefilename);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "upload");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_download (value gv, value remotefilenamev, value filenamev)
-{
- CAMLparam3 (gv, remotefilenamev, filenamev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("download: used handle after closing it");
-
- const char *remotefilename = String_val (remotefilenamev);
- const char *filename = String_val (filenamev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_download (g, remotefilename, filename);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "download");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_checksum (value gv, value csumtypev, value pathv)
-{
- CAMLparam3 (gv, csumtypev, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("checksum: used handle after closing it");
-
- const char *csumtype = String_val (csumtypev);
- const char *path = String_val (pathv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_checksum (g, csumtype, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "checksum");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_tar_in (value gv, value tarfilev, value directoryv)
-{
- CAMLparam3 (gv, tarfilev, directoryv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("tar_in: used handle after closing it");
-
- const char *tarfile = String_val (tarfilev);
- const char *directory = String_val (directoryv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_tar_in (g, tarfile, directory);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "tar_in");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_tar_out (value gv, value directoryv, value tarfilev)
-{
- CAMLparam3 (gv, directoryv, tarfilev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("tar_out: used handle after closing it");
-
- const char *directory = String_val (directoryv);
- const char *tarfile = String_val (tarfilev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_tar_out (g, directory, tarfile);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "tar_out");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_tgz_in (value gv, value tarballv, value directoryv)
-{
- CAMLparam3 (gv, tarballv, directoryv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("tgz_in: used handle after closing it");
-
- const char *tarball = String_val (tarballv);
- const char *directory = String_val (directoryv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_tgz_in (g, tarball, directory);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "tgz_in");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_tgz_out (value gv, value directoryv, value tarballv)
-{
- CAMLparam3 (gv, directoryv, tarballv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("tgz_out: used handle after closing it");
-
- const char *directory = String_val (directoryv);
- const char *tarball = String_val (tarballv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_tgz_out (g, directory, tarball);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "tgz_out");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mount_ro (value gv, value devicev, value mountpointv)
-{
- CAMLparam3 (gv, devicev, mountpointv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mount_ro: used handle after closing it");
-
- const char *device = String_val (devicev);
- const char *mountpoint = String_val (mountpointv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mount_ro (g, device, mountpoint);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mount_ro");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mount_options (value gv, value optionsv, value devicev, value mountpointv)
-{
- CAMLparam4 (gv, optionsv, devicev, mountpointv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mount_options: used handle after closing it");
-
- const char *options = String_val (optionsv);
- const char *device = String_val (devicev);
- const char *mountpoint = String_val (mountpointv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mount_options (g, options, device, mountpoint);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mount_options");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mount_vfs (value gv, value optionsv, value vfstypev, value devicev, value mountpointv)
-{
- CAMLparam5 (gv, optionsv, vfstypev, devicev, mountpointv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mount_vfs: used handle after closing it");
-
- const char *options = String_val (optionsv);
- const char *vfstype = String_val (vfstypev);
- const char *device = String_val (devicev);
- const char *mountpoint = String_val (mountpointv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mount_vfs");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_debug (value gv, value subcmdv, value extraargsv)
-{
- CAMLparam3 (gv, subcmdv, extraargsv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("debug: used handle after closing it");
-
- const char *subcmd = String_val (subcmdv);
- char **extraargs = ocaml_guestfs_strings_val (g, extraargsv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_debug (g, subcmd, extraargs);
- caml_leave_blocking_section ();
- ocaml_guestfs_free_strings (extraargs);
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "debug");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_lvremove (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("lvremove: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_lvremove (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "lvremove");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_vgremove (value gv, value vgnamev)
-{
- CAMLparam2 (gv, vgnamev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("vgremove: used handle after closing it");
-
- const char *vgname = String_val (vgnamev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_vgremove (g, vgname);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "vgremove");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_pvremove (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("pvremove: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_pvremove (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "pvremove");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_e2label (value gv, value devicev, value labelv)
-{
- CAMLparam3 (gv, devicev, labelv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_e2label: used handle after closing it");
-
- const char *device = String_val (devicev);
- const char *label = String_val (labelv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_e2label (g, device, label);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_e2label");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_get_e2label (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("get_e2label: used handle after closing it");
-
- const char *device = String_val (devicev);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_get_e2label (g, device);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "get_e2label");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_set_e2uuid (value gv, value devicev, value uuidv)
-{
- CAMLparam3 (gv, devicev, uuidv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("set_e2uuid: used handle after closing it");
-
- const char *device = String_val (devicev);
- const char *uuid = String_val (uuidv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_set_e2uuid (g, device, uuid);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "set_e2uuid");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_get_e2uuid (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("get_e2uuid: used handle after closing it");
-
- const char *device = String_val (devicev);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_get_e2uuid (g, device);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "get_e2uuid");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_fsck (value gv, value fstypev, value devicev)
-{
- CAMLparam3 (gv, fstypev, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("fsck: used handle after closing it");
-
- const char *fstype = String_val (fstypev);
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_fsck (g, fstype, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "fsck");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_zero (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("zero: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_zero (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "zero");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_grub_install (value gv, value rootv, value devicev)
-{
- CAMLparam3 (gv, rootv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("grub_install: used handle after closing it");
-
- const char *root = String_val (rootv);
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_grub_install (g, root, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "grub_install");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_cp (value gv, value srcv, value destv)
-{
- CAMLparam3 (gv, srcv, destv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("cp: used handle after closing it");
-
- const char *src = String_val (srcv);
- const char *dest = String_val (destv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_cp (g, src, dest);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "cp");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_cp_a (value gv, value srcv, value destv)
-{
- CAMLparam3 (gv, srcv, destv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("cp_a: used handle after closing it");
-
- const char *src = String_val (srcv);
- const char *dest = String_val (destv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_cp_a (g, src, dest);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "cp_a");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mv (value gv, value srcv, value destv)
-{
- CAMLparam3 (gv, srcv, destv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mv: used handle after closing it");
-
- const char *src = String_val (srcv);
- const char *dest = String_val (destv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mv (g, src, dest);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mv");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_drop_caches (value gv, value whattodropv)
-{
- CAMLparam2 (gv, whattodropv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("drop_caches: used handle after closing it");
-
- int whattodrop = Int_val (whattodropv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_drop_caches (g, whattodrop);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "drop_caches");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_dmesg (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("dmesg: used handle after closing it");
-
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_dmesg (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "dmesg");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_ping_daemon (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("ping_daemon: used handle after closing it");
-
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_ping_daemon (g);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "ping_daemon");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_equal (value gv, value file1v, value file2v)
-{
- CAMLparam3 (gv, file1v, file2v);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("equal: used handle after closing it");
-
- const char *file1 = String_val (file1v);
- const char *file2 = String_val (file2v);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_equal (g, file1, file2);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "equal");
-
- rv = Val_bool (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_strings (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("strings: used handle after closing it");
-
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_strings (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "strings");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_strings_e (value gv, value encodingv, value pathv)
-{
- CAMLparam3 (gv, encodingv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("strings_e: used handle after closing it");
-
- const char *encoding = String_val (encodingv);
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_strings_e (g, encoding, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "strings_e");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_hexdump (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("hexdump: used handle after closing it");
-
- const char *path = String_val (pathv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_hexdump (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "hexdump");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_zerofree (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("zerofree: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_zerofree (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "zerofree");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_pvresize (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("pvresize: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_pvresize (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "pvresize");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sfdisk_N (value gv, value devicev, value partnumv, value cylsv, value headsv, value sectorsv, value linev)
-{
- CAMLparam5 (gv, devicev, partnumv, cylsv, headsv);
- CAMLxparam2 (sectorsv, linev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("sfdisk_N: used handle after closing it");
-
- const char *device = String_val (devicev);
- int partnum = Int_val (partnumv);
- int cyls = Int_val (cylsv);
- int heads = Int_val (headsv);
- int sectors = Int_val (sectorsv);
- const char *line = String_val (linev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "sfdisk_N");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sfdisk_N_byte (value *argv, int argn)
-{
- return ocaml_guestfs_sfdisk_N (argv[0], argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
-}
-
-CAMLprim value
-ocaml_guestfs_sfdisk_l (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("sfdisk_l: used handle after closing it");
-
- const char *device = String_val (devicev);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_sfdisk_l (g, device);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "sfdisk_l");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sfdisk_kernel_geometry (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("sfdisk_kernel_geometry: used handle after closing it");
-
- const char *device = String_val (devicev);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_sfdisk_kernel_geometry (g, device);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "sfdisk_kernel_geometry");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sfdisk_disk_geometry (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("sfdisk_disk_geometry: used handle after closing it");
-
- const char *device = String_val (devicev);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_sfdisk_disk_geometry (g, device);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "sfdisk_disk_geometry");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_vg_activate_all (value gv, value activatev)
-{
- CAMLparam2 (gv, activatev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("vg_activate_all: used handle after closing it");
-
- int activate = Bool_val (activatev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_vg_activate_all (g, activate);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "vg_activate_all");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_vg_activate (value gv, value activatev, value volgroupsv)
-{
- CAMLparam3 (gv, activatev, volgroupsv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("vg_activate: used handle after closing it");
-
- int activate = Bool_val (activatev);
- char **volgroups = ocaml_guestfs_strings_val (g, volgroupsv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_vg_activate (g, activate, volgroups);
- caml_leave_blocking_section ();
- ocaml_guestfs_free_strings (volgroups);
- if (r == -1)
- ocaml_guestfs_raise_error (g, "vg_activate");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_lvresize (value gv, value devicev, value mbytesv)
-{
- CAMLparam3 (gv, devicev, mbytesv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("lvresize: used handle after closing it");
-
- const char *device = String_val (devicev);
- int mbytes = Int_val (mbytesv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_lvresize (g, device, mbytes);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "lvresize");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_resize2fs (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("resize2fs: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_resize2fs (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "resize2fs");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_find (value gv, value directoryv)
-{
- CAMLparam2 (gv, directoryv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("find: used handle after closing it");
-
- const char *directory = String_val (directoryv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_find (g, directory);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "find");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_e2fsck_f (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("e2fsck_f: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_e2fsck_f (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "e2fsck_f");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sleep (value gv, value secsv)
-{
- CAMLparam2 (gv, secsv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("sleep: used handle after closing it");
-
- int secs = Int_val (secsv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_sleep (g, secs);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "sleep");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_ntfs_3g_probe (value gv, value rwv, value devicev)
-{
- CAMLparam3 (gv, rwv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("ntfs_3g_probe: used handle after closing it");
-
- int rw = Bool_val (rwv);
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_ntfs_3g_probe (g, rw, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "ntfs_3g_probe");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sh (value gv, value commandv)
-{
- CAMLparam2 (gv, commandv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("sh: used handle after closing it");
-
- const char *command = String_val (commandv);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_sh (g, command);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "sh");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_sh_lines (value gv, value commandv)
-{
- CAMLparam2 (gv, commandv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("sh_lines: used handle after closing it");
-
- const char *command = String_val (commandv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_sh_lines (g, command);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "sh_lines");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_glob_expand (value gv, value patternv)
-{
- CAMLparam2 (gv, patternv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("glob_expand: used handle after closing it");
-
- const char *pattern = String_val (patternv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_glob_expand (g, pattern);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "glob_expand");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_scrub_device (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("scrub_device: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_scrub_device (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "scrub_device");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_scrub_file (value gv, value filev)
-{
- CAMLparam2 (gv, filev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("scrub_file: used handle after closing it");
-
- const char *file = String_val (filev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_scrub_file (g, file);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "scrub_file");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_scrub_freespace (value gv, value dirv)
-{
- CAMLparam2 (gv, dirv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("scrub_freespace: used handle after closing it");
-
- const char *dir = String_val (dirv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_scrub_freespace (g, dir);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "scrub_freespace");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mkdtemp (value gv, value templatev)
-{
- CAMLparam2 (gv, templatev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mkdtemp: used handle after closing it");
-
- const char *template = String_val (templatev);
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_mkdtemp (g, template);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "mkdtemp");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_wc_l (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("wc_l: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_wc_l (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "wc_l");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_wc_w (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("wc_w: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_wc_w (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "wc_w");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_wc_c (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("wc_c: used handle after closing it");
-
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_wc_c (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "wc_c");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_head (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("head: used handle after closing it");
-
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_head (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "head");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_head_n (value gv, value nrlinesv, value pathv)
-{
- CAMLparam3 (gv, nrlinesv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("head_n: used handle after closing it");
-
- int nrlines = Int_val (nrlinesv);
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_head_n (g, nrlines, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "head_n");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_tail (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("tail: used handle after closing it");
-
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_tail (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "tail");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_tail_n (value gv, value nrlinesv, value pathv)
-{
- CAMLparam3 (gv, nrlinesv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("tail_n: used handle after closing it");
-
- int nrlines = Int_val (nrlinesv);
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_tail_n (g, nrlines, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "tail_n");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_df (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("df: used handle after closing it");
-
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_df (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "df");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_df_h (value gv)
-{
- CAMLparam1 (gv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("df_h: used handle after closing it");
-
- char *r;
-
- caml_enter_blocking_section ();
- r = guestfs_df_h (g);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "df_h");
-
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_du (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("du: used handle after closing it");
-
- const char *path = String_val (pathv);
- int64_t r;
-
- caml_enter_blocking_section ();
- r = guestfs_du (g, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "du");
-
- rv = caml_copy_int64 (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_initrd_list (value gv, value pathv)
-{
- CAMLparam2 (gv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("initrd_list: used handle after closing it");
-
- const char *path = String_val (pathv);
- int i;
- char **r;
-
- caml_enter_blocking_section ();
- r = guestfs_initrd_list (g, path);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "initrd_list");
-
- rv = caml_copy_string_array ((const char **) r);
- for (i = 0; r[i] != NULL; ++i) free (r[i]);
- free (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mount_loop (value gv, value filev, value mountpointv)
-{
- CAMLparam3 (gv, filev, mountpointv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mount_loop: used handle after closing it");
-
- const char *file = String_val (filev);
- const char *mountpoint = String_val (mountpointv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mount_loop (g, file, mountpoint);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mount_loop");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mkswap (value gv, value devicev)
-{
- CAMLparam2 (gv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mkswap: used handle after closing it");
-
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mkswap (g, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mkswap");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mkswap_L (value gv, value labelv, value devicev)
-{
- CAMLparam3 (gv, labelv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mkswap_L: used handle after closing it");
-
- const char *label = String_val (labelv);
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mkswap_L (g, label, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mkswap_L");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mkswap_U (value gv, value uuidv, value devicev)
-{
- CAMLparam3 (gv, uuidv, devicev);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mkswap_U: used handle after closing it");
-
- const char *uuid = String_val (uuidv);
- const char *device = String_val (devicev);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mkswap_U (g, uuid, device);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mkswap_U");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mknod (value gv, value modev, value devmajorv, value devminorv, value pathv)
-{
- CAMLparam5 (gv, modev, devmajorv, devminorv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mknod: used handle after closing it");
-
- int mode = Int_val (modev);
- int devmajor = Int_val (devmajorv);
- int devminor = Int_val (devminorv);
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mknod (g, mode, devmajor, devminor, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mknod");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mkfifo (value gv, value modev, value pathv)
-{
- CAMLparam3 (gv, modev, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mkfifo: used handle after closing it");
-
- int mode = Int_val (modev);
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mkfifo (g, mode, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mkfifo");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mknod_b (value gv, value modev, value devmajorv, value devminorv, value pathv)
-{
- CAMLparam5 (gv, modev, devmajorv, devminorv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mknod_b: used handle after closing it");
-
- int mode = Int_val (modev);
- int devmajor = Int_val (devmajorv);
- int devminor = Int_val (devminorv);
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mknod_b (g, mode, devmajor, devminor, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mknod_b");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_mknod_c (value gv, value modev, value devmajorv, value devminorv, value pathv)
-{
- CAMLparam5 (gv, modev, devmajorv, devminorv, pathv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("mknod_c: used handle after closing it");
-
- int mode = Int_val (modev);
- int devmajor = Int_val (devmajorv);
- int devminor = Int_val (devminorv);
- const char *path = String_val (pathv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_mknod_c (g, mode, devmajor, devminor, path);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "mknod_c");
-
- rv = Val_unit;
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_umask (value gv, value maskv)
-{
- CAMLparam2 (gv, maskv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("umask: used handle after closing it");
-
- int mask = Int_val (maskv);
- int r;
-
- caml_enter_blocking_section ();
- r = guestfs_umask (g, mask);
- caml_leave_blocking_section ();
- if (r == -1)
- ocaml_guestfs_raise_error (g, "umask");
-
- rv = Val_int (r);
- CAMLreturn (rv);
-}
-
-CAMLprim value
-ocaml_guestfs_readdir (value gv, value dirv)
-{
- CAMLparam2 (gv, dirv);
- CAMLlocal1 (rv);
-
- guestfs_h *g = Guestfs_val (gv);
- if (g == NULL)
- caml_failwith ("readdir: used handle after closing it");
-
- const char *dir = String_val (dirv);
- struct guestfs_dirent_list *r;
-
- caml_enter_blocking_section ();
- r = guestfs_readdir (g, dir);
- caml_leave_blocking_section ();
- if (r == NULL)
- ocaml_guestfs_raise_error (g, "readdir");
-
- rv = copy_dirent_list (r);
- guestfs_free_dirent_list (r);
- CAMLreturn (rv);
-}
-
+++ /dev/null
-/* 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 "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include <guestfs.h>
-
-#ifndef PRId64
-#define PRId64 "lld"
-#endif
-
-static SV *
-my_newSVll(long long val) {
-#ifdef USE_64_BIT_ALL
- return newSViv(val);
-#else
- char buf[100];
- int len;
- len = snprintf(buf, 100, "%" PRId64, val);
- return newSVpv(buf, len);
-#endif
-}
-
-#ifndef PRIu64
-#define PRIu64 "llu"
-#endif
-
-static SV *
-my_newSVull(unsigned long long val) {
-#ifdef USE_64_BIT_ALL
- return newSVuv(val);
-#else
- char buf[100];
- int len;
- len = snprintf(buf, 100, "%" PRIu64, val);
- return newSVpv(buf, len);
-#endif
-}
-
-/* http://www.perlmonks.org/?node_id=680842 */
-static char **
-XS_unpack_charPtrPtr (SV *arg) {
- char **ret;
- AV *av;
- I32 i;
-
- if (!arg || !SvOK (arg) || !SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV)
- croak ("array reference expected");
-
- av = (AV *)SvRV (arg);
- ret = malloc ((av_len (av) + 1 + 1) * sizeof (char *));
- if (!ret)
- croak ("malloc failed");
-
- for (i = 0; i <= av_len (av); i++) {
- SV **elem = av_fetch (av, i, 0);
-
- if (!elem || !*elem)
- croak ("missing element in list");
-
- ret[i] = SvPV_nolen (*elem);
- }
-
- ret[i] = NULL;
-
- return ret;
-}
-
-MODULE = Sys::Guestfs PACKAGE = Sys::Guestfs
-
-PROTOTYPES: ENABLE
-
-guestfs_h *
-_create ()
- CODE:
- RETVAL = guestfs_create ();
- if (!RETVAL)
- croak ("could not create guestfs handle");
- guestfs_set_error_handler (RETVAL, NULL, NULL);
- OUTPUT:
- RETVAL
-
-void
-DESTROY (g)
- guestfs_h *g;
- PPCODE:
- guestfs_close (g);
-
-void
-test0 (g, str, optstr, strlist, b, integer, filein, fileout)
- guestfs_h *g;
- char *str;
- char *optstr = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL;
- char **strlist;
- int b;
- int integer;
- char *filein;
- char *fileout;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout);
- free (strlist);
- if (r == -1)
- croak ("test0: %s", guestfs_last_error (g));
-
-SV *
-test0rint (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- int valout;
- CODE:
- valout = guestfs_test0rint (g, val);
- if (valout == -1)
- croak ("test0rint: %s", guestfs_last_error (g));
- RETVAL = newSViv (valout);
- OUTPUT:
- RETVAL
-
-SV *
-test0rinterr (g)
- guestfs_h *g;
-PREINIT:
- int valout;
- CODE:
- valout = guestfs_test0rinterr (g);
- if (valout == -1)
- croak ("test0rinterr: %s", guestfs_last_error (g));
- RETVAL = newSViv (valout);
- OUTPUT:
- RETVAL
-
-SV *
-test0rint64 (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- int64_t valout;
- CODE:
- valout = guestfs_test0rint64 (g, val);
- if (valout == -1)
- croak ("test0rint64: %s", guestfs_last_error (g));
- RETVAL = my_newSVll (valout);
- OUTPUT:
- RETVAL
-
-SV *
-test0rint64err (g)
- guestfs_h *g;
-PREINIT:
- int64_t valout;
- CODE:
- valout = guestfs_test0rint64err (g);
- if (valout == -1)
- croak ("test0rint64err: %s", guestfs_last_error (g));
- RETVAL = my_newSVll (valout);
- OUTPUT:
- RETVAL
-
-SV *
-test0rbool (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- int valout;
- CODE:
- valout = guestfs_test0rbool (g, val);
- if (valout == -1)
- croak ("test0rbool: %s", guestfs_last_error (g));
- RETVAL = newSViv (valout);
- OUTPUT:
- RETVAL
-
-SV *
-test0rboolerr (g)
- guestfs_h *g;
-PREINIT:
- int valout;
- CODE:
- valout = guestfs_test0rboolerr (g);
- if (valout == -1)
- croak ("test0rboolerr: %s", guestfs_last_error (g));
- RETVAL = newSViv (valout);
- OUTPUT:
- RETVAL
-
-SV *
-test0rconststring (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- const char *valout;
- CODE:
- valout = guestfs_test0rconststring (g, val);
- if (valout == NULL)
- croak ("test0rconststring: %s", guestfs_last_error (g));
- RETVAL = newSVpv (valout, 0);
- OUTPUT:
- RETVAL
-
-SV *
-test0rconststringerr (g)
- guestfs_h *g;
-PREINIT:
- const char *valout;
- CODE:
- valout = guestfs_test0rconststringerr (g);
- if (valout == NULL)
- croak ("test0rconststringerr: %s", guestfs_last_error (g));
- RETVAL = newSVpv (valout, 0);
- OUTPUT:
- RETVAL
-
-SV *
-test0rstring (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- char *valout;
- CODE:
- valout = guestfs_test0rstring (g, val);
- if (valout == NULL)
- croak ("test0rstring: %s", guestfs_last_error (g));
- RETVAL = newSVpv (valout, 0);
- free (valout);
- OUTPUT:
- RETVAL
-
-SV *
-test0rstringerr (g)
- guestfs_h *g;
-PREINIT:
- char *valout;
- CODE:
- valout = guestfs_test0rstringerr (g);
- if (valout == NULL)
- croak ("test0rstringerr: %s", guestfs_last_error (g));
- RETVAL = newSVpv (valout, 0);
- free (valout);
- OUTPUT:
- RETVAL
-
-void
-test0rstringlist (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- char **valout;
- int i, n;
- PPCODE:
- valout = guestfs_test0rstringlist (g, val);
- if (valout == NULL)
- croak ("test0rstringlist: %s", guestfs_last_error (g));
- for (n = 0; valout[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (valout[i], 0)));
- free (valout[i]);
- }
- free (valout);
-
-void
-test0rstringlisterr (g)
- guestfs_h *g;
-PREINIT:
- char **valout;
- int i, n;
- PPCODE:
- valout = guestfs_test0rstringlisterr (g);
- if (valout == NULL)
- croak ("test0rstringlisterr: %s", guestfs_last_error (g));
- for (n = 0; valout[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (valout[i], 0)));
- free (valout[i]);
- }
- free (valout);
-
-void
-test0rintbool (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- struct guestfs_int_bool *r;
- PPCODE:
- r = guestfs_test0rintbool (g, val);
- if (r == NULL)
- croak ("test0rintbool: %s", guestfs_last_error (g));
- EXTEND (SP, 2);
- PUSHs (sv_2mortal (newSViv (r->i)));
- PUSHs (sv_2mortal (newSViv (r->b)));
- guestfs_free_int_bool (r);
-
-void
-test0rintboolerr (g)
- guestfs_h *g;
-PREINIT:
- struct guestfs_int_bool *r;
- PPCODE:
- r = guestfs_test0rintboolerr (g);
- if (r == NULL)
- croak ("test0rintboolerr: %s", guestfs_last_error (g));
- EXTEND (SP, 2);
- PUSHs (sv_2mortal (newSViv (r->i)));
- PUSHs (sv_2mortal (newSViv (r->b)));
- guestfs_free_int_bool (r);
-
-void
-test0rpvlist (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- struct guestfs_lvm_pv_list *valout;
- int i;
- HV *hv;
- PPCODE:
- valout = guestfs_test0rpvlist (g, val);
- if (valout == NULL)
- croak ("test0rpvlist: %s", guestfs_last_error (g));
- EXTEND (SP, valout->len);
- for (i = 0; i < valout->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "pv_name", 7, newSVpv (valout->val[i].pv_name, 0), 0);
- (void) hv_store (hv, "pv_uuid", 7, newSVpv (valout->val[i].pv_uuid, 32), 0);
- (void) hv_store (hv, "pv_fmt", 6, newSVpv (valout->val[i].pv_fmt, 0), 0);
- (void) hv_store (hv, "pv_size", 7, my_newSVull (valout->val[i].pv_size), 0);
- (void) hv_store (hv, "dev_size", 8, my_newSVull (valout->val[i].dev_size), 0);
- (void) hv_store (hv, "pv_free", 7, my_newSVull (valout->val[i].pv_free), 0);
- (void) hv_store (hv, "pv_used", 7, my_newSVull (valout->val[i].pv_used), 0);
- (void) hv_store (hv, "pv_attr", 7, newSVpv (valout->val[i].pv_attr, 0), 0);
- (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (valout->val[i].pv_pe_count), 0);
- (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (valout->val[i].pv_pe_alloc_count), 0);
- (void) hv_store (hv, "pv_tags", 7, newSVpv (valout->val[i].pv_tags, 0), 0);
- (void) hv_store (hv, "pe_start", 8, my_newSVull (valout->val[i].pe_start), 0);
- (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (valout->val[i].pv_mda_count), 0);
- (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (valout->val[i].pv_mda_free), 0);
- PUSHs (sv_2mortal (newRV ((SV *) hv)));
- }
- guestfs_free_lvm_pv_list (valout);
-
-void
-test0rpvlisterr (g)
- guestfs_h *g;
-PREINIT:
- struct guestfs_lvm_pv_list *valout;
- int i;
- HV *hv;
- PPCODE:
- valout = guestfs_test0rpvlisterr (g);
- if (valout == NULL)
- croak ("test0rpvlisterr: %s", guestfs_last_error (g));
- EXTEND (SP, valout->len);
- for (i = 0; i < valout->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "pv_name", 7, newSVpv (valout->val[i].pv_name, 0), 0);
- (void) hv_store (hv, "pv_uuid", 7, newSVpv (valout->val[i].pv_uuid, 32), 0);
- (void) hv_store (hv, "pv_fmt", 6, newSVpv (valout->val[i].pv_fmt, 0), 0);
- (void) hv_store (hv, "pv_size", 7, my_newSVull (valout->val[i].pv_size), 0);
- (void) hv_store (hv, "dev_size", 8, my_newSVull (valout->val[i].dev_size), 0);
- (void) hv_store (hv, "pv_free", 7, my_newSVull (valout->val[i].pv_free), 0);
- (void) hv_store (hv, "pv_used", 7, my_newSVull (valout->val[i].pv_used), 0);
- (void) hv_store (hv, "pv_attr", 7, newSVpv (valout->val[i].pv_attr, 0), 0);
- (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (valout->val[i].pv_pe_count), 0);
- (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (valout->val[i].pv_pe_alloc_count), 0);
- (void) hv_store (hv, "pv_tags", 7, newSVpv (valout->val[i].pv_tags, 0), 0);
- (void) hv_store (hv, "pe_start", 8, my_newSVull (valout->val[i].pe_start), 0);
- (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (valout->val[i].pv_mda_count), 0);
- (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (valout->val[i].pv_mda_free), 0);
- PUSHs (sv_2mortal (newRV ((SV *) hv)));
- }
- guestfs_free_lvm_pv_list (valout);
-
-void
-test0rvglist (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- struct guestfs_lvm_vg_list *valout;
- int i;
- HV *hv;
- PPCODE:
- valout = guestfs_test0rvglist (g, val);
- if (valout == NULL)
- croak ("test0rvglist: %s", guestfs_last_error (g));
- EXTEND (SP, valout->len);
- for (i = 0; i < valout->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "vg_name", 7, newSVpv (valout->val[i].vg_name, 0), 0);
- (void) hv_store (hv, "vg_uuid", 7, newSVpv (valout->val[i].vg_uuid, 32), 0);
- (void) hv_store (hv, "vg_fmt", 6, newSVpv (valout->val[i].vg_fmt, 0), 0);
- (void) hv_store (hv, "vg_attr", 7, newSVpv (valout->val[i].vg_attr, 0), 0);
- (void) hv_store (hv, "vg_size", 7, my_newSVull (valout->val[i].vg_size), 0);
- (void) hv_store (hv, "vg_free", 7, my_newSVull (valout->val[i].vg_free), 0);
- (void) hv_store (hv, "vg_sysid", 8, newSVpv (valout->val[i].vg_sysid, 0), 0);
- (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (valout->val[i].vg_extent_size), 0);
- (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (valout->val[i].vg_extent_count), 0);
- (void) hv_store (hv, "vg_free_count", 13, my_newSVll (valout->val[i].vg_free_count), 0);
- (void) hv_store (hv, "max_lv", 6, my_newSVll (valout->val[i].max_lv), 0);
- (void) hv_store (hv, "max_pv", 6, my_newSVll (valout->val[i].max_pv), 0);
- (void) hv_store (hv, "pv_count", 8, my_newSVll (valout->val[i].pv_count), 0);
- (void) hv_store (hv, "lv_count", 8, my_newSVll (valout->val[i].lv_count), 0);
- (void) hv_store (hv, "snap_count", 10, my_newSVll (valout->val[i].snap_count), 0);
- (void) hv_store (hv, "vg_seqno", 8, my_newSVll (valout->val[i].vg_seqno), 0);
- (void) hv_store (hv, "vg_tags", 7, newSVpv (valout->val[i].vg_tags, 0), 0);
- (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (valout->val[i].vg_mda_count), 0);
- (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (valout->val[i].vg_mda_free), 0);
- PUSHs (sv_2mortal (newRV ((SV *) hv)));
- }
- guestfs_free_lvm_vg_list (valout);
-
-void
-test0rvglisterr (g)
- guestfs_h *g;
-PREINIT:
- struct guestfs_lvm_vg_list *valout;
- int i;
- HV *hv;
- PPCODE:
- valout = guestfs_test0rvglisterr (g);
- if (valout == NULL)
- croak ("test0rvglisterr: %s", guestfs_last_error (g));
- EXTEND (SP, valout->len);
- for (i = 0; i < valout->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "vg_name", 7, newSVpv (valout->val[i].vg_name, 0), 0);
- (void) hv_store (hv, "vg_uuid", 7, newSVpv (valout->val[i].vg_uuid, 32), 0);
- (void) hv_store (hv, "vg_fmt", 6, newSVpv (valout->val[i].vg_fmt, 0), 0);
- (void) hv_store (hv, "vg_attr", 7, newSVpv (valout->val[i].vg_attr, 0), 0);
- (void) hv_store (hv, "vg_size", 7, my_newSVull (valout->val[i].vg_size), 0);
- (void) hv_store (hv, "vg_free", 7, my_newSVull (valout->val[i].vg_free), 0);
- (void) hv_store (hv, "vg_sysid", 8, newSVpv (valout->val[i].vg_sysid, 0), 0);
- (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (valout->val[i].vg_extent_size), 0);
- (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (valout->val[i].vg_extent_count), 0);
- (void) hv_store (hv, "vg_free_count", 13, my_newSVll (valout->val[i].vg_free_count), 0);
- (void) hv_store (hv, "max_lv", 6, my_newSVll (valout->val[i].max_lv), 0);
- (void) hv_store (hv, "max_pv", 6, my_newSVll (valout->val[i].max_pv), 0);
- (void) hv_store (hv, "pv_count", 8, my_newSVll (valout->val[i].pv_count), 0);
- (void) hv_store (hv, "lv_count", 8, my_newSVll (valout->val[i].lv_count), 0);
- (void) hv_store (hv, "snap_count", 10, my_newSVll (valout->val[i].snap_count), 0);
- (void) hv_store (hv, "vg_seqno", 8, my_newSVll (valout->val[i].vg_seqno), 0);
- (void) hv_store (hv, "vg_tags", 7, newSVpv (valout->val[i].vg_tags, 0), 0);
- (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (valout->val[i].vg_mda_count), 0);
- (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (valout->val[i].vg_mda_free), 0);
- PUSHs (sv_2mortal (newRV ((SV *) hv)));
- }
- guestfs_free_lvm_vg_list (valout);
-
-void
-test0rlvlist (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- struct guestfs_lvm_lv_list *valout;
- int i;
- HV *hv;
- PPCODE:
- valout = guestfs_test0rlvlist (g, val);
- if (valout == NULL)
- croak ("test0rlvlist: %s", guestfs_last_error (g));
- EXTEND (SP, valout->len);
- for (i = 0; i < valout->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "lv_name", 7, newSVpv (valout->val[i].lv_name, 0), 0);
- (void) hv_store (hv, "lv_uuid", 7, newSVpv (valout->val[i].lv_uuid, 32), 0);
- (void) hv_store (hv, "lv_attr", 7, newSVpv (valout->val[i].lv_attr, 0), 0);
- (void) hv_store (hv, "lv_major", 8, my_newSVll (valout->val[i].lv_major), 0);
- (void) hv_store (hv, "lv_minor", 8, my_newSVll (valout->val[i].lv_minor), 0);
- (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (valout->val[i].lv_kernel_major), 0);
- (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (valout->val[i].lv_kernel_minor), 0);
- (void) hv_store (hv, "lv_size", 7, my_newSVull (valout->val[i].lv_size), 0);
- (void) hv_store (hv, "seg_count", 9, my_newSVll (valout->val[i].seg_count), 0);
- (void) hv_store (hv, "origin", 6, newSVpv (valout->val[i].origin, 0), 0);
- (void) hv_store (hv, "snap_percent", 12, newSVnv (valout->val[i].snap_percent), 0);
- (void) hv_store (hv, "copy_percent", 12, newSVnv (valout->val[i].copy_percent), 0);
- (void) hv_store (hv, "move_pv", 7, newSVpv (valout->val[i].move_pv, 0), 0);
- (void) hv_store (hv, "lv_tags", 7, newSVpv (valout->val[i].lv_tags, 0), 0);
- (void) hv_store (hv, "mirror_log", 10, newSVpv (valout->val[i].mirror_log, 0), 0);
- (void) hv_store (hv, "modules", 7, newSVpv (valout->val[i].modules, 0), 0);
- PUSHs (sv_2mortal (newRV ((SV *) hv)));
- }
- guestfs_free_lvm_lv_list (valout);
-
-void
-test0rlvlisterr (g)
- guestfs_h *g;
-PREINIT:
- struct guestfs_lvm_lv_list *valout;
- int i;
- HV *hv;
- PPCODE:
- valout = guestfs_test0rlvlisterr (g);
- if (valout == NULL)
- croak ("test0rlvlisterr: %s", guestfs_last_error (g));
- EXTEND (SP, valout->len);
- for (i = 0; i < valout->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "lv_name", 7, newSVpv (valout->val[i].lv_name, 0), 0);
- (void) hv_store (hv, "lv_uuid", 7, newSVpv (valout->val[i].lv_uuid, 32), 0);
- (void) hv_store (hv, "lv_attr", 7, newSVpv (valout->val[i].lv_attr, 0), 0);
- (void) hv_store (hv, "lv_major", 8, my_newSVll (valout->val[i].lv_major), 0);
- (void) hv_store (hv, "lv_minor", 8, my_newSVll (valout->val[i].lv_minor), 0);
- (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (valout->val[i].lv_kernel_major), 0);
- (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (valout->val[i].lv_kernel_minor), 0);
- (void) hv_store (hv, "lv_size", 7, my_newSVull (valout->val[i].lv_size), 0);
- (void) hv_store (hv, "seg_count", 9, my_newSVll (valout->val[i].seg_count), 0);
- (void) hv_store (hv, "origin", 6, newSVpv (valout->val[i].origin, 0), 0);
- (void) hv_store (hv, "snap_percent", 12, newSVnv (valout->val[i].snap_percent), 0);
- (void) hv_store (hv, "copy_percent", 12, newSVnv (valout->val[i].copy_percent), 0);
- (void) hv_store (hv, "move_pv", 7, newSVpv (valout->val[i].move_pv, 0), 0);
- (void) hv_store (hv, "lv_tags", 7, newSVpv (valout->val[i].lv_tags, 0), 0);
- (void) hv_store (hv, "mirror_log", 10, newSVpv (valout->val[i].mirror_log, 0), 0);
- (void) hv_store (hv, "modules", 7, newSVpv (valout->val[i].modules, 0), 0);
- PUSHs (sv_2mortal (newRV ((SV *) hv)));
- }
- guestfs_free_lvm_lv_list (valout);
-
-void
-test0rstat (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- struct guestfs_stat *valout;
- PPCODE:
- valout = guestfs_test0rstat (g, val);
- if (valout == NULL)
- croak ("test0rstat: %s", guestfs_last_error (g));
- EXTEND (SP, 13);
- PUSHs (sv_2mortal (my_newSVll (valout->dev)));
- PUSHs (sv_2mortal (my_newSVll (valout->ino)));
- PUSHs (sv_2mortal (my_newSVll (valout->mode)));
- PUSHs (sv_2mortal (my_newSVll (valout->nlink)));
- PUSHs (sv_2mortal (my_newSVll (valout->uid)));
- PUSHs (sv_2mortal (my_newSVll (valout->gid)));
- PUSHs (sv_2mortal (my_newSVll (valout->rdev)));
- PUSHs (sv_2mortal (my_newSVll (valout->size)));
- PUSHs (sv_2mortal (my_newSVll (valout->blksize)));
- PUSHs (sv_2mortal (my_newSVll (valout->blocks)));
- PUSHs (sv_2mortal (my_newSVll (valout->atime)));
- PUSHs (sv_2mortal (my_newSVll (valout->mtime)));
- PUSHs (sv_2mortal (my_newSVll (valout->ctime)));
- free (valout);
-
-void
-test0rstaterr (g)
- guestfs_h *g;
-PREINIT:
- struct guestfs_stat *valout;
- PPCODE:
- valout = guestfs_test0rstaterr (g);
- if (valout == NULL)
- croak ("test0rstaterr: %s", guestfs_last_error (g));
- EXTEND (SP, 13);
- PUSHs (sv_2mortal (my_newSVll (valout->dev)));
- PUSHs (sv_2mortal (my_newSVll (valout->ino)));
- PUSHs (sv_2mortal (my_newSVll (valout->mode)));
- PUSHs (sv_2mortal (my_newSVll (valout->nlink)));
- PUSHs (sv_2mortal (my_newSVll (valout->uid)));
- PUSHs (sv_2mortal (my_newSVll (valout->gid)));
- PUSHs (sv_2mortal (my_newSVll (valout->rdev)));
- PUSHs (sv_2mortal (my_newSVll (valout->size)));
- PUSHs (sv_2mortal (my_newSVll (valout->blksize)));
- PUSHs (sv_2mortal (my_newSVll (valout->blocks)));
- PUSHs (sv_2mortal (my_newSVll (valout->atime)));
- PUSHs (sv_2mortal (my_newSVll (valout->mtime)));
- PUSHs (sv_2mortal (my_newSVll (valout->ctime)));
- free (valout);
-
-void
-test0rstatvfs (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- struct guestfs_statvfs *valout;
- PPCODE:
- valout = guestfs_test0rstatvfs (g, val);
- if (valout == NULL)
- croak ("test0rstatvfs: %s", guestfs_last_error (g));
- EXTEND (SP, 11);
- PUSHs (sv_2mortal (my_newSVll (valout->bsize)));
- PUSHs (sv_2mortal (my_newSVll (valout->frsize)));
- PUSHs (sv_2mortal (my_newSVll (valout->blocks)));
- PUSHs (sv_2mortal (my_newSVll (valout->bfree)));
- PUSHs (sv_2mortal (my_newSVll (valout->bavail)));
- PUSHs (sv_2mortal (my_newSVll (valout->files)));
- PUSHs (sv_2mortal (my_newSVll (valout->ffree)));
- PUSHs (sv_2mortal (my_newSVll (valout->favail)));
- PUSHs (sv_2mortal (my_newSVll (valout->fsid)));
- PUSHs (sv_2mortal (my_newSVll (valout->flag)));
- PUSHs (sv_2mortal (my_newSVll (valout->namemax)));
- free (valout);
-
-void
-test0rstatvfserr (g)
- guestfs_h *g;
-PREINIT:
- struct guestfs_statvfs *valout;
- PPCODE:
- valout = guestfs_test0rstatvfserr (g);
- if (valout == NULL)
- croak ("test0rstatvfserr: %s", guestfs_last_error (g));
- EXTEND (SP, 11);
- PUSHs (sv_2mortal (my_newSVll (valout->bsize)));
- PUSHs (sv_2mortal (my_newSVll (valout->frsize)));
- PUSHs (sv_2mortal (my_newSVll (valout->blocks)));
- PUSHs (sv_2mortal (my_newSVll (valout->bfree)));
- PUSHs (sv_2mortal (my_newSVll (valout->bavail)));
- PUSHs (sv_2mortal (my_newSVll (valout->files)));
- PUSHs (sv_2mortal (my_newSVll (valout->ffree)));
- PUSHs (sv_2mortal (my_newSVll (valout->favail)));
- PUSHs (sv_2mortal (my_newSVll (valout->fsid)));
- PUSHs (sv_2mortal (my_newSVll (valout->flag)));
- PUSHs (sv_2mortal (my_newSVll (valout->namemax)));
- free (valout);
-
-void
-test0rhashtable (g, val)
- guestfs_h *g;
- char *val;
-PREINIT:
- char **valout;
- int i, n;
- PPCODE:
- valout = guestfs_test0rhashtable (g, val);
- if (valout == NULL)
- croak ("test0rhashtable: %s", guestfs_last_error (g));
- for (n = 0; valout[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (valout[i], 0)));
- free (valout[i]);
- }
- free (valout);
-
-void
-test0rhashtableerr (g)
- guestfs_h *g;
-PREINIT:
- char **valout;
- int i, n;
- PPCODE:
- valout = guestfs_test0rhashtableerr (g);
- if (valout == NULL)
- croak ("test0rhashtableerr: %s", guestfs_last_error (g));
- for (n = 0; valout[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (valout[i], 0)));
- free (valout[i]);
- }
- free (valout);
-
-void
-launch (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_launch (g);
- if (r == -1)
- croak ("launch: %s", guestfs_last_error (g));
-
-void
-wait_ready (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_wait_ready (g);
- if (r == -1)
- croak ("wait_ready: %s", guestfs_last_error (g));
-
-void
-kill_subprocess (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_kill_subprocess (g);
- if (r == -1)
- croak ("kill_subprocess: %s", guestfs_last_error (g));
-
-void
-add_drive (g, filename)
- guestfs_h *g;
- char *filename;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_add_drive (g, filename);
- if (r == -1)
- croak ("add_drive: %s", guestfs_last_error (g));
-
-void
-add_cdrom (g, filename)
- guestfs_h *g;
- char *filename;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_add_cdrom (g, filename);
- if (r == -1)
- croak ("add_cdrom: %s", guestfs_last_error (g));
-
-void
-add_drive_ro (g, filename)
- guestfs_h *g;
- char *filename;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_add_drive_ro (g, filename);
- if (r == -1)
- croak ("add_drive_ro: %s", guestfs_last_error (g));
-
-void
-config (g, qemuparam, qemuvalue)
- guestfs_h *g;
- char *qemuparam;
- char *qemuvalue = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_config (g, qemuparam, qemuvalue);
- if (r == -1)
- croak ("config: %s", guestfs_last_error (g));
-
-void
-set_qemu (g, qemu)
- guestfs_h *g;
- char *qemu;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_qemu (g, qemu);
- if (r == -1)
- croak ("set_qemu: %s", guestfs_last_error (g));
-
-SV *
-get_qemu (g)
- guestfs_h *g;
-PREINIT:
- const char *qemu;
- CODE:
- qemu = guestfs_get_qemu (g);
- if (qemu == NULL)
- croak ("get_qemu: %s", guestfs_last_error (g));
- RETVAL = newSVpv (qemu, 0);
- OUTPUT:
- RETVAL
-
-void
-set_path (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_path (g, path);
- if (r == -1)
- croak ("set_path: %s", guestfs_last_error (g));
-
-SV *
-get_path (g)
- guestfs_h *g;
-PREINIT:
- const char *path;
- CODE:
- path = guestfs_get_path (g);
- if (path == NULL)
- croak ("get_path: %s", guestfs_last_error (g));
- RETVAL = newSVpv (path, 0);
- OUTPUT:
- RETVAL
-
-void
-set_append (g, append)
- guestfs_h *g;
- char *append;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_append (g, append);
- if (r == -1)
- croak ("set_append: %s", guestfs_last_error (g));
-
-SV *
-get_append (g)
- guestfs_h *g;
-PREINIT:
- const char *append;
- CODE:
- append = guestfs_get_append (g);
- if (append == NULL)
- croak ("get_append: %s", guestfs_last_error (g));
- RETVAL = newSVpv (append, 0);
- OUTPUT:
- RETVAL
-
-void
-set_autosync (g, autosync)
- guestfs_h *g;
- int autosync;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_autosync (g, autosync);
- if (r == -1)
- croak ("set_autosync: %s", guestfs_last_error (g));
-
-SV *
-get_autosync (g)
- guestfs_h *g;
-PREINIT:
- int autosync;
- CODE:
- autosync = guestfs_get_autosync (g);
- if (autosync == -1)
- croak ("get_autosync: %s", guestfs_last_error (g));
- RETVAL = newSViv (autosync);
- OUTPUT:
- RETVAL
-
-void
-set_verbose (g, verbose)
- guestfs_h *g;
- int verbose;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_verbose (g, verbose);
- if (r == -1)
- croak ("set_verbose: %s", guestfs_last_error (g));
-
-SV *
-get_verbose (g)
- guestfs_h *g;
-PREINIT:
- int verbose;
- CODE:
- verbose = guestfs_get_verbose (g);
- if (verbose == -1)
- croak ("get_verbose: %s", guestfs_last_error (g));
- RETVAL = newSViv (verbose);
- OUTPUT:
- RETVAL
-
-SV *
-is_ready (g)
- guestfs_h *g;
-PREINIT:
- int ready;
- CODE:
- ready = guestfs_is_ready (g);
- if (ready == -1)
- croak ("is_ready: %s", guestfs_last_error (g));
- RETVAL = newSViv (ready);
- OUTPUT:
- RETVAL
-
-SV *
-is_config (g)
- guestfs_h *g;
-PREINIT:
- int config;
- CODE:
- config = guestfs_is_config (g);
- if (config == -1)
- croak ("is_config: %s", guestfs_last_error (g));
- RETVAL = newSViv (config);
- OUTPUT:
- RETVAL
-
-SV *
-is_launching (g)
- guestfs_h *g;
-PREINIT:
- int launching;
- CODE:
- launching = guestfs_is_launching (g);
- if (launching == -1)
- croak ("is_launching: %s", guestfs_last_error (g));
- RETVAL = newSViv (launching);
- OUTPUT:
- RETVAL
-
-SV *
-is_busy (g)
- guestfs_h *g;
-PREINIT:
- int busy;
- CODE:
- busy = guestfs_is_busy (g);
- if (busy == -1)
- croak ("is_busy: %s", guestfs_last_error (g));
- RETVAL = newSViv (busy);
- OUTPUT:
- RETVAL
-
-SV *
-get_state (g)
- guestfs_h *g;
-PREINIT:
- int state;
- CODE:
- state = guestfs_get_state (g);
- if (state == -1)
- croak ("get_state: %s", guestfs_last_error (g));
- RETVAL = newSViv (state);
- OUTPUT:
- RETVAL
-
-void
-set_busy (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_busy (g);
- if (r == -1)
- croak ("set_busy: %s", guestfs_last_error (g));
-
-void
-set_ready (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_ready (g);
- if (r == -1)
- croak ("set_ready: %s", guestfs_last_error (g));
-
-void
-end_busy (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_end_busy (g);
- if (r == -1)
- croak ("end_busy: %s", guestfs_last_error (g));
-
-void
-set_memsize (g, memsize)
- guestfs_h *g;
- int memsize;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_memsize (g, memsize);
- if (r == -1)
- croak ("set_memsize: %s", guestfs_last_error (g));
-
-SV *
-get_memsize (g)
- guestfs_h *g;
-PREINIT:
- int memsize;
- CODE:
- memsize = guestfs_get_memsize (g);
- if (memsize == -1)
- croak ("get_memsize: %s", guestfs_last_error (g));
- RETVAL = newSViv (memsize);
- OUTPUT:
- RETVAL
-
-void
-mount (g, device, mountpoint)
- guestfs_h *g;
- char *device;
- char *mountpoint;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- croak ("mount: %s", guestfs_last_error (g));
-
-void
-sync (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_sync (g);
- if (r == -1)
- croak ("sync: %s", guestfs_last_error (g));
-
-void
-touch (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_touch (g, path);
- if (r == -1)
- croak ("touch: %s", guestfs_last_error (g));
-
-SV *
-cat (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char *content;
- CODE:
- content = guestfs_cat (g, path);
- if (content == NULL)
- croak ("cat: %s", guestfs_last_error (g));
- RETVAL = newSVpv (content, 0);
- free (content);
- OUTPUT:
- RETVAL
-
-SV *
-ll (g, directory)
- guestfs_h *g;
- char *directory;
-PREINIT:
- char *listing;
- CODE:
- listing = guestfs_ll (g, directory);
- if (listing == NULL)
- croak ("ll: %s", guestfs_last_error (g));
- RETVAL = newSVpv (listing, 0);
- free (listing);
- OUTPUT:
- RETVAL
-
-void
-ls (g, directory)
- guestfs_h *g;
- char *directory;
-PREINIT:
- char **listing;
- int i, n;
- PPCODE:
- listing = guestfs_ls (g, directory);
- if (listing == NULL)
- croak ("ls: %s", guestfs_last_error (g));
- for (n = 0; listing[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
- free (listing[i]);
- }
- free (listing);
-
-void
-list_devices (g)
- guestfs_h *g;
-PREINIT:
- char **devices;
- int i, n;
- PPCODE:
- devices = guestfs_list_devices (g);
- if (devices == NULL)
- croak ("list_devices: %s", guestfs_last_error (g));
- for (n = 0; devices[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
- free (devices[i]);
- }
- free (devices);
-
-void
-list_partitions (g)
- guestfs_h *g;
-PREINIT:
- char **partitions;
- int i, n;
- PPCODE:
- partitions = guestfs_list_partitions (g);
- if (partitions == NULL)
- croak ("list_partitions: %s", guestfs_last_error (g));
- for (n = 0; partitions[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
- free (partitions[i]);
- }
- free (partitions);
-
-void
-pvs (g)
- guestfs_h *g;
-PREINIT:
- char **physvols;
- int i, n;
- PPCODE:
- physvols = guestfs_pvs (g);
- if (physvols == NULL)
- croak ("pvs: %s", guestfs_last_error (g));
- for (n = 0; physvols[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
- free (physvols[i]);
- }
- free (physvols);
-
-void
-vgs (g)
- guestfs_h *g;
-PREINIT:
- char **volgroups;
- int i, n;
- PPCODE:
- volgroups = guestfs_vgs (g);
- if (volgroups == NULL)
- croak ("vgs: %s", guestfs_last_error (g));
- for (n = 0; volgroups[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
- free (volgroups[i]);
- }
- free (volgroups);
-
-void
-lvs (g)
- guestfs_h *g;
-PREINIT:
- char **logvols;
- int i, n;
- PPCODE:
- logvols = guestfs_lvs (g);
- if (logvols == NULL)
- croak ("lvs: %s", guestfs_last_error (g));
- for (n = 0; logvols[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
- free (logvols[i]);
- }
- free (logvols);
-
-void
-pvs_full (g)
- guestfs_h *g;
-PREINIT:
- struct guestfs_lvm_pv_list *physvols;
- int i;
- HV *hv;
- PPCODE:
- physvols = guestfs_pvs_full (g);
- if (physvols == NULL)
- croak ("pvs_full: %s", guestfs_last_error (g));
- EXTEND (SP, physvols->len);
- for (i = 0; i < physvols->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
- (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
- (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
- (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
- (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
- (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
- (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
- (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
- (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
- (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
- (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
- (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
- (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
- (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
- PUSHs (sv_2mortal (newRV ((SV *) hv)));
- }
- guestfs_free_lvm_pv_list (physvols);
-
-void
-vgs_full (g)
- guestfs_h *g;
-PREINIT:
- struct guestfs_lvm_vg_list *volgroups;
- int i;
- HV *hv;
- PPCODE:
- volgroups = guestfs_vgs_full (g);
- if (volgroups == NULL)
- croak ("vgs_full: %s", guestfs_last_error (g));
- EXTEND (SP, volgroups->len);
- for (i = 0; i < volgroups->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
- (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
- (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
- (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
- (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
- (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
- (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
- (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
- (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
- (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
- (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
- (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
- (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
- (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
- (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
- (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
- (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
- (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
- (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
- PUSHs (sv_2mortal (newRV ((SV *) hv)));
- }
- guestfs_free_lvm_vg_list (volgroups);
-
-void
-lvs_full (g)
- guestfs_h *g;
-PREINIT:
- struct guestfs_lvm_lv_list *logvols;
- int i;
- HV *hv;
- PPCODE:
- logvols = guestfs_lvs_full (g);
- if (logvols == NULL)
- croak ("lvs_full: %s", guestfs_last_error (g));
- EXTEND (SP, logvols->len);
- for (i = 0; i < logvols->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
- (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
- (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
- (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
- (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
- (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
- (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
- (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
- (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
- (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
- (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
- (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
- (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
- (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
- (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
- (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
- PUSHs (sv_2mortal (newRV ((SV *) hv)));
- }
- guestfs_free_lvm_lv_list (logvols);
-
-void
-read_lines (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char **lines;
- int i, n;
- PPCODE:
- lines = guestfs_read_lines (g, path);
- if (lines == NULL)
- croak ("read_lines: %s", guestfs_last_error (g));
- for (n = 0; lines[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
- free (lines[i]);
- }
- free (lines);
-
-void
-aug_init (g, root, flags)
- guestfs_h *g;
- char *root;
- int flags;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_aug_init (g, root, flags);
- if (r == -1)
- croak ("aug_init: %s", guestfs_last_error (g));
-
-void
-aug_close (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_aug_close (g);
- if (r == -1)
- croak ("aug_close: %s", guestfs_last_error (g));
-
-SV *
-aug_defvar (g, name, expr)
- guestfs_h *g;
- char *name;
- char *expr = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL;
-PREINIT:
- int nrnodes;
- CODE:
- nrnodes = guestfs_aug_defvar (g, name, expr);
- if (nrnodes == -1)
- croak ("aug_defvar: %s", guestfs_last_error (g));
- RETVAL = newSViv (nrnodes);
- OUTPUT:
- RETVAL
-
-void
-aug_defnode (g, name, expr, val)
- guestfs_h *g;
- char *name;
- char *expr;
- char *val;
-PREINIT:
- struct guestfs_int_bool *r;
- PPCODE:
- r = guestfs_aug_defnode (g, name, expr, val);
- if (r == NULL)
- croak ("aug_defnode: %s", guestfs_last_error (g));
- EXTEND (SP, 2);
- PUSHs (sv_2mortal (newSViv (r->i)));
- PUSHs (sv_2mortal (newSViv (r->b)));
- guestfs_free_int_bool (r);
-
-SV *
-aug_get (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char *val;
- CODE:
- val = guestfs_aug_get (g, path);
- if (val == NULL)
- croak ("aug_get: %s", guestfs_last_error (g));
- RETVAL = newSVpv (val, 0);
- free (val);
- OUTPUT:
- RETVAL
-
-void
-aug_set (g, path, val)
- guestfs_h *g;
- char *path;
- char *val;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_aug_set (g, path, val);
- if (r == -1)
- croak ("aug_set: %s", guestfs_last_error (g));
-
-void
-aug_insert (g, path, label, before)
- guestfs_h *g;
- char *path;
- char *label;
- int before;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_aug_insert (g, path, label, before);
- if (r == -1)
- croak ("aug_insert: %s", guestfs_last_error (g));
-
-SV *
-aug_rm (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int nrnodes;
- CODE:
- nrnodes = guestfs_aug_rm (g, path);
- if (nrnodes == -1)
- croak ("aug_rm: %s", guestfs_last_error (g));
- RETVAL = newSViv (nrnodes);
- OUTPUT:
- RETVAL
-
-void
-aug_mv (g, src, dest)
- guestfs_h *g;
- char *src;
- char *dest;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_aug_mv (g, src, dest);
- if (r == -1)
- croak ("aug_mv: %s", guestfs_last_error (g));
-
-void
-aug_match (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char **matches;
- int i, n;
- PPCODE:
- matches = guestfs_aug_match (g, path);
- if (matches == NULL)
- croak ("aug_match: %s", guestfs_last_error (g));
- for (n = 0; matches[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
- free (matches[i]);
- }
- free (matches);
-
-void
-aug_save (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_aug_save (g);
- if (r == -1)
- croak ("aug_save: %s", guestfs_last_error (g));
-
-void
-aug_load (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_aug_load (g);
- if (r == -1)
- croak ("aug_load: %s", guestfs_last_error (g));
-
-void
-aug_ls (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char **matches;
- int i, n;
- PPCODE:
- matches = guestfs_aug_ls (g, path);
- if (matches == NULL)
- croak ("aug_ls: %s", guestfs_last_error (g));
- for (n = 0; matches[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
- free (matches[i]);
- }
- free (matches);
-
-void
-rm (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_rm (g, path);
- if (r == -1)
- croak ("rm: %s", guestfs_last_error (g));
-
-void
-rmdir (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_rmdir (g, path);
- if (r == -1)
- croak ("rmdir: %s", guestfs_last_error (g));
-
-void
-rm_rf (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_rm_rf (g, path);
- if (r == -1)
- croak ("rm_rf: %s", guestfs_last_error (g));
-
-void
-mkdir (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mkdir (g, path);
- if (r == -1)
- croak ("mkdir: %s", guestfs_last_error (g));
-
-void
-mkdir_p (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- croak ("mkdir_p: %s", guestfs_last_error (g));
-
-void
-chmod (g, mode, path)
- guestfs_h *g;
- int mode;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_chmod (g, mode, path);
- if (r == -1)
- croak ("chmod: %s", guestfs_last_error (g));
-
-void
-chown (g, owner, group, path)
- guestfs_h *g;
- int owner;
- int group;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_chown (g, owner, group, path);
- if (r == -1)
- croak ("chown: %s", guestfs_last_error (g));
-
-SV *
-exists (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int existsflag;
- CODE:
- existsflag = guestfs_exists (g, path);
- if (existsflag == -1)
- croak ("exists: %s", guestfs_last_error (g));
- RETVAL = newSViv (existsflag);
- OUTPUT:
- RETVAL
-
-SV *
-is_file (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int fileflag;
- CODE:
- fileflag = guestfs_is_file (g, path);
- if (fileflag == -1)
- croak ("is_file: %s", guestfs_last_error (g));
- RETVAL = newSViv (fileflag);
- OUTPUT:
- RETVAL
-
-SV *
-is_dir (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int dirflag;
- CODE:
- dirflag = guestfs_is_dir (g, path);
- if (dirflag == -1)
- croak ("is_dir: %s", guestfs_last_error (g));
- RETVAL = newSViv (dirflag);
- OUTPUT:
- RETVAL
-
-void
-pvcreate (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- croak ("pvcreate: %s", guestfs_last_error (g));
-
-void
-vgcreate (g, volgroup, physvols)
- guestfs_h *g;
- char *volgroup;
- char **physvols;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_vgcreate (g, volgroup, physvols);
- free (physvols);
- if (r == -1)
- croak ("vgcreate: %s", guestfs_last_error (g));
-
-void
-lvcreate (g, logvol, volgroup, mbytes)
- guestfs_h *g;
- char *logvol;
- char *volgroup;
- int mbytes;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
- if (r == -1)
- croak ("lvcreate: %s", guestfs_last_error (g));
-
-void
-mkfs (g, fstype, device)
- guestfs_h *g;
- char *fstype;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- croak ("mkfs: %s", guestfs_last_error (g));
-
-void
-sfdisk (g, device, cyls, heads, sectors, lines)
- guestfs_h *g;
- char *device;
- int cyls;
- int heads;
- int sectors;
- char **lines;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
- free (lines);
- if (r == -1)
- croak ("sfdisk: %s", guestfs_last_error (g));
-
-void
-write_file (g, path, content, size)
- guestfs_h *g;
- char *path;
- char *content;
- int size;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_write_file (g, path, content, size);
- if (r == -1)
- croak ("write_file: %s", guestfs_last_error (g));
-
-void
-umount (g, pathordevice)
- guestfs_h *g;
- char *pathordevice;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- croak ("umount: %s", guestfs_last_error (g));
-
-void
-mounts (g)
- guestfs_h *g;
-PREINIT:
- char **devices;
- int i, n;
- PPCODE:
- devices = guestfs_mounts (g);
- if (devices == NULL)
- croak ("mounts: %s", guestfs_last_error (g));
- for (n = 0; devices[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
- free (devices[i]);
- }
- free (devices);
-
-void
-umount_all (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_umount_all (g);
- if (r == -1)
- croak ("umount_all: %s", guestfs_last_error (g));
-
-void
-lvm_remove_all (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- croak ("lvm_remove_all: %s", guestfs_last_error (g));
-
-SV *
-file (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char *description;
- CODE:
- description = guestfs_file (g, path);
- if (description == NULL)
- croak ("file: %s", guestfs_last_error (g));
- RETVAL = newSVpv (description, 0);
- free (description);
- OUTPUT:
- RETVAL
-
-SV *
-command (g, arguments)
- guestfs_h *g;
- char **arguments;
-PREINIT:
- char *output;
- CODE:
- output = guestfs_command (g, arguments);
- free (arguments);
- if (output == NULL)
- croak ("command: %s", guestfs_last_error (g));
- RETVAL = newSVpv (output, 0);
- free (output);
- OUTPUT:
- RETVAL
-
-void
-command_lines (g, arguments)
- guestfs_h *g;
- char **arguments;
-PREINIT:
- char **lines;
- int i, n;
- PPCODE:
- lines = guestfs_command_lines (g, arguments);
- free (arguments);
- if (lines == NULL)
- croak ("command_lines: %s", guestfs_last_error (g));
- for (n = 0; lines[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
- free (lines[i]);
- }
- free (lines);
-
-void
-stat (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- struct guestfs_stat *statbuf;
- PPCODE:
- statbuf = guestfs_stat (g, path);
- if (statbuf == NULL)
- croak ("stat: %s", guestfs_last_error (g));
- EXTEND (SP, 13);
- PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
- free (statbuf);
-
-void
-lstat (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- struct guestfs_stat *statbuf;
- PPCODE:
- statbuf = guestfs_lstat (g, path);
- if (statbuf == NULL)
- croak ("lstat: %s", guestfs_last_error (g));
- EXTEND (SP, 13);
- PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
- free (statbuf);
-
-void
-statvfs (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- struct guestfs_statvfs *statbuf;
- PPCODE:
- statbuf = guestfs_statvfs (g, path);
- if (statbuf == NULL)
- croak ("statvfs: %s", guestfs_last_error (g));
- EXTEND (SP, 11);
- PUSHs (sv_2mortal (my_newSVll (statbuf->bsize)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->frsize)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->bfree)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->bavail)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->files)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->ffree)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->favail)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->fsid)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->flag)));
- PUSHs (sv_2mortal (my_newSVll (statbuf->namemax)));
- free (statbuf);
-
-void
-tune2fs_l (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- char **superblock;
- int i, n;
- PPCODE:
- superblock = guestfs_tune2fs_l (g, device);
- if (superblock == NULL)
- croak ("tune2fs_l: %s", guestfs_last_error (g));
- for (n = 0; superblock[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (superblock[i], 0)));
- free (superblock[i]);
- }
- free (superblock);
-
-void
-blockdev_setro (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_blockdev_setro (g, device);
- if (r == -1)
- croak ("blockdev_setro: %s", guestfs_last_error (g));
-
-void
-blockdev_setrw (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- croak ("blockdev_setrw: %s", guestfs_last_error (g));
-
-SV *
-blockdev_getro (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int ro;
- CODE:
- ro = guestfs_blockdev_getro (g, device);
- if (ro == -1)
- croak ("blockdev_getro: %s", guestfs_last_error (g));
- RETVAL = newSViv (ro);
- OUTPUT:
- RETVAL
-
-SV *
-blockdev_getss (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int sectorsize;
- CODE:
- sectorsize = guestfs_blockdev_getss (g, device);
- if (sectorsize == -1)
- croak ("blockdev_getss: %s", guestfs_last_error (g));
- RETVAL = newSViv (sectorsize);
- OUTPUT:
- RETVAL
-
-SV *
-blockdev_getbsz (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int blocksize;
- CODE:
- blocksize = guestfs_blockdev_getbsz (g, device);
- if (blocksize == -1)
- croak ("blockdev_getbsz: %s", guestfs_last_error (g));
- RETVAL = newSViv (blocksize);
- OUTPUT:
- RETVAL
-
-void
-blockdev_setbsz (g, device, blocksize)
- guestfs_h *g;
- char *device;
- int blocksize;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_blockdev_setbsz (g, device, blocksize);
- if (r == -1)
- croak ("blockdev_setbsz: %s", guestfs_last_error (g));
-
-SV *
-blockdev_getsz (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int64_t sizeinsectors;
- CODE:
- sizeinsectors = guestfs_blockdev_getsz (g, device);
- if (sizeinsectors == -1)
- croak ("blockdev_getsz: %s", guestfs_last_error (g));
- RETVAL = my_newSVll (sizeinsectors);
- OUTPUT:
- RETVAL
-
-SV *
-blockdev_getsize64 (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int64_t sizeinbytes;
- CODE:
- sizeinbytes = guestfs_blockdev_getsize64 (g, device);
- if (sizeinbytes == -1)
- croak ("blockdev_getsize64: %s", guestfs_last_error (g));
- RETVAL = my_newSVll (sizeinbytes);
- OUTPUT:
- RETVAL
-
-void
-blockdev_flushbufs (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_blockdev_flushbufs (g, device);
- if (r == -1)
- croak ("blockdev_flushbufs: %s", guestfs_last_error (g));
-
-void
-blockdev_rereadpt (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_blockdev_rereadpt (g, device);
- if (r == -1)
- croak ("blockdev_rereadpt: %s", guestfs_last_error (g));
-
-void
-upload (g, filename, remotefilename)
- guestfs_h *g;
- char *filename;
- char *remotefilename;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_upload (g, filename, remotefilename);
- if (r == -1)
- croak ("upload: %s", guestfs_last_error (g));
-
-void
-download (g, remotefilename, filename)
- guestfs_h *g;
- char *remotefilename;
- char *filename;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_download (g, remotefilename, filename);
- if (r == -1)
- croak ("download: %s", guestfs_last_error (g));
-
-SV *
-checksum (g, csumtype, path)
- guestfs_h *g;
- char *csumtype;
- char *path;
-PREINIT:
- char *checksum;
- CODE:
- checksum = guestfs_checksum (g, csumtype, path);
- if (checksum == NULL)
- croak ("checksum: %s", guestfs_last_error (g));
- RETVAL = newSVpv (checksum, 0);
- free (checksum);
- OUTPUT:
- RETVAL
-
-void
-tar_in (g, tarfile, directory)
- guestfs_h *g;
- char *tarfile;
- char *directory;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_tar_in (g, tarfile, directory);
- if (r == -1)
- croak ("tar_in: %s", guestfs_last_error (g));
-
-void
-tar_out (g, directory, tarfile)
- guestfs_h *g;
- char *directory;
- char *tarfile;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_tar_out (g, directory, tarfile);
- if (r == -1)
- croak ("tar_out: %s", guestfs_last_error (g));
-
-void
-tgz_in (g, tarball, directory)
- guestfs_h *g;
- char *tarball;
- char *directory;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_tgz_in (g, tarball, directory);
- if (r == -1)
- croak ("tgz_in: %s", guestfs_last_error (g));
-
-void
-tgz_out (g, directory, tarball)
- guestfs_h *g;
- char *directory;
- char *tarball;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_tgz_out (g, directory, tarball);
- if (r == -1)
- croak ("tgz_out: %s", guestfs_last_error (g));
-
-void
-mount_ro (g, device, mountpoint)
- guestfs_h *g;
- char *device;
- char *mountpoint;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mount_ro (g, device, mountpoint);
- if (r == -1)
- croak ("mount_ro: %s", guestfs_last_error (g));
-
-void
-mount_options (g, options, device, mountpoint)
- guestfs_h *g;
- char *options;
- char *device;
- char *mountpoint;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mount_options (g, options, device, mountpoint);
- if (r == -1)
- croak ("mount_options: %s", guestfs_last_error (g));
-
-void
-mount_vfs (g, options, vfstype, device, mountpoint)
- guestfs_h *g;
- char *options;
- char *vfstype;
- char *device;
- char *mountpoint;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- croak ("mount_vfs: %s", guestfs_last_error (g));
-
-SV *
-debug (g, subcmd, extraargs)
- guestfs_h *g;
- char *subcmd;
- char **extraargs;
-PREINIT:
- char *result;
- CODE:
- result = guestfs_debug (g, subcmd, extraargs);
- free (extraargs);
- if (result == NULL)
- croak ("debug: %s", guestfs_last_error (g));
- RETVAL = newSVpv (result, 0);
- free (result);
- OUTPUT:
- RETVAL
-
-void
-lvremove (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_lvremove (g, device);
- if (r == -1)
- croak ("lvremove: %s", guestfs_last_error (g));
-
-void
-vgremove (g, vgname)
- guestfs_h *g;
- char *vgname;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- croak ("vgremove: %s", guestfs_last_error (g));
-
-void
-pvremove (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_pvremove (g, device);
- if (r == -1)
- croak ("pvremove: %s", guestfs_last_error (g));
-
-void
-set_e2label (g, device, label)
- guestfs_h *g;
- char *device;
- char *label;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_e2label (g, device, label);
- if (r == -1)
- croak ("set_e2label: %s", guestfs_last_error (g));
-
-SV *
-get_e2label (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- char *label;
- CODE:
- label = guestfs_get_e2label (g, device);
- if (label == NULL)
- croak ("get_e2label: %s", guestfs_last_error (g));
- RETVAL = newSVpv (label, 0);
- free (label);
- OUTPUT:
- RETVAL
-
-void
-set_e2uuid (g, device, uuid)
- guestfs_h *g;
- char *device;
- char *uuid;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- croak ("set_e2uuid: %s", guestfs_last_error (g));
-
-SV *
-get_e2uuid (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- char *uuid;
- CODE:
- uuid = guestfs_get_e2uuid (g, device);
- if (uuid == NULL)
- croak ("get_e2uuid: %s", guestfs_last_error (g));
- RETVAL = newSVpv (uuid, 0);
- free (uuid);
- OUTPUT:
- RETVAL
-
-SV *
-fsck (g, fstype, device)
- guestfs_h *g;
- char *fstype;
- char *device;
-PREINIT:
- int status;
- CODE:
- status = guestfs_fsck (g, fstype, device);
- if (status == -1)
- croak ("fsck: %s", guestfs_last_error (g));
- RETVAL = newSViv (status);
- OUTPUT:
- RETVAL
-
-void
-zero (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_zero (g, device);
- if (r == -1)
- croak ("zero: %s", guestfs_last_error (g));
-
-void
-grub_install (g, root, device)
- guestfs_h *g;
- char *root;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_grub_install (g, root, device);
- if (r == -1)
- croak ("grub_install: %s", guestfs_last_error (g));
-
-void
-cp (g, src, dest)
- guestfs_h *g;
- char *src;
- char *dest;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- croak ("cp: %s", guestfs_last_error (g));
-
-void
-cp_a (g, src, dest)
- guestfs_h *g;
- char *src;
- char *dest;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_cp_a (g, src, dest);
- if (r == -1)
- croak ("cp_a: %s", guestfs_last_error (g));
-
-void
-mv (g, src, dest)
- guestfs_h *g;
- char *src;
- char *dest;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mv (g, src, dest);
- if (r == -1)
- croak ("mv: %s", guestfs_last_error (g));
-
-void
-drop_caches (g, whattodrop)
- guestfs_h *g;
- int whattodrop;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_drop_caches (g, whattodrop);
- if (r == -1)
- croak ("drop_caches: %s", guestfs_last_error (g));
-
-SV *
-dmesg (g)
- guestfs_h *g;
-PREINIT:
- char *kmsgs;
- CODE:
- kmsgs = guestfs_dmesg (g);
- if (kmsgs == NULL)
- croak ("dmesg: %s", guestfs_last_error (g));
- RETVAL = newSVpv (kmsgs, 0);
- free (kmsgs);
- OUTPUT:
- RETVAL
-
-void
-ping_daemon (g)
- guestfs_h *g;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_ping_daemon (g);
- if (r == -1)
- croak ("ping_daemon: %s", guestfs_last_error (g));
-
-SV *
-equal (g, file1, file2)
- guestfs_h *g;
- char *file1;
- char *file2;
-PREINIT:
- int equality;
- CODE:
- equality = guestfs_equal (g, file1, file2);
- if (equality == -1)
- croak ("equal: %s", guestfs_last_error (g));
- RETVAL = newSViv (equality);
- OUTPUT:
- RETVAL
-
-void
-strings (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char **stringsout;
- int i, n;
- PPCODE:
- stringsout = guestfs_strings (g, path);
- if (stringsout == NULL)
- croak ("strings: %s", guestfs_last_error (g));
- for (n = 0; stringsout[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
- free (stringsout[i]);
- }
- free (stringsout);
-
-void
-strings_e (g, encoding, path)
- guestfs_h *g;
- char *encoding;
- char *path;
-PREINIT:
- char **stringsout;
- int i, n;
- PPCODE:
- stringsout = guestfs_strings_e (g, encoding, path);
- if (stringsout == NULL)
- croak ("strings_e: %s", guestfs_last_error (g));
- for (n = 0; stringsout[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
- free (stringsout[i]);
- }
- free (stringsout);
-
-SV *
-hexdump (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char *dump;
- CODE:
- dump = guestfs_hexdump (g, path);
- if (dump == NULL)
- croak ("hexdump: %s", guestfs_last_error (g));
- RETVAL = newSVpv (dump, 0);
- free (dump);
- OUTPUT:
- RETVAL
-
-void
-zerofree (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_zerofree (g, device);
- if (r == -1)
- croak ("zerofree: %s", guestfs_last_error (g));
-
-void
-pvresize (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_pvresize (g, device);
- if (r == -1)
- croak ("pvresize: %s", guestfs_last_error (g));
-
-void
-sfdisk_N (g, device, partnum, cyls, heads, sectors, line)
- guestfs_h *g;
- char *device;
- int partnum;
- int cyls;
- int heads;
- int sectors;
- char *line;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
- if (r == -1)
- croak ("sfdisk_N: %s", guestfs_last_error (g));
-
-SV *
-sfdisk_l (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- char *partitions;
- CODE:
- partitions = guestfs_sfdisk_l (g, device);
- if (partitions == NULL)
- croak ("sfdisk_l: %s", guestfs_last_error (g));
- RETVAL = newSVpv (partitions, 0);
- free (partitions);
- OUTPUT:
- RETVAL
-
-SV *
-sfdisk_kernel_geometry (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- char *partitions;
- CODE:
- partitions = guestfs_sfdisk_kernel_geometry (g, device);
- if (partitions == NULL)
- croak ("sfdisk_kernel_geometry: %s", guestfs_last_error (g));
- RETVAL = newSVpv (partitions, 0);
- free (partitions);
- OUTPUT:
- RETVAL
-
-SV *
-sfdisk_disk_geometry (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- char *partitions;
- CODE:
- partitions = guestfs_sfdisk_disk_geometry (g, device);
- if (partitions == NULL)
- croak ("sfdisk_disk_geometry: %s", guestfs_last_error (g));
- RETVAL = newSVpv (partitions, 0);
- free (partitions);
- OUTPUT:
- RETVAL
-
-void
-vg_activate_all (g, activate)
- guestfs_h *g;
- int activate;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_vg_activate_all (g, activate);
- if (r == -1)
- croak ("vg_activate_all: %s", guestfs_last_error (g));
-
-void
-vg_activate (g, activate, volgroups)
- guestfs_h *g;
- int activate;
- char **volgroups;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_vg_activate (g, activate, volgroups);
- free (volgroups);
- if (r == -1)
- croak ("vg_activate: %s", guestfs_last_error (g));
-
-void
-lvresize (g, device, mbytes)
- guestfs_h *g;
- char *device;
- int mbytes;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_lvresize (g, device, mbytes);
- if (r == -1)
- croak ("lvresize: %s", guestfs_last_error (g));
-
-void
-resize2fs (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_resize2fs (g, device);
- if (r == -1)
- croak ("resize2fs: %s", guestfs_last_error (g));
-
-void
-find (g, directory)
- guestfs_h *g;
- char *directory;
-PREINIT:
- char **names;
- int i, n;
- PPCODE:
- names = guestfs_find (g, directory);
- if (names == NULL)
- croak ("find: %s", guestfs_last_error (g));
- for (n = 0; names[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (names[i], 0)));
- free (names[i]);
- }
- free (names);
-
-void
-e2fsck_f (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_e2fsck_f (g, device);
- if (r == -1)
- croak ("e2fsck_f: %s", guestfs_last_error (g));
-
-void
-sleep (g, secs)
- guestfs_h *g;
- int secs;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_sleep (g, secs);
- if (r == -1)
- croak ("sleep: %s", guestfs_last_error (g));
-
-SV *
-ntfs_3g_probe (g, rw, device)
- guestfs_h *g;
- int rw;
- char *device;
-PREINIT:
- int status;
- CODE:
- status = guestfs_ntfs_3g_probe (g, rw, device);
- if (status == -1)
- croak ("ntfs_3g_probe: %s", guestfs_last_error (g));
- RETVAL = newSViv (status);
- OUTPUT:
- RETVAL
-
-SV *
-sh (g, command)
- guestfs_h *g;
- char *command;
-PREINIT:
- char *output;
- CODE:
- output = guestfs_sh (g, command);
- if (output == NULL)
- croak ("sh: %s", guestfs_last_error (g));
- RETVAL = newSVpv (output, 0);
- free (output);
- OUTPUT:
- RETVAL
-
-void
-sh_lines (g, command)
- guestfs_h *g;
- char *command;
-PREINIT:
- char **lines;
- int i, n;
- PPCODE:
- lines = guestfs_sh_lines (g, command);
- if (lines == NULL)
- croak ("sh_lines: %s", guestfs_last_error (g));
- for (n = 0; lines[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
- free (lines[i]);
- }
- free (lines);
-
-void
-glob_expand (g, pattern)
- guestfs_h *g;
- char *pattern;
-PREINIT:
- char **paths;
- int i, n;
- PPCODE:
- paths = guestfs_glob_expand (g, pattern);
- if (paths == NULL)
- croak ("glob_expand: %s", guestfs_last_error (g));
- for (n = 0; paths[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (paths[i], 0)));
- free (paths[i]);
- }
- free (paths);
-
-void
-scrub_device (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_scrub_device (g, device);
- if (r == -1)
- croak ("scrub_device: %s", guestfs_last_error (g));
-
-void
-scrub_file (g, file)
- guestfs_h *g;
- char *file;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_scrub_file (g, file);
- if (r == -1)
- croak ("scrub_file: %s", guestfs_last_error (g));
-
-void
-scrub_freespace (g, dir)
- guestfs_h *g;
- char *dir;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_scrub_freespace (g, dir);
- if (r == -1)
- croak ("scrub_freespace: %s", guestfs_last_error (g));
-
-SV *
-mkdtemp (g, template)
- guestfs_h *g;
- char *template;
-PREINIT:
- char *dir;
- CODE:
- dir = guestfs_mkdtemp (g, template);
- if (dir == NULL)
- croak ("mkdtemp: %s", guestfs_last_error (g));
- RETVAL = newSVpv (dir, 0);
- free (dir);
- OUTPUT:
- RETVAL
-
-SV *
-wc_l (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int lines;
- CODE:
- lines = guestfs_wc_l (g, path);
- if (lines == -1)
- croak ("wc_l: %s", guestfs_last_error (g));
- RETVAL = newSViv (lines);
- OUTPUT:
- RETVAL
-
-SV *
-wc_w (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int words;
- CODE:
- words = guestfs_wc_w (g, path);
- if (words == -1)
- croak ("wc_w: %s", guestfs_last_error (g));
- RETVAL = newSViv (words);
- OUTPUT:
- RETVAL
-
-SV *
-wc_c (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int chars;
- CODE:
- chars = guestfs_wc_c (g, path);
- if (chars == -1)
- croak ("wc_c: %s", guestfs_last_error (g));
- RETVAL = newSViv (chars);
- OUTPUT:
- RETVAL
-
-void
-head (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char **lines;
- int i, n;
- PPCODE:
- lines = guestfs_head (g, path);
- if (lines == NULL)
- croak ("head: %s", guestfs_last_error (g));
- for (n = 0; lines[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
- free (lines[i]);
- }
- free (lines);
-
-void
-head_n (g, nrlines, path)
- guestfs_h *g;
- int nrlines;
- char *path;
-PREINIT:
- char **lines;
- int i, n;
- PPCODE:
- lines = guestfs_head_n (g, nrlines, path);
- if (lines == NULL)
- croak ("head_n: %s", guestfs_last_error (g));
- for (n = 0; lines[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
- free (lines[i]);
- }
- free (lines);
-
-void
-tail (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char **lines;
- int i, n;
- PPCODE:
- lines = guestfs_tail (g, path);
- if (lines == NULL)
- croak ("tail: %s", guestfs_last_error (g));
- for (n = 0; lines[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
- free (lines[i]);
- }
- free (lines);
-
-void
-tail_n (g, nrlines, path)
- guestfs_h *g;
- int nrlines;
- char *path;
-PREINIT:
- char **lines;
- int i, n;
- PPCODE:
- lines = guestfs_tail_n (g, nrlines, path);
- if (lines == NULL)
- croak ("tail_n: %s", guestfs_last_error (g));
- for (n = 0; lines[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
- free (lines[i]);
- }
- free (lines);
-
-SV *
-df (g)
- guestfs_h *g;
-PREINIT:
- char *output;
- CODE:
- output = guestfs_df (g);
- if (output == NULL)
- croak ("df: %s", guestfs_last_error (g));
- RETVAL = newSVpv (output, 0);
- free (output);
- OUTPUT:
- RETVAL
-
-SV *
-df_h (g)
- guestfs_h *g;
-PREINIT:
- char *output;
- CODE:
- output = guestfs_df_h (g);
- if (output == NULL)
- croak ("df_h: %s", guestfs_last_error (g));
- RETVAL = newSVpv (output, 0);
- free (output);
- OUTPUT:
- RETVAL
-
-SV *
-du (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- int64_t sizekb;
- CODE:
- sizekb = guestfs_du (g, path);
- if (sizekb == -1)
- croak ("du: %s", guestfs_last_error (g));
- RETVAL = my_newSVll (sizekb);
- OUTPUT:
- RETVAL
-
-void
-initrd_list (g, path)
- guestfs_h *g;
- char *path;
-PREINIT:
- char **filenames;
- int i, n;
- PPCODE:
- filenames = guestfs_initrd_list (g, path);
- if (filenames == NULL)
- croak ("initrd_list: %s", guestfs_last_error (g));
- for (n = 0; filenames[n] != NULL; ++n) /**/;
- EXTEND (SP, n);
- for (i = 0; i < n; ++i) {
- PUSHs (sv_2mortal (newSVpv (filenames[i], 0)));
- free (filenames[i]);
- }
- free (filenames);
-
-void
-mount_loop (g, file, mountpoint)
- guestfs_h *g;
- char *file;
- char *mountpoint;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mount_loop (g, file, mountpoint);
- if (r == -1)
- croak ("mount_loop: %s", guestfs_last_error (g));
-
-void
-mkswap (g, device)
- guestfs_h *g;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mkswap (g, device);
- if (r == -1)
- croak ("mkswap: %s", guestfs_last_error (g));
-
-void
-mkswap_L (g, label, device)
- guestfs_h *g;
- char *label;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mkswap_L (g, label, device);
- if (r == -1)
- croak ("mkswap_L: %s", guestfs_last_error (g));
-
-void
-mkswap_U (g, uuid, device)
- guestfs_h *g;
- char *uuid;
- char *device;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mkswap_U (g, uuid, device);
- if (r == -1)
- croak ("mkswap_U: %s", guestfs_last_error (g));
-
-void
-mknod (g, mode, devmajor, devminor, path)
- guestfs_h *g;
- int mode;
- int devmajor;
- int devminor;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mknod (g, mode, devmajor, devminor, path);
- if (r == -1)
- croak ("mknod: %s", guestfs_last_error (g));
-
-void
-mkfifo (g, mode, path)
- guestfs_h *g;
- int mode;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mkfifo (g, mode, path);
- if (r == -1)
- croak ("mkfifo: %s", guestfs_last_error (g));
-
-void
-mknod_b (g, mode, devmajor, devminor, path)
- guestfs_h *g;
- int mode;
- int devmajor;
- int devminor;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mknod_b (g, mode, devmajor, devminor, path);
- if (r == -1)
- croak ("mknod_b: %s", guestfs_last_error (g));
-
-void
-mknod_c (g, mode, devmajor, devminor, path)
- guestfs_h *g;
- int mode;
- int devmajor;
- int devminor;
- char *path;
-PREINIT:
- int r;
- PPCODE:
- r = guestfs_mknod_c (g, mode, devmajor, devminor, path);
- if (r == -1)
- croak ("mknod_c: %s", guestfs_last_error (g));
-
-SV *
-umask (g, mask)
- guestfs_h *g;
- int mask;
-PREINIT:
- int oldmask;
- CODE:
- oldmask = guestfs_umask (g, mask);
- if (oldmask == -1)
- croak ("umask: %s", guestfs_last_error (g));
- RETVAL = newSViv (oldmask);
- OUTPUT:
- RETVAL
-
-void
-readdir (g, dir)
- guestfs_h *g;
- char *dir;
-PREINIT:
- struct guestfs_dirent_list *entries;
- int i;
- HV *hv;
- PPCODE:
- entries = guestfs_readdir (g, dir);
- if (entries == NULL)
- croak ("readdir: %s", guestfs_last_error (g));
- EXTEND (SP, entries->len);
- for (i = 0; i < entries->len; ++i) {
- hv = newHV ();
- (void) hv_store (hv, "ino", 3, my_newSVull (entries->val[i].ino), 0);
- (void) hv_store (hv, "ftyp", 4, newSVpv (&entries->val[i].ftyp, 1), 0);
- (void) hv_store (hv, "name", 4, newSVpv (entries->val[i].name, 0), 0);
- PUSHs (newRV (sv_2mortal ((SV *) hv)));
- }
- guestfs_free_dirent_list (entries);
-
+++ /dev/null
-#!/usr/bin/perl -w
-# 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 program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-use strict;
-
-use Sys::Guestfs;
-
-my $g = Sys::Guestfs->new ();
-$g->test0 ("abc", "def", [], 0, 0, "123", "456");
-$g->test0 ("abc", undef, [], 0, 0, "123", "456");
-$g->test0 ("", "def", [], 0, 0, "123", "456");
-$g->test0 ("", "", [], 0, 0, "123", "456");
-$g->test0 ("abc", "def", ["1"], 0, 0, "123", "456");
-$g->test0 ("abc", "def", ["1","2"], 0, 0, "123", "456");
-$g->test0 ("abc", "def", ["1"], 1, 0, "123", "456");
-$g->test0 ("abc", "def", ["1"], 0, -1, "123", "456");
-$g->test0 ("abc", "def", ["1"], 0, -2, "123", "456");
-$g->test0 ("abc", "def", ["1"], 0, 1, "123", "456");
-$g->test0 ("abc", "def", ["1"], 0, 2, "123", "456");
-$g->test0 ("abc", "def", ["1"], 0, 4095, "123", "456");
-$g->test0 ("abc", "def", ["1"], 0, 0, "", "");
-print "EOF\n"
+++ /dev/null
-# 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
-
-=pod
-
-=head1 NAME
-
-Sys::Guestfs - Perl bindings for libguestfs
-
-=head1 SYNOPSIS
-
- use Sys::Guestfs;
-
- my $h = Sys::Guestfs->new ();
- $h->add_drive ('guest.img');
- $h->launch ();
- $h->wait_ready ();
- $h->mount ('/dev/sda1', '/');
- $h->touch ('/hello');
- $h->sync ();
-
-=head1 DESCRIPTION
-
-The C<Sys::Guestfs> module provides a Perl XS binding to the
-libguestfs API for examining and modifying virtual machine
-disk images.
-
-Amongst the things this is good for: making batch configuration
-changes to guests, getting disk used/free statistics (see also:
-virt-df), migrating between virtualization systems (see also:
-virt-p2v), performing partial backups, performing partial guest
-clones, cloning guests and changing registry/UUID/hostname info, and
-much else besides.
-
-Libguestfs uses Linux kernel and qemu code, and can access any type of
-guest filesystem that Linux and qemu can, including but not limited
-to: ext2/3/4, btrfs, FAT and NTFS, LVM, many different disk partition
-schemes, qcow, qcow2, vmdk.
-
-Libguestfs provides ways to enumerate guest storage (eg. partitions,
-LVs, what filesystem is in each LV, etc.). It can also run commands
-in the context of the guest. Also you can access filesystems over FTP.
-
-=head1 ERRORS
-
-All errors turn into calls to C<croak> (see L<Carp(3)>).
-
-=head1 METHODS
-
-=over 4
-
-=cut
-
-package Sys::Guestfs;
-
-use strict;
-use warnings;
-
-require XSLoader;
-XSLoader::load ('Sys::Guestfs');
-
-=item $h = Sys::Guestfs->new ();
-
-Create a new guestfs handle.
-
-=cut
-
-sub new {
- my $proto = shift;
- my $class = ref ($proto) || $proto;
-
- my $self = Sys::Guestfs::_create ();
- bless $self, $class;
- return $self;
-}
-
-=item $h->add_cdrom ($filename);
-
-This function adds a virtual CD-ROM disk image to the guest.
-
-This is equivalent to the qemu parameter C<-cdrom filename>.
-
-Note that this call checks for the existence of C<filename>. This
-stops you from specifying other types of drive which are supported
-by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
-the general C<$h-E<gt>config> call instead.
-
-=item $h->add_drive ($filename);
-
-This function adds a virtual machine disk image C<filename> to the
-guest. The first time you call this function, the disk appears as IDE
-disk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and
-so on.
-
-You don't necessarily need to be root when using libguestfs. However
-you obviously do need sufficient permissions to access the filename
-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,cache=off,if=virtio>.
-
-Note that this call checks for the existence of C<filename>. This
-stops you from specifying other types of drive which are supported
-by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
-the general C<$h-E<gt>config> call instead.
-
-=item $h->add_drive_ro ($filename);
-
-This adds a drive in snapshot mode, making it effectively
-read-only.
-
-Note that writes to the device are allowed, and will be seen for
-the duration of the guestfs handle, but they are written
-to a temporary file which is discarded as soon as the guestfs
-handle is closed. We don't currently have any method to enable
-changes to be committed, although qemu can support this.
-
-This is equivalent to the qemu parameter
-C<-drive file=filename,snapshot=on,if=virtio>.
-
-Note that this call checks for the existence of C<filename>. This
-stops you from specifying other types of drive which are supported
-by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
-the general C<$h-E<gt>config> call instead.
-
-=item $h->aug_close ();
-
-Close the current Augeas handle and free up any resources
-used by it. After calling this, you have to call
-C<$h-E<gt>aug_init> again before you can use any other
-Augeas functions.
-
-=item ($nrnodes, $created) = $h->aug_defnode ($name, $expr, $val);
-
-Defines a variable C<name> whose value is the result of
-evaluating C<expr>.
-
-If C<expr> evaluates to an empty nodeset, a node is created,
-equivalent to calling C<$h-E<gt>aug_set> C<expr>, C<value>.
-C<name> will be the nodeset containing that single node.
-
-On success this returns a pair containing the
-number of nodes in the nodeset, and a boolean flag
-if a node was created.
-
-=item $nrnodes = $h->aug_defvar ($name, $expr);
-
-Defines an Augeas variable C<name> whose value is the result
-of evaluating C<expr>. If C<expr> is NULL, then C<name> is
-undefined.
-
-On success this returns the number of nodes in C<expr>, or
-C<0> if C<expr> evaluates to something which is not a nodeset.
-
-=item $val = $h->aug_get ($path);
-
-Look up the value associated with C<path>. If C<path>
-matches exactly one node, the C<value> is returned.
-
-=item $h->aug_init ($root, $flags);
-
-Create a new Augeas handle for editing configuration files.
-If there was any previous Augeas handle associated with this
-guestfs session, then it is closed.
-
-You must call this before using any other C<$h-E<gt>aug_*>
-commands.
-
-C<root> is the filesystem root. C<root> must not be NULL,
-use C</> instead.
-
-The flags are the same as the flags defined in
-E<lt>augeas.hE<gt>, the logical I<or> of the following
-integers:
-
-=over 4
-
-=item C<AUG_SAVE_BACKUP> = 1
-
-Keep the original file with a C<.augsave> extension.
-
-=item C<AUG_SAVE_NEWFILE> = 2
-
-Save changes into a file with extension C<.augnew>, and
-do not overwrite original. Overrides C<AUG_SAVE_BACKUP>.
-
-=item C<AUG_TYPE_CHECK> = 4
-
-Typecheck lenses (can be expensive).
-
-=item C<AUG_NO_STDINC> = 8
-
-Do not use standard load path for modules.
-
-=item C<AUG_SAVE_NOOP> = 16
-
-Make save a no-op, just record what would have been changed.
-
-=item C<AUG_NO_LOAD> = 32
-
-Do not load the tree in C<$h-E<gt>aug_init>.
-
-=back
-
-To close the handle, you can call C<$h-E<gt>aug_close>.
-
-To find out more about Augeas, see L<http://augeas.net/>.
-
-=item $h->aug_insert ($path, $label, $before);
-
-Create a new sibling C<label> for C<path>, inserting it into
-the tree before or after C<path> (depending on the boolean
-flag C<before>).
-
-C<path> must match exactly one existing node in the tree, and
-C<label> must be a label, ie. not contain C</>, C<*> or end
-with a bracketed index C<[N]>.
-
-=item $h->aug_load ();
-
-Load files into the tree.
-
-See C<aug_load> in the Augeas documentation for the full gory
-details.
-
-=item @matches = $h->aug_ls ($path);
-
-This is just a shortcut for listing C<$h-E<gt>aug_match>
-C<path/*> and sorting the resulting nodes into alphabetical order.
-
-=item @matches = $h->aug_match ($path);
-
-Returns a list of paths which match the path expression C<path>.
-The returned paths are sufficiently qualified so that they match
-exactly one node in the current tree.
-
-=item $h->aug_mv ($src, $dest);
-
-Move the node C<src> to C<dest>. C<src> must match exactly
-one node. C<dest> is overwritten if it exists.
-
-=item $nrnodes = $h->aug_rm ($path);
-
-Remove C<path> and all of its children.
-
-On success this returns the number of entries which were removed.
-
-=item $h->aug_save ();
-
-This writes all pending changes to disk.
-
-The flags which were passed to C<$h-E<gt>aug_init> affect exactly
-how files are saved.
-
-=item $h->aug_set ($path, $val);
-
-Set the value associated with C<path> to C<value>.
-
-=item $h->blockdev_flushbufs ($device);
-
-This tells the kernel to flush internal buffers associated
-with C<device>.
-
-This uses the L<blockdev(8)> command.
-
-=item $blocksize = $h->blockdev_getbsz ($device);
-
-This returns the block size of a device.
-
-(Note this is different from both I<size in blocks> and
-I<filesystem block size>).
-
-This uses the L<blockdev(8)> command.
-
-=item $ro = $h->blockdev_getro ($device);
-
-Returns a boolean indicating if the block device is read-only
-(true if read-only, false if not).
-
-This uses the L<blockdev(8)> command.
-
-=item $sizeinbytes = $h->blockdev_getsize64 ($device);
-
-This returns the size of the device in bytes.
-
-See also C<$h-E<gt>blockdev_getsz>.
-
-This uses the L<blockdev(8)> command.
-
-=item $sectorsize = $h->blockdev_getss ($device);
-
-This returns the size of sectors on a block device.
-Usually 512, but can be larger for modern devices.
-
-(Note, this is not the size in sectors, use C<$h-E<gt>blockdev_getsz>
-for that).
-
-This uses the L<blockdev(8)> command.
-
-=item $sizeinsectors = $h->blockdev_getsz ($device);
-
-This returns the size of the device in units of 512-byte sectors
-(even if the sectorsize isn't 512 bytes ... weird).
-
-See also C<$h-E<gt>blockdev_getss> for the real sector size of
-the device, and C<$h-E<gt>blockdev_getsize64> for the more
-useful I<size in bytes>.
-
-This uses the L<blockdev(8)> command.
-
-=item $h->blockdev_rereadpt ($device);
-
-Reread the partition table on C<device>.
-
-This uses the L<blockdev(8)> command.
-
-=item $h->blockdev_setbsz ($device, $blocksize);
-
-This sets the block size of a device.
-
-(Note this is different from both I<size in blocks> and
-I<filesystem block size>).
-
-This uses the L<blockdev(8)> command.
-
-=item $h->blockdev_setro ($device);
-
-Sets the block device named C<device> to read-only.
-
-This uses the L<blockdev(8)> command.
-
-=item $h->blockdev_setrw ($device);
-
-Sets the block device named C<device> to read-write.
-
-This uses the L<blockdev(8)> command.
-
-=item $content = $h->cat ($path);
-
-Return the contents of the file named C<path>.
-
-Note that this function cannot correctly handle binary files
-(specifically, files containing C<\0> character which is treated
-as end of string). For those you need to use the C<$h-E<gt>download>
-function which has a more complex interface.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item $checksum = $h->checksum ($csumtype, $path);
-
-This call computes the MD5, SHAx or CRC checksum of the
-file named C<path>.
-
-The type of checksum to compute is given by the C<csumtype>
-parameter which must have one of the following values:
-
-=over 4
-
-=item C<crc>
-
-Compute the cyclic redundancy check (CRC) specified by POSIX
-for the C<cksum> command.
-
-=item C<md5>
-
-Compute the MD5 hash (using the C<md5sum> program).
-
-=item C<sha1>
-
-Compute the SHA1 hash (using the C<sha1sum> program).
-
-=item C<sha224>
-
-Compute the SHA224 hash (using the C<sha224sum> program).
-
-=item C<sha256>
-
-Compute the SHA256 hash (using the C<sha256sum> program).
-
-=item C<sha384>
-
-Compute the SHA384 hash (using the C<sha384sum> program).
-
-=item C<sha512>
-
-Compute the SHA512 hash (using the C<sha512sum> program).
-
-=back
-
-The checksum is returned as a printable string.
-
-=item $h->chmod ($mode, $path);
-
-Change the mode (permissions) of C<path> to C<mode>. Only
-numeric modes are supported.
-
-=item $h->chown ($owner, $group, $path);
-
-Change the file owner to C<owner> and group to C<group>.
-
-Only numeric uid and gid are supported. If you want to use
-names, you will need to locate and parse the password file
-yourself (Augeas support makes this relatively easy).
-
-=item $output = $h->command (\@arguments);
-
-This call runs a command from the guest filesystem. The
-filesystem must be mounted, and must contain a compatible
-operating system (ie. something Linux, with the same
-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). Note that
-the command runs directly, and is I<not> invoked via
-the shell (see C<$h-E<gt>sh>).
-
-The return value is anything printed to I<stdout> by
-the command.
-
-If the command returns a non-zero exit status, then
-this function returns an error message. The error message
-string is the content of I<stderr> from the command.
-
-The C<$PATH> environment variable will contain at least
-C</usr/bin> and C</bin>. If you require a program from
-another location, you should provide the full path in the
-first parameter.
-
-Shared libraries and data files required by the program
-must be available on filesystems which are mounted in the
-correct places. It is the caller's responsibility to ensure
-all filesystems that are needed are mounted at the right
-locations.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item @lines = $h->command_lines (\@arguments);
-
-This is the same as C<$h-E<gt>command>, but splits the
-result into a list of lines.
-
-See also: C<$h-E<gt>sh_lines>
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item $h->config ($qemuparam, $qemuvalue);
-
-This can be used to add arbitrary qemu command line parameters
-of the form C<-param value>. Actually it's not quite arbitrary - we
-prevent you from setting some parameters which would interfere with
-parameters that we use.
-
-The first character of C<param> string must be a C<-> (dash).
-
-C<value> can be NULL.
-
-=item $h->cp ($src, $dest);
-
-This copies a file from C<src> to C<dest> where C<dest> is
-either a destination filename or destination directory.
-
-=item $h->cp_a ($src, $dest);
-
-This copies a file or directory from C<src> to C<dest>
-recursively using the C<cp -a> command.
-
-=item $result = $h->debug ($subcmd, \@extraargs);
-
-The C<$h-E<gt>debug> command exposes some internals of
-C<guestfsd> (the guestfs daemon) that runs inside the
-qemu subprocess.
-
-There is no comprehensive help for this command. You have
-to look at the file C<daemon/debug.c> in the libguestfs source
-to find out what you can do.
-
-=item $output = $h->df ();
-
-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.
-
-=item $output = $h->df_h ();
-
-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.
-
-=item $kmsgs = $h->dmesg ();
-
-This returns the kernel messages (C<dmesg> output) from
-the guest kernel. This is sometimes useful for extended
-debugging of problems.
-
-Another way to get the same information is to enable
-verbose messages with C<$h-E<gt>set_verbose> or by setting
-the environment variable C<LIBGUESTFS_DEBUG=1> before
-running the program.
-
-=item $h->download ($remotefilename, $filename);
-
-Download file C<remotefilename> and save it as C<filename>
-on the local machine.
-
-C<filename> can also be a named pipe.
-
-See also C<$h-E<gt>upload>, C<$h-E<gt>cat>.
-
-=item $h->drop_caches ($whattodrop);
-
-This instructs the guest kernel to drop its page cache,
-and/or dentries and inode caches. The parameter C<whattodrop>
-tells the kernel what precisely to drop, see
-L<http://linux-mm.org/Drop_Caches>
-
-Setting C<whattodrop> to 3 should drop everything.
-
-This automatically calls L<sync(2)> before the operation,
-so that the maximum guest memory is freed.
-
-=item $sizekb = $h->du ($path);
-
-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).
-
-=item $h->e2fsck_f ($device);
-
-This runs C<e2fsck -p -f device>, ie. runs the ext2/ext3
-filesystem checker on C<device>, noninteractively (C<-p>),
-even if the filesystem appears to be clean (C<-f>).
-
-This command is only needed because of C<$h-E<gt>resize2fs>
-(q.v.). Normally you should use C<$h-E<gt>fsck>.
-
-=item $h->end_busy ();
-
-This sets the state to C<READY>, or if in C<CONFIG> then it leaves the
-state as is. This is only used when implementing
-actions using the low-level API.
-
-For more information on states, see L<guestfs(3)>.
-
-=item $equality = $h->equal ($file1, $file2);
-
-This compares the two files C<file1> and C<file2> and returns
-true if their content is exactly equal, or false otherwise.
-
-The external L<cmp(1)> program is used for the comparison.
-
-=item $existsflag = $h->exists ($path);
-
-This returns C<true> if and only if there is a file, directory
-(or anything) with the given C<path> name.
-
-See also C<$h-E<gt>is_file>, C<$h-E<gt>is_dir>, C<$h-E<gt>stat>.
-
-=item $description = $h->file ($path);
-
-This call uses the standard L<file(1)> command to determine
-the type or contents of the file. This also works on devices,
-for example to find out whether a partition contains a filesystem.
-
-The exact command which runs is C<file -bsL path>. Note in
-particular that the filename is not prepended to the output
-(the C<-b> option).
-
-=item @names = $h->find ($directory);
-
-This command lists out all files and directories, recursively,
-starting at C<directory>. It is essentially equivalent to
-running the shell command C<find directory -print> but some
-post-processing happens on the output, described below.
-
-This returns a list of strings I<without any prefix>. Thus
-if the directory structure was:
-
- /tmp/a
- /tmp/b
- /tmp/c/d
-
-then the returned list from C<$h-E<gt>find> C</tmp> would be
-4 elements:
-
- a
- b
- c
- c/d
-
-If C<directory> is not a directory, then this command returns
-an error.
-
-The returned list is sorted.
-
-=item $status = $h->fsck ($fstype, $device);
-
-This runs the filesystem checker (fsck) on C<device> which
-should have filesystem type C<fstype>.
-
-The returned integer is the status. See L<fsck(8)> for the
-list of status codes from C<fsck>.
-
-Notes:
-
-=over 4
-
-=item *
-
-Multiple status codes can be summed together.
-
-=item *
-
-A non-zero return code can mean "success", for example if
-errors have been corrected on the filesystem.
-
-=item *
-
-Checking or repairing NTFS volumes is not supported
-(by linux-ntfs).
-
-=back
-
-This command is entirely equivalent to running C<fsck -a -t fstype device>.
-
-=item $append = $h->get_append ();
-
-Return the additional kernel options which are added to the
-guest kernel command line.
-
-If C<NULL> then no options are added.
-
-=item $autosync = $h->get_autosync ();
-
-Get the autosync flag.
-
-=item $label = $h->get_e2label ($device);
-
-This returns the ext2/3/4 filesystem label of the filesystem on
-C<device>.
-
-=item $uuid = $h->get_e2uuid ($device);
-
-This returns the ext2/3/4 filesystem UUID of the filesystem on
-C<device>.
-
-=item $memsize = $h->get_memsize ();
-
-This gets the memory size in megabytes allocated to the
-qemu subprocess.
-
-If C<$h-E<gt>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)>.
-
-=item $path = $h->get_path ();
-
-Return the current search path.
-
-This is always non-NULL. If it wasn't set already, then this will
-return the default path.
-
-=item $qemu = $h->get_qemu ();
-
-Return the current qemu binary.
-
-This is always non-NULL. If it wasn't set already, then this will
-return the default qemu binary name.
-
-=item $state = $h->get_state ();
-
-This returns the current state as an opaque integer. This is
-only useful for printing debug and internal error messages.
-
-For more information on states, see L<guestfs(3)>.
-
-=item $verbose = $h->get_verbose ();
-
-This returns the verbose messages flag.
-
-=item @paths = $h->glob_expand ($pattern);
-
-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.
-
-=item $h->grub_install ($root, $device);
-
-This command installs GRUB (the Grand Unified Bootloader) on
-C<device>, with the root directory being C<root>.
-
-=item @lines = $h->head ($path);
-
-This command returns up to the first 10 lines of a file as
-a list of strings.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item @lines = $h->head_n ($nrlines, $path);
-
-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.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item $dump = $h->hexdump ($path);
-
-This runs C<hexdump -C> on the given C<path>. The result is
-the human-readable, canonical hex dump of the file.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item @filenames = $h->initrd_list ($path);
-
-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).
-
-=item $busy = $h->is_busy ();
-
-This returns true iff this handle is busy processing a command
-(in the C<BUSY> state).
-
-For more information on states, see L<guestfs(3)>.
-
-=item $config = $h->is_config ();
-
-This returns true iff this handle is being configured
-(in the C<CONFIG> state).
-
-For more information on states, see L<guestfs(3)>.
-
-=item $dirflag = $h->is_dir ($path);
-
-This returns C<true> if and only if there is a directory
-with the given C<path> name. Note that it returns false for
-other objects like files.
-
-See also C<$h-E<gt>stat>.
-
-=item $fileflag = $h->is_file ($path);
-
-This returns C<true> if and only if there is a file
-with the given C<path> name. Note that it returns false for
-other objects like directories.
-
-See also C<$h-E<gt>stat>.
-
-=item $launching = $h->is_launching ();
-
-This returns true iff this handle is launching the subprocess
-(in the C<LAUNCHING> state).
-
-For more information on states, see L<guestfs(3)>.
-
-=item $ready = $h->is_ready ();
-
-This returns true iff this handle is ready to accept commands
-(in the C<READY> state).
-
-For more information on states, see L<guestfs(3)>.
-
-=item $h->kill_subprocess ();
-
-This kills the qemu subprocess. You should never need to call this.
-
-=item $h->launch ();
-
-Internally libguestfs is implemented by running a virtual machine
-using L<qemu(1)>.
-
-You should call this after configuring the handle
-(eg. adding drives) but before performing any actions.
-
-=item @devices = $h->list_devices ();
-
-List all the block devices.
-
-The full block device names are returned, eg. C</dev/sda>
-
-=item @partitions = $h->list_partitions ();
-
-List all the partitions detected on all block devices.
-
-The full partition device names are returned, eg. C</dev/sda1>
-
-This does not return logical volumes. For that you will need to
-call C<$h-E<gt>lvs>.
-
-=item $listing = $h->ll ($directory);
-
-List the files in C<directory> (relative to the root directory,
-there is no cwd) in the format of 'ls -la'.
-
-This command is mostly useful for interactive sessions. It
-is I<not> intended that you try to parse the output string.
-
-=item @listing = $h->ls ($directory);
-
-List the files in C<directory> (relative to the root directory,
-there is no cwd). The '.' and '..' entries are not returned, but
-hidden files are shown.
-
-This command is mostly useful for interactive sessions. Programs
-should probably use C<$h-E<gt>readdir> instead.
-
-=item %statbuf = $h->lstat ($path);
-
-Returns file information for the given C<path>.
-
-This is the same as C<$h-E<gt>stat> except that if C<path>
-is a symbolic link, then the link is stat-ed, not the file it
-refers to.
-
-This is the same as the C<lstat(2)> system call.
-
-=item $h->lvcreate ($logvol, $volgroup, $mbytes);
-
-This creates an LVM volume group called C<logvol>
-on the volume group C<volgroup>, with C<size> megabytes.
-
-=item $h->lvm_remove_all ();
-
-This command removes all LVM logical volumes, volume groups
-and physical volumes.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=item $h->lvremove ($device);
-
-Remove an LVM logical volume C<device>, where C<device> is
-the path to the LV, such as C</dev/VG/LV>.
-
-You can also remove all LVs in a volume group by specifying
-the VG name, C</dev/VG>.
-
-=item $h->lvresize ($device, $mbytes);
-
-This resizes (expands or shrinks) an existing LVM logical
-volume to C<mbytes>. When reducing, data in the reduced part
-is lost.
-
-=item @logvols = $h->lvs ();
-
-List all the logical volumes detected. This is the equivalent
-of the L<lvs(8)> command.
-
-This returns a list of the logical volume device names
-(eg. C</dev/VolGroup00/LogVol00>).
-
-See also C<$h-E<gt>lvs_full>.
-
-=item @logvols = $h->lvs_full ();
-
-List all the logical volumes detected. This is the equivalent
-of the L<lvs(8)> command. The "full" version includes all fields.
-
-=item $h->mkdir ($path);
-
-Create a directory named C<path>.
-
-=item $h->mkdir_p ($path);
-
-Create a directory named C<path>, creating any parent directories
-as necessary. This is like the C<mkdir -p> shell command.
-
-=item $dir = $h->mkdtemp ($template);
-
-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)>
-
-=item $h->mkfifo ($mode, $path);
-
-This call creates a FIFO (named pipe) called C<path> with
-mode C<mode>. It is just a convenient wrapper around
-C<$h-E<gt>mknod>.
-
-=item $h->mkfs ($fstype, $device);
-
-This creates a filesystem on C<device> (usually a partition
-or LVM logical volume). The filesystem type is C<fstype>, for
-example C<ext3>.
-
-=item $h->mknod ($mode, $devmajor, $devminor, $path);
-
-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.
-
-=item $h->mknod_b ($mode, $devmajor, $devminor, $path);
-
-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<$h-E<gt>mknod>.
-
-=item $h->mknod_c ($mode, $devmajor, $devminor, $path);
-
-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<$h-E<gt>mknod>.
-
-=item $h->mkswap ($device);
-
-Create a swap partition on C<device>.
-
-=item $h->mkswap_L ($label, $device);
-
-Create a swap partition on C<device> with label C<label>.
-
-=item $h->mkswap_U ($uuid, $device);
-
-Create a swap partition on C<device> with UUID C<uuid>.
-
-=item $h->mount ($device, $mountpoint);
-
-Mount a guest disk at a position in the filesystem. Block devices
-are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
-the guest. If those block devices contain partitions, they will have
-the usual names (eg. C</dev/sda1>). Also LVM C</dev/VG/LV>-style
-names can be used.
-
-The rules are the same as for L<mount(2)>: A filesystem must
-first be mounted on C</> before others can be mounted. Other
-filesystems can only be mounted on directories which already
-exist.
-
-The mounted filesystem is writable, if we have sufficient permissions
-on the underlying device.
-
-The filesystem options C<sync> and C<noatime> are set with this
-call, in order to improve reliability.
-
-=item $h->mount_loop ($file, $mountpoint);
-
-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>.
-
-=item $h->mount_options ($options, $device, $mountpoint);
-
-This is the same as the C<$h-E<gt>mount> command, but it
-allows you to set the mount options as for the
-L<mount(8)> I<-o> flag.
-
-=item $h->mount_ro ($device, $mountpoint);
-
-This is the same as the C<$h-E<gt>mount> command, but it
-mounts the filesystem with the read-only (I<-o ro>) flag.
-
-=item $h->mount_vfs ($options, $vfstype, $device, $mountpoint);
-
-This is the same as the C<$h-E<gt>mount> command, but it
-allows you to set both the mount options and the vfstype
-as for the L<mount(8)> I<-o> and I<-t> flags.
-
-=item @devices = $h->mounts ();
-
-This returns the list of currently mounted filesystems. It returns
-the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
-
-Some internal mounts are not shown.
-
-=item $h->mv ($src, $dest);
-
-This moves a file from C<src> to C<dest> where C<dest> is
-either a destination filename or destination directory.
-
-=item $status = $h->ntfs_3g_probe ($rw, $device);
-
-This command runs the L<ntfs-3g.probe(8)> command which probes
-an NTFS C<device> for mountability. (Not all NTFS volumes can
-be mounted read-write, and some cannot be mounted at all).
-
-C<rw> is a boolean flag. Set it to true if you want to test
-if the volume can be mounted read-write. Set it to false if
-you want to test if the volume can be mounted read-only.
-
-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.
-
-=item $h->ping_daemon ();
-
-This is a test probe into the guestfs daemon running inside
-the qemu subprocess. Calling this function checks that the
-daemon responds to the ping message, without affecting the daemon
-or attached block device(s) in any other way.
-
-=item $h->pvcreate ($device);
-
-This creates an LVM physical volume on the named C<device>,
-where C<device> should usually be a partition name such
-as C</dev/sda1>.
-
-=item $h->pvremove ($device);
-
-This wipes a physical volume C<device> so that LVM will no longer
-recognise it.
-
-The implementation uses the C<pvremove> command which refuses to
-wipe physical volumes that contain any volume groups, so you have
-to remove those first.
-
-=item $h->pvresize ($device);
-
-This resizes (expands or shrinks) an existing LVM physical
-volume to match the new size of the underlying device.
-
-=item @physvols = $h->pvs ();
-
-List all the physical volumes detected. This is the equivalent
-of the L<pvs(8)> command.
-
-This returns a list of just the device names that contain
-PVs (eg. C</dev/sda2>).
-
-See also C<$h-E<gt>pvs_full>.
-
-=item @physvols = $h->pvs_full ();
-
-List all the physical volumes detected. This is the equivalent
-of the L<pvs(8)> command. The "full" version includes all fields.
-
-=item @lines = $h->read_lines ($path);
-
-Return the contents of the file named C<path>.
-
-The file contents are returned as a list of lines. Trailing
-C<LF> and C<CRLF> character sequences are I<not> returned.
-
-Note that this function cannot correctly handle binary files
-(specifically, files containing C<\0> character which is treated
-as end of line). For those you need to use the C<$h-E<gt>read_file>
-function which has a more complex interface.
-
-=item @entries = $h->readdir ($dir);
-
-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<$h-E<gt>ls>. To get a printable
-directory for human consumption, use C<$h-E<gt>ll>.
-
-=item $h->resize2fs ($device);
-
-This resizes an ext2 or ext3 filesystem to match the size of
-the underlying device.
-
-I<Note:> It is sometimes required that you run C<$h-E<gt>e2fsck_f>
-on the C<device> before calling this command. For unknown reasons
-C<resize2fs> sometimes gives an error about this and sometimes not.
-In any case, it is always safe to call C<$h-E<gt>e2fsck_f> before
-calling this function.
-
-=item $h->rm ($path);
-
-Remove the single file C<path>.
-
-=item $h->rm_rf ($path);
-
-Remove the file or directory C<path>, recursively removing the
-contents if its a directory. This is like the C<rm -rf> shell
-command.
-
-=item $h->rmdir ($path);
-
-Remove the single directory C<path>.
-
-=item $h->scrub_device ($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.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=item $h->scrub_file ($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.
-
-=item $h->scrub_freespace ($dir);
-
-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<$h-E<gt>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.
-
-=item $h->set_append ($append);
-
-This function is used to add additional options to the
-guest kernel command line.
-
-The default is C<NULL> unless overridden by setting
-C<LIBGUESTFS_APPEND> environment variable.
-
-Setting C<append> to C<NULL> means I<no> additional options
-are passed (libguestfs always adds a few of its own).
-
-=item $h->set_autosync ($autosync);
-
-If C<autosync> is true, this enables autosync. Libguestfs will make a
-best effort attempt to run C<$h-E<gt>umount_all> followed by
-C<$h-E<gt>sync> when the handle is closed
-(also if the program exits without closing handles).
-
-This is disabled by default (except in guestfish where it is
-enabled by default).
-
-=item $h->set_busy ();
-
-This sets the state to C<BUSY>. This is only used when implementing
-actions using the low-level API.
-
-For more information on states, see L<guestfs(3)>.
-
-=item $h->set_e2label ($device, $label);
-
-This sets the ext2/3/4 filesystem label of the filesystem on
-C<device> to C<label>. Filesystem labels are limited to
-16 characters.
-
-You can use either C<$h-E<gt>tune2fs_l> or C<$h-E<gt>get_e2label>
-to return the existing label on a filesystem.
-
-=item $h->set_e2uuid ($device, $uuid);
-
-This sets the ext2/3/4 filesystem UUID of the filesystem on
-C<device> to C<uuid>. The format of the UUID and alternatives
-such as C<clear>, C<random> and C<time> are described in the
-L<tune2fs(8)> manpage.
-
-You can use either C<$h-E<gt>tune2fs_l> or C<$h-E<gt>get_e2uuid>
-to return the existing UUID of a filesystem.
-
-=item $h->set_memsize ($memsize);
-
-This sets the memory size in megabytes allocated to the
-qemu subprocess. This only has any effect if called before
-C<$h-E<gt>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)>.
-
-=item $h->set_path ($path);
-
-Set the path that libguestfs searches for kernel and initrd.img.
-
-The default is C<$libdir/guestfs> unless overridden by setting
-C<LIBGUESTFS_PATH> environment variable.
-
-Setting C<path> to C<NULL> restores the default path.
-
-=item $h->set_qemu ($qemu);
-
-Set the qemu binary that we will use.
-
-The default is chosen when the library was compiled by the
-configure script.
-
-You can also override this by setting the C<LIBGUESTFS_QEMU>
-environment variable.
-
-Setting C<qemu> to C<NULL> restores the default qemu binary.
-
-=item $h->set_ready ();
-
-This sets the state to C<READY>. This is only used when implementing
-actions using the low-level API.
-
-For more information on states, see L<guestfs(3)>.
-
-=item $h->set_verbose ($verbose);
-
-If C<verbose> is true, this turns on verbose messages (to C<stderr>).
-
-Verbose messages are disabled unless the environment variable
-C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
-
-=item $h->sfdisk ($device, $cyls, $heads, $sectors, \@lines);
-
-This is a direct interface to the L<sfdisk(8)> program for creating
-partitions on block devices.
-
-C<device> should be a block device, for example C</dev/sda>.
-
-C<cyls>, C<heads> and C<sectors> are the number of cylinders, heads
-and sectors on the device, which are passed directly to sfdisk as
-the I<-C>, I<-H> and I<-S> parameters. If you pass C<0> for any
-of these, then the corresponding parameter is omitted. Usually for
-'large' disks, you can just pass C<0> for these, but for small
-(floppy-sized) disks, sfdisk (or rather, the kernel) cannot work
-out the right geometry and you will need to tell it.
-
-C<lines> is a list of lines that we feed to C<sfdisk>. For more
-information refer to the L<sfdisk(8)> manpage.
-
-To create a single partition occupying the whole disk, you would
-pass C<lines> as a single element list, when the single element being
-the string C<,> (comma).
-
-See also: C<$h-E<gt>sfdisk_l>, C<$h-E<gt>sfdisk_N>
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=item $h->sfdisk_N ($device, $partnum, $cyls, $heads, $sectors, $line);
-
-This runs L<sfdisk(8)> option to modify just the single
-partition C<n> (note: C<n> counts from 1).
-
-For other parameters, see C<$h-E<gt>sfdisk>. You should usually
-pass C<0> for the cyls/heads/sectors parameters.
-
-B<This command is dangerous. Without careful use you
-can easily destroy all your data>.
-
-=item $partitions = $h->sfdisk_disk_geometry ($device);
-
-This displays the disk geometry of C<device> read from the
-partition table. Especially in the case where the underlying
-block device has been resized, this can be different from the
-kernel's idea of the geometry (see C<$h-E<gt>sfdisk_kernel_geometry>).
-
-The result is in human-readable format, and not designed to
-be parsed.
-
-=item $partitions = $h->sfdisk_kernel_geometry ($device);
-
-This displays the kernel's idea of the geometry of C<device>.
-
-The result is in human-readable format, and not designed to
-be parsed.
-
-=item $partitions = $h->sfdisk_l ($device);
-
-This displays the partition table on C<device>, in the
-human-readable output of the L<sfdisk(8)> command. It is
-not intended to be parsed.
-
-=item $output = $h->sh ($command);
-
-This call runs a command from the guest filesystem via the
-guest's C</bin/sh>.
-
-This is like C<$h-E<gt>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<$h-E<gt>command> apply to this call.
-
-=item @lines = $h->sh_lines ($command);
-
-This is the same as C<$h-E<gt>sh>, but splits the result
-into a list of lines.
-
-See also: C<$h-E<gt>command_lines>
-
-=item $h->sleep ($secs);
-
-Sleep for C<secs> seconds.
-
-=item %statbuf = $h->stat ($path);
-
-Returns file information for the given C<path>.
-
-This is the same as the C<stat(2)> system call.
-
-=item %statbuf = $h->statvfs ($path);
-
-Returns file system statistics for any mounted file system.
-C<path> should be a file or directory in the mounted file system
-(typically it is the mount point itself, but it doesn't need to be).
-
-This is the same as the C<statvfs(2)> system call.
-
-=item @stringsout = $h->strings ($path);
-
-This runs the L<strings(1)> command on a file and returns
-the list of printable strings found.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item @stringsout = $h->strings_e ($encoding, $path);
-
-This is like the C<$h-E<gt>strings> command, but allows you to
-specify the encoding.
-
-See the L<strings(1)> manpage for the full list of encodings.
-
-Commonly useful encodings are C<l> (lower case L) which will
-show strings inside Windows/x86 files.
-
-The returned strings are transcoded to UTF-8.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item $h->sync ();
-
-This syncs the disk, so that any writes are flushed through to the
-underlying disk image.
-
-You should always call this if you have modified a disk image, before
-closing the handle.
-
-=item @lines = $h->tail ($path);
-
-This command returns up to the last 10 lines of a file as
-a list of strings.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item @lines = $h->tail_n ($nrlines, $path);
-
-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.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item $h->tar_in ($tarfile, $directory);
-
-This command uploads and unpacks local file C<tarfile> (an
-I<uncompressed> tar file) into C<directory>.
-
-To upload a compressed tarball, use C<$h-E<gt>tgz_in>.
-
-=item $h->tar_out ($directory, $tarfile);
-
-This command packs the contents of C<directory> and downloads
-it to local file C<tarfile>.
-
-To download a compressed tarball, use C<$h-E<gt>tgz_out>.
-
-=item $h->tgz_in ($tarball, $directory);
-
-This command uploads and unpacks local file C<tarball> (a
-I<gzip compressed> tar file) into C<directory>.
-
-To upload an uncompressed tarball, use C<$h-E<gt>tar_in>.
-
-=item $h->tgz_out ($directory, $tarball);
-
-This command packs the contents of C<directory> and downloads
-it to local file C<tarball>.
-
-To download an uncompressed tarball, use C<$h-E<gt>tar_out>.
-
-=item $h->touch ($path);
-
-Touch acts like the L<touch(1)> command. It can be used to
-update the timestamps on a file, or, if the file does not exist,
-to create a new zero-length file.
-
-=item %superblock = $h->tune2fs_l ($device);
-
-This returns the contents of the ext2, ext3 or ext4 filesystem
-superblock on C<device>.
-
-It is the same as running C<tune2fs -l device>. See L<tune2fs(8)>
-manpage for more details. The list of fields returned isn't
-clearly defined, and depends on both the version of C<tune2fs>
-that libguestfs was built against, and the filesystem itself.
-
-=item $oldmask = $h->umask ($mask);
-
-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<$h-E<gt>mknod>, C<$h-E<gt>mkdir>.
-
-This call returns the previous umask.
-
-=item $h->umount ($pathordevice);
-
-This unmounts the given filesystem. The filesystem may be
-specified either by its mountpoint (path) or the device which
-contains the filesystem.
-
-=item $h->umount_all ();
-
-This unmounts all mounted filesystems.
-
-Some internal mounts are not unmounted by this call.
-
-=item $h->upload ($filename, $remotefilename);
-
-Upload local file C<filename> to C<remotefilename> on the
-filesystem.
-
-C<filename> can also be a named pipe.
-
-See also C<$h-E<gt>download>.
-
-=item $h->vg_activate ($activate, \@volgroups);
-
-This command activates or (if C<activate> is false) deactivates
-all logical volumes in the listed volume groups C<volgroups>.
-If activated, then they are made known to the
-kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
-then those devices disappear.
-
-This command is the same as running C<vgchange -a y|n volgroups...>
-
-Note that if C<volgroups> is an empty list then B<all> volume groups
-are activated or deactivated.
-
-=item $h->vg_activate_all ($activate);
-
-This command activates or (if C<activate> is false) deactivates
-all logical volumes in all volume groups.
-If activated, then they are made known to the
-kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
-then those devices disappear.
-
-This command is the same as running C<vgchange -a y|n>
-
-=item $h->vgcreate ($volgroup, \@physvols);
-
-This creates an LVM volume group called C<volgroup>
-from the non-empty list of physical volumes C<physvols>.
-
-=item $h->vgremove ($vgname);
-
-Remove an LVM volume group C<vgname>, (for example C<VG>).
-
-This also forcibly removes all logical volumes in the volume
-group (if any).
-
-=item @volgroups = $h->vgs ();
-
-List all the volumes groups detected. This is the equivalent
-of the L<vgs(8)> command.
-
-This returns a list of just the volume group names that were
-detected (eg. C<VolGroup00>).
-
-See also C<$h-E<gt>vgs_full>.
-
-=item @volgroups = $h->vgs_full ();
-
-List all the volumes groups detected. This is the equivalent
-of the L<vgs(8)> command. The "full" version includes all fields.
-
-=item $h->wait_ready ();
-
-Internally libguestfs is implemented by running a virtual machine
-using L<qemu(1)>.
-
-You should call this after C<$h-E<gt>launch> to wait for the launch
-to complete.
-
-=item $chars = $h->wc_c ($path);
-
-This command counts the characters in a file, using the
-C<wc -c> external command.
-
-=item $lines = $h->wc_l ($path);
-
-This command counts the lines in a file, using the
-C<wc -l> external command.
-
-=item $words = $h->wc_w ($path);
-
-This command counts the words in a file, using the
-C<wc -w> external command.
-
-=item $h->write_file ($path, $content, $size);
-
-This call creates a file called C<path>. The contents of the
-file is the string C<content> (which can contain any 8 bit data),
-with length C<size>.
-
-As a special case, if C<size> is C<0>
-then the length is calculated using C<strlen> (so in this case
-the content cannot contain embedded ASCII NULs).
-
-I<NB.> Owing to a bug, writing content containing ASCII NUL
-characters does I<not> work, even if the length is specified.
-We hope to resolve this bug in a future version. In the meantime
-use C<$h-E<gt>upload>.
-
-Because of the message protocol, there is a transfer limit
-of somewhere between 2MB and 4MB. To transfer large files you should use
-FTP.
-
-=item $h->zero ($device);
-
-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.
-
-See also: C<$h-E<gt>scrub_device>.
-
-=item $h->zerofree ($device);
-
-This runs the I<zerofree> program on C<device>. This program
-claims to zero unused inodes and disk blocks on an ext2/3
-filesystem, thus making it possible to compress the filesystem
-more effectively.
-
-You should B<not> run this program if the filesystem is
-mounted.
-
-It is possible that using this program can damage the filesystem
-or data on the filesystem.
-
-=cut
-
-1;
-
-=back
-
-=head1 COPYRIGHT
-
-Copyright (C) 2009 Red Hat Inc.
-
-=head1 LICENSE
-
-Please see the file COPYING.LIB for the full license.
-
-=head1 SEE ALSO
-
-L<guestfs(3)>, L<guestfish(1)>.
-
-=cut
+++ /dev/null
-# 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 program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-import guestfs
-
-g = guestfs.GuestFS ()
-g.test0 ("abc", "def", [], 0, 0, "123", "456")
-g.test0 ("abc", None, [], 0, 0, "123", "456")
-g.test0 ("", "def", [], 0, 0, "123", "456")
-g.test0 ("", "", [], 0, 0, "123", "456")
-g.test0 ("abc", "def", ["1"], 0, 0, "123", "456")
-g.test0 ("abc", "def", ["1","2"], 0, 0, "123", "456")
-g.test0 ("abc", "def", ["1"], 1, 0, "123", "456")
-g.test0 ("abc", "def", ["1"], 0, -1, "123", "456")
-g.test0 ("abc", "def", ["1"], 0, -2, "123", "456")
-g.test0 ("abc", "def", ["1"], 0, 1, "123", "456")
-g.test0 ("abc", "def", ["1"], 0, 2, "123", "456")
-g.test0 ("abc", "def", ["1"], 0, 4095, "123", "456")
-g.test0 ("abc", "def", ["1"], 0, 0, "", "")
-print "EOF"
+++ /dev/null
-/* 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 <assert.h>
-
-#include <Python.h>
-
-#include "guestfs.h"
-
-typedef struct {
- PyObject_HEAD
- guestfs_h *g;
-} Pyguestfs_Object;
-
-static guestfs_h *
-get_handle (PyObject *obj)
-{
- assert (obj);
- assert (obj != Py_None);
- return ((Pyguestfs_Object *) obj)->g;
-}
-
-static PyObject *
-put_handle (guestfs_h *g)
-{
- assert (g);
- return
- PyCObject_FromVoidPtrAndDesc ((void *) g, (char *) "guestfs_h", NULL);
-}
-
-/* This list should be freed (but not the strings) after use. */
-static const char **
-get_string_list (PyObject *obj)
-{
- int i, len;
- const char **r;
-
- assert (obj);
-
- if (!PyList_Check (obj)) {
- PyErr_SetString (PyExc_RuntimeError, "expecting a list parameter");
- return NULL;
- }
-
- len = PyList_Size (obj);
- r = malloc (sizeof (char *) * (len+1));
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, "get_string_list: out of memory");
- return NULL;
- }
-
- for (i = 0; i < len; ++i)
- r[i] = PyString_AsString (PyList_GetItem (obj, i));
- r[len] = NULL;
-
- return r;
-}
-
-static PyObject *
-put_string_list (char * const * const argv)
-{
- PyObject *list;
- int argc, i;
-
- for (argc = 0; argv[argc] != NULL; ++argc)
- ;
-
- list = PyList_New (argc);
- for (i = 0; i < argc; ++i)
- PyList_SetItem (list, i, PyString_FromString (argv[i]));
-
- return list;
-}
-
-static PyObject *
-put_table (char * const * const argv)
-{
- PyObject *list, *item;
- int argc, i;
-
- for (argc = 0; argv[argc] != NULL; ++argc)
- ;
-
- list = PyList_New (argc >> 1);
- for (i = 0; i < argc; i += 2) {
- item = PyTuple_New (2);
- PyTuple_SetItem (item, 0, PyString_FromString (argv[i]));
- PyTuple_SetItem (item, 1, PyString_FromString (argv[i+1]));
- PyList_SetItem (list, i >> 1, item);
- }
-
- return list;
-}
-
-static void
-free_strings (char **argv)
-{
- int argc;
-
- for (argc = 0; argv[argc] != NULL; ++argc)
- free (argv[argc]);
- free (argv);
-}
-
-static PyObject *
-py_guestfs_create (PyObject *self, PyObject *args)
-{
- guestfs_h *g;
-
- g = guestfs_create ();
- if (g == NULL) {
- PyErr_SetString (PyExc_RuntimeError,
- "guestfs.create: failed to allocate handle");
- return NULL;
- }
- guestfs_set_error_handler (g, NULL, NULL);
- return put_handle (g);
-}
-
-static PyObject *
-py_guestfs_close (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_close", &py_g))
- return NULL;
- g = get_handle (py_g);
-
- guestfs_close (g);
-
- Py_INCREF (Py_None);
- return Py_None;
-}
-
-static PyObject *
-put_lvm_pv (struct guestfs_lvm_pv *pv)
-{
- PyObject *dict;
-
- dict = PyDict_New ();
- PyDict_SetItemString (dict, "pv_name",
- PyString_FromString (pv->pv_name));
- PyDict_SetItemString (dict, "pv_uuid",
- PyString_FromStringAndSize (pv->pv_uuid, 32));
- PyDict_SetItemString (dict, "pv_fmt",
- PyString_FromString (pv->pv_fmt));
- PyDict_SetItemString (dict, "pv_size",
- PyLong_FromUnsignedLongLong (pv->pv_size));
- PyDict_SetItemString (dict, "dev_size",
- PyLong_FromUnsignedLongLong (pv->dev_size));
- PyDict_SetItemString (dict, "pv_free",
- PyLong_FromUnsignedLongLong (pv->pv_free));
- PyDict_SetItemString (dict, "pv_used",
- PyLong_FromUnsignedLongLong (pv->pv_used));
- PyDict_SetItemString (dict, "pv_attr",
- PyString_FromString (pv->pv_attr));
- PyDict_SetItemString (dict, "pv_pe_count",
- PyLong_FromLongLong (pv->pv_pe_count));
- PyDict_SetItemString (dict, "pv_pe_alloc_count",
- PyLong_FromLongLong (pv->pv_pe_alloc_count));
- PyDict_SetItemString (dict, "pv_tags",
- PyString_FromString (pv->pv_tags));
- PyDict_SetItemString (dict, "pe_start",
- PyLong_FromUnsignedLongLong (pv->pe_start));
- PyDict_SetItemString (dict, "pv_mda_count",
- PyLong_FromLongLong (pv->pv_mda_count));
- PyDict_SetItemString (dict, "pv_mda_free",
- PyLong_FromUnsignedLongLong (pv->pv_mda_free));
- return dict;
-};
-
-static PyObject *
-put_lvm_pv_list (struct guestfs_lvm_pv_list *pvs)
-{
- PyObject *list;
- int i;
-
- list = PyList_New (pvs->len);
- for (i = 0; i < pvs->len; ++i)
- PyList_SetItem (list, i, put_lvm_pv (&pvs->val[i]));
- return list;
-};
-
-static PyObject *
-put_lvm_vg (struct guestfs_lvm_vg *vg)
-{
- PyObject *dict;
-
- dict = PyDict_New ();
- PyDict_SetItemString (dict, "vg_name",
- PyString_FromString (vg->vg_name));
- PyDict_SetItemString (dict, "vg_uuid",
- PyString_FromStringAndSize (vg->vg_uuid, 32));
- PyDict_SetItemString (dict, "vg_fmt",
- PyString_FromString (vg->vg_fmt));
- PyDict_SetItemString (dict, "vg_attr",
- PyString_FromString (vg->vg_attr));
- PyDict_SetItemString (dict, "vg_size",
- PyLong_FromUnsignedLongLong (vg->vg_size));
- PyDict_SetItemString (dict, "vg_free",
- PyLong_FromUnsignedLongLong (vg->vg_free));
- PyDict_SetItemString (dict, "vg_sysid",
- PyString_FromString (vg->vg_sysid));
- PyDict_SetItemString (dict, "vg_extent_size",
- PyLong_FromUnsignedLongLong (vg->vg_extent_size));
- PyDict_SetItemString (dict, "vg_extent_count",
- PyLong_FromLongLong (vg->vg_extent_count));
- PyDict_SetItemString (dict, "vg_free_count",
- PyLong_FromLongLong (vg->vg_free_count));
- PyDict_SetItemString (dict, "max_lv",
- PyLong_FromLongLong (vg->max_lv));
- PyDict_SetItemString (dict, "max_pv",
- PyLong_FromLongLong (vg->max_pv));
- PyDict_SetItemString (dict, "pv_count",
- PyLong_FromLongLong (vg->pv_count));
- PyDict_SetItemString (dict, "lv_count",
- PyLong_FromLongLong (vg->lv_count));
- PyDict_SetItemString (dict, "snap_count",
- PyLong_FromLongLong (vg->snap_count));
- PyDict_SetItemString (dict, "vg_seqno",
- PyLong_FromLongLong (vg->vg_seqno));
- PyDict_SetItemString (dict, "vg_tags",
- PyString_FromString (vg->vg_tags));
- PyDict_SetItemString (dict, "vg_mda_count",
- PyLong_FromLongLong (vg->vg_mda_count));
- PyDict_SetItemString (dict, "vg_mda_free",
- PyLong_FromUnsignedLongLong (vg->vg_mda_free));
- return dict;
-};
-
-static PyObject *
-put_lvm_vg_list (struct guestfs_lvm_vg_list *vgs)
-{
- PyObject *list;
- int i;
-
- list = PyList_New (vgs->len);
- for (i = 0; i < vgs->len; ++i)
- PyList_SetItem (list, i, put_lvm_vg (&vgs->val[i]));
- return list;
-};
-
-static PyObject *
-put_lvm_lv (struct guestfs_lvm_lv *lv)
-{
- PyObject *dict;
-
- dict = PyDict_New ();
- PyDict_SetItemString (dict, "lv_name",
- PyString_FromString (lv->lv_name));
- PyDict_SetItemString (dict, "lv_uuid",
- PyString_FromStringAndSize (lv->lv_uuid, 32));
- PyDict_SetItemString (dict, "lv_attr",
- PyString_FromString (lv->lv_attr));
- PyDict_SetItemString (dict, "lv_major",
- PyLong_FromLongLong (lv->lv_major));
- PyDict_SetItemString (dict, "lv_minor",
- PyLong_FromLongLong (lv->lv_minor));
- PyDict_SetItemString (dict, "lv_kernel_major",
- PyLong_FromLongLong (lv->lv_kernel_major));
- PyDict_SetItemString (dict, "lv_kernel_minor",
- PyLong_FromLongLong (lv->lv_kernel_minor));
- PyDict_SetItemString (dict, "lv_size",
- PyLong_FromUnsignedLongLong (lv->lv_size));
- PyDict_SetItemString (dict, "seg_count",
- PyLong_FromLongLong (lv->seg_count));
- PyDict_SetItemString (dict, "origin",
- PyString_FromString (lv->origin));
- if (lv->snap_percent >= 0)
- PyDict_SetItemString (dict, "snap_percent",
- PyFloat_FromDouble ((double) lv->snap_percent));
- else {
- Py_INCREF (Py_None);
- PyDict_SetItemString (dict, "snap_percent", Py_None); }
- if (lv->copy_percent >= 0)
- PyDict_SetItemString (dict, "copy_percent",
- PyFloat_FromDouble ((double) lv->copy_percent));
- else {
- Py_INCREF (Py_None);
- PyDict_SetItemString (dict, "copy_percent", Py_None); }
- PyDict_SetItemString (dict, "move_pv",
- PyString_FromString (lv->move_pv));
- PyDict_SetItemString (dict, "lv_tags",
- PyString_FromString (lv->lv_tags));
- PyDict_SetItemString (dict, "mirror_log",
- PyString_FromString (lv->mirror_log));
- PyDict_SetItemString (dict, "modules",
- PyString_FromString (lv->modules));
- return dict;
-};
-
-static PyObject *
-put_lvm_lv_list (struct guestfs_lvm_lv_list *lvs)
-{
- PyObject *list;
- int i;
-
- list = PyList_New (lvs->len);
- for (i = 0; i < lvs->len; ++i)
- PyList_SetItem (list, i, put_lvm_lv (&lvs->val[i]));
- return list;
-};
-
-static PyObject *
-put_stat (struct guestfs_stat *stat)
-{
- PyObject *dict;
-
- dict = PyDict_New ();
- PyDict_SetItemString (dict, "dev",
- PyLong_FromLongLong (stat->dev));
- PyDict_SetItemString (dict, "ino",
- PyLong_FromLongLong (stat->ino));
- PyDict_SetItemString (dict, "mode",
- PyLong_FromLongLong (stat->mode));
- PyDict_SetItemString (dict, "nlink",
- PyLong_FromLongLong (stat->nlink));
- PyDict_SetItemString (dict, "uid",
- PyLong_FromLongLong (stat->uid));
- PyDict_SetItemString (dict, "gid",
- PyLong_FromLongLong (stat->gid));
- PyDict_SetItemString (dict, "rdev",
- PyLong_FromLongLong (stat->rdev));
- PyDict_SetItemString (dict, "size",
- PyLong_FromLongLong (stat->size));
- PyDict_SetItemString (dict, "blksize",
- PyLong_FromLongLong (stat->blksize));
- PyDict_SetItemString (dict, "blocks",
- PyLong_FromLongLong (stat->blocks));
- PyDict_SetItemString (dict, "atime",
- PyLong_FromLongLong (stat->atime));
- PyDict_SetItemString (dict, "mtime",
- PyLong_FromLongLong (stat->mtime));
- PyDict_SetItemString (dict, "ctime",
- PyLong_FromLongLong (stat->ctime));
- return dict;
-};
-
-static PyObject *
-put_statvfs (struct guestfs_statvfs *statvfs)
-{
- PyObject *dict;
-
- dict = PyDict_New ();
- PyDict_SetItemString (dict, "bsize",
- PyLong_FromLongLong (statvfs->bsize));
- PyDict_SetItemString (dict, "frsize",
- PyLong_FromLongLong (statvfs->frsize));
- PyDict_SetItemString (dict, "blocks",
- PyLong_FromLongLong (statvfs->blocks));
- PyDict_SetItemString (dict, "bfree",
- PyLong_FromLongLong (statvfs->bfree));
- PyDict_SetItemString (dict, "bavail",
- PyLong_FromLongLong (statvfs->bavail));
- PyDict_SetItemString (dict, "files",
- PyLong_FromLongLong (statvfs->files));
- PyDict_SetItemString (dict, "ffree",
- PyLong_FromLongLong (statvfs->ffree));
- PyDict_SetItemString (dict, "favail",
- PyLong_FromLongLong (statvfs->favail));
- PyDict_SetItemString (dict, "fsid",
- PyLong_FromLongLong (statvfs->fsid));
- PyDict_SetItemString (dict, "flag",
- PyLong_FromLongLong (statvfs->flag));
- PyDict_SetItemString (dict, "namemax",
- PyLong_FromLongLong (statvfs->namemax));
- return dict;
-};
-
-static PyObject *
-put_dirent (struct guestfs_dirent *dirent)
-{
- PyObject *dict;
-
- dict = PyDict_New ();
- PyDict_SetItemString (dict, "ino",
- PyLong_FromLongLong (dirent->ino));
- PyDict_SetItemString (dict, "ftyp",
- PyString_FromStringAndSize (&dirent->ftyp, 1));
- PyDict_SetItemString (dict, "name",
- PyString_FromString (dirent->name));
- return dict;
-};
-
-static PyObject *
-put_dirent_list (struct guestfs_dirent_list *dirents)
-{
- PyObject *list;
- int i;
-
- list = PyList_New (dirents->len);
- for (i = 0; i < dirents->len; ++i)
- PyList_SetItem (list, i, put_dirent (&dirents->val[i]));
- return list;
-};
-
-static PyObject *
-py_guestfs_test0 (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *str;
- const char *optstr;
- PyObject *py_strlist;
- const char **strlist;
- int b;
- int integer;
- const char *filein;
- const char *fileout;
-
- if (!PyArg_ParseTuple (args, (char *) "OszOiiss:guestfs_test0",
- &py_g, &str, &optstr, &py_strlist, &b, &integer, &filein, &fileout))
- return NULL;
- g = get_handle (py_g);
- strlist = get_string_list (py_strlist);
- if (!strlist) return NULL;
-
- r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout);
- free (strlist);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rint (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rint",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rint (g, val);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rinterr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rinterr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rinterr (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rint64 (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int64_t r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rint64",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rint64 (g, val);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyLong_FromLongLong (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rint64err (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int64_t r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rint64err",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rint64err (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyLong_FromLongLong (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rbool (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rbool",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rbool (g, val);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rboolerr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rboolerr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rboolerr (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rconststring (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- const char *r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rconststring",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rconststring (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rconststringerr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- const char *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rconststringerr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rconststringerr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rstring (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rstring",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rstring (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rstringerr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rstringerr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rstringerr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rstringlist (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rstringlist",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rstringlist (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rstringlisterr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rstringlisterr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rstringlisterr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rintbool (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_int_bool *r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rintbool",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rintbool (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyTuple_New (2);
- PyTuple_SetItem (py_r, 0, PyInt_FromLong ((long) r->i));
- PyTuple_SetItem (py_r, 1, PyInt_FromLong ((long) r->b));
- guestfs_free_int_bool (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rintboolerr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_int_bool *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rintboolerr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rintboolerr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyTuple_New (2);
- PyTuple_SetItem (py_r, 0, PyInt_FromLong ((long) r->i));
- PyTuple_SetItem (py_r, 1, PyInt_FromLong ((long) r->b));
- guestfs_free_int_bool (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rpvlist (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_lvm_pv_list *r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rpvlist",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rpvlist (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_lvm_pv_list (r);
- guestfs_free_lvm_pv_list (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rpvlisterr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_lvm_pv_list *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rpvlisterr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rpvlisterr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_lvm_pv_list (r);
- guestfs_free_lvm_pv_list (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rvglist (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_lvm_vg_list *r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rvglist",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rvglist (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_lvm_vg_list (r);
- guestfs_free_lvm_vg_list (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rvglisterr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_lvm_vg_list *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rvglisterr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rvglisterr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_lvm_vg_list (r);
- guestfs_free_lvm_vg_list (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rlvlist (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_lvm_lv_list *r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rlvlist",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rlvlist (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_lvm_lv_list (r);
- guestfs_free_lvm_lv_list (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rlvlisterr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_lvm_lv_list *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rlvlisterr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rlvlisterr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_lvm_lv_list (r);
- guestfs_free_lvm_lv_list (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rstat (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_stat *r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rstat",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rstat (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_stat (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rstaterr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_stat *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rstaterr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rstaterr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_stat (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rstatvfs (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_statvfs *r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rstatvfs",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rstatvfs (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_statvfs (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rstatvfserr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_statvfs *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rstatvfserr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rstatvfserr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_statvfs (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rhashtable (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rhashtable",
- &py_g, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rhashtable (g, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_table (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_test0rhashtableerr (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rhashtableerr",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_test0rhashtableerr (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_table (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_launch (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_launch",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_launch (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_wait_ready (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_wait_ready",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_wait_ready (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_kill_subprocess (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_kill_subprocess",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_kill_subprocess (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_add_drive (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *filename;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_add_drive",
- &py_g, &filename))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_add_drive (g, filename);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_add_cdrom (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *filename;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_add_cdrom",
- &py_g, &filename))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_add_cdrom (g, filename);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_add_drive_ro (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *filename;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_add_drive_ro",
- &py_g, &filename))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_add_drive_ro (g, filename);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_config (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *qemuparam;
- const char *qemuvalue;
-
- if (!PyArg_ParseTuple (args, (char *) "Osz:guestfs_config",
- &py_g, &qemuparam, &qemuvalue))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_config (g, qemuparam, qemuvalue);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_qemu (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *qemu;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_set_qemu",
- &py_g, &qemu))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_qemu (g, qemu);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_get_qemu (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- const char *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_qemu",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_get_qemu (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_path (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_set_path",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_path (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_get_path (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- const char *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_path",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_get_path (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_append (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *append;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_set_append",
- &py_g, &append))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_append (g, append);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_get_append (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- const char *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_append",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_get_append (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_autosync (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int autosync;
-
- if (!PyArg_ParseTuple (args, (char *) "Oi:guestfs_set_autosync",
- &py_g, &autosync))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_autosync (g, autosync);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_get_autosync (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_autosync",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_get_autosync (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_verbose (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int verbose;
-
- if (!PyArg_ParseTuple (args, (char *) "Oi:guestfs_set_verbose",
- &py_g, &verbose))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_verbose (g, verbose);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_get_verbose (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_verbose",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_get_verbose (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_is_ready (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_is_ready",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_is_ready (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_is_config (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_is_config",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_is_config (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_is_launching (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_is_launching",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_is_launching (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_is_busy (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_is_busy",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_is_busy (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_get_state (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_state",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_get_state (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_busy (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_set_busy",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_busy (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_ready (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_set_ready",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_ready (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_end_busy (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_end_busy",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_end_busy (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_memsize (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int memsize;
-
- if (!PyArg_ParseTuple (args, (char *) "Oi:guestfs_set_memsize",
- &py_g, &memsize))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_memsize (g, memsize);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_get_memsize (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_memsize",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_get_memsize (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mount (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
- const char *mountpoint;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mount",
- &py_g, &device, &mountpoint))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_sync (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_sync",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_sync (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_touch (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_touch",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_touch (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_cat (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_cat",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_cat (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_ll (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *directory;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_ll",
- &py_g, &directory))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_ll (g, directory);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_ls (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *directory;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_ls",
- &py_g, &directory))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_ls (g, directory);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_list_devices (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_list_devices",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_list_devices (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_list_partitions (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_list_partitions",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_list_partitions (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_pvs (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_pvs",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_pvs (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_vgs (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_vgs",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_vgs (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_lvs (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_lvs",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_lvs (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_pvs_full (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_lvm_pv_list *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_pvs_full",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_pvs_full (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_lvm_pv_list (r);
- guestfs_free_lvm_pv_list (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_vgs_full (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_lvm_vg_list *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_vgs_full",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_vgs_full (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_lvm_vg_list (r);
- guestfs_free_lvm_vg_list (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_lvs_full (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_lvm_lv_list *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_lvs_full",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_lvs_full (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_lvm_lv_list (r);
- guestfs_free_lvm_lv_list (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_read_lines (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_read_lines",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_read_lines (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_init (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *root;
- int flags;
-
- if (!PyArg_ParseTuple (args, (char *) "Osi:guestfs_aug_init",
- &py_g, &root, &flags))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_init (g, root, flags);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_close (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_aug_close",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_close (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_defvar (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *name;
- const char *expr;
-
- if (!PyArg_ParseTuple (args, (char *) "Osz:guestfs_aug_defvar",
- &py_g, &name, &expr))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_defvar (g, name, expr);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_defnode (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_int_bool *r;
- const char *name;
- const char *expr;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Osss:guestfs_aug_defnode",
- &py_g, &name, &expr, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_defnode (g, name, expr, val);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyTuple_New (2);
- PyTuple_SetItem (py_r, 0, PyInt_FromLong ((long) r->i));
- PyTuple_SetItem (py_r, 1, PyInt_FromLong ((long) r->b));
- guestfs_free_int_bool (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_get (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_aug_get",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_get (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_set (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
- const char *val;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_aug_set",
- &py_g, &path, &val))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_set (g, path, val);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_insert (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
- const char *label;
- int before;
-
- if (!PyArg_ParseTuple (args, (char *) "Ossi:guestfs_aug_insert",
- &py_g, &path, &label, &before))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_insert (g, path, label, before);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_rm (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_aug_rm",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_rm (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_mv (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *src;
- const char *dest;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_aug_mv",
- &py_g, &src, &dest))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_mv (g, src, dest);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_match (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_aug_match",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_match (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_save (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_aug_save",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_save (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_load (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_aug_load",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_load (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_aug_ls (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_aug_ls",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_aug_ls (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_rm (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_rm",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_rm (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_rmdir (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_rmdir",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_rmdir (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_rm_rf (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_rm_rf",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_rm_rf (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mkdir (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_mkdir",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mkdir (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mkdir_p (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_mkdir_p",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mkdir_p (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_chmod (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int mode;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Ois:guestfs_chmod",
- &py_g, &mode, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_chmod (g, mode, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_chown (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int owner;
- int group;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Oiis:guestfs_chown",
- &py_g, &owner, &group, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_chown (g, owner, group, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_exists (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_exists",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_exists (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_is_file (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_is_file",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_is_file (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_is_dir (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_is_dir",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_is_dir (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_pvcreate (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_pvcreate",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_pvcreate (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_vgcreate (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *volgroup;
- PyObject *py_physvols;
- const char **physvols;
-
- if (!PyArg_ParseTuple (args, (char *) "OsO:guestfs_vgcreate",
- &py_g, &volgroup, &py_physvols))
- return NULL;
- g = get_handle (py_g);
- physvols = get_string_list (py_physvols);
- if (!physvols) return NULL;
-
- r = guestfs_vgcreate (g, volgroup, physvols);
- free (physvols);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_lvcreate (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *logvol;
- const char *volgroup;
- int mbytes;
-
- if (!PyArg_ParseTuple (args, (char *) "Ossi:guestfs_lvcreate",
- &py_g, &logvol, &volgroup, &mbytes))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mkfs (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *fstype;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mkfs",
- &py_g, &fstype, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_sfdisk (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
- int cyls;
- int heads;
- int sectors;
- PyObject *py_lines;
- const char **lines;
-
- if (!PyArg_ParseTuple (args, (char *) "OsiiiO:guestfs_sfdisk",
- &py_g, &device, &cyls, &heads, §ors, &py_lines))
- return NULL;
- g = get_handle (py_g);
- lines = get_string_list (py_lines);
- if (!lines) return NULL;
-
- r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
- free (lines);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_write_file (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
- const char *content;
- int size;
-
- if (!PyArg_ParseTuple (args, (char *) "Ossi:guestfs_write_file",
- &py_g, &path, &content, &size))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_write_file (g, path, content, size);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_umount (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *pathordevice;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_umount",
- &py_g, &pathordevice))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_umount (g, pathordevice);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mounts (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_mounts",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mounts (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_umount_all (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_umount_all",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_umount_all (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_lvm_remove_all (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_lvm_remove_all",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_lvm_remove_all (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_file (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_file",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_file (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_command (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- PyObject *py_arguments;
- const char **arguments;
-
- if (!PyArg_ParseTuple (args, (char *) "OO:guestfs_command",
- &py_g, &py_arguments))
- return NULL;
- g = get_handle (py_g);
- arguments = get_string_list (py_arguments);
- if (!arguments) return NULL;
-
- r = guestfs_command (g, arguments);
- free (arguments);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_command_lines (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- PyObject *py_arguments;
- const char **arguments;
-
- if (!PyArg_ParseTuple (args, (char *) "OO:guestfs_command_lines",
- &py_g, &py_arguments))
- return NULL;
- g = get_handle (py_g);
- arguments = get_string_list (py_arguments);
- if (!arguments) return NULL;
-
- r = guestfs_command_lines (g, arguments);
- free (arguments);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_stat (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_stat *r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_stat",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_stat (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_stat (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_lstat (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_stat *r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_lstat",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_lstat (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_stat (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_statvfs (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_statvfs *r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_statvfs",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_statvfs (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_statvfs (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_tune2fs_l (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_tune2fs_l",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_tune2fs_l (g, device);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_table (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_setro (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_blockdev_setro",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_setro (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_setrw (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_blockdev_setrw",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_getro (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_blockdev_getro",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_getro (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_getss (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_blockdev_getss",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_getss (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_getbsz (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_blockdev_getbsz",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_getbsz (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_setbsz (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
- int blocksize;
-
- if (!PyArg_ParseTuple (args, (char *) "Osi:guestfs_blockdev_setbsz",
- &py_g, &device, &blocksize))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_setbsz (g, device, blocksize);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_getsz (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int64_t r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_blockdev_getsz",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_getsz (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyLong_FromLongLong (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_getsize64 (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int64_t r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_blockdev_getsize64",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_getsize64 (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyLong_FromLongLong (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_flushbufs (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_blockdev_flushbufs",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_flushbufs (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_blockdev_rereadpt (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_blockdev_rereadpt",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_blockdev_rereadpt (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_upload (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *filename;
- const char *remotefilename;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_upload",
- &py_g, &filename, &remotefilename))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_upload (g, filename, remotefilename);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_download (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *remotefilename;
- const char *filename;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_download",
- &py_g, &remotefilename, &filename))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_download (g, remotefilename, filename);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_checksum (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *csumtype;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_checksum",
- &py_g, &csumtype, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_tar_in (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *tarfile;
- const char *directory;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_tar_in",
- &py_g, &tarfile, &directory))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_tar_in (g, tarfile, directory);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_tar_out (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *directory;
- const char *tarfile;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_tar_out",
- &py_g, &directory, &tarfile))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_tar_out (g, directory, tarfile);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_tgz_in (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *tarball;
- const char *directory;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_tgz_in",
- &py_g, &tarball, &directory))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_tgz_in (g, tarball, directory);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_tgz_out (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *directory;
- const char *tarball;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_tgz_out",
- &py_g, &directory, &tarball))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_tgz_out (g, directory, tarball);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mount_ro (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
- const char *mountpoint;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mount_ro",
- &py_g, &device, &mountpoint))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mount_ro (g, device, mountpoint);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mount_options (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *options;
- const char *device;
- const char *mountpoint;
-
- if (!PyArg_ParseTuple (args, (char *) "Osss:guestfs_mount_options",
- &py_g, &options, &device, &mountpoint))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mount_options (g, options, device, mountpoint);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mount_vfs (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *options;
- const char *vfstype;
- const char *device;
- const char *mountpoint;
-
- if (!PyArg_ParseTuple (args, (char *) "Ossss:guestfs_mount_vfs",
- &py_g, &options, &vfstype, &device, &mountpoint))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_debug (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *subcmd;
- PyObject *py_extraargs;
- const char **extraargs;
-
- if (!PyArg_ParseTuple (args, (char *) "OsO:guestfs_debug",
- &py_g, &subcmd, &py_extraargs))
- return NULL;
- g = get_handle (py_g);
- extraargs = get_string_list (py_extraargs);
- if (!extraargs) return NULL;
-
- r = guestfs_debug (g, subcmd, extraargs);
- free (extraargs);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_lvremove (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_lvremove",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_lvremove (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_vgremove (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *vgname;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_vgremove",
- &py_g, &vgname))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_vgremove (g, vgname);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_pvremove (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_pvremove",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_pvremove (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_e2label (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
- const char *label;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_set_e2label",
- &py_g, &device, &label))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_e2label (g, device, label);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_get_e2label (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_get_e2label",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_get_e2label (g, device);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_set_e2uuid (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
- const char *uuid;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_set_e2uuid",
- &py_g, &device, &uuid))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_get_e2uuid (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_get_e2uuid",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_get_e2uuid (g, device);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_fsck (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *fstype;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_fsck",
- &py_g, &fstype, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_fsck (g, fstype, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_zero (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_zero",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_zero (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_grub_install (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *root;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_grub_install",
- &py_g, &root, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_grub_install (g, root, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_cp (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *src;
- const char *dest;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_cp",
- &py_g, &src, &dest))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_cp (g, src, dest);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_cp_a (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *src;
- const char *dest;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_cp_a",
- &py_g, &src, &dest))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_cp_a (g, src, dest);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mv (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *src;
- const char *dest;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mv",
- &py_g, &src, &dest))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mv (g, src, dest);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_drop_caches (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int whattodrop;
-
- if (!PyArg_ParseTuple (args, (char *) "Oi:guestfs_drop_caches",
- &py_g, &whattodrop))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_drop_caches (g, whattodrop);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_dmesg (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_dmesg",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_dmesg (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_ping_daemon (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_ping_daemon",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_ping_daemon (g);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_equal (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *file1;
- const char *file2;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_equal",
- &py_g, &file1, &file2))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_equal (g, file1, file2);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_strings (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_strings",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_strings (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_strings_e (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *encoding;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_strings_e",
- &py_g, &encoding, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_strings_e (g, encoding, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_hexdump (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_hexdump",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_hexdump (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_zerofree (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_zerofree",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_zerofree (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_pvresize (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_pvresize",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_pvresize (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_sfdisk_N (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
- int partnum;
- int cyls;
- int heads;
- int sectors;
- const char *line;
-
- if (!PyArg_ParseTuple (args, (char *) "Osiiiis:guestfs_sfdisk_N",
- &py_g, &device, &partnum, &cyls, &heads, §ors, &line))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_sfdisk_l (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_sfdisk_l",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_sfdisk_l (g, device);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_sfdisk_kernel_geometry (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_sfdisk_kernel_geometry",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_sfdisk_kernel_geometry (g, device);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_sfdisk_disk_geometry (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_sfdisk_disk_geometry",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_sfdisk_disk_geometry (g, device);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_vg_activate_all (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int activate;
-
- if (!PyArg_ParseTuple (args, (char *) "Oi:guestfs_vg_activate_all",
- &py_g, &activate))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_vg_activate_all (g, activate);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_vg_activate (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int activate;
- PyObject *py_volgroups;
- const char **volgroups;
-
- if (!PyArg_ParseTuple (args, (char *) "OiO:guestfs_vg_activate",
- &py_g, &activate, &py_volgroups))
- return NULL;
- g = get_handle (py_g);
- volgroups = get_string_list (py_volgroups);
- if (!volgroups) return NULL;
-
- r = guestfs_vg_activate (g, activate, volgroups);
- free (volgroups);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_lvresize (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
- int mbytes;
-
- if (!PyArg_ParseTuple (args, (char *) "Osi:guestfs_lvresize",
- &py_g, &device, &mbytes))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_lvresize (g, device, mbytes);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_resize2fs (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_resize2fs",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_resize2fs (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_find (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *directory;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_find",
- &py_g, &directory))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_find (g, directory);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_e2fsck_f (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_e2fsck_f",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_e2fsck_f (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_sleep (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int secs;
-
- if (!PyArg_ParseTuple (args, (char *) "Oi:guestfs_sleep",
- &py_g, &secs))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_sleep (g, secs);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_ntfs_3g_probe (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int rw;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Ois:guestfs_ntfs_3g_probe",
- &py_g, &rw, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_ntfs_3g_probe (g, rw, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_sh (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *command;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_sh",
- &py_g, &command))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_sh (g, command);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_sh_lines (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *command;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_sh_lines",
- &py_g, &command))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_sh_lines (g, command);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_glob_expand (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *pattern;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_glob_expand",
- &py_g, &pattern))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_glob_expand (g, pattern);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_scrub_device (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_scrub_device",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_scrub_device (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_scrub_file (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *file;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_scrub_file",
- &py_g, &file))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_scrub_file (g, file);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_scrub_freespace (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *dir;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_scrub_freespace",
- &py_g, &dir))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_scrub_freespace (g, dir);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mkdtemp (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
- const char *template;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_mkdtemp",
- &py_g, &template))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mkdtemp (g, template);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_wc_l (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_wc_l",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_wc_l (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_wc_w (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_wc_w",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_wc_w (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_wc_c (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_wc_c",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_wc_c (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_head (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_head",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_head (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_head_n (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- int nrlines;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Ois:guestfs_head_n",
- &py_g, &nrlines, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_head_n (g, nrlines, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_tail (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_tail",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_tail (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_tail_n (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- int nrlines;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Ois:guestfs_tail_n",
- &py_g, &nrlines, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_tail_n (g, nrlines, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_df (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_df",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_df (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_df_h (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char *r;
-
- if (!PyArg_ParseTuple (args, (char *) "O:guestfs_df_h",
- &py_g))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_df_h (g);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyString_FromString (r);
- free (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_du (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int64_t r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_du",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_du (g, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyLong_FromLongLong (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_initrd_list (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- char **r;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_initrd_list",
- &py_g, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_initrd_list (g, path);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_string_list (r);
- free_strings (r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mount_loop (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *file;
- const char *mountpoint;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mount_loop",
- &py_g, &file, &mountpoint))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mount_loop (g, file, mountpoint);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mkswap (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_mkswap",
- &py_g, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mkswap (g, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mkswap_L (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *label;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mkswap_L",
- &py_g, &label, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mkswap_L (g, label, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mkswap_U (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- const char *uuid;
- const char *device;
-
- if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mkswap_U",
- &py_g, &uuid, &device))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mkswap_U (g, uuid, device);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mknod (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int mode;
- int devmajor;
- int devminor;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Oiiis:guestfs_mknod",
- &py_g, &mode, &devmajor, &devminor, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mknod (g, mode, devmajor, devminor, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mkfifo (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int mode;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Ois:guestfs_mkfifo",
- &py_g, &mode, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mkfifo (g, mode, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mknod_b (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int mode;
- int devmajor;
- int devminor;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Oiiis:guestfs_mknod_b",
- &py_g, &mode, &devmajor, &devminor, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mknod_b (g, mode, devmajor, devminor, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_mknod_c (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int mode;
- int devmajor;
- int devminor;
- const char *path;
-
- if (!PyArg_ParseTuple (args, (char *) "Oiiis:guestfs_mknod_c",
- &py_g, &mode, &devmajor, &devminor, &path))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_mknod_c (g, mode, devmajor, devminor, path);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- Py_INCREF (Py_None);
- py_r = Py_None;
- return py_r;
-}
-
-static PyObject *
-py_guestfs_umask (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- int r;
- int mask;
-
- if (!PyArg_ParseTuple (args, (char *) "Oi:guestfs_umask",
- &py_g, &mask))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_umask (g, mask);
- if (r == -1) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = PyInt_FromLong ((long) r);
- return py_r;
-}
-
-static PyObject *
-py_guestfs_readdir (PyObject *self, PyObject *args)
-{
- PyObject *py_g;
- guestfs_h *g;
- PyObject *py_r;
- struct guestfs_dirent_list *r;
- const char *dir;
-
- if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_readdir",
- &py_g, &dir))
- return NULL;
- g = get_handle (py_g);
-
- r = guestfs_readdir (g, dir);
- if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
- return NULL;
- }
-
- py_r = put_dirent_list (r);
- guestfs_free_dirent_list (r);
- return py_r;
-}
-
-static PyMethodDef methods[] = {
- { (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
- { (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
- { (char *) "test0", py_guestfs_test0, METH_VARARGS, NULL },
- { (char *) "test0rint", py_guestfs_test0rint, METH_VARARGS, NULL },
- { (char *) "test0rinterr", py_guestfs_test0rinterr, METH_VARARGS, NULL },
- { (char *) "test0rint64", py_guestfs_test0rint64, METH_VARARGS, NULL },
- { (char *) "test0rint64err", py_guestfs_test0rint64err, METH_VARARGS, NULL },
- { (char *) "test0rbool", py_guestfs_test0rbool, METH_VARARGS, NULL },
- { (char *) "test0rboolerr", py_guestfs_test0rboolerr, METH_VARARGS, NULL },
- { (char *) "test0rconststring", py_guestfs_test0rconststring, METH_VARARGS, NULL },
- { (char *) "test0rconststringerr", py_guestfs_test0rconststringerr, METH_VARARGS, NULL },
- { (char *) "test0rstring", py_guestfs_test0rstring, METH_VARARGS, NULL },
- { (char *) "test0rstringerr", py_guestfs_test0rstringerr, METH_VARARGS, NULL },
- { (char *) "test0rstringlist", py_guestfs_test0rstringlist, METH_VARARGS, NULL },
- { (char *) "test0rstringlisterr", py_guestfs_test0rstringlisterr, METH_VARARGS, NULL },
- { (char *) "test0rintbool", py_guestfs_test0rintbool, METH_VARARGS, NULL },
- { (char *) "test0rintboolerr", py_guestfs_test0rintboolerr, METH_VARARGS, NULL },
- { (char *) "test0rpvlist", py_guestfs_test0rpvlist, METH_VARARGS, NULL },
- { (char *) "test0rpvlisterr", py_guestfs_test0rpvlisterr, METH_VARARGS, NULL },
- { (char *) "test0rvglist", py_guestfs_test0rvglist, METH_VARARGS, NULL },
- { (char *) "test0rvglisterr", py_guestfs_test0rvglisterr, METH_VARARGS, NULL },
- { (char *) "test0rlvlist", py_guestfs_test0rlvlist, METH_VARARGS, NULL },
- { (char *) "test0rlvlisterr", py_guestfs_test0rlvlisterr, METH_VARARGS, NULL },
- { (char *) "test0rstat", py_guestfs_test0rstat, METH_VARARGS, NULL },
- { (char *) "test0rstaterr", py_guestfs_test0rstaterr, METH_VARARGS, NULL },
- { (char *) "test0rstatvfs", py_guestfs_test0rstatvfs, METH_VARARGS, NULL },
- { (char *) "test0rstatvfserr", py_guestfs_test0rstatvfserr, METH_VARARGS, NULL },
- { (char *) "test0rhashtable", py_guestfs_test0rhashtable, METH_VARARGS, NULL },
- { (char *) "test0rhashtableerr", py_guestfs_test0rhashtableerr, METH_VARARGS, NULL },
- { (char *) "launch", py_guestfs_launch, METH_VARARGS, NULL },
- { (char *) "wait_ready", py_guestfs_wait_ready, METH_VARARGS, NULL },
- { (char *) "kill_subprocess", py_guestfs_kill_subprocess, METH_VARARGS, NULL },
- { (char *) "add_drive", py_guestfs_add_drive, METH_VARARGS, NULL },
- { (char *) "add_cdrom", py_guestfs_add_cdrom, METH_VARARGS, NULL },
- { (char *) "add_drive_ro", py_guestfs_add_drive_ro, METH_VARARGS, NULL },
- { (char *) "config", py_guestfs_config, METH_VARARGS, NULL },
- { (char *) "set_qemu", py_guestfs_set_qemu, METH_VARARGS, NULL },
- { (char *) "get_qemu", py_guestfs_get_qemu, METH_VARARGS, NULL },
- { (char *) "set_path", py_guestfs_set_path, METH_VARARGS, NULL },
- { (char *) "get_path", py_guestfs_get_path, METH_VARARGS, NULL },
- { (char *) "set_append", py_guestfs_set_append, METH_VARARGS, NULL },
- { (char *) "get_append", py_guestfs_get_append, METH_VARARGS, NULL },
- { (char *) "set_autosync", py_guestfs_set_autosync, METH_VARARGS, NULL },
- { (char *) "get_autosync", py_guestfs_get_autosync, METH_VARARGS, NULL },
- { (char *) "set_verbose", py_guestfs_set_verbose, METH_VARARGS, NULL },
- { (char *) "get_verbose", py_guestfs_get_verbose, METH_VARARGS, NULL },
- { (char *) "is_ready", py_guestfs_is_ready, METH_VARARGS, NULL },
- { (char *) "is_config", py_guestfs_is_config, METH_VARARGS, NULL },
- { (char *) "is_launching", py_guestfs_is_launching, METH_VARARGS, NULL },
- { (char *) "is_busy", py_guestfs_is_busy, METH_VARARGS, NULL },
- { (char *) "get_state", py_guestfs_get_state, METH_VARARGS, NULL },
- { (char *) "set_busy", py_guestfs_set_busy, METH_VARARGS, NULL },
- { (char *) "set_ready", py_guestfs_set_ready, METH_VARARGS, NULL },
- { (char *) "end_busy", py_guestfs_end_busy, METH_VARARGS, NULL },
- { (char *) "set_memsize", py_guestfs_set_memsize, METH_VARARGS, NULL },
- { (char *) "get_memsize", py_guestfs_get_memsize, METH_VARARGS, NULL },
- { (char *) "mount", py_guestfs_mount, METH_VARARGS, NULL },
- { (char *) "sync", py_guestfs_sync, METH_VARARGS, NULL },
- { (char *) "touch", py_guestfs_touch, METH_VARARGS, NULL },
- { (char *) "cat", py_guestfs_cat, METH_VARARGS, NULL },
- { (char *) "ll", py_guestfs_ll, METH_VARARGS, NULL },
- { (char *) "ls", py_guestfs_ls, METH_VARARGS, NULL },
- { (char *) "list_devices", py_guestfs_list_devices, METH_VARARGS, NULL },
- { (char *) "list_partitions", py_guestfs_list_partitions, METH_VARARGS, NULL },
- { (char *) "pvs", py_guestfs_pvs, METH_VARARGS, NULL },
- { (char *) "vgs", py_guestfs_vgs, METH_VARARGS, NULL },
- { (char *) "lvs", py_guestfs_lvs, METH_VARARGS, NULL },
- { (char *) "pvs_full", py_guestfs_pvs_full, METH_VARARGS, NULL },
- { (char *) "vgs_full", py_guestfs_vgs_full, METH_VARARGS, NULL },
- { (char *) "lvs_full", py_guestfs_lvs_full, METH_VARARGS, NULL },
- { (char *) "read_lines", py_guestfs_read_lines, METH_VARARGS, NULL },
- { (char *) "aug_init", py_guestfs_aug_init, METH_VARARGS, NULL },
- { (char *) "aug_close", py_guestfs_aug_close, METH_VARARGS, NULL },
- { (char *) "aug_defvar", py_guestfs_aug_defvar, METH_VARARGS, NULL },
- { (char *) "aug_defnode", py_guestfs_aug_defnode, METH_VARARGS, NULL },
- { (char *) "aug_get", py_guestfs_aug_get, METH_VARARGS, NULL },
- { (char *) "aug_set", py_guestfs_aug_set, METH_VARARGS, NULL },
- { (char *) "aug_insert", py_guestfs_aug_insert, METH_VARARGS, NULL },
- { (char *) "aug_rm", py_guestfs_aug_rm, METH_VARARGS, NULL },
- { (char *) "aug_mv", py_guestfs_aug_mv, METH_VARARGS, NULL },
- { (char *) "aug_match", py_guestfs_aug_match, METH_VARARGS, NULL },
- { (char *) "aug_save", py_guestfs_aug_save, METH_VARARGS, NULL },
- { (char *) "aug_load", py_guestfs_aug_load, METH_VARARGS, NULL },
- { (char *) "aug_ls", py_guestfs_aug_ls, METH_VARARGS, NULL },
- { (char *) "rm", py_guestfs_rm, METH_VARARGS, NULL },
- { (char *) "rmdir", py_guestfs_rmdir, METH_VARARGS, NULL },
- { (char *) "rm_rf", py_guestfs_rm_rf, METH_VARARGS, NULL },
- { (char *) "mkdir", py_guestfs_mkdir, METH_VARARGS, NULL },
- { (char *) "mkdir_p", py_guestfs_mkdir_p, METH_VARARGS, NULL },
- { (char *) "chmod", py_guestfs_chmod, METH_VARARGS, NULL },
- { (char *) "chown", py_guestfs_chown, METH_VARARGS, NULL },
- { (char *) "exists", py_guestfs_exists, METH_VARARGS, NULL },
- { (char *) "is_file", py_guestfs_is_file, METH_VARARGS, NULL },
- { (char *) "is_dir", py_guestfs_is_dir, METH_VARARGS, NULL },
- { (char *) "pvcreate", py_guestfs_pvcreate, METH_VARARGS, NULL },
- { (char *) "vgcreate", py_guestfs_vgcreate, METH_VARARGS, NULL },
- { (char *) "lvcreate", py_guestfs_lvcreate, METH_VARARGS, NULL },
- { (char *) "mkfs", py_guestfs_mkfs, METH_VARARGS, NULL },
- { (char *) "sfdisk", py_guestfs_sfdisk, METH_VARARGS, NULL },
- { (char *) "write_file", py_guestfs_write_file, METH_VARARGS, NULL },
- { (char *) "umount", py_guestfs_umount, METH_VARARGS, NULL },
- { (char *) "mounts", py_guestfs_mounts, METH_VARARGS, NULL },
- { (char *) "umount_all", py_guestfs_umount_all, METH_VARARGS, NULL },
- { (char *) "lvm_remove_all", py_guestfs_lvm_remove_all, METH_VARARGS, NULL },
- { (char *) "file", py_guestfs_file, METH_VARARGS, NULL },
- { (char *) "command", py_guestfs_command, METH_VARARGS, NULL },
- { (char *) "command_lines", py_guestfs_command_lines, METH_VARARGS, NULL },
- { (char *) "stat", py_guestfs_stat, METH_VARARGS, NULL },
- { (char *) "lstat", py_guestfs_lstat, METH_VARARGS, NULL },
- { (char *) "statvfs", py_guestfs_statvfs, METH_VARARGS, NULL },
- { (char *) "tune2fs_l", py_guestfs_tune2fs_l, METH_VARARGS, NULL },
- { (char *) "blockdev_setro", py_guestfs_blockdev_setro, METH_VARARGS, NULL },
- { (char *) "blockdev_setrw", py_guestfs_blockdev_setrw, METH_VARARGS, NULL },
- { (char *) "blockdev_getro", py_guestfs_blockdev_getro, METH_VARARGS, NULL },
- { (char *) "blockdev_getss", py_guestfs_blockdev_getss, METH_VARARGS, NULL },
- { (char *) "blockdev_getbsz", py_guestfs_blockdev_getbsz, METH_VARARGS, NULL },
- { (char *) "blockdev_setbsz", py_guestfs_blockdev_setbsz, METH_VARARGS, NULL },
- { (char *) "blockdev_getsz", py_guestfs_blockdev_getsz, METH_VARARGS, NULL },
- { (char *) "blockdev_getsize64", py_guestfs_blockdev_getsize64, METH_VARARGS, NULL },
- { (char *) "blockdev_flushbufs", py_guestfs_blockdev_flushbufs, METH_VARARGS, NULL },
- { (char *) "blockdev_rereadpt", py_guestfs_blockdev_rereadpt, METH_VARARGS, NULL },
- { (char *) "upload", py_guestfs_upload, METH_VARARGS, NULL },
- { (char *) "download", py_guestfs_download, METH_VARARGS, NULL },
- { (char *) "checksum", py_guestfs_checksum, METH_VARARGS, NULL },
- { (char *) "tar_in", py_guestfs_tar_in, METH_VARARGS, NULL },
- { (char *) "tar_out", py_guestfs_tar_out, METH_VARARGS, NULL },
- { (char *) "tgz_in", py_guestfs_tgz_in, METH_VARARGS, NULL },
- { (char *) "tgz_out", py_guestfs_tgz_out, METH_VARARGS, NULL },
- { (char *) "mount_ro", py_guestfs_mount_ro, METH_VARARGS, NULL },
- { (char *) "mount_options", py_guestfs_mount_options, METH_VARARGS, NULL },
- { (char *) "mount_vfs", py_guestfs_mount_vfs, METH_VARARGS, NULL },
- { (char *) "debug", py_guestfs_debug, METH_VARARGS, NULL },
- { (char *) "lvremove", py_guestfs_lvremove, METH_VARARGS, NULL },
- { (char *) "vgremove", py_guestfs_vgremove, METH_VARARGS, NULL },
- { (char *) "pvremove", py_guestfs_pvremove, METH_VARARGS, NULL },
- { (char *) "set_e2label", py_guestfs_set_e2label, METH_VARARGS, NULL },
- { (char *) "get_e2label", py_guestfs_get_e2label, METH_VARARGS, NULL },
- { (char *) "set_e2uuid", py_guestfs_set_e2uuid, METH_VARARGS, NULL },
- { (char *) "get_e2uuid", py_guestfs_get_e2uuid, METH_VARARGS, NULL },
- { (char *) "fsck", py_guestfs_fsck, METH_VARARGS, NULL },
- { (char *) "zero", py_guestfs_zero, METH_VARARGS, NULL },
- { (char *) "grub_install", py_guestfs_grub_install, METH_VARARGS, NULL },
- { (char *) "cp", py_guestfs_cp, METH_VARARGS, NULL },
- { (char *) "cp_a", py_guestfs_cp_a, METH_VARARGS, NULL },
- { (char *) "mv", py_guestfs_mv, METH_VARARGS, NULL },
- { (char *) "drop_caches", py_guestfs_drop_caches, METH_VARARGS, NULL },
- { (char *) "dmesg", py_guestfs_dmesg, METH_VARARGS, NULL },
- { (char *) "ping_daemon", py_guestfs_ping_daemon, METH_VARARGS, NULL },
- { (char *) "equal", py_guestfs_equal, METH_VARARGS, NULL },
- { (char *) "strings", py_guestfs_strings, METH_VARARGS, NULL },
- { (char *) "strings_e", py_guestfs_strings_e, METH_VARARGS, NULL },
- { (char *) "hexdump", py_guestfs_hexdump, METH_VARARGS, NULL },
- { (char *) "zerofree", py_guestfs_zerofree, METH_VARARGS, NULL },
- { (char *) "pvresize", py_guestfs_pvresize, METH_VARARGS, NULL },
- { (char *) "sfdisk_N", py_guestfs_sfdisk_N, METH_VARARGS, NULL },
- { (char *) "sfdisk_l", py_guestfs_sfdisk_l, METH_VARARGS, NULL },
- { (char *) "sfdisk_kernel_geometry", py_guestfs_sfdisk_kernel_geometry, METH_VARARGS, NULL },
- { (char *) "sfdisk_disk_geometry", py_guestfs_sfdisk_disk_geometry, METH_VARARGS, NULL },
- { (char *) "vg_activate_all", py_guestfs_vg_activate_all, METH_VARARGS, NULL },
- { (char *) "vg_activate", py_guestfs_vg_activate, METH_VARARGS, NULL },
- { (char *) "lvresize", py_guestfs_lvresize, METH_VARARGS, NULL },
- { (char *) "resize2fs", py_guestfs_resize2fs, METH_VARARGS, NULL },
- { (char *) "find", py_guestfs_find, METH_VARARGS, NULL },
- { (char *) "e2fsck_f", py_guestfs_e2fsck_f, METH_VARARGS, NULL },
- { (char *) "sleep", py_guestfs_sleep, METH_VARARGS, NULL },
- { (char *) "ntfs_3g_probe", py_guestfs_ntfs_3g_probe, METH_VARARGS, NULL },
- { (char *) "sh", py_guestfs_sh, METH_VARARGS, NULL },
- { (char *) "sh_lines", py_guestfs_sh_lines, METH_VARARGS, NULL },
- { (char *) "glob_expand", py_guestfs_glob_expand, METH_VARARGS, NULL },
- { (char *) "scrub_device", py_guestfs_scrub_device, METH_VARARGS, NULL },
- { (char *) "scrub_file", py_guestfs_scrub_file, METH_VARARGS, NULL },
- { (char *) "scrub_freespace", py_guestfs_scrub_freespace, METH_VARARGS, NULL },
- { (char *) "mkdtemp", py_guestfs_mkdtemp, METH_VARARGS, NULL },
- { (char *) "wc_l", py_guestfs_wc_l, METH_VARARGS, NULL },
- { (char *) "wc_w", py_guestfs_wc_w, METH_VARARGS, NULL },
- { (char *) "wc_c", py_guestfs_wc_c, METH_VARARGS, NULL },
- { (char *) "head", py_guestfs_head, METH_VARARGS, NULL },
- { (char *) "head_n", py_guestfs_head_n, METH_VARARGS, NULL },
- { (char *) "tail", py_guestfs_tail, METH_VARARGS, NULL },
- { (char *) "tail_n", py_guestfs_tail_n, METH_VARARGS, NULL },
- { (char *) "df", py_guestfs_df, METH_VARARGS, NULL },
- { (char *) "df_h", py_guestfs_df_h, METH_VARARGS, NULL },
- { (char *) "du", py_guestfs_du, METH_VARARGS, NULL },
- { (char *) "initrd_list", py_guestfs_initrd_list, METH_VARARGS, NULL },
- { (char *) "mount_loop", py_guestfs_mount_loop, METH_VARARGS, NULL },
- { (char *) "mkswap", py_guestfs_mkswap, METH_VARARGS, NULL },
- { (char *) "mkswap_L", py_guestfs_mkswap_L, METH_VARARGS, NULL },
- { (char *) "mkswap_U", py_guestfs_mkswap_U, METH_VARARGS, NULL },
- { (char *) "mknod", py_guestfs_mknod, METH_VARARGS, NULL },
- { (char *) "mkfifo", py_guestfs_mkfifo, METH_VARARGS, NULL },
- { (char *) "mknod_b", py_guestfs_mknod_b, METH_VARARGS, NULL },
- { (char *) "mknod_c", py_guestfs_mknod_c, METH_VARARGS, NULL },
- { (char *) "umask", py_guestfs_umask, METH_VARARGS, NULL },
- { (char *) "readdir", py_guestfs_readdir, METH_VARARGS, NULL },
- { NULL, NULL, 0, NULL }
-};
-
-void
-initlibguestfsmod (void)
-{
- static int initialized = 0;
-
- if (initialized) return;
- Py_InitModule ((char *) "libguestfsmod", methods);
- initialized = 1;
-}
+++ /dev/null
-# 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
-
-u"""Python bindings for libguestfs
-
-import guestfs
-g = guestfs.GuestFS ()
-g.add_drive ("guest.img")
-g.launch ()
-g.wait_ready ()
-parts = g.list_partitions ()
-
-The guestfs module provides a Python binding to the libguestfs API
-for examining and modifying virtual machine disk images.
-
-Amongst the things this is good for: making batch configuration
-changes to guests, getting disk used/free statistics (see also:
-virt-df), migrating between virtualization systems (see also:
-virt-p2v), performing partial backups, performing partial guest
-clones, cloning guests and changing registry/UUID/hostname info, and
-much else besides.
-
-Libguestfs uses Linux kernel and qemu code, and can access any type of
-guest filesystem that Linux and qemu can, including but not limited
-to: ext2/3/4, btrfs, FAT and NTFS, LVM, many different disk partition
-schemes, qcow, qcow2, vmdk.
-
-Libguestfs provides ways to enumerate guest storage (eg. partitions,
-LVs, what filesystem is in each LV, etc.). It can also run commands
-in the context of the guest. Also you can access filesystems over FTP.
-
-Errors which happen while using the API are turned into Python
-RuntimeError exceptions.
-
-To create a guestfs handle you usually have to perform the following
-sequence of calls:
-
-# Create the handle, call add_drive at least once, and possibly
-# several times if the guest has multiple block devices:
-g = guestfs.GuestFS ()
-g.add_drive ("guest.img")
-
-# Launch the qemu subprocess and wait for it to become ready:
-g.launch ()
-g.wait_ready ()
-
-# Now you can issue commands, for example:
-logvols = g.lvs ()
-
-"""
-
-import libguestfsmod
-
-class GuestFS:
- """Instances of this class are libguestfs API handles."""
-
- def __init__ (self):
- """Create a new libguestfs handle."""
- self._o = libguestfsmod.create ()
-
- def __del__ (self):
- libguestfsmod.close (self._o)
-
- def test0 (self, str, optstr, strlist, b, integer, filein, fileout):
- return libguestfsmod.test0 (self._o, str, optstr, strlist, b, integer, filein, fileout)
-
- def test0rint (self, val):
- return libguestfsmod.test0rint (self._o, val)
-
- def test0rinterr (self):
- return libguestfsmod.test0rinterr (self._o)
-
- def test0rint64 (self, val):
- return libguestfsmod.test0rint64 (self._o, val)
-
- def test0rint64err (self):
- return libguestfsmod.test0rint64err (self._o)
-
- def test0rbool (self, val):
- return libguestfsmod.test0rbool (self._o, val)
-
- def test0rboolerr (self):
- return libguestfsmod.test0rboolerr (self._o)
-
- def test0rconststring (self, val):
- return libguestfsmod.test0rconststring (self._o, val)
-
- def test0rconststringerr (self):
- return libguestfsmod.test0rconststringerr (self._o)
-
- def test0rstring (self, val):
- return libguestfsmod.test0rstring (self._o, val)
-
- def test0rstringerr (self):
- return libguestfsmod.test0rstringerr (self._o)
-
- def test0rstringlist (self, val):
- return libguestfsmod.test0rstringlist (self._o, val)
-
- def test0rstringlisterr (self):
- return libguestfsmod.test0rstringlisterr (self._o)
-
- def test0rintbool (self, val):
- return libguestfsmod.test0rintbool (self._o, val)
-
- def test0rintboolerr (self):
- return libguestfsmod.test0rintboolerr (self._o)
-
- def test0rpvlist (self, val):
- return libguestfsmod.test0rpvlist (self._o, val)
-
- def test0rpvlisterr (self):
- return libguestfsmod.test0rpvlisterr (self._o)
-
- def test0rvglist (self, val):
- return libguestfsmod.test0rvglist (self._o, val)
-
- def test0rvglisterr (self):
- return libguestfsmod.test0rvglisterr (self._o)
-
- def test0rlvlist (self, val):
- return libguestfsmod.test0rlvlist (self._o, val)
-
- def test0rlvlisterr (self):
- return libguestfsmod.test0rlvlisterr (self._o)
-
- def test0rstat (self, val):
- return libguestfsmod.test0rstat (self._o, val)
-
- def test0rstaterr (self):
- return libguestfsmod.test0rstaterr (self._o)
-
- def test0rstatvfs (self, val):
- return libguestfsmod.test0rstatvfs (self._o, val)
-
- def test0rstatvfserr (self):
- return libguestfsmod.test0rstatvfserr (self._o)
-
- def test0rhashtable (self, val):
- return libguestfsmod.test0rhashtable (self._o, val)
-
- def test0rhashtableerr (self):
- return libguestfsmod.test0rhashtableerr (self._o)
-
- def launch (self):
- u"""Internally libguestfs is implemented by running a
- virtual machine using qemu(1).
-
- You should call this after configuring the handle (eg.
- adding drives) but before performing any actions.
- """
- return libguestfsmod.launch (self._o)
-
- def wait_ready (self):
- u"""Internally libguestfs is implemented by running a
- virtual machine using qemu(1).
-
- You should call this after "g.launch" to wait for the
- launch to complete.
- """
- return libguestfsmod.wait_ready (self._o)
-
- def kill_subprocess (self):
- u"""This kills the qemu subprocess. You should never need to
- call this.
- """
- return libguestfsmod.kill_subprocess (self._o)
-
- def add_drive (self, filename):
- u"""This function adds a virtual machine disk image
- "filename" to the guest. The first time you call this
- function, the disk appears as IDE disk 0 ("/dev/sda") in
- the guest, the second time as "/dev/sdb", and so on.
-
- You don't necessarily need to be root when using
- libguestfs. However you obviously do need sufficient
- permissions to access the filename 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 "-drive
- file=filename,cache=off,if=virtio".
-
- Note that this call checks for the existence of
- "filename". This stops you from specifying other types
- of drive which are supported by qemu such as "nbd:" and
- "http:" URLs. To specify those, use the general
- "g.config" call instead.
- """
- return libguestfsmod.add_drive (self._o, filename)
-
- def add_cdrom (self, filename):
- u"""This function adds a virtual CD-ROM disk image to the
- guest.
-
- This is equivalent to the qemu parameter "-cdrom
- filename".
-
- Note that this call checks for the existence of
- "filename". This stops you from specifying other types
- of drive which are supported by qemu such as "nbd:" and
- "http:" URLs. To specify those, use the general
- "g.config" call instead.
- """
- return libguestfsmod.add_cdrom (self._o, filename)
-
- def add_drive_ro (self, filename):
- u"""This adds a drive in snapshot mode, making it
- effectively read-only.
-
- Note that writes to the device are allowed, and will be
- seen for the duration of the guestfs handle, but they
- are written to a temporary file which is discarded as
- soon as the guestfs 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 "-drive
- file=filename,snapshot=on,if=virtio".
-
- Note that this call checks for the existence of
- "filename". This stops you from specifying other types
- of drive which are supported by qemu such as "nbd:" and
- "http:" URLs. To specify those, use the general
- "g.config" call instead.
- """
- return libguestfsmod.add_drive_ro (self._o, filename)
-
- def config (self, qemuparam, qemuvalue):
- u"""This can be used to add arbitrary qemu command line
- parameters of the form "-param value". Actually it's not
- quite arbitrary - we prevent you from setting some
- parameters which would interfere with parameters that we
- use.
-
- The first character of "param" string must be a "-"
- (dash).
-
- "value" can be NULL.
- """
- return libguestfsmod.config (self._o, qemuparam, qemuvalue)
-
- def set_qemu (self, qemu):
- u"""Set the qemu binary that we will use.
-
- The default is chosen when the library was compiled by
- the configure script.
-
- You can also override this by setting the
- "LIBGUESTFS_QEMU" environment variable.
-
- Setting "qemu" to "NULL" restores the default qemu
- binary.
- """
- return libguestfsmod.set_qemu (self._o, qemu)
-
- def get_qemu (self):
- u"""Return the current qemu binary.
-
- This is always non-NULL. If it wasn't set already, then
- this will return the default qemu binary name.
- """
- return libguestfsmod.get_qemu (self._o)
-
- def set_path (self, path):
- u"""Set the path that libguestfs searches for kernel and
- initrd.img.
-
- The default is "$libdir/guestfs" unless overridden by
- setting "LIBGUESTFS_PATH" environment variable.
-
- Setting "path" to "NULL" restores the default path.
- """
- return libguestfsmod.set_path (self._o, path)
-
- def get_path (self):
- u"""Return the current search path.
-
- This is always non-NULL. If it wasn't set already, then
- this will return the default path.
- """
- return libguestfsmod.get_path (self._o)
-
- def set_append (self, append):
- u"""This function is used to add additional options to the
- guest kernel command line.
-
- The default is "NULL" unless overridden by setting
- "LIBGUESTFS_APPEND" environment variable.
-
- Setting "append" to "NULL" means *no* additional options
- are passed (libguestfs always adds a few of its own).
- """
- return libguestfsmod.set_append (self._o, append)
-
- def get_append (self):
- u"""Return the additional kernel options which are added to
- the guest kernel command line.
-
- If "NULL" then no options are added.
- """
- return libguestfsmod.get_append (self._o)
-
- def set_autosync (self, autosync):
- u"""If "autosync" is true, this enables autosync. Libguestfs
- will make a best effort attempt to run "g.umount_all"
- followed by "g.sync" when the handle is closed (also if
- the program exits without closing handles).
-
- This is disabled by default (except in guestfish where
- it is enabled by default).
- """
- return libguestfsmod.set_autosync (self._o, autosync)
-
- def get_autosync (self):
- u"""Get the autosync flag.
- """
- return libguestfsmod.get_autosync (self._o)
-
- def set_verbose (self, verbose):
- u"""If "verbose" is true, this turns on verbose messages (to
- "stderr").
-
- Verbose messages are disabled unless the environment
- variable "LIBGUESTFS_DEBUG" is defined and set to 1.
- """
- return libguestfsmod.set_verbose (self._o, verbose)
-
- def get_verbose (self):
- u"""This returns the verbose messages flag.
- """
- return libguestfsmod.get_verbose (self._o)
-
- def is_ready (self):
- u"""This returns true iff this handle is ready to accept
- commands (in the "READY" state).
-
- For more information on states, see guestfs(3).
- """
- return libguestfsmod.is_ready (self._o)
-
- def is_config (self):
- u"""This returns true iff this handle is being configured
- (in the "CONFIG" state).
-
- For more information on states, see guestfs(3).
- """
- return libguestfsmod.is_config (self._o)
-
- def is_launching (self):
- u"""This returns true iff this handle is launching the
- subprocess (in the "LAUNCHING" state).
-
- For more information on states, see guestfs(3).
- """
- return libguestfsmod.is_launching (self._o)
-
- def is_busy (self):
- u"""This returns true iff this handle is busy processing a
- command (in the "BUSY" state).
-
- For more information on states, see guestfs(3).
- """
- return libguestfsmod.is_busy (self._o)
-
- def get_state (self):
- u"""This returns the current state as an opaque integer.
- This is only useful for printing debug and internal
- error messages.
-
- For more information on states, see guestfs(3).
- """
- return libguestfsmod.get_state (self._o)
-
- def set_busy (self):
- u"""This sets the state to "BUSY". This is only used when
- implementing actions using the low-level API.
-
- For more information on states, see guestfs(3).
- """
- return libguestfsmod.set_busy (self._o)
-
- def set_ready (self):
- u"""This sets the state to "READY". This is only used when
- implementing actions using the low-level API.
-
- For more information on states, see guestfs(3).
- """
- return libguestfsmod.set_ready (self._o)
-
- def end_busy (self):
- u"""This sets the state to "READY", or if in "CONFIG" then
- it leaves the state as is. This is only used when
- implementing actions using the low-level API.
-
- For more information on states, see guestfs(3).
- """
- return libguestfsmod.end_busy (self._o)
-
- def set_memsize (self, memsize):
- u"""This sets the memory size in megabytes allocated to the
- qemu subprocess. This only has any effect if called
- before "g.launch".
-
- You can also change this by setting the environment
- variable "LIBGUESTFS_MEMSIZE" before the handle is
- created.
-
- For more information on the architecture of libguestfs,
- see guestfs(3).
- """
- return libguestfsmod.set_memsize (self._o, memsize)
-
- def get_memsize (self):
- u"""This gets the memory size in megabytes allocated to the
- qemu subprocess.
-
- If "g.set_memsize" was not called on this handle, and if
- "LIBGUESTFS_MEMSIZE" was not set, then this returns the
- compiled-in default value for memsize.
-
- For more information on the architecture of libguestfs,
- see guestfs(3).
- """
- return libguestfsmod.get_memsize (self._o)
-
- def mount (self, device, mountpoint):
- u"""Mount a guest disk at a position in the filesystem.
- Block devices are named "/dev/sda", "/dev/sdb" and so
- on, as they were added to the guest. If those block
- devices contain partitions, they will have the usual
- names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
- names can be used.
-
- The rules are the same as for mount(2): A filesystem
- must first be mounted on "/" before others can be
- mounted. Other filesystems can only be mounted on
- directories which already exist.
-
- The mounted filesystem is writable, if we have
- sufficient permissions on the underlying device.
-
- The filesystem options "sync" and "noatime" are set with
- this call, in order to improve reliability.
- """
- return libguestfsmod.mount (self._o, device, mountpoint)
-
- def sync (self):
- u"""This syncs the disk, so that any writes are flushed
- through to the underlying disk image.
-
- You should always call this if you have modified a disk
- image, before closing the handle.
- """
- return libguestfsmod.sync (self._o)
-
- def touch (self, path):
- u"""Touch acts like the touch(1) command. It can be used to
- update the timestamps on a file, or, if the file does
- not exist, to create a new zero-length file.
- """
- return libguestfsmod.touch (self._o, path)
-
- def cat (self, path):
- u"""Return the contents of the file named "path".
-
- Note that this function cannot correctly handle binary
- files (specifically, files containing "\\0" character
- which is treated as end of string). For those you need
- to use the "g.download" function which has a more
- complex interface.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.cat (self._o, path)
-
- def ll (self, directory):
- u"""List the files in "directory" (relative to the root
- directory, there is no cwd) in the format of 'ls -la'.
-
- This command is mostly useful for interactive sessions.
- It is *not* intended that you try to parse the output
- string.
- """
- return libguestfsmod.ll (self._o, directory)
-
- def ls (self, directory):
- u"""List the files in "directory" (relative to the root
- directory, there is no cwd). The '.' and '..' entries
- are not returned, but hidden files are shown.
-
- This command is mostly useful for interactive sessions.
- Programs should probably use "g.readdir" instead.
-
- This function returns a list of strings.
- """
- return libguestfsmod.ls (self._o, directory)
-
- def list_devices (self):
- u"""List all the block devices.
-
- The full block device names are returned, eg. "/dev/sda"
-
- This function returns a list of strings.
- """
- return libguestfsmod.list_devices (self._o)
-
- def list_partitions (self):
- u"""List all the partitions detected on all block devices.
-
- The full partition device names are returned, eg.
- "/dev/sda1"
-
- This does not return logical volumes. For that you will
- need to call "g.lvs".
-
- This function returns a list of strings.
- """
- return libguestfsmod.list_partitions (self._o)
-
- def pvs (self):
- u"""List all the physical volumes detected. This is the
- equivalent of the pvs(8) command.
-
- This returns a list of just the device names that
- contain PVs (eg. "/dev/sda2").
-
- See also "g.pvs_full".
-
- This function returns a list of strings.
- """
- return libguestfsmod.pvs (self._o)
-
- def vgs (self):
- u"""List all the volumes groups detected. This is the
- equivalent of the vgs(8) command.
-
- This returns a list of just the volume group names that
- were detected (eg. "VolGroup00").
-
- See also "g.vgs_full".
-
- This function returns a list of strings.
- """
- return libguestfsmod.vgs (self._o)
-
- def lvs (self):
- u"""List all the logical volumes detected. This is the
- equivalent of the lvs(8) command.
-
- This returns a list of the logical volume device names
- (eg. "/dev/VolGroup00/LogVol00").
-
- See also "g.lvs_full".
-
- This function returns a list of strings.
- """
- return libguestfsmod.lvs (self._o)
-
- def pvs_full (self):
- u"""List all the physical volumes detected. This is the
- equivalent of the pvs(8) command. The "full" version
- includes all fields.
-
- This function returns a list of PVs. Each PV is
- represented as a dictionary.
- """
- return libguestfsmod.pvs_full (self._o)
-
- def vgs_full (self):
- u"""List all the volumes groups detected. This is the
- equivalent of the vgs(8) command. The "full" version
- includes all fields.
-
- This function returns a list of VGs. Each VG is
- represented as a dictionary.
- """
- return libguestfsmod.vgs_full (self._o)
-
- def lvs_full (self):
- u"""List all the logical volumes detected. This is the
- equivalent of the lvs(8) command. The "full" version
- includes all fields.
-
- This function returns a list of LVs. Each LV is
- represented as a dictionary.
- """
- return libguestfsmod.lvs_full (self._o)
-
- def read_lines (self, path):
- u"""Return the contents of the file named "path".
-
- The file contents are returned as a list of lines.
- Trailing "LF" and "CRLF" character sequences are *not*
- returned.
-
- Note that this function cannot correctly handle binary
- files (specifically, files containing "\\0" character
- which is treated as end of line). For those you need to
- use the "g.read_file" function which has a more complex
- interface.
-
- This function returns a list of strings.
- """
- return libguestfsmod.read_lines (self._o, path)
-
- def aug_init (self, root, flags):
- u"""Create a new Augeas handle for editing configuration
- files. If there was any previous Augeas handle
- associated with this guestfs session, then it is closed.
-
- You must call this before using any other "g.aug_*"
- commands.
-
- "root" is the filesystem root. "root" must not be NULL,
- use "/" instead.
-
- The flags are the same as the flags defined in
- <augeas.h>, the logical *or* of the following integers:
-
- "AUG_SAVE_BACKUP" = 1
- Keep the original file with a ".augsave" extension.
-
- "AUG_SAVE_NEWFILE" = 2
- Save changes into a file with extension ".augnew",
- and do not overwrite original. Overrides
- "AUG_SAVE_BACKUP".
-
- "AUG_TYPE_CHECK" = 4
- Typecheck lenses (can be expensive).
-
- "AUG_NO_STDINC" = 8
- Do not use standard load path for modules.
-
- "AUG_SAVE_NOOP" = 16
- Make save a no-op, just record what would have been
- changed.
-
- "AUG_NO_LOAD" = 32
- Do not load the tree in "g.aug_init".
-
- To close the handle, you can call "g.aug_close".
-
- To find out more about Augeas, see <http://augeas.net/>.
- """
- return libguestfsmod.aug_init (self._o, root, flags)
-
- def aug_close (self):
- u"""Close the current Augeas handle and free up any
- resources used by it. After calling this, you have to
- call "g.aug_init" again before you can use any other
- Augeas functions.
- """
- return libguestfsmod.aug_close (self._o)
-
- def aug_defvar (self, name, expr):
- u"""Defines an Augeas variable "name" whose value is the
- result of evaluating "expr". If "expr" is NULL, then
- "name" is undefined.
-
- On success this returns the number of nodes in "expr",
- or 0 if "expr" evaluates to something which is not a
- nodeset.
- """
- return libguestfsmod.aug_defvar (self._o, name, expr)
-
- def aug_defnode (self, name, expr, val):
- u"""Defines a variable "name" whose value is the result of
- evaluating "expr".
-
- If "expr" evaluates to an empty nodeset, a node is
- created, equivalent to calling "g.aug_set" "expr",
- "value". "name" will be the nodeset containing that
- single node.
-
- On success this returns a pair containing the number of
- nodes in the nodeset, and a boolean flag if a node was
- created.
-
- This function returns a tuple (int, bool).
- """
- return libguestfsmod.aug_defnode (self._o, name, expr, val)
-
- def aug_get (self, path):
- u"""Look up the value associated with "path". If "path"
- matches exactly one node, the "value" is returned.
- """
- return libguestfsmod.aug_get (self._o, path)
-
- def aug_set (self, path, val):
- u"""Set the value associated with "path" to "value".
- """
- return libguestfsmod.aug_set (self._o, path, val)
-
- def aug_insert (self, path, label, before):
- u"""Create a new sibling "label" for "path", inserting it
- into the tree before or after "path" (depending on the
- boolean flag "before").
-
- "path" must match exactly one existing node in the tree,
- and "label" must be a label, ie. not contain "/", "*" or
- end with a bracketed index "[N]".
- """
- return libguestfsmod.aug_insert (self._o, path, label, before)
-
- def aug_rm (self, path):
- u"""Remove "path" and all of its children.
-
- On success this returns the number of entries which were
- removed.
- """
- return libguestfsmod.aug_rm (self._o, path)
-
- def aug_mv (self, src, dest):
- u"""Move the node "src" to "dest". "src" must match exactly
- one node. "dest" is overwritten if it exists.
- """
- return libguestfsmod.aug_mv (self._o, src, dest)
-
- def aug_match (self, path):
- u"""Returns a list of paths which match the path expression
- "path". The returned paths are sufficiently qualified so
- that they match exactly one node in the current tree.
-
- This function returns a list of strings.
- """
- return libguestfsmod.aug_match (self._o, path)
-
- def aug_save (self):
- u"""This writes all pending changes to disk.
-
- The flags which were passed to "g.aug_init" affect
- exactly how files are saved.
- """
- return libguestfsmod.aug_save (self._o)
-
- def aug_load (self):
- u"""Load files into the tree.
-
- See "aug_load" in the Augeas documentation for the full
- gory details.
- """
- return libguestfsmod.aug_load (self._o)
-
- def aug_ls (self, path):
- u"""This is just a shortcut for listing "g.aug_match"
- "path/*" and sorting the resulting nodes into
- alphabetical order.
-
- This function returns a list of strings.
- """
- return libguestfsmod.aug_ls (self._o, path)
-
- def rm (self, path):
- u"""Remove the single file "path".
- """
- return libguestfsmod.rm (self._o, path)
-
- def rmdir (self, path):
- u"""Remove the single directory "path".
- """
- return libguestfsmod.rmdir (self._o, path)
-
- def rm_rf (self, path):
- u"""Remove the file or directory "path", recursively
- removing the contents if its a directory. This is like
- the "rm -rf" shell command.
- """
- return libguestfsmod.rm_rf (self._o, path)
-
- def mkdir (self, path):
- u"""Create a directory named "path".
- """
- return libguestfsmod.mkdir (self._o, path)
-
- def mkdir_p (self, path):
- u"""Create a directory named "path", creating any parent
- directories as necessary. This is like the "mkdir -p"
- shell command.
- """
- return libguestfsmod.mkdir_p (self._o, path)
-
- def chmod (self, mode, path):
- u"""Change the mode (permissions) of "path" to "mode". Only
- numeric modes are supported.
- """
- return libguestfsmod.chmod (self._o, mode, path)
-
- def chown (self, owner, group, path):
- u"""Change the file owner to "owner" and group to "group".
-
- Only numeric uid and gid are supported. If you want to
- use names, you will need to locate and parse the
- password file yourself (Augeas support makes this
- relatively easy).
- """
- return libguestfsmod.chown (self._o, owner, group, path)
-
- def exists (self, path):
- u"""This returns "true" if and only if there is a file,
- directory (or anything) with the given "path" name.
-
- See also "g.is_file", "g.is_dir", "g.stat".
- """
- return libguestfsmod.exists (self._o, path)
-
- def is_file (self, path):
- u"""This returns "true" if and only if there is a file with
- the given "path" name. Note that it returns false for
- other objects like directories.
-
- See also "g.stat".
- """
- return libguestfsmod.is_file (self._o, path)
-
- def is_dir (self, path):
- u"""This returns "true" if and only if there is a directory
- with the given "path" name. Note that it returns false
- for other objects like files.
-
- See also "g.stat".
- """
- return libguestfsmod.is_dir (self._o, path)
-
- def pvcreate (self, device):
- u"""This creates an LVM physical volume on the named
- "device", where "device" should usually be a partition
- name such as "/dev/sda1".
- """
- return libguestfsmod.pvcreate (self._o, device)
-
- def vgcreate (self, volgroup, physvols):
- u"""This creates an LVM volume group called "volgroup" from
- the non-empty list of physical volumes "physvols".
- """
- return libguestfsmod.vgcreate (self._o, volgroup, physvols)
-
- def lvcreate (self, logvol, volgroup, mbytes):
- u"""This creates an LVM volume group called "logvol" on the
- volume group "volgroup", with "size" megabytes.
- """
- return libguestfsmod.lvcreate (self._o, logvol, volgroup, mbytes)
-
- def mkfs (self, fstype, device):
- u"""This creates a filesystem on "device" (usually a
- partition or LVM logical volume). The filesystem type is
- "fstype", for example "ext3".
- """
- return libguestfsmod.mkfs (self._o, fstype, device)
-
- def sfdisk (self, device, cyls, heads, sectors, lines):
- u"""This is a direct interface to the sfdisk(8) program for
- creating partitions on block devices.
-
- "device" should be a block device, for example
- "/dev/sda".
-
- "cyls", "heads" and "sectors" are the number of
- cylinders, heads and sectors on the device, which are
- passed directly to sfdisk as the *-C*, *-H* and *-S*
- parameters. If you pass 0 for any of these, then the
- corresponding parameter is omitted. Usually for 'large'
- disks, you can just pass 0 for these, but for small
- (floppy-sized) disks, sfdisk (or rather, the kernel)
- cannot work out the right geometry and you will need to
- tell it.
-
- "lines" is a list of lines that we feed to "sfdisk". For
- more information refer to the sfdisk(8) manpage.
-
- To create a single partition occupying the whole disk,
- you would pass "lines" as a single element list, when
- the single element being the string "," (comma).
-
- See also: "g.sfdisk_l", "g.sfdisk_N"
-
- This command is dangerous. Without careful use you can
- easily destroy all your data.
- """
- return libguestfsmod.sfdisk (self._o, device, cyls, heads, sectors, lines)
-
- def write_file (self, path, content, size):
- u"""This call creates a file called "path". The contents of
- the file is the string "content" (which can contain any
- 8 bit data), with length "size".
-
- As a special case, if "size" is 0 then the length is
- calculated using "strlen" (so in this case the content
- cannot contain embedded ASCII NULs).
-
- *NB.* Owing to a bug, writing content containing ASCII
- NUL characters does *not* work, even if the length is
- specified. We hope to resolve this bug in a future
- version. In the meantime use "g.upload".
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.write_file (self._o, path, content, size)
-
- def umount (self, pathordevice):
- u"""This unmounts the given filesystem. The filesystem may
- be specified either by its mountpoint (path) or the
- device which contains the filesystem.
- """
- return libguestfsmod.umount (self._o, pathordevice)
-
- def mounts (self):
- u"""This returns the list of currently mounted filesystems.
- It returns the list of devices (eg. "/dev/sda1",
- "/dev/VG/LV").
-
- Some internal mounts are not shown.
-
- This function returns a list of strings.
- """
- return libguestfsmod.mounts (self._o)
-
- def umount_all (self):
- u"""This unmounts all mounted filesystems.
-
- Some internal mounts are not unmounted by this call.
- """
- return libguestfsmod.umount_all (self._o)
-
- def lvm_remove_all (self):
- u"""This command removes all LVM logical volumes, volume
- groups and physical volumes.
-
- This command is dangerous. Without careful use you can
- easily destroy all your data.
- """
- return libguestfsmod.lvm_remove_all (self._o)
-
- def file (self, path):
- u"""This call uses the standard file(1) command to determine
- the type or contents of the file. This also works on
- devices, for example to find out whether a partition
- contains a filesystem.
-
- The exact command which runs is "file -bsL path". Note
- in particular that the filename is not prepended to the
- output (the "-b" option).
- """
- return libguestfsmod.file (self._o, path)
-
- def command (self, arguments):
- u"""This call runs a command from the guest filesystem. The
- filesystem must be mounted, and must contain a
- compatible operating system (ie. something Linux, with
- the same 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). Note that
- the command runs directly, and is *not* invoked via the
- shell (see "g.sh").
-
- The return value is anything printed to *stdout* by the
- command.
-
- If the command returns a non-zero exit status, then this
- function returns an error message. The error message
- string is the content of *stderr* from the command.
-
- The $PATH environment variable will contain at least
- "/usr/bin" and "/bin". If you require a program from
- another location, you should provide the full path in
- the first parameter.
-
- Shared libraries and data files required by the program
- must be available on filesystems which are mounted in
- the correct places. It is the caller's responsibility to
- ensure all filesystems that are needed are mounted at
- the right locations.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.command (self._o, arguments)
-
- def command_lines (self, arguments):
- u"""This is the same as "g.command", but splits the result
- into a list of lines.
-
- See also: "g.sh_lines"
-
- This function returns a list of strings.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.command_lines (self._o, arguments)
-
- def stat (self, path):
- u"""Returns file information for the given "path".
-
- This is the same as the stat(2) system call.
-
- This function returns a dictionary, with keys matching
- the various fields in the stat structure.
- """
- return libguestfsmod.stat (self._o, path)
-
- def lstat (self, path):
- u"""Returns file information for the given "path".
-
- This is the same as "g.stat" except that if "path" is a
- symbolic link, then the link is stat-ed, not the file it
- refers to.
-
- This is the same as the lstat(2) system call.
-
- This function returns a dictionary, with keys matching
- the various fields in the stat structure.
- """
- return libguestfsmod.lstat (self._o, path)
-
- def statvfs (self, path):
- u"""Returns file system statistics for any mounted file
- system. "path" should be a file or directory in the
- mounted file system (typically it is the mount point
- itself, but it doesn't need to be).
-
- This is the same as the statvfs(2) system call.
-
- This function returns a dictionary, with keys matching
- the various fields in the statvfs structure.
- """
- return libguestfsmod.statvfs (self._o, path)
-
- def tune2fs_l (self, device):
- u"""This returns the contents of the ext2, ext3 or ext4
- filesystem superblock on "device".
-
- It is the same as running "tune2fs -l device". See
- tune2fs(8) manpage for more details. The list of fields
- returned isn't clearly defined, and depends on both the
- version of "tune2fs" that libguestfs was built against,
- and the filesystem itself.
-
- This function returns a dictionary.
- """
- return libguestfsmod.tune2fs_l (self._o, device)
-
- def blockdev_setro (self, device):
- u"""Sets the block device named "device" to read-only.
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_setro (self._o, device)
-
- def blockdev_setrw (self, device):
- u"""Sets the block device named "device" to read-write.
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_setrw (self._o, device)
-
- def blockdev_getro (self, device):
- u"""Returns a boolean indicating if the block device is
- read-only (true if read-only, false if not).
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_getro (self._o, device)
-
- def blockdev_getss (self, device):
- u"""This returns the size of sectors on a block device.
- Usually 512, but can be larger for modern devices.
-
- (Note, this is not the size in sectors, use
- "g.blockdev_getsz" for that).
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_getss (self._o, device)
-
- def blockdev_getbsz (self, device):
- u"""This returns the block size of a device.
-
- (Note this is different from both *size in blocks* and
- *filesystem block size*).
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_getbsz (self._o, device)
-
- def blockdev_setbsz (self, device, blocksize):
- u"""This sets the block size of a device.
-
- (Note this is different from both *size in blocks* and
- *filesystem block size*).
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_setbsz (self._o, device, blocksize)
-
- def blockdev_getsz (self, device):
- u"""This returns the size of the device in units of 512-byte
- sectors (even if the sectorsize isn't 512 bytes ...
- weird).
-
- See also "g.blockdev_getss" for the real sector size of
- the device, and "g.blockdev_getsize64" for the more
- useful *size in bytes*.
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_getsz (self._o, device)
-
- def blockdev_getsize64 (self, device):
- u"""This returns the size of the device in bytes.
-
- See also "g.blockdev_getsz".
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_getsize64 (self._o, device)
-
- def blockdev_flushbufs (self, device):
- u"""This tells the kernel to flush internal buffers
- associated with "device".
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_flushbufs (self._o, device)
-
- def blockdev_rereadpt (self, device):
- u"""Reread the partition table on "device".
-
- This uses the blockdev(8) command.
- """
- return libguestfsmod.blockdev_rereadpt (self._o, device)
-
- def upload (self, filename, remotefilename):
- u"""Upload local file "filename" to "remotefilename" on the
- filesystem.
-
- "filename" can also be a named pipe.
-
- See also "g.download".
- """
- return libguestfsmod.upload (self._o, filename, remotefilename)
-
- def download (self, remotefilename, filename):
- u"""Download file "remotefilename" and save it as "filename"
- on the local machine.
-
- "filename" can also be a named pipe.
-
- See also "g.upload", "g.cat".
- """
- return libguestfsmod.download (self._o, remotefilename, filename)
-
- def checksum (self, csumtype, path):
- u"""This call computes the MD5, SHAx or CRC checksum of the
- file named "path".
-
- The type of checksum to compute is given by the
- "csumtype" parameter which must have one of the
- following values:
-
- "crc"
- Compute the cyclic redundancy check (CRC) specified
- by POSIX for the "cksum" command.
-
- "md5"
- Compute the MD5 hash (using the "md5sum" program).
-
- "sha1"
- Compute the SHA1 hash (using the "sha1sum" program).
-
- "sha224"
- Compute the SHA224 hash (using the "sha224sum"
- program).
-
- "sha256"
- Compute the SHA256 hash (using the "sha256sum"
- program).
-
- "sha384"
- Compute the SHA384 hash (using the "sha384sum"
- program).
-
- "sha512"
- Compute the SHA512 hash (using the "sha512sum"
- program).
-
- The checksum is returned as a printable string.
- """
- return libguestfsmod.checksum (self._o, csumtype, path)
-
- def tar_in (self, tarfile, directory):
- u"""This command uploads and unpacks local file "tarfile"
- (an *uncompressed* tar file) into "directory".
-
- To upload a compressed tarball, use "g.tgz_in".
- """
- return libguestfsmod.tar_in (self._o, tarfile, directory)
-
- def tar_out (self, directory, tarfile):
- u"""This command packs the contents of "directory" and
- downloads it to local file "tarfile".
-
- To download a compressed tarball, use "g.tgz_out".
- """
- return libguestfsmod.tar_out (self._o, directory, tarfile)
-
- def tgz_in (self, tarball, directory):
- u"""This command uploads and unpacks local file "tarball" (a
- *gzip compressed* tar file) into "directory".
-
- To upload an uncompressed tarball, use "g.tar_in".
- """
- return libguestfsmod.tgz_in (self._o, tarball, directory)
-
- def tgz_out (self, directory, tarball):
- u"""This command packs the contents of "directory" and
- downloads it to local file "tarball".
-
- To download an uncompressed tarball, use "g.tar_out".
- """
- return libguestfsmod.tgz_out (self._o, directory, tarball)
-
- def mount_ro (self, device, mountpoint):
- u"""This is the same as the "g.mount" command, but it mounts
- the filesystem with the read-only (*-o ro*) flag.
- """
- return libguestfsmod.mount_ro (self._o, device, mountpoint)
-
- def mount_options (self, options, device, mountpoint):
- u"""This is the same as the "g.mount" command, but it allows
- you to set the mount options as for the mount(8) *-o*
- flag.
- """
- return libguestfsmod.mount_options (self._o, options, device, mountpoint)
-
- def mount_vfs (self, options, vfstype, device, mountpoint):
- u"""This is the same as the "g.mount" command, but it allows
- you to set both the mount options and the vfstype as for
- the mount(8) *-o* and *-t* flags.
- """
- return libguestfsmod.mount_vfs (self._o, options, vfstype, device, mountpoint)
-
- def debug (self, subcmd, extraargs):
- u"""The "g.debug" command exposes some internals of
- "guestfsd" (the guestfs daemon) that runs inside the
- qemu subprocess.
-
- There is no comprehensive help for this command. You
- have to look at the file "daemon/debug.c" in the
- libguestfs source to find out what you can do.
- """
- return libguestfsmod.debug (self._o, subcmd, extraargs)
-
- def lvremove (self, device):
- u"""Remove an LVM logical volume "device", where "device" is
- the path to the LV, such as "/dev/VG/LV".
-
- You can also remove all LVs in a volume group by
- specifying the VG name, "/dev/VG".
- """
- return libguestfsmod.lvremove (self._o, device)
-
- def vgremove (self, vgname):
- u"""Remove an LVM volume group "vgname", (for example "VG").
-
- This also forcibly removes all logical volumes in the
- volume group (if any).
- """
- return libguestfsmod.vgremove (self._o, vgname)
-
- def pvremove (self, device):
- u"""This wipes a physical volume "device" so that LVM will
- no longer recognise it.
-
- The implementation uses the "pvremove" command which
- refuses to wipe physical volumes that contain any volume
- groups, so you have to remove those first.
- """
- return libguestfsmod.pvremove (self._o, device)
-
- def set_e2label (self, device, label):
- u"""This sets the ext2/3/4 filesystem label of the
- filesystem on "device" to "label". Filesystem labels are
- limited to 16 characters.
-
- You can use either "g.tune2fs_l" or "g.get_e2label" to
- return the existing label on a filesystem.
- """
- return libguestfsmod.set_e2label (self._o, device, label)
-
- def get_e2label (self, device):
- u"""This returns the ext2/3/4 filesystem label of the
- filesystem on "device".
- """
- return libguestfsmod.get_e2label (self._o, device)
-
- def set_e2uuid (self, device, uuid):
- u"""This sets the ext2/3/4 filesystem UUID of the filesystem
- on "device" to "uuid". The format of the UUID and
- alternatives such as "clear", "random" and "time" are
- described in the tune2fs(8) manpage.
-
- You can use either "g.tune2fs_l" or "g.get_e2uuid" to
- return the existing UUID of a filesystem.
- """
- return libguestfsmod.set_e2uuid (self._o, device, uuid)
-
- def get_e2uuid (self, device):
- u"""This returns the ext2/3/4 filesystem UUID of the
- filesystem on "device".
- """
- return libguestfsmod.get_e2uuid (self._o, device)
-
- def fsck (self, fstype, device):
- u"""This runs the filesystem checker (fsck) on "device"
- which should have filesystem type "fstype".
-
- The returned integer is the status. See fsck(8) for the
- list of status codes from "fsck".
-
- Notes:
-
- * Multiple status codes can be summed together.
-
- * A non-zero return code can mean "success", for
- example if errors have been corrected on the
- filesystem.
-
- * Checking or repairing NTFS volumes is not supported
- (by linux-ntfs).
-
- This command is entirely equivalent to running "fsck -a
- -t fstype device".
- """
- return libguestfsmod.fsck (self._o, fstype, device)
-
- def zero (self, device):
- u"""This command writes zeroes over the first few blocks of
- "device".
-
- How many blocks are zeroed isn't specified (but it's
- *not* enough to securely wipe the device). It should be
- sufficient to remove any partition tables, filesystem
- superblocks and so on.
-
- See also: "g.scrub_device".
- """
- return libguestfsmod.zero (self._o, device)
-
- def grub_install (self, root, device):
- u"""This command installs GRUB (the Grand Unified
- Bootloader) on "device", with the root directory being
- "root".
- """
- return libguestfsmod.grub_install (self._o, root, device)
-
- def cp (self, src, dest):
- u"""This copies a file from "src" to "dest" where "dest" is
- either a destination filename or destination directory.
- """
- return libguestfsmod.cp (self._o, src, dest)
-
- def cp_a (self, src, dest):
- u"""This copies a file or directory from "src" to "dest"
- recursively using the "cp -a" command.
- """
- return libguestfsmod.cp_a (self._o, src, dest)
-
- def mv (self, src, dest):
- u"""This moves a file from "src" to "dest" where "dest" is
- either a destination filename or destination directory.
- """
- return libguestfsmod.mv (self._o, src, dest)
-
- def drop_caches (self, whattodrop):
- u"""This instructs the guest kernel to drop its page cache,
- and/or dentries and inode caches. The parameter
- "whattodrop" tells the kernel what precisely to drop,
- see <http://linux-mm.org/Drop_Caches>
-
- Setting "whattodrop" to 3 should drop everything.
-
- This automatically calls sync(2) before the operation,
- so that the maximum guest memory is freed.
- """
- return libguestfsmod.drop_caches (self._o, whattodrop)
-
- def dmesg (self):
- u"""This returns the kernel messages ("dmesg" output) from
- the guest kernel. This is sometimes useful for extended
- debugging of problems.
-
- Another way to get the same information is to enable
- verbose messages with "g.set_verbose" or by setting the
- environment variable "LIBGUESTFS_DEBUG=1" before running
- the program.
- """
- return libguestfsmod.dmesg (self._o)
-
- def ping_daemon (self):
- u"""This is a test probe into the guestfs daemon running
- inside the qemu subprocess. Calling this function checks
- that the daemon responds to the ping message, without
- affecting the daemon or attached block device(s) in any
- other way.
- """
- return libguestfsmod.ping_daemon (self._o)
-
- def equal (self, file1, file2):
- u"""This compares the two files "file1" and "file2" and
- returns true if their content is exactly equal, or false
- otherwise.
-
- The external cmp(1) program is used for the comparison.
- """
- return libguestfsmod.equal (self._o, file1, file2)
-
- def strings (self, path):
- u"""This runs the strings(1) command on a file and returns
- the list of printable strings found.
-
- This function returns a list of strings.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.strings (self._o, path)
-
- def strings_e (self, encoding, path):
- u"""This is like the "g.strings" command, but allows you to
- specify the encoding.
-
- See the strings(1) manpage for the full list of
- encodings.
-
- Commonly useful encodings are "l" (lower case L) which
- will show strings inside Windows/x86 files.
-
- The returned strings are transcoded to UTF-8.
-
- This function returns a list of strings.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.strings_e (self._o, encoding, path)
-
- def hexdump (self, path):
- u"""This runs "hexdump -C" on the given "path". The result
- is the human-readable, canonical hex dump of the file.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.hexdump (self._o, path)
-
- def zerofree (self, device):
- u"""This runs the *zerofree* program on "device". This
- program claims to zero unused inodes and disk blocks on
- an ext2/3 filesystem, thus making it possible to
- compress the filesystem more effectively.
-
- You should not run this program if the filesystem is
- mounted.
-
- It is possible that using this program can damage the
- filesystem or data on the filesystem.
- """
- return libguestfsmod.zerofree (self._o, device)
-
- def pvresize (self, device):
- u"""This resizes (expands or shrinks) an existing LVM
- physical volume to match the new size of the underlying
- device.
- """
- return libguestfsmod.pvresize (self._o, device)
-
- def sfdisk_N (self, device, partnum, cyls, heads, sectors, line):
- u"""This runs sfdisk(8) option to modify just the single
- partition "n" (note: "n" counts from 1).
-
- For other parameters, see "g.sfdisk". You should usually
- pass 0 for the cyls/heads/sectors parameters.
-
- This command is dangerous. Without careful use you can
- easily destroy all your data.
- """
- return libguestfsmod.sfdisk_N (self._o, device, partnum, cyls, heads, sectors, line)
-
- def sfdisk_l (self, device):
- u"""This displays the partition table on "device", in the
- human-readable output of the sfdisk(8) command. It is
- not intended to be parsed.
- """
- return libguestfsmod.sfdisk_l (self._o, device)
-
- def sfdisk_kernel_geometry (self, device):
- u"""This displays the kernel's idea of the geometry of
- "device".
-
- The result is in human-readable format, and not designed
- to be parsed.
- """
- return libguestfsmod.sfdisk_kernel_geometry (self._o, device)
-
- def sfdisk_disk_geometry (self, device):
- u"""This displays the disk geometry of "device" read from
- the partition table. Especially in the case where the
- underlying block device has been resized, this can be
- different from the kernel's idea of the geometry (see
- "g.sfdisk_kernel_geometry").
-
- The result is in human-readable format, and not designed
- to be parsed.
- """
- return libguestfsmod.sfdisk_disk_geometry (self._o, device)
-
- def vg_activate_all (self, activate):
- u"""This command activates or (if "activate" is false)
- deactivates all logical volumes in all volume groups. If
- activated, then they are made known to the kernel, ie.
- they appear as "/dev/mapper" devices. If deactivated,
- then those devices disappear.
-
- This command is the same as running "vgchange -a y|n"
- """
- return libguestfsmod.vg_activate_all (self._o, activate)
-
- def vg_activate (self, activate, volgroups):
- u"""This command activates or (if "activate" is false)
- deactivates all logical volumes in the listed volume
- groups "volgroups". If activated, then they are made
- known to the kernel, ie. they appear as "/dev/mapper"
- devices. If deactivated, then those devices disappear.
-
- This command is the same as running "vgchange -a y|n
- volgroups..."
-
- Note that if "volgroups" is an empty list then all
- volume groups are activated or deactivated.
- """
- return libguestfsmod.vg_activate (self._o, activate, volgroups)
-
- def lvresize (self, device, mbytes):
- u"""This resizes (expands or shrinks) an existing LVM
- logical volume to "mbytes". When reducing, data in the
- reduced part is lost.
- """
- return libguestfsmod.lvresize (self._o, device, mbytes)
-
- def resize2fs (self, device):
- u"""This resizes an ext2 or ext3 filesystem to match the
- size of the underlying device.
-
- *Note:* It is sometimes required that you run
- "g.e2fsck_f" on the "device" before calling this
- command. For unknown reasons "resize2fs" sometimes gives
- an error about this and sometimes not. In any case, it
- is always safe to call "g.e2fsck_f" before calling this
- function.
- """
- return libguestfsmod.resize2fs (self._o, device)
-
- def find (self, directory):
- u"""This command lists out all files and directories,
- recursively, starting at "directory". It is essentially
- equivalent to running the shell command "find directory
- -print" but some post-processing happens on the output,
- described below.
-
- This returns a list of strings *without any prefix*.
- Thus if the directory structure was:
-
- /tmp/a
- /tmp/b
- /tmp/c/d
-
- then the returned list from "g.find" "/tmp" would be 4
- elements:
-
- a
- b
- c
- c/d
-
- If "directory" is not a directory, then this command
- returns an error.
-
- The returned list is sorted.
-
- This function returns a list of strings.
- """
- return libguestfsmod.find (self._o, directory)
-
- def e2fsck_f (self, device):
- u"""This runs "e2fsck -p -f device", ie. runs the ext2/ext3
- filesystem checker on "device", noninteractively ("-p"),
- even if the filesystem appears to be clean ("-f").
-
- This command is only needed because of "g.resize2fs"
- (q.v.). Normally you should use "g.fsck".
- """
- return libguestfsmod.e2fsck_f (self._o, device)
-
- def sleep (self, secs):
- u"""Sleep for "secs" seconds.
- """
- return libguestfsmod.sleep (self._o, secs)
-
- def ntfs_3g_probe (self, rw, device):
- u"""This command runs the ntfs-3g.probe(8) command which
- probes an NTFS "device" for mountability. (Not all NTFS
- volumes can be mounted read-write, and some cannot be
- mounted at all).
-
- "rw" is a boolean flag. Set it to true if you want to
- test if the volume can be mounted read-write. Set it to
- false if you want to test if the volume can be mounted
- read-only.
-
- The return value is an integer which 0 if the operation
- would succeed, or some non-zero value documented in the
- ntfs-3g.probe(8) manual page.
- """
- return libguestfsmod.ntfs_3g_probe (self._o, rw, device)
-
- def sh (self, command):
- u"""This call runs a command from the guest filesystem via
- the guest's "/bin/sh".
-
- This is like "g.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 "g.command" apply to this call.
- """
- return libguestfsmod.sh (self._o, command)
-
- def sh_lines (self, command):
- u"""This is the same as "g.sh", but splits the result into a
- list of lines.
-
- See also: "g.command_lines"
-
- This function returns a list of strings.
- """
- return libguestfsmod.sh_lines (self._o, command)
-
- def glob_expand (self, pattern):
- u"""This command searches for all the pathnames matching
- "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 glob(3) function with
- flags "GLOB_MARK|GLOB_BRACE". See that manual page for
- more details.
-
- This function returns a list of strings.
- """
- return libguestfsmod.glob_expand (self._o, pattern)
-
- def scrub_device (self, device):
- u"""This command writes patterns over "device" to make data
- retrieval more difficult.
-
- It is an interface to the scrub(1) program. See that
- manual page for more details.
-
- This command is dangerous. Without careful use you can
- easily destroy all your data.
- """
- return libguestfsmod.scrub_device (self._o, device)
-
- def scrub_file (self, file):
- u"""This command writes patterns over a file to make data
- retrieval more difficult.
-
- The file is *removed* after scrubbing.
-
- It is an interface to the scrub(1) program. See that
- manual page for more details.
- """
- return libguestfsmod.scrub_file (self._o, file)
-
- def scrub_freespace (self, dir):
- u"""This command creates the directory "dir" and then fills
- it with files until the filesystem is full, and scrubs
- the files as for "g.scrub_file", and deletes them. The
- intention is to scrub any free space on the partition
- containing "dir".
-
- It is an interface to the scrub(1) program. See that
- manual page for more details.
- """
- return libguestfsmod.scrub_freespace (self._o, dir)
-
- def mkdtemp (self, template):
- u"""This command creates a temporary directory. The
- "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: mkdtemp(3)
- """
- return libguestfsmod.mkdtemp (self._o, template)
-
- def wc_l (self, path):
- u"""This command counts the lines in a file, using the "wc
- -l" external command.
- """
- return libguestfsmod.wc_l (self._o, path)
-
- def wc_w (self, path):
- u"""This command counts the words in a file, using the "wc
- -w" external command.
- """
- return libguestfsmod.wc_w (self._o, path)
-
- def wc_c (self, path):
- u"""This command counts the characters in a file, using the
- "wc -c" external command.
- """
- return libguestfsmod.wc_c (self._o, path)
-
- def head (self, path):
- u"""This command returns up to the first 10 lines of a file
- as a list of strings.
-
- This function returns a list of strings.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.head (self._o, path)
-
- def head_n (self, nrlines, path):
- u"""If the parameter "nrlines" is a positive number, this
- returns the first "nrlines" lines of the file "path".
-
- If the parameter "nrlines" is a negative number, this
- returns lines from the file "path", excluding the last
- "nrlines" lines.
-
- If the parameter "nrlines" is zero, this returns an
- empty list.
-
- This function returns a list of strings.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.head_n (self._o, nrlines, path)
-
- def tail (self, path):
- u"""This command returns up to the last 10 lines of a file
- as a list of strings.
-
- This function returns a list of strings.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.tail (self._o, path)
-
- def tail_n (self, nrlines, path):
- u"""If the parameter "nrlines" is a positive number, this
- returns the last "nrlines" lines of the file "path".
-
- If the parameter "nrlines" is a negative number, this
- returns lines from the file "path", starting with the
- "-nrlines"th line.
-
- If the parameter "nrlines" is zero, this returns an
- empty list.
-
- This function returns a list of strings.
-
- Because of the message protocol, there is a transfer
- limit of somewhere between 2MB and 4MB. To transfer
- large files you should use FTP.
- """
- return libguestfsmod.tail_n (self._o, nrlines, path)
-
- def df (self):
- u"""This command runs the "df" command to report disk space
- used.
-
- This command is mostly useful for interactive sessions.
- It is *not* intended that you try to parse the output
- string. Use "statvfs" from programs.
- """
- return libguestfsmod.df (self._o)
-
- def df_h (self):
- u"""This command runs the "df -h" command to report disk
- space used in human-readable format.
-
- This command is mostly useful for interactive sessions.
- It is *not* intended that you try to parse the output
- string. Use "statvfs" from programs.
- """
- return libguestfsmod.df_h (self._o)
-
- def du (self, path):
- u"""This command runs the "du -s" command to estimate file
- space usage for "path".
-
- "path" can be a file or a directory. If "path" is a
- directory then the estimate includes the contents of the
- directory and all subdirectories (recursively).
-
- The result is the estimated size in *kilobytes* (ie.
- units of 1024 bytes).
- """
- return libguestfsmod.du (self._o, path)
-
- def initrd_list (self, path):
- u"""This command lists out files contained in an initrd.
-
- The files are listed without any initial "/" 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 *only* support the newer
- initramfs format (compressed cpio files).
-
- This function returns a list of strings.
- """
- return libguestfsmod.initrd_list (self._o, path)
-
- def mount_loop (self, file, mountpoint):
- u"""This command lets you mount "file" (a filesystem image
- in a file) on a mount point. It is entirely equivalent
- to the command "mount -o loop file mountpoint".
- """
- return libguestfsmod.mount_loop (self._o, file, mountpoint)
-
- def mkswap (self, device):
- u"""Create a swap partition on "device".
- """
- return libguestfsmod.mkswap (self._o, device)
-
- def mkswap_L (self, label, device):
- u"""Create a swap partition on "device" with label "label".
- """
- return libguestfsmod.mkswap_L (self._o, label, device)
-
- def mkswap_U (self, uuid, device):
- u"""Create a swap partition on "device" with UUID "uuid".
- """
- return libguestfsmod.mkswap_U (self._o, uuid, device)
-
- def mknod (self, mode, devmajor, devminor, path):
- u"""This call creates block or character special devices, or
- named pipes (FIFOs).
-
- The "mode" parameter should be the mode, using the
- standard constants. "devmajor" and "devminor" are the
- device major and minor numbers, only used when creating
- block and character special devices.
- """
- return libguestfsmod.mknod (self._o, mode, devmajor, devminor, path)
-
- def mkfifo (self, mode, path):
- u"""This call creates a FIFO (named pipe) called "path" with
- mode "mode". It is just a convenient wrapper around
- "g.mknod".
- """
- return libguestfsmod.mkfifo (self._o, mode, path)
-
- def mknod_b (self, mode, devmajor, devminor, path):
- u"""This call creates a block device node called "path" with
- mode "mode" and device major/minor "devmajor" and
- "devminor". It is just a convenient wrapper around
- "g.mknod".
- """
- return libguestfsmod.mknod_b (self._o, mode, devmajor, devminor, path)
-
- def mknod_c (self, mode, devmajor, devminor, path):
- u"""This call creates a char device node called "path" with
- mode "mode" and device major/minor "devmajor" and
- "devminor". It is just a convenient wrapper around
- "g.mknod".
- """
- return libguestfsmod.mknod_c (self._o, mode, devmajor, devminor, path)
-
- def umask (self, mask):
- u"""This function sets the mask used for creating new files
- and device nodes to "mask & 0777".
-
- Typical umask values would be 022 which creates new
- files with permissions like "-rw-r--r--" or
- "-rwxr-xr-x", and 002 which creates new files with
- permissions like "-rw-rw-r--" or "-rwxrwxr-x".
-
- The default umask is 022. This is important because it
- means that directories and device nodes will be created
- with 0644 or 0755 mode even if you specify 0777.
-
- See also umask(2), "g.mknod", "g.mkdir".
-
- This call returns the previous umask.
- """
- return libguestfsmod.umask (self._o, mask)
-
- def readdir (self, dir):
- u"""This returns the list of directory entries in directory
- "dir".
-
- All entries in the directory are returned, including "."
- and "..". The entries are *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 "g.ls". To get a
- printable directory for human consumption, use "g.ll".
-
- This function returns a list of directory entries. Each
- directory entry is represented as a dictionary.
- """
- return libguestfsmod.readdir (self._o, dir)
-
+++ /dev/null
-# 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 program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-require 'guestfs'
-
-g = Guestfs::create()
-g.test0("abc", "def", [], false, 0, "123", "456")
-g.test0("abc", nil, [], false, 0, "123", "456")
-g.test0("", "def", [], false, 0, "123", "456")
-g.test0("", "", [], false, 0, "123", "456")
-g.test0("abc", "def", ["1"], false, 0, "123", "456")
-g.test0("abc", "def", ["1","2"], false, 0, "123", "456")
-g.test0("abc", "def", ["1"], true, 0, "123", "456")
-g.test0("abc", "def", ["1"], false, -1, "123", "456")
-g.test0("abc", "def", ["1"], false, -2, "123", "456")
-g.test0("abc", "def", ["1"], false, 1, "123", "456")
-g.test0("abc", "def", ["1"], false, 2, "123", "456")
-g.test0("abc", "def", ["1"], false, 4095, "123", "456")
-g.test0("abc", "def", ["1"], false, 0, "", "")
-print "EOF\n"
+++ /dev/null
-/* 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 <ruby.h>
-
-#include "guestfs.h"
-
-#include "extconf.h"
-
-/* For Ruby < 1.9 */
-#ifndef RARRAY_LEN
-#define RARRAY_LEN(r) (RARRAY((r))->len)
-#endif
-
-static VALUE m_guestfs; /* guestfs module */
-static VALUE c_guestfs; /* guestfs_h handle */
-static VALUE e_Error; /* used for all errors */
-
-static void ruby_guestfs_free (void *p)
-{
- if (!p) return;
- guestfs_close ((guestfs_h *) p);
-}
-
-static VALUE ruby_guestfs_create (VALUE m)
-{
- guestfs_h *g;
-
- g = guestfs_create ();
- if (!g)
- rb_raise (e_Error, "failed to create guestfs handle");
-
- /* Don't print error messages to stderr by default. */
- guestfs_set_error_handler (g, NULL, NULL);
-
- /* Wrap it, and make sure the close function is called when the
- * handle goes away.
- */
- return Data_Wrap_Struct (c_guestfs, NULL, ruby_guestfs_free, g);
-}
-
-static VALUE ruby_guestfs_close (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
-
- ruby_guestfs_free (g);
- DATA_PTR (gv) = NULL;
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_test0 (VALUE gv, VALUE strv, VALUE optstrv, VALUE strlistv, VALUE bv, VALUE integerv, VALUE fileinv, VALUE fileoutv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0");
-
- Check_Type (strv, T_STRING);
- const char *str = StringValueCStr (strv);
- if (!str)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "str", "test0");
- const char *optstr = !NIL_P (optstrv) ? StringValueCStr (optstrv) : NULL;
- char **strlist;
- Check_Type (strlistv, T_ARRAY);
- {
- int i, len;
- len = RARRAY_LEN (strlistv);
- strlist = guestfs_safe_malloc (g, sizeof (char *) * (len+1));
- for (i = 0; i < len; ++i) {
- VALUE v = rb_ary_entry (strlistv, i);
- strlist[i] = StringValueCStr (v);
- }
- strlist[len] = NULL;
- }
- int b = RTEST (bv);
- int integer = NUM2INT (integerv);
- Check_Type (fileinv, T_STRING);
- const char *filein = StringValueCStr (fileinv);
- if (!filein)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "filein", "test0");
- Check_Type (fileoutv, T_STRING);
- const char *fileout = StringValueCStr (fileoutv);
- if (!fileout)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "fileout", "test0");
-
- int r;
-
- r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout);
- free (strlist);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_test0rint (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rint");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rint");
-
- int r;
-
- r = guestfs_test0rint (g, val);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_test0rinterr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rinterr");
-
-
- int r;
-
- r = guestfs_test0rinterr (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_test0rint64 (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rint64");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rint64");
-
- int64_t r;
-
- r = guestfs_test0rint64 (g, val);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return ULL2NUM (r);
-}
-
-static VALUE ruby_guestfs_test0rint64err (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rint64err");
-
-
- int64_t r;
-
- r = guestfs_test0rint64err (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return ULL2NUM (r);
-}
-
-static VALUE ruby_guestfs_test0rbool (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rbool");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rbool");
-
- int r;
-
- r = guestfs_test0rbool (g, val);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_test0rboolerr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rboolerr");
-
-
- int r;
-
- r = guestfs_test0rboolerr (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_test0rconststring (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rconststring");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rconststring");
-
- const char *r;
-
- r = guestfs_test0rconststring (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return rb_str_new2 (r);
-}
-
-static VALUE ruby_guestfs_test0rconststringerr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rconststringerr");
-
-
- const char *r;
-
- r = guestfs_test0rconststringerr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return rb_str_new2 (r);
-}
-
-static VALUE ruby_guestfs_test0rstring (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstring");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rstring");
-
- char *r;
-
- r = guestfs_test0rstring (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rstringerr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstringerr");
-
-
- char *r;
-
- r = guestfs_test0rstringerr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rstringlist (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstringlist");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rstringlist");
-
- char **r;
-
- r = guestfs_test0rstringlist (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rstringlisterr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstringlisterr");
-
-
- char **r;
-
- r = guestfs_test0rstringlisterr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rintbool (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rintbool");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rintbool");
-
- struct guestfs_int_bool *r;
-
- r = guestfs_test0rintbool (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (2);
- rb_ary_push (rv, INT2NUM (r->i));
- rb_ary_push (rv, INT2NUM (r->b));
- guestfs_free_int_bool (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rintboolerr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rintboolerr");
-
-
- struct guestfs_int_bool *r;
-
- r = guestfs_test0rintboolerr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (2);
- rb_ary_push (rv, INT2NUM (r->i));
- rb_ary_push (rv, INT2NUM (r->b));
- guestfs_free_int_bool (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rpvlist (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rpvlist");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rpvlist");
-
- struct guestfs_lvm_pv_list *r;
-
- r = guestfs_test0rpvlist (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("pv_name"), rb_str_new2 (r->val[i].pv_name));
- rb_hash_aset (rv, rb_str_new2 ("pv_uuid"), rb_str_new (r->val[i].pv_uuid, 32));
- rb_hash_aset (rv, rb_str_new2 ("pv_fmt"), rb_str_new2 (r->val[i].pv_fmt));
- rb_hash_aset (rv, rb_str_new2 ("pv_size"), ULL2NUM (r->val[i].pv_size));
- rb_hash_aset (rv, rb_str_new2 ("dev_size"), ULL2NUM (r->val[i].dev_size));
- rb_hash_aset (rv, rb_str_new2 ("pv_free"), ULL2NUM (r->val[i].pv_free));
- rb_hash_aset (rv, rb_str_new2 ("pv_used"), ULL2NUM (r->val[i].pv_used));
- rb_hash_aset (rv, rb_str_new2 ("pv_attr"), rb_str_new2 (r->val[i].pv_attr));
- rb_hash_aset (rv, rb_str_new2 ("pv_pe_count"), ULL2NUM (r->val[i].pv_pe_count));
- rb_hash_aset (rv, rb_str_new2 ("pv_pe_alloc_count"), ULL2NUM (r->val[i].pv_pe_alloc_count));
- rb_hash_aset (rv, rb_str_new2 ("pv_tags"), rb_str_new2 (r->val[i].pv_tags));
- rb_hash_aset (rv, rb_str_new2 ("pe_start"), ULL2NUM (r->val[i].pe_start));
- rb_hash_aset (rv, rb_str_new2 ("pv_mda_count"), ULL2NUM (r->val[i].pv_mda_count));
- rb_hash_aset (rv, rb_str_new2 ("pv_mda_free"), ULL2NUM (r->val[i].pv_mda_free));
- rb_ary_push (rv, hv);
- }
- guestfs_free_lvm_pv_list (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rpvlisterr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rpvlisterr");
-
-
- struct guestfs_lvm_pv_list *r;
-
- r = guestfs_test0rpvlisterr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("pv_name"), rb_str_new2 (r->val[i].pv_name));
- rb_hash_aset (rv, rb_str_new2 ("pv_uuid"), rb_str_new (r->val[i].pv_uuid, 32));
- rb_hash_aset (rv, rb_str_new2 ("pv_fmt"), rb_str_new2 (r->val[i].pv_fmt));
- rb_hash_aset (rv, rb_str_new2 ("pv_size"), ULL2NUM (r->val[i].pv_size));
- rb_hash_aset (rv, rb_str_new2 ("dev_size"), ULL2NUM (r->val[i].dev_size));
- rb_hash_aset (rv, rb_str_new2 ("pv_free"), ULL2NUM (r->val[i].pv_free));
- rb_hash_aset (rv, rb_str_new2 ("pv_used"), ULL2NUM (r->val[i].pv_used));
- rb_hash_aset (rv, rb_str_new2 ("pv_attr"), rb_str_new2 (r->val[i].pv_attr));
- rb_hash_aset (rv, rb_str_new2 ("pv_pe_count"), ULL2NUM (r->val[i].pv_pe_count));
- rb_hash_aset (rv, rb_str_new2 ("pv_pe_alloc_count"), ULL2NUM (r->val[i].pv_pe_alloc_count));
- rb_hash_aset (rv, rb_str_new2 ("pv_tags"), rb_str_new2 (r->val[i].pv_tags));
- rb_hash_aset (rv, rb_str_new2 ("pe_start"), ULL2NUM (r->val[i].pe_start));
- rb_hash_aset (rv, rb_str_new2 ("pv_mda_count"), ULL2NUM (r->val[i].pv_mda_count));
- rb_hash_aset (rv, rb_str_new2 ("pv_mda_free"), ULL2NUM (r->val[i].pv_mda_free));
- rb_ary_push (rv, hv);
- }
- guestfs_free_lvm_pv_list (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rvglist (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rvglist");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rvglist");
-
- struct guestfs_lvm_vg_list *r;
-
- r = guestfs_test0rvglist (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("vg_name"), rb_str_new2 (r->val[i].vg_name));
- rb_hash_aset (rv, rb_str_new2 ("vg_uuid"), rb_str_new (r->val[i].vg_uuid, 32));
- rb_hash_aset (rv, rb_str_new2 ("vg_fmt"), rb_str_new2 (r->val[i].vg_fmt));
- rb_hash_aset (rv, rb_str_new2 ("vg_attr"), rb_str_new2 (r->val[i].vg_attr));
- rb_hash_aset (rv, rb_str_new2 ("vg_size"), ULL2NUM (r->val[i].vg_size));
- rb_hash_aset (rv, rb_str_new2 ("vg_free"), ULL2NUM (r->val[i].vg_free));
- rb_hash_aset (rv, rb_str_new2 ("vg_sysid"), rb_str_new2 (r->val[i].vg_sysid));
- rb_hash_aset (rv, rb_str_new2 ("vg_extent_size"), ULL2NUM (r->val[i].vg_extent_size));
- rb_hash_aset (rv, rb_str_new2 ("vg_extent_count"), ULL2NUM (r->val[i].vg_extent_count));
- rb_hash_aset (rv, rb_str_new2 ("vg_free_count"), ULL2NUM (r->val[i].vg_free_count));
- rb_hash_aset (rv, rb_str_new2 ("max_lv"), ULL2NUM (r->val[i].max_lv));
- rb_hash_aset (rv, rb_str_new2 ("max_pv"), ULL2NUM (r->val[i].max_pv));
- rb_hash_aset (rv, rb_str_new2 ("pv_count"), ULL2NUM (r->val[i].pv_count));
- rb_hash_aset (rv, rb_str_new2 ("lv_count"), ULL2NUM (r->val[i].lv_count));
- rb_hash_aset (rv, rb_str_new2 ("snap_count"), ULL2NUM (r->val[i].snap_count));
- rb_hash_aset (rv, rb_str_new2 ("vg_seqno"), ULL2NUM (r->val[i].vg_seqno));
- rb_hash_aset (rv, rb_str_new2 ("vg_tags"), rb_str_new2 (r->val[i].vg_tags));
- rb_hash_aset (rv, rb_str_new2 ("vg_mda_count"), ULL2NUM (r->val[i].vg_mda_count));
- rb_hash_aset (rv, rb_str_new2 ("vg_mda_free"), ULL2NUM (r->val[i].vg_mda_free));
- rb_ary_push (rv, hv);
- }
- guestfs_free_lvm_vg_list (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rvglisterr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rvglisterr");
-
-
- struct guestfs_lvm_vg_list *r;
-
- r = guestfs_test0rvglisterr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("vg_name"), rb_str_new2 (r->val[i].vg_name));
- rb_hash_aset (rv, rb_str_new2 ("vg_uuid"), rb_str_new (r->val[i].vg_uuid, 32));
- rb_hash_aset (rv, rb_str_new2 ("vg_fmt"), rb_str_new2 (r->val[i].vg_fmt));
- rb_hash_aset (rv, rb_str_new2 ("vg_attr"), rb_str_new2 (r->val[i].vg_attr));
- rb_hash_aset (rv, rb_str_new2 ("vg_size"), ULL2NUM (r->val[i].vg_size));
- rb_hash_aset (rv, rb_str_new2 ("vg_free"), ULL2NUM (r->val[i].vg_free));
- rb_hash_aset (rv, rb_str_new2 ("vg_sysid"), rb_str_new2 (r->val[i].vg_sysid));
- rb_hash_aset (rv, rb_str_new2 ("vg_extent_size"), ULL2NUM (r->val[i].vg_extent_size));
- rb_hash_aset (rv, rb_str_new2 ("vg_extent_count"), ULL2NUM (r->val[i].vg_extent_count));
- rb_hash_aset (rv, rb_str_new2 ("vg_free_count"), ULL2NUM (r->val[i].vg_free_count));
- rb_hash_aset (rv, rb_str_new2 ("max_lv"), ULL2NUM (r->val[i].max_lv));
- rb_hash_aset (rv, rb_str_new2 ("max_pv"), ULL2NUM (r->val[i].max_pv));
- rb_hash_aset (rv, rb_str_new2 ("pv_count"), ULL2NUM (r->val[i].pv_count));
- rb_hash_aset (rv, rb_str_new2 ("lv_count"), ULL2NUM (r->val[i].lv_count));
- rb_hash_aset (rv, rb_str_new2 ("snap_count"), ULL2NUM (r->val[i].snap_count));
- rb_hash_aset (rv, rb_str_new2 ("vg_seqno"), ULL2NUM (r->val[i].vg_seqno));
- rb_hash_aset (rv, rb_str_new2 ("vg_tags"), rb_str_new2 (r->val[i].vg_tags));
- rb_hash_aset (rv, rb_str_new2 ("vg_mda_count"), ULL2NUM (r->val[i].vg_mda_count));
- rb_hash_aset (rv, rb_str_new2 ("vg_mda_free"), ULL2NUM (r->val[i].vg_mda_free));
- rb_ary_push (rv, hv);
- }
- guestfs_free_lvm_vg_list (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rlvlist (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rlvlist");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rlvlist");
-
- struct guestfs_lvm_lv_list *r;
-
- r = guestfs_test0rlvlist (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("lv_name"), rb_str_new2 (r->val[i].lv_name));
- rb_hash_aset (rv, rb_str_new2 ("lv_uuid"), rb_str_new (r->val[i].lv_uuid, 32));
- rb_hash_aset (rv, rb_str_new2 ("lv_attr"), rb_str_new2 (r->val[i].lv_attr));
- rb_hash_aset (rv, rb_str_new2 ("lv_major"), ULL2NUM (r->val[i].lv_major));
- rb_hash_aset (rv, rb_str_new2 ("lv_minor"), ULL2NUM (r->val[i].lv_minor));
- rb_hash_aset (rv, rb_str_new2 ("lv_kernel_major"), ULL2NUM (r->val[i].lv_kernel_major));
- rb_hash_aset (rv, rb_str_new2 ("lv_kernel_minor"), ULL2NUM (r->val[i].lv_kernel_minor));
- rb_hash_aset (rv, rb_str_new2 ("lv_size"), ULL2NUM (r->val[i].lv_size));
- rb_hash_aset (rv, rb_str_new2 ("seg_count"), ULL2NUM (r->val[i].seg_count));
- rb_hash_aset (rv, rb_str_new2 ("origin"), rb_str_new2 (r->val[i].origin));
- rb_hash_aset (rv, rb_str_new2 ("snap_percent"), rb_dbl2big (r->val[i].snap_percent));
- rb_hash_aset (rv, rb_str_new2 ("copy_percent"), rb_dbl2big (r->val[i].copy_percent));
- rb_hash_aset (rv, rb_str_new2 ("move_pv"), rb_str_new2 (r->val[i].move_pv));
- rb_hash_aset (rv, rb_str_new2 ("lv_tags"), rb_str_new2 (r->val[i].lv_tags));
- rb_hash_aset (rv, rb_str_new2 ("mirror_log"), rb_str_new2 (r->val[i].mirror_log));
- rb_hash_aset (rv, rb_str_new2 ("modules"), rb_str_new2 (r->val[i].modules));
- rb_ary_push (rv, hv);
- }
- guestfs_free_lvm_lv_list (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rlvlisterr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rlvlisterr");
-
-
- struct guestfs_lvm_lv_list *r;
-
- r = guestfs_test0rlvlisterr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("lv_name"), rb_str_new2 (r->val[i].lv_name));
- rb_hash_aset (rv, rb_str_new2 ("lv_uuid"), rb_str_new (r->val[i].lv_uuid, 32));
- rb_hash_aset (rv, rb_str_new2 ("lv_attr"), rb_str_new2 (r->val[i].lv_attr));
- rb_hash_aset (rv, rb_str_new2 ("lv_major"), ULL2NUM (r->val[i].lv_major));
- rb_hash_aset (rv, rb_str_new2 ("lv_minor"), ULL2NUM (r->val[i].lv_minor));
- rb_hash_aset (rv, rb_str_new2 ("lv_kernel_major"), ULL2NUM (r->val[i].lv_kernel_major));
- rb_hash_aset (rv, rb_str_new2 ("lv_kernel_minor"), ULL2NUM (r->val[i].lv_kernel_minor));
- rb_hash_aset (rv, rb_str_new2 ("lv_size"), ULL2NUM (r->val[i].lv_size));
- rb_hash_aset (rv, rb_str_new2 ("seg_count"), ULL2NUM (r->val[i].seg_count));
- rb_hash_aset (rv, rb_str_new2 ("origin"), rb_str_new2 (r->val[i].origin));
- rb_hash_aset (rv, rb_str_new2 ("snap_percent"), rb_dbl2big (r->val[i].snap_percent));
- rb_hash_aset (rv, rb_str_new2 ("copy_percent"), rb_dbl2big (r->val[i].copy_percent));
- rb_hash_aset (rv, rb_str_new2 ("move_pv"), rb_str_new2 (r->val[i].move_pv));
- rb_hash_aset (rv, rb_str_new2 ("lv_tags"), rb_str_new2 (r->val[i].lv_tags));
- rb_hash_aset (rv, rb_str_new2 ("mirror_log"), rb_str_new2 (r->val[i].mirror_log));
- rb_hash_aset (rv, rb_str_new2 ("modules"), rb_str_new2 (r->val[i].modules));
- rb_ary_push (rv, hv);
- }
- guestfs_free_lvm_lv_list (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rstat (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstat");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rstat");
-
- struct guestfs_stat *r;
-
- r = guestfs_test0rstat (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("dev"), ULL2NUM (r->dev));
- rb_hash_aset (rv, rb_str_new2 ("ino"), ULL2NUM (r->ino));
- rb_hash_aset (rv, rb_str_new2 ("mode"), ULL2NUM (r->mode));
- rb_hash_aset (rv, rb_str_new2 ("nlink"), ULL2NUM (r->nlink));
- rb_hash_aset (rv, rb_str_new2 ("uid"), ULL2NUM (r->uid));
- rb_hash_aset (rv, rb_str_new2 ("gid"), ULL2NUM (r->gid));
- rb_hash_aset (rv, rb_str_new2 ("rdev"), ULL2NUM (r->rdev));
- rb_hash_aset (rv, rb_str_new2 ("size"), ULL2NUM (r->size));
- rb_hash_aset (rv, rb_str_new2 ("blksize"), ULL2NUM (r->blksize));
- rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks));
- rb_hash_aset (rv, rb_str_new2 ("atime"), ULL2NUM (r->atime));
- rb_hash_aset (rv, rb_str_new2 ("mtime"), ULL2NUM (r->mtime));
- rb_hash_aset (rv, rb_str_new2 ("ctime"), ULL2NUM (r->ctime));
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rstaterr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstaterr");
-
-
- struct guestfs_stat *r;
-
- r = guestfs_test0rstaterr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("dev"), ULL2NUM (r->dev));
- rb_hash_aset (rv, rb_str_new2 ("ino"), ULL2NUM (r->ino));
- rb_hash_aset (rv, rb_str_new2 ("mode"), ULL2NUM (r->mode));
- rb_hash_aset (rv, rb_str_new2 ("nlink"), ULL2NUM (r->nlink));
- rb_hash_aset (rv, rb_str_new2 ("uid"), ULL2NUM (r->uid));
- rb_hash_aset (rv, rb_str_new2 ("gid"), ULL2NUM (r->gid));
- rb_hash_aset (rv, rb_str_new2 ("rdev"), ULL2NUM (r->rdev));
- rb_hash_aset (rv, rb_str_new2 ("size"), ULL2NUM (r->size));
- rb_hash_aset (rv, rb_str_new2 ("blksize"), ULL2NUM (r->blksize));
- rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks));
- rb_hash_aset (rv, rb_str_new2 ("atime"), ULL2NUM (r->atime));
- rb_hash_aset (rv, rb_str_new2 ("mtime"), ULL2NUM (r->mtime));
- rb_hash_aset (rv, rb_str_new2 ("ctime"), ULL2NUM (r->ctime));
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rstatvfs (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstatvfs");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rstatvfs");
-
- struct guestfs_statvfs *r;
-
- r = guestfs_test0rstatvfs (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("bsize"), ULL2NUM (r->bsize));
- rb_hash_aset (rv, rb_str_new2 ("frsize"), ULL2NUM (r->frsize));
- rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks));
- rb_hash_aset (rv, rb_str_new2 ("bfree"), ULL2NUM (r->bfree));
- rb_hash_aset (rv, rb_str_new2 ("bavail"), ULL2NUM (r->bavail));
- rb_hash_aset (rv, rb_str_new2 ("files"), ULL2NUM (r->files));
- rb_hash_aset (rv, rb_str_new2 ("ffree"), ULL2NUM (r->ffree));
- rb_hash_aset (rv, rb_str_new2 ("favail"), ULL2NUM (r->favail));
- rb_hash_aset (rv, rb_str_new2 ("fsid"), ULL2NUM (r->fsid));
- rb_hash_aset (rv, rb_str_new2 ("flag"), ULL2NUM (r->flag));
- rb_hash_aset (rv, rb_str_new2 ("namemax"), ULL2NUM (r->namemax));
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rstatvfserr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstatvfserr");
-
-
- struct guestfs_statvfs *r;
-
- r = guestfs_test0rstatvfserr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("bsize"), ULL2NUM (r->bsize));
- rb_hash_aset (rv, rb_str_new2 ("frsize"), ULL2NUM (r->frsize));
- rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks));
- rb_hash_aset (rv, rb_str_new2 ("bfree"), ULL2NUM (r->bfree));
- rb_hash_aset (rv, rb_str_new2 ("bavail"), ULL2NUM (r->bavail));
- rb_hash_aset (rv, rb_str_new2 ("files"), ULL2NUM (r->files));
- rb_hash_aset (rv, rb_str_new2 ("ffree"), ULL2NUM (r->ffree));
- rb_hash_aset (rv, rb_str_new2 ("favail"), ULL2NUM (r->favail));
- rb_hash_aset (rv, rb_str_new2 ("fsid"), ULL2NUM (r->fsid));
- rb_hash_aset (rv, rb_str_new2 ("flag"), ULL2NUM (r->flag));
- rb_hash_aset (rv, rb_str_new2 ("namemax"), ULL2NUM (r->namemax));
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rhashtable (VALUE gv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rhashtable");
-
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "test0rhashtable");
-
- char **r;
-
- r = guestfs_test0rhashtable (g, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- int i;
- for (i = 0; r[i] != NULL; i+=2) {
- rb_hash_aset (rv, rb_str_new2 (r[i]), rb_str_new2 (r[i+1]));
- free (r[i]);
- free (r[i+1]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_test0rhashtableerr (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rhashtableerr");
-
-
- char **r;
-
- r = guestfs_test0rhashtableerr (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- int i;
- for (i = 0; r[i] != NULL; i+=2) {
- rb_hash_aset (rv, rb_str_new2 (r[i]), rb_str_new2 (r[i+1]));
- free (r[i]);
- free (r[i+1]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_launch (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "launch");
-
-
- int r;
-
- r = guestfs_launch (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_wait_ready (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "wait_ready");
-
-
- int r;
-
- r = guestfs_wait_ready (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_kill_subprocess (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "kill_subprocess");
-
-
- int r;
-
- r = guestfs_kill_subprocess (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_add_drive (VALUE gv, VALUE filenamev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "add_drive");
-
- Check_Type (filenamev, T_STRING);
- const char *filename = StringValueCStr (filenamev);
- if (!filename)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "filename", "add_drive");
-
- int r;
-
- r = guestfs_add_drive (g, filename);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_add_cdrom (VALUE gv, VALUE filenamev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "add_cdrom");
-
- Check_Type (filenamev, T_STRING);
- const char *filename = StringValueCStr (filenamev);
- if (!filename)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "filename", "add_cdrom");
-
- int r;
-
- r = guestfs_add_cdrom (g, filename);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_add_drive_ro (VALUE gv, VALUE filenamev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "add_drive_ro");
-
- Check_Type (filenamev, T_STRING);
- const char *filename = StringValueCStr (filenamev);
- if (!filename)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "filename", "add_drive_ro");
-
- int r;
-
- r = guestfs_add_drive_ro (g, filename);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_config (VALUE gv, VALUE qemuparamv, VALUE qemuvaluev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "config");
-
- Check_Type (qemuparamv, T_STRING);
- const char *qemuparam = StringValueCStr (qemuparamv);
- if (!qemuparam)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "qemuparam", "config");
- const char *qemuvalue = !NIL_P (qemuvaluev) ? StringValueCStr (qemuvaluev) : NULL;
-
- int r;
-
- r = guestfs_config (g, qemuparam, qemuvalue);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_set_qemu (VALUE gv, VALUE qemuv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_qemu");
-
- Check_Type (qemuv, T_STRING);
- const char *qemu = StringValueCStr (qemuv);
- if (!qemu)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "qemu", "set_qemu");
-
- int r;
-
- r = guestfs_set_qemu (g, qemu);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_get_qemu (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "get_qemu");
-
-
- const char *r;
-
- r = guestfs_get_qemu (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return rb_str_new2 (r);
-}
-
-static VALUE ruby_guestfs_set_path (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_path");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "set_path");
-
- int r;
-
- r = guestfs_set_path (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_get_path (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "get_path");
-
-
- const char *r;
-
- r = guestfs_get_path (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return rb_str_new2 (r);
-}
-
-static VALUE ruby_guestfs_set_append (VALUE gv, VALUE appendv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_append");
-
- Check_Type (appendv, T_STRING);
- const char *append = StringValueCStr (appendv);
- if (!append)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "append", "set_append");
-
- int r;
-
- r = guestfs_set_append (g, append);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_get_append (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "get_append");
-
-
- const char *r;
-
- r = guestfs_get_append (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return rb_str_new2 (r);
-}
-
-static VALUE ruby_guestfs_set_autosync (VALUE gv, VALUE autosyncv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_autosync");
-
- int autosync = RTEST (autosyncv);
-
- int r;
-
- r = guestfs_set_autosync (g, autosync);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_get_autosync (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "get_autosync");
-
-
- int r;
-
- r = guestfs_get_autosync (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_set_verbose (VALUE gv, VALUE verbosev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_verbose");
-
- int verbose = RTEST (verbosev);
-
- int r;
-
- r = guestfs_set_verbose (g, verbose);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_get_verbose (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "get_verbose");
-
-
- int r;
-
- r = guestfs_get_verbose (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_is_ready (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "is_ready");
-
-
- int r;
-
- r = guestfs_is_ready (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_is_config (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "is_config");
-
-
- int r;
-
- r = guestfs_is_config (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_is_launching (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "is_launching");
-
-
- int r;
-
- r = guestfs_is_launching (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_is_busy (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "is_busy");
-
-
- int r;
-
- r = guestfs_is_busy (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_get_state (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "get_state");
-
-
- int r;
-
- r = guestfs_get_state (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_set_busy (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_busy");
-
-
- int r;
-
- r = guestfs_set_busy (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_set_ready (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_ready");
-
-
- int r;
-
- r = guestfs_set_ready (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_end_busy (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "end_busy");
-
-
- int r;
-
- r = guestfs_end_busy (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_set_memsize (VALUE gv, VALUE memsizev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_memsize");
-
- int memsize = NUM2INT (memsizev);
-
- int r;
-
- r = guestfs_set_memsize (g, memsize);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_get_memsize (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "get_memsize");
-
-
- int r;
-
- r = guestfs_get_memsize (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_mount (VALUE gv, VALUE devicev, VALUE mountpointv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mount");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "mount");
- Check_Type (mountpointv, T_STRING);
- const char *mountpoint = StringValueCStr (mountpointv);
- if (!mountpoint)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "mountpoint", "mount");
-
- int r;
-
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_sync (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "sync");
-
-
- int r;
-
- r = guestfs_sync (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_touch (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "touch");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "touch");
-
- int r;
-
- r = guestfs_touch (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_cat (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "cat");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "cat");
-
- char *r;
-
- r = guestfs_cat (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_ll (VALUE gv, VALUE directoryv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "ll");
-
- Check_Type (directoryv, T_STRING);
- const char *directory = StringValueCStr (directoryv);
- if (!directory)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "directory", "ll");
-
- char *r;
-
- r = guestfs_ll (g, directory);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_ls (VALUE gv, VALUE directoryv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "ls");
-
- Check_Type (directoryv, T_STRING);
- const char *directory = StringValueCStr (directoryv);
- if (!directory)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "directory", "ls");
-
- char **r;
-
- r = guestfs_ls (g, directory);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_list_devices (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "list_devices");
-
-
- char **r;
-
- r = guestfs_list_devices (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_list_partitions (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "list_partitions");
-
-
- char **r;
-
- r = guestfs_list_partitions (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_pvs (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "pvs");
-
-
- char **r;
-
- r = guestfs_pvs (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_vgs (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "vgs");
-
-
- char **r;
-
- r = guestfs_vgs (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_lvs (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "lvs");
-
-
- char **r;
-
- r = guestfs_lvs (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_pvs_full (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "pvs_full");
-
-
- struct guestfs_lvm_pv_list *r;
-
- r = guestfs_pvs_full (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("pv_name"), rb_str_new2 (r->val[i].pv_name));
- rb_hash_aset (rv, rb_str_new2 ("pv_uuid"), rb_str_new (r->val[i].pv_uuid, 32));
- rb_hash_aset (rv, rb_str_new2 ("pv_fmt"), rb_str_new2 (r->val[i].pv_fmt));
- rb_hash_aset (rv, rb_str_new2 ("pv_size"), ULL2NUM (r->val[i].pv_size));
- rb_hash_aset (rv, rb_str_new2 ("dev_size"), ULL2NUM (r->val[i].dev_size));
- rb_hash_aset (rv, rb_str_new2 ("pv_free"), ULL2NUM (r->val[i].pv_free));
- rb_hash_aset (rv, rb_str_new2 ("pv_used"), ULL2NUM (r->val[i].pv_used));
- rb_hash_aset (rv, rb_str_new2 ("pv_attr"), rb_str_new2 (r->val[i].pv_attr));
- rb_hash_aset (rv, rb_str_new2 ("pv_pe_count"), ULL2NUM (r->val[i].pv_pe_count));
- rb_hash_aset (rv, rb_str_new2 ("pv_pe_alloc_count"), ULL2NUM (r->val[i].pv_pe_alloc_count));
- rb_hash_aset (rv, rb_str_new2 ("pv_tags"), rb_str_new2 (r->val[i].pv_tags));
- rb_hash_aset (rv, rb_str_new2 ("pe_start"), ULL2NUM (r->val[i].pe_start));
- rb_hash_aset (rv, rb_str_new2 ("pv_mda_count"), ULL2NUM (r->val[i].pv_mda_count));
- rb_hash_aset (rv, rb_str_new2 ("pv_mda_free"), ULL2NUM (r->val[i].pv_mda_free));
- rb_ary_push (rv, hv);
- }
- guestfs_free_lvm_pv_list (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_vgs_full (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "vgs_full");
-
-
- struct guestfs_lvm_vg_list *r;
-
- r = guestfs_vgs_full (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("vg_name"), rb_str_new2 (r->val[i].vg_name));
- rb_hash_aset (rv, rb_str_new2 ("vg_uuid"), rb_str_new (r->val[i].vg_uuid, 32));
- rb_hash_aset (rv, rb_str_new2 ("vg_fmt"), rb_str_new2 (r->val[i].vg_fmt));
- rb_hash_aset (rv, rb_str_new2 ("vg_attr"), rb_str_new2 (r->val[i].vg_attr));
- rb_hash_aset (rv, rb_str_new2 ("vg_size"), ULL2NUM (r->val[i].vg_size));
- rb_hash_aset (rv, rb_str_new2 ("vg_free"), ULL2NUM (r->val[i].vg_free));
- rb_hash_aset (rv, rb_str_new2 ("vg_sysid"), rb_str_new2 (r->val[i].vg_sysid));
- rb_hash_aset (rv, rb_str_new2 ("vg_extent_size"), ULL2NUM (r->val[i].vg_extent_size));
- rb_hash_aset (rv, rb_str_new2 ("vg_extent_count"), ULL2NUM (r->val[i].vg_extent_count));
- rb_hash_aset (rv, rb_str_new2 ("vg_free_count"), ULL2NUM (r->val[i].vg_free_count));
- rb_hash_aset (rv, rb_str_new2 ("max_lv"), ULL2NUM (r->val[i].max_lv));
- rb_hash_aset (rv, rb_str_new2 ("max_pv"), ULL2NUM (r->val[i].max_pv));
- rb_hash_aset (rv, rb_str_new2 ("pv_count"), ULL2NUM (r->val[i].pv_count));
- rb_hash_aset (rv, rb_str_new2 ("lv_count"), ULL2NUM (r->val[i].lv_count));
- rb_hash_aset (rv, rb_str_new2 ("snap_count"), ULL2NUM (r->val[i].snap_count));
- rb_hash_aset (rv, rb_str_new2 ("vg_seqno"), ULL2NUM (r->val[i].vg_seqno));
- rb_hash_aset (rv, rb_str_new2 ("vg_tags"), rb_str_new2 (r->val[i].vg_tags));
- rb_hash_aset (rv, rb_str_new2 ("vg_mda_count"), ULL2NUM (r->val[i].vg_mda_count));
- rb_hash_aset (rv, rb_str_new2 ("vg_mda_free"), ULL2NUM (r->val[i].vg_mda_free));
- rb_ary_push (rv, hv);
- }
- guestfs_free_lvm_vg_list (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_lvs_full (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "lvs_full");
-
-
- struct guestfs_lvm_lv_list *r;
-
- r = guestfs_lvs_full (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("lv_name"), rb_str_new2 (r->val[i].lv_name));
- rb_hash_aset (rv, rb_str_new2 ("lv_uuid"), rb_str_new (r->val[i].lv_uuid, 32));
- rb_hash_aset (rv, rb_str_new2 ("lv_attr"), rb_str_new2 (r->val[i].lv_attr));
- rb_hash_aset (rv, rb_str_new2 ("lv_major"), ULL2NUM (r->val[i].lv_major));
- rb_hash_aset (rv, rb_str_new2 ("lv_minor"), ULL2NUM (r->val[i].lv_minor));
- rb_hash_aset (rv, rb_str_new2 ("lv_kernel_major"), ULL2NUM (r->val[i].lv_kernel_major));
- rb_hash_aset (rv, rb_str_new2 ("lv_kernel_minor"), ULL2NUM (r->val[i].lv_kernel_minor));
- rb_hash_aset (rv, rb_str_new2 ("lv_size"), ULL2NUM (r->val[i].lv_size));
- rb_hash_aset (rv, rb_str_new2 ("seg_count"), ULL2NUM (r->val[i].seg_count));
- rb_hash_aset (rv, rb_str_new2 ("origin"), rb_str_new2 (r->val[i].origin));
- rb_hash_aset (rv, rb_str_new2 ("snap_percent"), rb_dbl2big (r->val[i].snap_percent));
- rb_hash_aset (rv, rb_str_new2 ("copy_percent"), rb_dbl2big (r->val[i].copy_percent));
- rb_hash_aset (rv, rb_str_new2 ("move_pv"), rb_str_new2 (r->val[i].move_pv));
- rb_hash_aset (rv, rb_str_new2 ("lv_tags"), rb_str_new2 (r->val[i].lv_tags));
- rb_hash_aset (rv, rb_str_new2 ("mirror_log"), rb_str_new2 (r->val[i].mirror_log));
- rb_hash_aset (rv, rb_str_new2 ("modules"), rb_str_new2 (r->val[i].modules));
- rb_ary_push (rv, hv);
- }
- guestfs_free_lvm_lv_list (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_read_lines (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "read_lines");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "read_lines");
-
- char **r;
-
- r = guestfs_read_lines (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_aug_init (VALUE gv, VALUE rootv, VALUE flagsv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_init");
-
- Check_Type (rootv, T_STRING);
- const char *root = StringValueCStr (rootv);
- if (!root)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "root", "aug_init");
- int flags = NUM2INT (flagsv);
-
- int r;
-
- r = guestfs_aug_init (g, root, flags);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_aug_close (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_close");
-
-
- int r;
-
- r = guestfs_aug_close (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_aug_defvar (VALUE gv, VALUE namev, VALUE exprv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_defvar");
-
- Check_Type (namev, T_STRING);
- const char *name = StringValueCStr (namev);
- if (!name)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "name", "aug_defvar");
- const char *expr = !NIL_P (exprv) ? StringValueCStr (exprv) : NULL;
-
- int r;
-
- r = guestfs_aug_defvar (g, name, expr);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_aug_defnode (VALUE gv, VALUE namev, VALUE exprv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_defnode");
-
- Check_Type (namev, T_STRING);
- const char *name = StringValueCStr (namev);
- if (!name)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "name", "aug_defnode");
- Check_Type (exprv, T_STRING);
- const char *expr = StringValueCStr (exprv);
- if (!expr)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "expr", "aug_defnode");
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "aug_defnode");
-
- struct guestfs_int_bool *r;
-
- r = guestfs_aug_defnode (g, name, expr, val);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (2);
- rb_ary_push (rv, INT2NUM (r->i));
- rb_ary_push (rv, INT2NUM (r->b));
- guestfs_free_int_bool (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_aug_get (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_get");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "aug_get");
-
- char *r;
-
- r = guestfs_aug_get (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_aug_set (VALUE gv, VALUE pathv, VALUE valv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_set");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "aug_set");
- Check_Type (valv, T_STRING);
- const char *val = StringValueCStr (valv);
- if (!val)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "val", "aug_set");
-
- int r;
-
- r = guestfs_aug_set (g, path, val);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_aug_insert (VALUE gv, VALUE pathv, VALUE labelv, VALUE beforev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_insert");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "aug_insert");
- Check_Type (labelv, T_STRING);
- const char *label = StringValueCStr (labelv);
- if (!label)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "label", "aug_insert");
- int before = RTEST (beforev);
-
- int r;
-
- r = guestfs_aug_insert (g, path, label, before);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_aug_rm (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_rm");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "aug_rm");
-
- int r;
-
- r = guestfs_aug_rm (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_aug_mv (VALUE gv, VALUE srcv, VALUE destv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_mv");
-
- Check_Type (srcv, T_STRING);
- const char *src = StringValueCStr (srcv);
- if (!src)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "src", "aug_mv");
- Check_Type (destv, T_STRING);
- const char *dest = StringValueCStr (destv);
- if (!dest)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "dest", "aug_mv");
-
- int r;
-
- r = guestfs_aug_mv (g, src, dest);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_aug_match (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_match");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "aug_match");
-
- char **r;
-
- r = guestfs_aug_match (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_aug_save (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_save");
-
-
- int r;
-
- r = guestfs_aug_save (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_aug_load (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_load");
-
-
- int r;
-
- r = guestfs_aug_load (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_aug_ls (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_ls");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "aug_ls");
-
- char **r;
-
- r = guestfs_aug_ls (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_rm (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "rm");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "rm");
-
- int r;
-
- r = guestfs_rm (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_rmdir (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "rmdir");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "rmdir");
-
- int r;
-
- r = guestfs_rmdir (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_rm_rf (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "rm_rf");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "rm_rf");
-
- int r;
-
- r = guestfs_rm_rf (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mkdir (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mkdir");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "mkdir");
-
- int r;
-
- r = guestfs_mkdir (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mkdir_p (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mkdir_p");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "mkdir_p");
-
- int r;
-
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_chmod (VALUE gv, VALUE modev, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "chmod");
-
- int mode = NUM2INT (modev);
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "chmod");
-
- int r;
-
- r = guestfs_chmod (g, mode, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_chown (VALUE gv, VALUE ownerv, VALUE groupv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "chown");
-
- int owner = NUM2INT (ownerv);
- int group = NUM2INT (groupv);
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "chown");
-
- int r;
-
- r = guestfs_chown (g, owner, group, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_exists (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "exists");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "exists");
-
- int r;
-
- r = guestfs_exists (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_is_file (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "is_file");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "is_file");
-
- int r;
-
- r = guestfs_is_file (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_is_dir (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "is_dir");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "is_dir");
-
- int r;
-
- r = guestfs_is_dir (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_pvcreate (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "pvcreate");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "pvcreate");
-
- int r;
-
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_vgcreate (VALUE gv, VALUE volgroupv, VALUE physvolsv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "vgcreate");
-
- Check_Type (volgroupv, T_STRING);
- const char *volgroup = StringValueCStr (volgroupv);
- if (!volgroup)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "volgroup", "vgcreate");
- char **physvols;
- Check_Type (physvolsv, T_ARRAY);
- {
- int i, len;
- len = RARRAY_LEN (physvolsv);
- physvols = guestfs_safe_malloc (g, sizeof (char *) * (len+1));
- for (i = 0; i < len; ++i) {
- VALUE v = rb_ary_entry (physvolsv, i);
- physvols[i] = StringValueCStr (v);
- }
- physvols[len] = NULL;
- }
-
- int r;
-
- r = guestfs_vgcreate (g, volgroup, physvols);
- free (physvols);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_lvcreate (VALUE gv, VALUE logvolv, VALUE volgroupv, VALUE mbytesv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "lvcreate");
-
- Check_Type (logvolv, T_STRING);
- const char *logvol = StringValueCStr (logvolv);
- if (!logvol)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "logvol", "lvcreate");
- Check_Type (volgroupv, T_STRING);
- const char *volgroup = StringValueCStr (volgroupv);
- if (!volgroup)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "volgroup", "lvcreate");
- int mbytes = NUM2INT (mbytesv);
-
- int r;
-
- r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mkfs (VALUE gv, VALUE fstypev, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mkfs");
-
- Check_Type (fstypev, T_STRING);
- const char *fstype = StringValueCStr (fstypev);
- if (!fstype)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "fstype", "mkfs");
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "mkfs");
-
- int r;
-
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_sfdisk (VALUE gv, VALUE devicev, VALUE cylsv, VALUE headsv, VALUE sectorsv, VALUE linesv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "sfdisk");
- int cyls = NUM2INT (cylsv);
- int heads = NUM2INT (headsv);
- int sectors = NUM2INT (sectorsv);
- char **lines;
- Check_Type (linesv, T_ARRAY);
- {
- int i, len;
- len = RARRAY_LEN (linesv);
- lines = guestfs_safe_malloc (g, sizeof (char *) * (len+1));
- for (i = 0; i < len; ++i) {
- VALUE v = rb_ary_entry (linesv, i);
- lines[i] = StringValueCStr (v);
- }
- lines[len] = NULL;
- }
-
- int r;
-
- r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
- free (lines);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_write_file (VALUE gv, VALUE pathv, VALUE contentv, VALUE sizev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "write_file");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "write_file");
- Check_Type (contentv, T_STRING);
- const char *content = StringValueCStr (contentv);
- if (!content)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "content", "write_file");
- int size = NUM2INT (sizev);
-
- int r;
-
- r = guestfs_write_file (g, path, content, size);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_umount (VALUE gv, VALUE pathordevicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "umount");
-
- Check_Type (pathordevicev, T_STRING);
- const char *pathordevice = StringValueCStr (pathordevicev);
- if (!pathordevice)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "pathordevice", "umount");
-
- int r;
-
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mounts (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mounts");
-
-
- char **r;
-
- r = guestfs_mounts (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_umount_all (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "umount_all");
-
-
- int r;
-
- r = guestfs_umount_all (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_lvm_remove_all (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "lvm_remove_all");
-
-
- int r;
-
- r = guestfs_lvm_remove_all (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_file (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "file");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "file");
-
- char *r;
-
- r = guestfs_file (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_command (VALUE gv, VALUE argumentsv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "command");
-
- char **arguments;
- Check_Type (argumentsv, T_ARRAY);
- {
- int i, len;
- len = RARRAY_LEN (argumentsv);
- arguments = guestfs_safe_malloc (g, sizeof (char *) * (len+1));
- for (i = 0; i < len; ++i) {
- VALUE v = rb_ary_entry (argumentsv, i);
- arguments[i] = StringValueCStr (v);
- }
- arguments[len] = NULL;
- }
-
- char *r;
-
- r = guestfs_command (g, arguments);
- free (arguments);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_command_lines (VALUE gv, VALUE argumentsv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "command_lines");
-
- char **arguments;
- Check_Type (argumentsv, T_ARRAY);
- {
- int i, len;
- len = RARRAY_LEN (argumentsv);
- arguments = guestfs_safe_malloc (g, sizeof (char *) * (len+1));
- for (i = 0; i < len; ++i) {
- VALUE v = rb_ary_entry (argumentsv, i);
- arguments[i] = StringValueCStr (v);
- }
- arguments[len] = NULL;
- }
-
- char **r;
-
- r = guestfs_command_lines (g, arguments);
- free (arguments);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_stat (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "stat");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "stat");
-
- struct guestfs_stat *r;
-
- r = guestfs_stat (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("dev"), ULL2NUM (r->dev));
- rb_hash_aset (rv, rb_str_new2 ("ino"), ULL2NUM (r->ino));
- rb_hash_aset (rv, rb_str_new2 ("mode"), ULL2NUM (r->mode));
- rb_hash_aset (rv, rb_str_new2 ("nlink"), ULL2NUM (r->nlink));
- rb_hash_aset (rv, rb_str_new2 ("uid"), ULL2NUM (r->uid));
- rb_hash_aset (rv, rb_str_new2 ("gid"), ULL2NUM (r->gid));
- rb_hash_aset (rv, rb_str_new2 ("rdev"), ULL2NUM (r->rdev));
- rb_hash_aset (rv, rb_str_new2 ("size"), ULL2NUM (r->size));
- rb_hash_aset (rv, rb_str_new2 ("blksize"), ULL2NUM (r->blksize));
- rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks));
- rb_hash_aset (rv, rb_str_new2 ("atime"), ULL2NUM (r->atime));
- rb_hash_aset (rv, rb_str_new2 ("mtime"), ULL2NUM (r->mtime));
- rb_hash_aset (rv, rb_str_new2 ("ctime"), ULL2NUM (r->ctime));
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_lstat (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "lstat");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "lstat");
-
- struct guestfs_stat *r;
-
- r = guestfs_lstat (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("dev"), ULL2NUM (r->dev));
- rb_hash_aset (rv, rb_str_new2 ("ino"), ULL2NUM (r->ino));
- rb_hash_aset (rv, rb_str_new2 ("mode"), ULL2NUM (r->mode));
- rb_hash_aset (rv, rb_str_new2 ("nlink"), ULL2NUM (r->nlink));
- rb_hash_aset (rv, rb_str_new2 ("uid"), ULL2NUM (r->uid));
- rb_hash_aset (rv, rb_str_new2 ("gid"), ULL2NUM (r->gid));
- rb_hash_aset (rv, rb_str_new2 ("rdev"), ULL2NUM (r->rdev));
- rb_hash_aset (rv, rb_str_new2 ("size"), ULL2NUM (r->size));
- rb_hash_aset (rv, rb_str_new2 ("blksize"), ULL2NUM (r->blksize));
- rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks));
- rb_hash_aset (rv, rb_str_new2 ("atime"), ULL2NUM (r->atime));
- rb_hash_aset (rv, rb_str_new2 ("mtime"), ULL2NUM (r->mtime));
- rb_hash_aset (rv, rb_str_new2 ("ctime"), ULL2NUM (r->ctime));
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_statvfs (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "statvfs");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "statvfs");
-
- struct guestfs_statvfs *r;
-
- r = guestfs_statvfs (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("bsize"), ULL2NUM (r->bsize));
- rb_hash_aset (rv, rb_str_new2 ("frsize"), ULL2NUM (r->frsize));
- rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks));
- rb_hash_aset (rv, rb_str_new2 ("bfree"), ULL2NUM (r->bfree));
- rb_hash_aset (rv, rb_str_new2 ("bavail"), ULL2NUM (r->bavail));
- rb_hash_aset (rv, rb_str_new2 ("files"), ULL2NUM (r->files));
- rb_hash_aset (rv, rb_str_new2 ("ffree"), ULL2NUM (r->ffree));
- rb_hash_aset (rv, rb_str_new2 ("favail"), ULL2NUM (r->favail));
- rb_hash_aset (rv, rb_str_new2 ("fsid"), ULL2NUM (r->fsid));
- rb_hash_aset (rv, rb_str_new2 ("flag"), ULL2NUM (r->flag));
- rb_hash_aset (rv, rb_str_new2 ("namemax"), ULL2NUM (r->namemax));
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_tune2fs_l (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "tune2fs_l");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "tune2fs_l");
-
- char **r;
-
- r = guestfs_tune2fs_l (g, device);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_hash_new ();
- int i;
- for (i = 0; r[i] != NULL; i+=2) {
- rb_hash_aset (rv, rb_str_new2 (r[i]), rb_str_new2 (r[i+1]));
- free (r[i]);
- free (r[i+1]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_blockdev_setro (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_setro");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_setro");
-
- int r;
-
- r = guestfs_blockdev_setro (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_blockdev_setrw (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_setrw");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_setrw");
-
- int r;
-
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_blockdev_getro (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getro");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_getro");
-
- int r;
-
- r = guestfs_blockdev_getro (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_blockdev_getss (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getss");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_getss");
-
- int r;
-
- r = guestfs_blockdev_getss (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_blockdev_getbsz (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getbsz");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_getbsz");
-
- int r;
-
- r = guestfs_blockdev_getbsz (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_blockdev_setbsz (VALUE gv, VALUE devicev, VALUE blocksizev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_setbsz");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_setbsz");
- int blocksize = NUM2INT (blocksizev);
-
- int r;
-
- r = guestfs_blockdev_setbsz (g, device, blocksize);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_blockdev_getsz (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getsz");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_getsz");
-
- int64_t r;
-
- r = guestfs_blockdev_getsz (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return ULL2NUM (r);
-}
-
-static VALUE ruby_guestfs_blockdev_getsize64 (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getsize64");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_getsize64");
-
- int64_t r;
-
- r = guestfs_blockdev_getsize64 (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return ULL2NUM (r);
-}
-
-static VALUE ruby_guestfs_blockdev_flushbufs (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_flushbufs");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_flushbufs");
-
- int r;
-
- r = guestfs_blockdev_flushbufs (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_blockdev_rereadpt (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_rereadpt");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "blockdev_rereadpt");
-
- int r;
-
- r = guestfs_blockdev_rereadpt (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_upload (VALUE gv, VALUE filenamev, VALUE remotefilenamev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "upload");
-
- Check_Type (filenamev, T_STRING);
- const char *filename = StringValueCStr (filenamev);
- if (!filename)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "filename", "upload");
- Check_Type (remotefilenamev, T_STRING);
- const char *remotefilename = StringValueCStr (remotefilenamev);
- if (!remotefilename)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "remotefilename", "upload");
-
- int r;
-
- r = guestfs_upload (g, filename, remotefilename);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_download (VALUE gv, VALUE remotefilenamev, VALUE filenamev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "download");
-
- Check_Type (remotefilenamev, T_STRING);
- const char *remotefilename = StringValueCStr (remotefilenamev);
- if (!remotefilename)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "remotefilename", "download");
- Check_Type (filenamev, T_STRING);
- const char *filename = StringValueCStr (filenamev);
- if (!filename)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "filename", "download");
-
- int r;
-
- r = guestfs_download (g, remotefilename, filename);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_checksum (VALUE gv, VALUE csumtypev, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "checksum");
-
- Check_Type (csumtypev, T_STRING);
- const char *csumtype = StringValueCStr (csumtypev);
- if (!csumtype)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "csumtype", "checksum");
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "checksum");
-
- char *r;
-
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_tar_in (VALUE gv, VALUE tarfilev, VALUE directoryv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "tar_in");
-
- Check_Type (tarfilev, T_STRING);
- const char *tarfile = StringValueCStr (tarfilev);
- if (!tarfile)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "tarfile", "tar_in");
- Check_Type (directoryv, T_STRING);
- const char *directory = StringValueCStr (directoryv);
- if (!directory)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "directory", "tar_in");
-
- int r;
-
- r = guestfs_tar_in (g, tarfile, directory);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_tar_out (VALUE gv, VALUE directoryv, VALUE tarfilev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "tar_out");
-
- Check_Type (directoryv, T_STRING);
- const char *directory = StringValueCStr (directoryv);
- if (!directory)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "directory", "tar_out");
- Check_Type (tarfilev, T_STRING);
- const char *tarfile = StringValueCStr (tarfilev);
- if (!tarfile)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "tarfile", "tar_out");
-
- int r;
-
- r = guestfs_tar_out (g, directory, tarfile);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_tgz_in (VALUE gv, VALUE tarballv, VALUE directoryv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "tgz_in");
-
- Check_Type (tarballv, T_STRING);
- const char *tarball = StringValueCStr (tarballv);
- if (!tarball)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "tarball", "tgz_in");
- Check_Type (directoryv, T_STRING);
- const char *directory = StringValueCStr (directoryv);
- if (!directory)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "directory", "tgz_in");
-
- int r;
-
- r = guestfs_tgz_in (g, tarball, directory);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_tgz_out (VALUE gv, VALUE directoryv, VALUE tarballv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "tgz_out");
-
- Check_Type (directoryv, T_STRING);
- const char *directory = StringValueCStr (directoryv);
- if (!directory)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "directory", "tgz_out");
- Check_Type (tarballv, T_STRING);
- const char *tarball = StringValueCStr (tarballv);
- if (!tarball)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "tarball", "tgz_out");
-
- int r;
-
- r = guestfs_tgz_out (g, directory, tarball);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mount_ro (VALUE gv, VALUE devicev, VALUE mountpointv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_ro");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "mount_ro");
- Check_Type (mountpointv, T_STRING);
- const char *mountpoint = StringValueCStr (mountpointv);
- if (!mountpoint)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "mountpoint", "mount_ro");
-
- int r;
-
- r = guestfs_mount_ro (g, device, mountpoint);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mount_options (VALUE gv, VALUE optionsv, VALUE devicev, VALUE mountpointv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_options");
-
- Check_Type (optionsv, T_STRING);
- const char *options = StringValueCStr (optionsv);
- if (!options)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "options", "mount_options");
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "mount_options");
- Check_Type (mountpointv, T_STRING);
- const char *mountpoint = StringValueCStr (mountpointv);
- if (!mountpoint)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "mountpoint", "mount_options");
-
- int r;
-
- r = guestfs_mount_options (g, options, device, mountpoint);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mount_vfs (VALUE gv, VALUE optionsv, VALUE vfstypev, VALUE devicev, VALUE mountpointv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_vfs");
-
- Check_Type (optionsv, T_STRING);
- const char *options = StringValueCStr (optionsv);
- if (!options)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "options", "mount_vfs");
- Check_Type (vfstypev, T_STRING);
- const char *vfstype = StringValueCStr (vfstypev);
- if (!vfstype)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "vfstype", "mount_vfs");
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "mount_vfs");
- Check_Type (mountpointv, T_STRING);
- const char *mountpoint = StringValueCStr (mountpointv);
- if (!mountpoint)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "mountpoint", "mount_vfs");
-
- int r;
-
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_debug (VALUE gv, VALUE subcmdv, VALUE extraargsv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "debug");
-
- Check_Type (subcmdv, T_STRING);
- const char *subcmd = StringValueCStr (subcmdv);
- if (!subcmd)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "subcmd", "debug");
- char **extraargs;
- Check_Type (extraargsv, T_ARRAY);
- {
- int i, len;
- len = RARRAY_LEN (extraargsv);
- extraargs = guestfs_safe_malloc (g, sizeof (char *) * (len+1));
- for (i = 0; i < len; ++i) {
- VALUE v = rb_ary_entry (extraargsv, i);
- extraargs[i] = StringValueCStr (v);
- }
- extraargs[len] = NULL;
- }
-
- char *r;
-
- r = guestfs_debug (g, subcmd, extraargs);
- free (extraargs);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_lvremove (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "lvremove");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "lvremove");
-
- int r;
-
- r = guestfs_lvremove (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_vgremove (VALUE gv, VALUE vgnamev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "vgremove");
-
- Check_Type (vgnamev, T_STRING);
- const char *vgname = StringValueCStr (vgnamev);
- if (!vgname)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "vgname", "vgremove");
-
- int r;
-
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_pvremove (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "pvremove");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "pvremove");
-
- int r;
-
- r = guestfs_pvremove (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_set_e2label (VALUE gv, VALUE devicev, VALUE labelv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_e2label");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "set_e2label");
- Check_Type (labelv, T_STRING);
- const char *label = StringValueCStr (labelv);
- if (!label)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "label", "set_e2label");
-
- int r;
-
- r = guestfs_set_e2label (g, device, label);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_get_e2label (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "get_e2label");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "get_e2label");
-
- char *r;
-
- r = guestfs_get_e2label (g, device);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_set_e2uuid (VALUE gv, VALUE devicev, VALUE uuidv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "set_e2uuid");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "set_e2uuid");
- Check_Type (uuidv, T_STRING);
- const char *uuid = StringValueCStr (uuidv);
- if (!uuid)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "uuid", "set_e2uuid");
-
- int r;
-
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_get_e2uuid (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "get_e2uuid");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "get_e2uuid");
-
- char *r;
-
- r = guestfs_get_e2uuid (g, device);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_fsck (VALUE gv, VALUE fstypev, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "fsck");
-
- Check_Type (fstypev, T_STRING);
- const char *fstype = StringValueCStr (fstypev);
- if (!fstype)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "fstype", "fsck");
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "fsck");
-
- int r;
-
- r = guestfs_fsck (g, fstype, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_zero (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "zero");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "zero");
-
- int r;
-
- r = guestfs_zero (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_grub_install (VALUE gv, VALUE rootv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "grub_install");
-
- Check_Type (rootv, T_STRING);
- const char *root = StringValueCStr (rootv);
- if (!root)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "root", "grub_install");
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "grub_install");
-
- int r;
-
- r = guestfs_grub_install (g, root, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_cp (VALUE gv, VALUE srcv, VALUE destv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "cp");
-
- Check_Type (srcv, T_STRING);
- const char *src = StringValueCStr (srcv);
- if (!src)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "src", "cp");
- Check_Type (destv, T_STRING);
- const char *dest = StringValueCStr (destv);
- if (!dest)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "dest", "cp");
-
- int r;
-
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_cp_a (VALUE gv, VALUE srcv, VALUE destv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "cp_a");
-
- Check_Type (srcv, T_STRING);
- const char *src = StringValueCStr (srcv);
- if (!src)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "src", "cp_a");
- Check_Type (destv, T_STRING);
- const char *dest = StringValueCStr (destv);
- if (!dest)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "dest", "cp_a");
-
- int r;
-
- r = guestfs_cp_a (g, src, dest);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mv (VALUE gv, VALUE srcv, VALUE destv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mv");
-
- Check_Type (srcv, T_STRING);
- const char *src = StringValueCStr (srcv);
- if (!src)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "src", "mv");
- Check_Type (destv, T_STRING);
- const char *dest = StringValueCStr (destv);
- if (!dest)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "dest", "mv");
-
- int r;
-
- r = guestfs_mv (g, src, dest);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_drop_caches (VALUE gv, VALUE whattodropv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "drop_caches");
-
- int whattodrop = NUM2INT (whattodropv);
-
- int r;
-
- r = guestfs_drop_caches (g, whattodrop);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_dmesg (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "dmesg");
-
-
- char *r;
-
- r = guestfs_dmesg (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_ping_daemon (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "ping_daemon");
-
-
- int r;
-
- r = guestfs_ping_daemon (g);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_equal (VALUE gv, VALUE file1v, VALUE file2v)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "equal");
-
- Check_Type (file1v, T_STRING);
- const char *file1 = StringValueCStr (file1v);
- if (!file1)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "file1", "equal");
- Check_Type (file2v, T_STRING);
- const char *file2 = StringValueCStr (file2v);
- if (!file2)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "file2", "equal");
-
- int r;
-
- r = guestfs_equal (g, file1, file2);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_strings (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "strings");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "strings");
-
- char **r;
-
- r = guestfs_strings (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_strings_e (VALUE gv, VALUE encodingv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "strings_e");
-
- Check_Type (encodingv, T_STRING);
- const char *encoding = StringValueCStr (encodingv);
- if (!encoding)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "encoding", "strings_e");
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "strings_e");
-
- char **r;
-
- r = guestfs_strings_e (g, encoding, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_hexdump (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "hexdump");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "hexdump");
-
- char *r;
-
- r = guestfs_hexdump (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_zerofree (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "zerofree");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "zerofree");
-
- int r;
-
- r = guestfs_zerofree (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_pvresize (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "pvresize");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "pvresize");
-
- int r;
-
- r = guestfs_pvresize (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_sfdisk_N (VALUE gv, VALUE devicev, VALUE partnumv, VALUE cylsv, VALUE headsv, VALUE sectorsv, VALUE linev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk_N");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "sfdisk_N");
- int partnum = NUM2INT (partnumv);
- int cyls = NUM2INT (cylsv);
- int heads = NUM2INT (headsv);
- int sectors = NUM2INT (sectorsv);
- Check_Type (linev, T_STRING);
- const char *line = StringValueCStr (linev);
- if (!line)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "line", "sfdisk_N");
-
- int r;
-
- r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_sfdisk_l (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk_l");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "sfdisk_l");
-
- char *r;
-
- r = guestfs_sfdisk_l (g, device);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_sfdisk_kernel_geometry (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk_kernel_geometry");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "sfdisk_kernel_geometry");
-
- char *r;
-
- r = guestfs_sfdisk_kernel_geometry (g, device);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_sfdisk_disk_geometry (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk_disk_geometry");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "sfdisk_disk_geometry");
-
- char *r;
-
- r = guestfs_sfdisk_disk_geometry (g, device);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_vg_activate_all (VALUE gv, VALUE activatev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "vg_activate_all");
-
- int activate = RTEST (activatev);
-
- int r;
-
- r = guestfs_vg_activate_all (g, activate);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_vg_activate (VALUE gv, VALUE activatev, VALUE volgroupsv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "vg_activate");
-
- int activate = RTEST (activatev);
- char **volgroups;
- Check_Type (volgroupsv, T_ARRAY);
- {
- int i, len;
- len = RARRAY_LEN (volgroupsv);
- volgroups = guestfs_safe_malloc (g, sizeof (char *) * (len+1));
- for (i = 0; i < len; ++i) {
- VALUE v = rb_ary_entry (volgroupsv, i);
- volgroups[i] = StringValueCStr (v);
- }
- volgroups[len] = NULL;
- }
-
- int r;
-
- r = guestfs_vg_activate (g, activate, volgroups);
- free (volgroups);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_lvresize (VALUE gv, VALUE devicev, VALUE mbytesv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "lvresize");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "lvresize");
- int mbytes = NUM2INT (mbytesv);
-
- int r;
-
- r = guestfs_lvresize (g, device, mbytes);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_resize2fs (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "resize2fs");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "resize2fs");
-
- int r;
-
- r = guestfs_resize2fs (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_find (VALUE gv, VALUE directoryv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "find");
-
- Check_Type (directoryv, T_STRING);
- const char *directory = StringValueCStr (directoryv);
- if (!directory)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "directory", "find");
-
- char **r;
-
- r = guestfs_find (g, directory);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_e2fsck_f (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "e2fsck_f");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "e2fsck_f");
-
- int r;
-
- r = guestfs_e2fsck_f (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_sleep (VALUE gv, VALUE secsv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "sleep");
-
- int secs = NUM2INT (secsv);
-
- int r;
-
- r = guestfs_sleep (g, secs);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_ntfs_3g_probe (VALUE gv, VALUE rwv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "ntfs_3g_probe");
-
- int rw = RTEST (rwv);
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "ntfs_3g_probe");
-
- int r;
-
- r = guestfs_ntfs_3g_probe (g, rw, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_sh (VALUE gv, VALUE commandv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "sh");
-
- Check_Type (commandv, T_STRING);
- const char *command = StringValueCStr (commandv);
- if (!command)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "command", "sh");
-
- char *r;
-
- r = guestfs_sh (g, command);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_sh_lines (VALUE gv, VALUE commandv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "sh_lines");
-
- Check_Type (commandv, T_STRING);
- const char *command = StringValueCStr (commandv);
- if (!command)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "command", "sh_lines");
-
- char **r;
-
- r = guestfs_sh_lines (g, command);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_glob_expand (VALUE gv, VALUE patternv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "glob_expand");
-
- Check_Type (patternv, T_STRING);
- const char *pattern = StringValueCStr (patternv);
- if (!pattern)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "pattern", "glob_expand");
-
- char **r;
-
- r = guestfs_glob_expand (g, pattern);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_scrub_device (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "scrub_device");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "scrub_device");
-
- int r;
-
- r = guestfs_scrub_device (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_scrub_file (VALUE gv, VALUE filev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "scrub_file");
-
- Check_Type (filev, T_STRING);
- const char *file = StringValueCStr (filev);
- if (!file)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "file", "scrub_file");
-
- int r;
-
- r = guestfs_scrub_file (g, file);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_scrub_freespace (VALUE gv, VALUE dirv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "scrub_freespace");
-
- Check_Type (dirv, T_STRING);
- const char *dir = StringValueCStr (dirv);
- if (!dir)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "dir", "scrub_freespace");
-
- int r;
-
- r = guestfs_scrub_freespace (g, dir);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mkdtemp (VALUE gv, VALUE templatev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mkdtemp");
-
- Check_Type (templatev, T_STRING);
- const char *template = StringValueCStr (templatev);
- if (!template)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "template", "mkdtemp");
-
- char *r;
-
- r = guestfs_mkdtemp (g, template);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_wc_l (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "wc_l");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "wc_l");
-
- int r;
-
- r = guestfs_wc_l (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_wc_w (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "wc_w");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "wc_w");
-
- int r;
-
- r = guestfs_wc_w (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_wc_c (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "wc_c");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "wc_c");
-
- int r;
-
- r = guestfs_wc_c (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_head (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "head");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "head");
-
- char **r;
-
- r = guestfs_head (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_head_n (VALUE gv, VALUE nrlinesv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "head_n");
-
- int nrlines = NUM2INT (nrlinesv);
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "head_n");
-
- char **r;
-
- r = guestfs_head_n (g, nrlines, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_tail (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "tail");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "tail");
-
- char **r;
-
- r = guestfs_tail (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_tail_n (VALUE gv, VALUE nrlinesv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "tail_n");
-
- int nrlines = NUM2INT (nrlinesv);
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "tail_n");
-
- char **r;
-
- r = guestfs_tail_n (g, nrlines, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_df (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "df");
-
-
- char *r;
-
- r = guestfs_df (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_df_h (VALUE gv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "df_h");
-
-
- char *r;
-
- r = guestfs_df_h (g);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_str_new2 (r);
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_du (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "du");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "du");
-
- int64_t r;
-
- r = guestfs_du (g, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return ULL2NUM (r);
-}
-
-static VALUE ruby_guestfs_initrd_list (VALUE gv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "initrd_list");
-
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "initrd_list");
-
- char **r;
-
- r = guestfs_initrd_list (g, path);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- int i, len = 0;
- for (i = 0; r[i] != NULL; ++i) len++;
- VALUE rv = rb_ary_new2 (len);
- for (i = 0; r[i] != NULL; ++i) {
- rb_ary_push (rv, rb_str_new2 (r[i]));
- free (r[i]);
- }
- free (r);
- return rv;
-}
-
-static VALUE ruby_guestfs_mount_loop (VALUE gv, VALUE filev, VALUE mountpointv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_loop");
-
- Check_Type (filev, T_STRING);
- const char *file = StringValueCStr (filev);
- if (!file)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "file", "mount_loop");
- Check_Type (mountpointv, T_STRING);
- const char *mountpoint = StringValueCStr (mountpointv);
- if (!mountpoint)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "mountpoint", "mount_loop");
-
- int r;
-
- r = guestfs_mount_loop (g, file, mountpoint);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mkswap (VALUE gv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mkswap");
-
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "mkswap");
-
- int r;
-
- r = guestfs_mkswap (g, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mkswap_L (VALUE gv, VALUE labelv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mkswap_L");
-
- Check_Type (labelv, T_STRING);
- const char *label = StringValueCStr (labelv);
- if (!label)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "label", "mkswap_L");
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "mkswap_L");
-
- int r;
-
- r = guestfs_mkswap_L (g, label, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mkswap_U (VALUE gv, VALUE uuidv, VALUE devicev)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mkswap_U");
-
- Check_Type (uuidv, T_STRING);
- const char *uuid = StringValueCStr (uuidv);
- if (!uuid)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "uuid", "mkswap_U");
- Check_Type (devicev, T_STRING);
- const char *device = StringValueCStr (devicev);
- if (!device)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "device", "mkswap_U");
-
- int r;
-
- r = guestfs_mkswap_U (g, uuid, device);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mknod (VALUE gv, VALUE modev, VALUE devmajorv, VALUE devminorv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mknod");
-
- int mode = NUM2INT (modev);
- int devmajor = NUM2INT (devmajorv);
- int devminor = NUM2INT (devminorv);
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "mknod");
-
- int r;
-
- r = guestfs_mknod (g, mode, devmajor, devminor, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mkfifo (VALUE gv, VALUE modev, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mkfifo");
-
- int mode = NUM2INT (modev);
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "mkfifo");
-
- int r;
-
- r = guestfs_mkfifo (g, mode, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mknod_b (VALUE gv, VALUE modev, VALUE devmajorv, VALUE devminorv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mknod_b");
-
- int mode = NUM2INT (modev);
- int devmajor = NUM2INT (devmajorv);
- int devminor = NUM2INT (devminorv);
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "mknod_b");
-
- int r;
-
- r = guestfs_mknod_b (g, mode, devmajor, devminor, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_mknod_c (VALUE gv, VALUE modev, VALUE devmajorv, VALUE devminorv, VALUE pathv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "mknod_c");
-
- int mode = NUM2INT (modev);
- int devmajor = NUM2INT (devmajorv);
- int devminor = NUM2INT (devminorv);
- Check_Type (pathv, T_STRING);
- const char *path = StringValueCStr (pathv);
- if (!path)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "path", "mknod_c");
-
- int r;
-
- r = guestfs_mknod_c (g, mode, devmajor, devminor, path);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return Qnil;
-}
-
-static VALUE ruby_guestfs_umask (VALUE gv, VALUE maskv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "umask");
-
- int mask = NUM2INT (maskv);
-
- int r;
-
- r = guestfs_umask (g, mask);
- if (r == -1)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- return INT2NUM (r);
-}
-
-static VALUE ruby_guestfs_readdir (VALUE gv, VALUE dirv)
-{
- guestfs_h *g;
- Data_Get_Struct (gv, guestfs_h, g);
- if (!g)
- rb_raise (rb_eArgError, "%s: used handle after closing it", "readdir");
-
- Check_Type (dirv, T_STRING);
- const char *dir = StringValueCStr (dirv);
- if (!dir)
- rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
- "dir", "readdir");
-
- struct guestfs_dirent_list *r;
-
- r = guestfs_readdir (g, dir);
- if (r == NULL)
- rb_raise (e_Error, "%s", guestfs_last_error (g));
-
- VALUE rv = rb_ary_new2 (r->len);
- int i;
- for (i = 0; i < r->len; ++i) {
- VALUE hv = rb_hash_new ();
- rb_hash_aset (rv, rb_str_new2 ("ino"), ULL2NUM (r->val[i].ino));
- rb_hash_aset (rv, rb_str_new2 ("ftyp"), ULL2NUM (r->val[i].ftyp));
- rb_hash_aset (rv, rb_str_new2 ("name"), rb_str_new2 (r->val[i].name));
- rb_ary_push (rv, hv);
- }
- guestfs_free_dirent_list (r);
- return rv;
-}
-
-/* Initialize the module. */
-void Init__guestfs ()
-{
- m_guestfs = rb_define_module ("Guestfs");
- c_guestfs = rb_define_class_under (m_guestfs, "Guestfs", rb_cObject);
- e_Error = rb_define_class_under (m_guestfs, "Error", rb_eStandardError);
-
- rb_define_module_function (m_guestfs, "create", ruby_guestfs_create, 0);
- rb_define_method (c_guestfs, "close", ruby_guestfs_close, 0);
-
- rb_define_method (c_guestfs, "test0",
- ruby_guestfs_test0, 7);
- rb_define_method (c_guestfs, "test0rint",
- ruby_guestfs_test0rint, 1);
- rb_define_method (c_guestfs, "test0rinterr",
- ruby_guestfs_test0rinterr, 0);
- rb_define_method (c_guestfs, "test0rint64",
- ruby_guestfs_test0rint64, 1);
- rb_define_method (c_guestfs, "test0rint64err",
- ruby_guestfs_test0rint64err, 0);
- rb_define_method (c_guestfs, "test0rbool",
- ruby_guestfs_test0rbool, 1);
- rb_define_method (c_guestfs, "test0rboolerr",
- ruby_guestfs_test0rboolerr, 0);
- rb_define_method (c_guestfs, "test0rconststring",
- ruby_guestfs_test0rconststring, 1);
- rb_define_method (c_guestfs, "test0rconststringerr",
- ruby_guestfs_test0rconststringerr, 0);
- rb_define_method (c_guestfs, "test0rstring",
- ruby_guestfs_test0rstring, 1);
- rb_define_method (c_guestfs, "test0rstringerr",
- ruby_guestfs_test0rstringerr, 0);
- rb_define_method (c_guestfs, "test0rstringlist",
- ruby_guestfs_test0rstringlist, 1);
- rb_define_method (c_guestfs, "test0rstringlisterr",
- ruby_guestfs_test0rstringlisterr, 0);
- rb_define_method (c_guestfs, "test0rintbool",
- ruby_guestfs_test0rintbool, 1);
- rb_define_method (c_guestfs, "test0rintboolerr",
- ruby_guestfs_test0rintboolerr, 0);
- rb_define_method (c_guestfs, "test0rpvlist",
- ruby_guestfs_test0rpvlist, 1);
- rb_define_method (c_guestfs, "test0rpvlisterr",
- ruby_guestfs_test0rpvlisterr, 0);
- rb_define_method (c_guestfs, "test0rvglist",
- ruby_guestfs_test0rvglist, 1);
- rb_define_method (c_guestfs, "test0rvglisterr",
- ruby_guestfs_test0rvglisterr, 0);
- rb_define_method (c_guestfs, "test0rlvlist",
- ruby_guestfs_test0rlvlist, 1);
- rb_define_method (c_guestfs, "test0rlvlisterr",
- ruby_guestfs_test0rlvlisterr, 0);
- rb_define_method (c_guestfs, "test0rstat",
- ruby_guestfs_test0rstat, 1);
- rb_define_method (c_guestfs, "test0rstaterr",
- ruby_guestfs_test0rstaterr, 0);
- rb_define_method (c_guestfs, "test0rstatvfs",
- ruby_guestfs_test0rstatvfs, 1);
- rb_define_method (c_guestfs, "test0rstatvfserr",
- ruby_guestfs_test0rstatvfserr, 0);
- rb_define_method (c_guestfs, "test0rhashtable",
- ruby_guestfs_test0rhashtable, 1);
- rb_define_method (c_guestfs, "test0rhashtableerr",
- ruby_guestfs_test0rhashtableerr, 0);
- rb_define_method (c_guestfs, "launch",
- ruby_guestfs_launch, 0);
- rb_define_method (c_guestfs, "wait_ready",
- ruby_guestfs_wait_ready, 0);
- rb_define_method (c_guestfs, "kill_subprocess",
- ruby_guestfs_kill_subprocess, 0);
- rb_define_method (c_guestfs, "add_drive",
- ruby_guestfs_add_drive, 1);
- rb_define_method (c_guestfs, "add_cdrom",
- ruby_guestfs_add_cdrom, 1);
- rb_define_method (c_guestfs, "add_drive_ro",
- ruby_guestfs_add_drive_ro, 1);
- rb_define_method (c_guestfs, "config",
- ruby_guestfs_config, 2);
- rb_define_method (c_guestfs, "set_qemu",
- ruby_guestfs_set_qemu, 1);
- rb_define_method (c_guestfs, "get_qemu",
- ruby_guestfs_get_qemu, 0);
- rb_define_method (c_guestfs, "set_path",
- ruby_guestfs_set_path, 1);
- rb_define_method (c_guestfs, "get_path",
- ruby_guestfs_get_path, 0);
- rb_define_method (c_guestfs, "set_append",
- ruby_guestfs_set_append, 1);
- rb_define_method (c_guestfs, "get_append",
- ruby_guestfs_get_append, 0);
- rb_define_method (c_guestfs, "set_autosync",
- ruby_guestfs_set_autosync, 1);
- rb_define_method (c_guestfs, "get_autosync",
- ruby_guestfs_get_autosync, 0);
- rb_define_method (c_guestfs, "set_verbose",
- ruby_guestfs_set_verbose, 1);
- rb_define_method (c_guestfs, "get_verbose",
- ruby_guestfs_get_verbose, 0);
- rb_define_method (c_guestfs, "is_ready",
- ruby_guestfs_is_ready, 0);
- rb_define_method (c_guestfs, "is_config",
- ruby_guestfs_is_config, 0);
- rb_define_method (c_guestfs, "is_launching",
- ruby_guestfs_is_launching, 0);
- rb_define_method (c_guestfs, "is_busy",
- ruby_guestfs_is_busy, 0);
- rb_define_method (c_guestfs, "get_state",
- ruby_guestfs_get_state, 0);
- rb_define_method (c_guestfs, "set_busy",
- ruby_guestfs_set_busy, 0);
- rb_define_method (c_guestfs, "set_ready",
- ruby_guestfs_set_ready, 0);
- rb_define_method (c_guestfs, "end_busy",
- ruby_guestfs_end_busy, 0);
- rb_define_method (c_guestfs, "set_memsize",
- ruby_guestfs_set_memsize, 1);
- rb_define_method (c_guestfs, "get_memsize",
- ruby_guestfs_get_memsize, 0);
- rb_define_method (c_guestfs, "mount",
- ruby_guestfs_mount, 2);
- rb_define_method (c_guestfs, "sync",
- ruby_guestfs_sync, 0);
- rb_define_method (c_guestfs, "touch",
- ruby_guestfs_touch, 1);
- rb_define_method (c_guestfs, "cat",
- ruby_guestfs_cat, 1);
- rb_define_method (c_guestfs, "ll",
- ruby_guestfs_ll, 1);
- rb_define_method (c_guestfs, "ls",
- ruby_guestfs_ls, 1);
- rb_define_method (c_guestfs, "list_devices",
- ruby_guestfs_list_devices, 0);
- rb_define_method (c_guestfs, "list_partitions",
- ruby_guestfs_list_partitions, 0);
- rb_define_method (c_guestfs, "pvs",
- ruby_guestfs_pvs, 0);
- rb_define_method (c_guestfs, "vgs",
- ruby_guestfs_vgs, 0);
- rb_define_method (c_guestfs, "lvs",
- ruby_guestfs_lvs, 0);
- rb_define_method (c_guestfs, "pvs_full",
- ruby_guestfs_pvs_full, 0);
- rb_define_method (c_guestfs, "vgs_full",
- ruby_guestfs_vgs_full, 0);
- rb_define_method (c_guestfs, "lvs_full",
- ruby_guestfs_lvs_full, 0);
- rb_define_method (c_guestfs, "read_lines",
- ruby_guestfs_read_lines, 1);
- rb_define_method (c_guestfs, "aug_init",
- ruby_guestfs_aug_init, 2);
- rb_define_method (c_guestfs, "aug_close",
- ruby_guestfs_aug_close, 0);
- rb_define_method (c_guestfs, "aug_defvar",
- ruby_guestfs_aug_defvar, 2);
- rb_define_method (c_guestfs, "aug_defnode",
- ruby_guestfs_aug_defnode, 3);
- rb_define_method (c_guestfs, "aug_get",
- ruby_guestfs_aug_get, 1);
- rb_define_method (c_guestfs, "aug_set",
- ruby_guestfs_aug_set, 2);
- rb_define_method (c_guestfs, "aug_insert",
- ruby_guestfs_aug_insert, 3);
- rb_define_method (c_guestfs, "aug_rm",
- ruby_guestfs_aug_rm, 1);
- rb_define_method (c_guestfs, "aug_mv",
- ruby_guestfs_aug_mv, 2);
- rb_define_method (c_guestfs, "aug_match",
- ruby_guestfs_aug_match, 1);
- rb_define_method (c_guestfs, "aug_save",
- ruby_guestfs_aug_save, 0);
- rb_define_method (c_guestfs, "aug_load",
- ruby_guestfs_aug_load, 0);
- rb_define_method (c_guestfs, "aug_ls",
- ruby_guestfs_aug_ls, 1);
- rb_define_method (c_guestfs, "rm",
- ruby_guestfs_rm, 1);
- rb_define_method (c_guestfs, "rmdir",
- ruby_guestfs_rmdir, 1);
- rb_define_method (c_guestfs, "rm_rf",
- ruby_guestfs_rm_rf, 1);
- rb_define_method (c_guestfs, "mkdir",
- ruby_guestfs_mkdir, 1);
- rb_define_method (c_guestfs, "mkdir_p",
- ruby_guestfs_mkdir_p, 1);
- rb_define_method (c_guestfs, "chmod",
- ruby_guestfs_chmod, 2);
- rb_define_method (c_guestfs, "chown",
- ruby_guestfs_chown, 3);
- rb_define_method (c_guestfs, "exists",
- ruby_guestfs_exists, 1);
- rb_define_method (c_guestfs, "is_file",
- ruby_guestfs_is_file, 1);
- rb_define_method (c_guestfs, "is_dir",
- ruby_guestfs_is_dir, 1);
- rb_define_method (c_guestfs, "pvcreate",
- ruby_guestfs_pvcreate, 1);
- rb_define_method (c_guestfs, "vgcreate",
- ruby_guestfs_vgcreate, 2);
- rb_define_method (c_guestfs, "lvcreate",
- ruby_guestfs_lvcreate, 3);
- rb_define_method (c_guestfs, "mkfs",
- ruby_guestfs_mkfs, 2);
- rb_define_method (c_guestfs, "sfdisk",
- ruby_guestfs_sfdisk, 5);
- rb_define_method (c_guestfs, "write_file",
- ruby_guestfs_write_file, 3);
- rb_define_method (c_guestfs, "umount",
- ruby_guestfs_umount, 1);
- rb_define_method (c_guestfs, "mounts",
- ruby_guestfs_mounts, 0);
- rb_define_method (c_guestfs, "umount_all",
- ruby_guestfs_umount_all, 0);
- rb_define_method (c_guestfs, "lvm_remove_all",
- ruby_guestfs_lvm_remove_all, 0);
- rb_define_method (c_guestfs, "file",
- ruby_guestfs_file, 1);
- rb_define_method (c_guestfs, "command",
- ruby_guestfs_command, 1);
- rb_define_method (c_guestfs, "command_lines",
- ruby_guestfs_command_lines, 1);
- rb_define_method (c_guestfs, "stat",
- ruby_guestfs_stat, 1);
- rb_define_method (c_guestfs, "lstat",
- ruby_guestfs_lstat, 1);
- rb_define_method (c_guestfs, "statvfs",
- ruby_guestfs_statvfs, 1);
- rb_define_method (c_guestfs, "tune2fs_l",
- ruby_guestfs_tune2fs_l, 1);
- rb_define_method (c_guestfs, "blockdev_setro",
- ruby_guestfs_blockdev_setro, 1);
- rb_define_method (c_guestfs, "blockdev_setrw",
- ruby_guestfs_blockdev_setrw, 1);
- rb_define_method (c_guestfs, "blockdev_getro",
- ruby_guestfs_blockdev_getro, 1);
- rb_define_method (c_guestfs, "blockdev_getss",
- ruby_guestfs_blockdev_getss, 1);
- rb_define_method (c_guestfs, "blockdev_getbsz",
- ruby_guestfs_blockdev_getbsz, 1);
- rb_define_method (c_guestfs, "blockdev_setbsz",
- ruby_guestfs_blockdev_setbsz, 2);
- rb_define_method (c_guestfs, "blockdev_getsz",
- ruby_guestfs_blockdev_getsz, 1);
- rb_define_method (c_guestfs, "blockdev_getsize64",
- ruby_guestfs_blockdev_getsize64, 1);
- rb_define_method (c_guestfs, "blockdev_flushbufs",
- ruby_guestfs_blockdev_flushbufs, 1);
- rb_define_method (c_guestfs, "blockdev_rereadpt",
- ruby_guestfs_blockdev_rereadpt, 1);
- rb_define_method (c_guestfs, "upload",
- ruby_guestfs_upload, 2);
- rb_define_method (c_guestfs, "download",
- ruby_guestfs_download, 2);
- rb_define_method (c_guestfs, "checksum",
- ruby_guestfs_checksum, 2);
- rb_define_method (c_guestfs, "tar_in",
- ruby_guestfs_tar_in, 2);
- rb_define_method (c_guestfs, "tar_out",
- ruby_guestfs_tar_out, 2);
- rb_define_method (c_guestfs, "tgz_in",
- ruby_guestfs_tgz_in, 2);
- rb_define_method (c_guestfs, "tgz_out",
- ruby_guestfs_tgz_out, 2);
- rb_define_method (c_guestfs, "mount_ro",
- ruby_guestfs_mount_ro, 2);
- rb_define_method (c_guestfs, "mount_options",
- ruby_guestfs_mount_options, 3);
- rb_define_method (c_guestfs, "mount_vfs",
- ruby_guestfs_mount_vfs, 4);
- rb_define_method (c_guestfs, "debug",
- ruby_guestfs_debug, 2);
- rb_define_method (c_guestfs, "lvremove",
- ruby_guestfs_lvremove, 1);
- rb_define_method (c_guestfs, "vgremove",
- ruby_guestfs_vgremove, 1);
- rb_define_method (c_guestfs, "pvremove",
- ruby_guestfs_pvremove, 1);
- rb_define_method (c_guestfs, "set_e2label",
- ruby_guestfs_set_e2label, 2);
- rb_define_method (c_guestfs, "get_e2label",
- ruby_guestfs_get_e2label, 1);
- rb_define_method (c_guestfs, "set_e2uuid",
- ruby_guestfs_set_e2uuid, 2);
- rb_define_method (c_guestfs, "get_e2uuid",
- ruby_guestfs_get_e2uuid, 1);
- rb_define_method (c_guestfs, "fsck",
- ruby_guestfs_fsck, 2);
- rb_define_method (c_guestfs, "zero",
- ruby_guestfs_zero, 1);
- rb_define_method (c_guestfs, "grub_install",
- ruby_guestfs_grub_install, 2);
- rb_define_method (c_guestfs, "cp",
- ruby_guestfs_cp, 2);
- rb_define_method (c_guestfs, "cp_a",
- ruby_guestfs_cp_a, 2);
- rb_define_method (c_guestfs, "mv",
- ruby_guestfs_mv, 2);
- rb_define_method (c_guestfs, "drop_caches",
- ruby_guestfs_drop_caches, 1);
- rb_define_method (c_guestfs, "dmesg",
- ruby_guestfs_dmesg, 0);
- rb_define_method (c_guestfs, "ping_daemon",
- ruby_guestfs_ping_daemon, 0);
- rb_define_method (c_guestfs, "equal",
- ruby_guestfs_equal, 2);
- rb_define_method (c_guestfs, "strings",
- ruby_guestfs_strings, 1);
- rb_define_method (c_guestfs, "strings_e",
- ruby_guestfs_strings_e, 2);
- rb_define_method (c_guestfs, "hexdump",
- ruby_guestfs_hexdump, 1);
- rb_define_method (c_guestfs, "zerofree",
- ruby_guestfs_zerofree, 1);
- rb_define_method (c_guestfs, "pvresize",
- ruby_guestfs_pvresize, 1);
- rb_define_method (c_guestfs, "sfdisk_N",
- ruby_guestfs_sfdisk_N, 6);
- rb_define_method (c_guestfs, "sfdisk_l",
- ruby_guestfs_sfdisk_l, 1);
- rb_define_method (c_guestfs, "sfdisk_kernel_geometry",
- ruby_guestfs_sfdisk_kernel_geometry, 1);
- rb_define_method (c_guestfs, "sfdisk_disk_geometry",
- ruby_guestfs_sfdisk_disk_geometry, 1);
- rb_define_method (c_guestfs, "vg_activate_all",
- ruby_guestfs_vg_activate_all, 1);
- rb_define_method (c_guestfs, "vg_activate",
- ruby_guestfs_vg_activate, 2);
- rb_define_method (c_guestfs, "lvresize",
- ruby_guestfs_lvresize, 2);
- rb_define_method (c_guestfs, "resize2fs",
- ruby_guestfs_resize2fs, 1);
- rb_define_method (c_guestfs, "find",
- ruby_guestfs_find, 1);
- rb_define_method (c_guestfs, "e2fsck_f",
- ruby_guestfs_e2fsck_f, 1);
- rb_define_method (c_guestfs, "sleep",
- ruby_guestfs_sleep, 1);
- rb_define_method (c_guestfs, "ntfs_3g_probe",
- ruby_guestfs_ntfs_3g_probe, 2);
- rb_define_method (c_guestfs, "sh",
- ruby_guestfs_sh, 1);
- rb_define_method (c_guestfs, "sh_lines",
- ruby_guestfs_sh_lines, 1);
- rb_define_method (c_guestfs, "glob_expand",
- ruby_guestfs_glob_expand, 1);
- rb_define_method (c_guestfs, "scrub_device",
- ruby_guestfs_scrub_device, 1);
- rb_define_method (c_guestfs, "scrub_file",
- ruby_guestfs_scrub_file, 1);
- rb_define_method (c_guestfs, "scrub_freespace",
- ruby_guestfs_scrub_freespace, 1);
- rb_define_method (c_guestfs, "mkdtemp",
- ruby_guestfs_mkdtemp, 1);
- rb_define_method (c_guestfs, "wc_l",
- ruby_guestfs_wc_l, 1);
- rb_define_method (c_guestfs, "wc_w",
- ruby_guestfs_wc_w, 1);
- rb_define_method (c_guestfs, "wc_c",
- ruby_guestfs_wc_c, 1);
- rb_define_method (c_guestfs, "head",
- ruby_guestfs_head, 1);
- rb_define_method (c_guestfs, "head_n",
- ruby_guestfs_head_n, 2);
- rb_define_method (c_guestfs, "tail",
- ruby_guestfs_tail, 1);
- rb_define_method (c_guestfs, "tail_n",
- ruby_guestfs_tail_n, 2);
- rb_define_method (c_guestfs, "df",
- ruby_guestfs_df, 0);
- rb_define_method (c_guestfs, "df_h",
- ruby_guestfs_df_h, 0);
- rb_define_method (c_guestfs, "du",
- ruby_guestfs_du, 1);
- rb_define_method (c_guestfs, "initrd_list",
- ruby_guestfs_initrd_list, 1);
- rb_define_method (c_guestfs, "mount_loop",
- ruby_guestfs_mount_loop, 2);
- rb_define_method (c_guestfs, "mkswap",
- ruby_guestfs_mkswap, 1);
- rb_define_method (c_guestfs, "mkswap_L",
- ruby_guestfs_mkswap_L, 2);
- rb_define_method (c_guestfs, "mkswap_U",
- ruby_guestfs_mkswap_U, 2);
- rb_define_method (c_guestfs, "mknod",
- ruby_guestfs_mknod, 4);
- rb_define_method (c_guestfs, "mkfifo",
- ruby_guestfs_mkfifo, 2);
- rb_define_method (c_guestfs, "mknod_b",
- ruby_guestfs_mknod_b, 4);
- rb_define_method (c_guestfs, "mknod_c",
- ruby_guestfs_mknod_c, 4);
- rb_define_method (c_guestfs, "umask",
- ruby_guestfs_umask, 1);
- rb_define_method (c_guestfs, "readdir",
- ruby_guestfs_readdir, 1);
-}
+++ /dev/null
-/* 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 partnum,
- 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.partnum = partnum;
- 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;
-}
-
-struct sh_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_sh_ret ret;
-};
-
-static void sh_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct sh_ctx *ctx = (struct sh_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_sh");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_sh");
- 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_sh");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_sh_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_sh");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_sh (guestfs_h *g,
- const char *command)
-{
- struct guestfs_sh_args args;
- struct sh_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_sh") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.command = (char *) command;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SH,
- (xdrproc_t) xdr_guestfs_sh_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, sh_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_sh");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SH, 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 sh_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_sh_lines_ret ret;
-};
-
-static void sh_lines_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct sh_lines_ctx *ctx = (struct sh_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_sh_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_sh_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_sh_lines");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_sh_lines_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_sh_lines");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_sh_lines (guestfs_h *g,
- const char *command)
-{
- struct guestfs_sh_lines_args args;
- struct sh_lines_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_sh_lines") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.command = (char *) command;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SH_LINES,
- (xdrproc_t) xdr_guestfs_sh_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, sh_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_sh_lines");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SH_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 glob_expand_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_glob_expand_ret ret;
-};
-
-static void glob_expand_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct glob_expand_ctx *ctx = (struct glob_expand_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_glob_expand");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_glob_expand");
- 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_glob_expand");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_glob_expand_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_glob_expand");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_glob_expand (guestfs_h *g,
- const char *pattern)
-{
- struct guestfs_glob_expand_args args;
- struct glob_expand_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_glob_expand") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.pattern = (char *) pattern;
- serial = guestfs__send_sync (g, GUESTFS_PROC_GLOB_EXPAND,
- (xdrproc_t) xdr_guestfs_glob_expand_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, glob_expand_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_glob_expand");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_GLOB_EXPAND, 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.paths.paths_val =
- safe_realloc (g, ctx.ret.paths.paths_val,
- sizeof (char *) * (ctx.ret.paths.paths_len + 1));
- ctx.ret.paths.paths_val[ctx.ret.paths.paths_len] = NULL;
- return ctx.ret.paths.paths_val;
-}
-
-struct scrub_device_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 scrub_device_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct scrub_device_ctx *ctx = (struct scrub_device_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_scrub_device");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_scrub_device");
- 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_scrub_device");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_scrub_device (guestfs_h *g,
- const char *device)
-{
- struct guestfs_scrub_device_args args;
- struct scrub_device_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_scrub_device") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SCRUB_DEVICE,
- (xdrproc_t) xdr_guestfs_scrub_device_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, scrub_device_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_scrub_device");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SCRUB_DEVICE, 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 scrub_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 scrub_file_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct scrub_file_ctx *ctx = (struct scrub_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_scrub_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_scrub_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_scrub_file");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_scrub_file (guestfs_h *g,
- const char *file)
-{
- struct guestfs_scrub_file_args args;
- struct scrub_file_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_scrub_file") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.file = (char *) file;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SCRUB_FILE,
- (xdrproc_t) xdr_guestfs_scrub_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, scrub_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_scrub_file");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SCRUB_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 scrub_freespace_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 scrub_freespace_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct scrub_freespace_ctx *ctx = (struct scrub_freespace_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_scrub_freespace");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_scrub_freespace");
- 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_scrub_freespace");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_scrub_freespace (guestfs_h *g,
- const char *dir)
-{
- struct guestfs_scrub_freespace_args args;
- struct scrub_freespace_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_scrub_freespace") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.dir = (char *) dir;
- serial = guestfs__send_sync (g, GUESTFS_PROC_SCRUB_FREESPACE,
- (xdrproc_t) xdr_guestfs_scrub_freespace_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, scrub_freespace_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_scrub_freespace");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SCRUB_FREESPACE, 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 mkdtemp_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_mkdtemp_ret ret;
-};
-
-static void mkdtemp_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mkdtemp_ctx *ctx = (struct mkdtemp_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_mkdtemp");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mkdtemp");
- 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_mkdtemp");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_mkdtemp_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_mkdtemp");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_mkdtemp (guestfs_h *g,
- const char *template)
-{
- struct guestfs_mkdtemp_args args;
- struct mkdtemp_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mkdtemp") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.template = (char *) template;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKDTEMP,
- (xdrproc_t) xdr_guestfs_mkdtemp_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, mkdtemp_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_mkdtemp");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKDTEMP, 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.dir; /* caller will free */
-}
-
-struct wc_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_wc_l_ret ret;
-};
-
-static void wc_l_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct wc_l_ctx *ctx = (struct wc_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_wc_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_wc_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_wc_l");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_wc_l_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_wc_l");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_wc_l (guestfs_h *g,
- const char *path)
-{
- struct guestfs_wc_l_args args;
- struct wc_l_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_wc_l") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_WC_L,
- (xdrproc_t) xdr_guestfs_wc_l_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, wc_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_wc_l");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_WC_L, 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.lines;
-}
-
-struct wc_w_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_wc_w_ret ret;
-};
-
-static void wc_w_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct wc_w_ctx *ctx = (struct wc_w_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_wc_w");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_wc_w");
- 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_wc_w");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_wc_w_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_wc_w");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_wc_w (guestfs_h *g,
- const char *path)
-{
- struct guestfs_wc_w_args args;
- struct wc_w_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_wc_w") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_WC_W,
- (xdrproc_t) xdr_guestfs_wc_w_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, wc_w_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_wc_w");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_WC_W, 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.words;
-}
-
-struct wc_c_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_wc_c_ret ret;
-};
-
-static void wc_c_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct wc_c_ctx *ctx = (struct wc_c_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_wc_c");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_wc_c");
- 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_wc_c");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_wc_c_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_wc_c");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_wc_c (guestfs_h *g,
- const char *path)
-{
- struct guestfs_wc_c_args args;
- struct wc_c_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_wc_c") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_WC_C,
- (xdrproc_t) xdr_guestfs_wc_c_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, wc_c_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_wc_c");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_WC_C, 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.chars;
-}
-
-struct head_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_head_ret ret;
-};
-
-static void head_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct head_ctx *ctx = (struct head_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_head");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_head");
- 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_head");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_head_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_head");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_head (guestfs_h *g,
- const char *path)
-{
- struct guestfs_head_args args;
- struct head_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_head") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_HEAD,
- (xdrproc_t) xdr_guestfs_head_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, head_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_head");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_HEAD, 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 head_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;
- struct guestfs_head_n_ret ret;
-};
-
-static void head_n_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct head_n_ctx *ctx = (struct head_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_head_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_head_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_head_n");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_head_n_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_head_n");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_head_n (guestfs_h *g,
- int nrlines,
- const char *path)
-{
- struct guestfs_head_n_args args;
- struct head_n_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_head_n") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.nrlines = nrlines;
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_HEAD_N,
- (xdrproc_t) xdr_guestfs_head_n_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, head_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_head_n");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_HEAD_N, 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 tail_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_tail_ret ret;
-};
-
-static void tail_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct tail_ctx *ctx = (struct tail_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_tail");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_tail");
- 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_tail");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_tail_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_tail");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_tail (guestfs_h *g,
- const char *path)
-{
- struct guestfs_tail_args args;
- struct tail_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_tail") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_TAIL,
- (xdrproc_t) xdr_guestfs_tail_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, tail_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_tail");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TAIL, 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 tail_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;
- struct guestfs_tail_n_ret ret;
-};
-
-static void tail_n_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct tail_n_ctx *ctx = (struct tail_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_tail_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_tail_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_tail_n");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_tail_n_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_tail_n");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_tail_n (guestfs_h *g,
- int nrlines,
- const char *path)
-{
- struct guestfs_tail_n_args args;
- struct tail_n_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_tail_n") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.nrlines = nrlines;
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_TAIL_N,
- (xdrproc_t) xdr_guestfs_tail_n_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, tail_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_tail_n");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TAIL_N, 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 df_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_df_ret ret;
-};
-
-static void df_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct df_ctx *ctx = (struct df_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_df");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_df");
- 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_df");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_df_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_df");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_df (guestfs_h *g)
-{
- struct df_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_df") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_DF, 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, df_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_df");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DF, 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 df_h_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_df_h_ret ret;
-};
-
-static void df_h_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct df_h_ctx *ctx = (struct df_h_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_df_h");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_df_h");
- 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_df_h");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_df_h_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_df_h");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char *guestfs_df_h (guestfs_h *g)
-{
- struct df_h_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_df_h") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- serial = guestfs__send_sync (g, GUESTFS_PROC_DF_H, 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, df_h_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_df_h");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DF_H, 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 du_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_du_ret ret;
-};
-
-static void du_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct du_ctx *ctx = (struct du_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_du");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_du");
- 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_du");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_du_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_du");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int64_t guestfs_du (guestfs_h *g,
- const char *path)
-{
- struct guestfs_du_args args;
- struct du_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_du") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_DU,
- (xdrproc_t) xdr_guestfs_du_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, du_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_du");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DU, 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.sizekb;
-}
-
-struct initrd_list_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_initrd_list_ret ret;
-};
-
-static void initrd_list_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct initrd_list_ctx *ctx = (struct initrd_list_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_initrd_list");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_initrd_list");
- 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_initrd_list");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_initrd_list_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_initrd_list");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-char **guestfs_initrd_list (guestfs_h *g,
- const char *path)
-{
- struct guestfs_initrd_list_args args;
- struct initrd_list_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_initrd_list") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_INITRD_LIST,
- (xdrproc_t) xdr_guestfs_initrd_list_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, initrd_list_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_initrd_list");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_INITRD_LIST, 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.filenames.filenames_val =
- safe_realloc (g, ctx.ret.filenames.filenames_val,
- sizeof (char *) * (ctx.ret.filenames.filenames_len + 1));
- ctx.ret.filenames.filenames_val[ctx.ret.filenames.filenames_len] = NULL;
- return ctx.ret.filenames.filenames_val;
-}
-
-struct mount_loop_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_loop_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mount_loop_ctx *ctx = (struct mount_loop_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_loop");
- 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_loop");
- 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_loop");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mount_loop (guestfs_h *g,
- const char *file,
- const char *mountpoint)
-{
- struct guestfs_mount_loop_args args;
- struct mount_loop_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mount_loop") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.file = (char *) file;
- args.mountpoint = (char *) mountpoint;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNT_LOOP,
- (xdrproc_t) xdr_guestfs_mount_loop_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_loop_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_loop");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNT_LOOP, 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 mkswap_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 mkswap_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mkswap_ctx *ctx = (struct mkswap_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_mkswap");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mkswap");
- 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_mkswap");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mkswap (guestfs_h *g,
- const char *device)
-{
- struct guestfs_mkswap_args args;
- struct mkswap_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mkswap") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKSWAP,
- (xdrproc_t) xdr_guestfs_mkswap_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, mkswap_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_mkswap");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKSWAP, 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 mkswap_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;
-};
-
-static void mkswap_L_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mkswap_L_ctx *ctx = (struct mkswap_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_mkswap_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_mkswap_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_mkswap_L");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mkswap_L (guestfs_h *g,
- const char *label,
- const char *device)
-{
- struct guestfs_mkswap_L_args args;
- struct mkswap_L_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mkswap_L") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.label = (char *) label;
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKSWAP_L,
- (xdrproc_t) xdr_guestfs_mkswap_L_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, mkswap_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_mkswap_L");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKSWAP_L, 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 mkswap_U_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 mkswap_U_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mkswap_U_ctx *ctx = (struct mkswap_U_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_mkswap_U");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mkswap_U");
- 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_mkswap_U");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mkswap_U (guestfs_h *g,
- const char *uuid,
- const char *device)
-{
- struct guestfs_mkswap_U_args args;
- struct mkswap_U_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mkswap_U") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.uuid = (char *) uuid;
- args.device = (char *) device;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKSWAP_U,
- (xdrproc_t) xdr_guestfs_mkswap_U_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, mkswap_U_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_mkswap_U");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKSWAP_U, 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 mknod_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 mknod_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mknod_ctx *ctx = (struct mknod_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_mknod");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mknod");
- 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_mknod");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mknod (guestfs_h *g,
- int mode,
- int devmajor,
- int devminor,
- const char *path)
-{
- struct guestfs_mknod_args args;
- struct mknod_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mknod") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.mode = mode;
- args.devmajor = devmajor;
- args.devminor = devminor;
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKNOD,
- (xdrproc_t) xdr_guestfs_mknod_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, mknod_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_mknod");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKNOD, 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 mkfifo_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 mkfifo_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mkfifo_ctx *ctx = (struct mkfifo_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_mkfifo");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mkfifo");
- 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_mkfifo");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mkfifo (guestfs_h *g,
- int mode,
- const char *path)
-{
- struct guestfs_mkfifo_args args;
- struct mkfifo_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mkfifo") == -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_MKFIFO,
- (xdrproc_t) xdr_guestfs_mkfifo_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, mkfifo_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_mkfifo");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKFIFO, 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 mknod_b_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 mknod_b_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mknod_b_ctx *ctx = (struct mknod_b_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_mknod_b");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mknod_b");
- 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_mknod_b");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mknod_b (guestfs_h *g,
- int mode,
- int devmajor,
- int devminor,
- const char *path)
-{
- struct guestfs_mknod_b_args args;
- struct mknod_b_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mknod_b") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.mode = mode;
- args.devmajor = devmajor;
- args.devminor = devminor;
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKNOD_B,
- (xdrproc_t) xdr_guestfs_mknod_b_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, mknod_b_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_mknod_b");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKNOD_B, 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 mknod_c_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 mknod_c_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct mknod_c_ctx *ctx = (struct mknod_c_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_mknod_c");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_mknod_c");
- 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_mknod_c");
- return;
- }
- goto done;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_mknod_c (guestfs_h *g,
- int mode,
- int devmajor,
- int devminor,
- const char *path)
-{
- struct guestfs_mknod_c_args args;
- struct mknod_c_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_mknod_c") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.mode = mode;
- args.devmajor = devmajor;
- args.devminor = devminor;
- args.path = (char *) path;
- serial = guestfs__send_sync (g, GUESTFS_PROC_MKNOD_C,
- (xdrproc_t) xdr_guestfs_mknod_c_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, mknod_c_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_mknod_c");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKNOD_C, 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 umask_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_umask_ret ret;
-};
-
-static void umask_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct umask_ctx *ctx = (struct umask_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_umask");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_umask");
- 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_umask");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_umask_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_umask");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-int guestfs_umask (guestfs_h *g,
- int mask)
-{
- struct guestfs_umask_args args;
- struct umask_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_umask") == -1) return -1;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.mask = mask;
- serial = guestfs__send_sync (g, GUESTFS_PROC_UMASK,
- (xdrproc_t) xdr_guestfs_umask_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, umask_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_umask");
- guestfs_end_busy (g);
- return -1;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_UMASK, 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.oldmask;
-}
-
-struct readdir_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_readdir_ret ret;
-};
-
-static void readdir_reply_cb (guestfs_h *g, void *data, XDR *xdr)
-{
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- struct readdir_ctx *ctx = (struct readdir_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_readdir");
- return;
- }
-
- ml->main_loop_quit (ml, g);
-
- if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
- error (g, "%s: failed to parse reply header", "guestfs_readdir");
- 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_readdir");
- return;
- }
- goto done;
- }
- if (!xdr_guestfs_readdir_ret (xdr, &ctx->ret)) {
- error (g, "%s: failed to parse reply", "guestfs_readdir");
- return;
- }
- done:
- ctx->cb_sequence = 1;
-}
-
-struct guestfs_dirent_list *guestfs_readdir (guestfs_h *g,
- const char *dir)
-{
- struct guestfs_readdir_args args;
- struct readdir_ctx ctx;
- guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int serial;
-
- if (check_state (g, "guestfs_readdir") == -1) return NULL;
- guestfs_set_busy (g);
-
- memset (&ctx, 0, sizeof ctx);
-
- args.dir = (char *) dir;
- serial = guestfs__send_sync (g, GUESTFS_PROC_READDIR,
- (xdrproc_t) xdr_guestfs_readdir_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, readdir_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_readdir");
- guestfs_end_busy (g);
- return NULL;
- }
-
- if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_READDIR, 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.entries, sizeof (ctx.ret.entries));
-}
-
+++ /dev/null
-/* 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_set_memsize (guestfs_h *handle, int memsize);
-extern int guestfs_get_memsize (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 partnum, 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);
-extern char *guestfs_sh (guestfs_h *handle, const char *command);
-extern char **guestfs_sh_lines (guestfs_h *handle, const char *command);
-extern char **guestfs_glob_expand (guestfs_h *handle, const char *pattern);
-extern int guestfs_scrub_device (guestfs_h *handle, const char *device);
-extern int guestfs_scrub_file (guestfs_h *handle, const char *file);
-extern int guestfs_scrub_freespace (guestfs_h *handle, const char *dir);
-extern char *guestfs_mkdtemp (guestfs_h *handle, const char *template);
-extern int guestfs_wc_l (guestfs_h *handle, const char *path);
-extern int guestfs_wc_w (guestfs_h *handle, const char *path);
-extern int guestfs_wc_c (guestfs_h *handle, const char *path);
-extern char **guestfs_head (guestfs_h *handle, const char *path);
-extern char **guestfs_head_n (guestfs_h *handle, int nrlines, const char *path);
-extern char **guestfs_tail (guestfs_h *handle, const char *path);
-extern char **guestfs_tail_n (guestfs_h *handle, int nrlines, const char *path);
-extern char *guestfs_df (guestfs_h *handle);
-extern char *guestfs_df_h (guestfs_h *handle);
-extern int64_t guestfs_du (guestfs_h *handle, const char *path);
-extern char **guestfs_initrd_list (guestfs_h *handle, const char *path);
-extern int guestfs_mount_loop (guestfs_h *handle, const char *file, const char *mountpoint);
-extern int guestfs_mkswap (guestfs_h *handle, const char *device);
-extern int guestfs_mkswap_L (guestfs_h *handle, const char *label, const char *device);
-extern int guestfs_mkswap_U (guestfs_h *handle, const char *uuid, const char *device);
-extern int guestfs_mknod (guestfs_h *handle, int mode, int devmajor, int devminor, const char *path);
-extern int guestfs_mkfifo (guestfs_h *handle, int mode, const char *path);
-extern int guestfs_mknod_b (guestfs_h *handle, int mode, int devmajor, int devminor, const char *path);
-extern int guestfs_mknod_c (guestfs_h *handle, int mode, int devmajor, int devminor, const char *path);
-extern int guestfs_umask (guestfs_h *handle, int mask);
-extern struct guestfs_dirent_list *guestfs_readdir (guestfs_h *handle, const char *dir);
+++ /dev/null
-/* 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;
-}
-
+++ /dev/null
-/* 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;
-};
-
-struct guestfs_dirent {
- int64_t ino;
- char ftyp;
- char *name;
-};
-
-struct guestfs_dirent_list {
- uint32_t len;
- struct guestfs_dirent *val;
-};
-
+++ /dev/null
-/* 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_int_dirent {
- hyper ino;
- char ftyp;
- string name<>;
-};
-
-typedef struct guestfs_int_dirent guestfs_int_dirent_list<>;
-
-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 partnum;
- 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;
-};
-
-struct guestfs_sh_args {
- string command<>;
-};
-
-struct guestfs_sh_ret {
- string output<>;
-};
-
-struct guestfs_sh_lines_args {
- string command<>;
-};
-
-struct guestfs_sh_lines_ret {
- str lines<>;
-};
-
-struct guestfs_glob_expand_args {
- string pattern<>;
-};
-
-struct guestfs_glob_expand_ret {
- str paths<>;
-};
-
-struct guestfs_scrub_device_args {
- string device<>;
-};
-
-struct guestfs_scrub_file_args {
- string file<>;
-};
-
-struct guestfs_scrub_freespace_args {
- string dir<>;
-};
-
-struct guestfs_mkdtemp_args {
- string template<>;
-};
-
-struct guestfs_mkdtemp_ret {
- string dir<>;
-};
-
-struct guestfs_wc_l_args {
- string path<>;
-};
-
-struct guestfs_wc_l_ret {
- int lines;
-};
-
-struct guestfs_wc_w_args {
- string path<>;
-};
-
-struct guestfs_wc_w_ret {
- int words;
-};
-
-struct guestfs_wc_c_args {
- string path<>;
-};
-
-struct guestfs_wc_c_ret {
- int chars;
-};
-
-struct guestfs_head_args {
- string path<>;
-};
-
-struct guestfs_head_ret {
- str lines<>;
-};
-
-struct guestfs_head_n_args {
- int nrlines;
- string path<>;
-};
-
-struct guestfs_head_n_ret {
- str lines<>;
-};
-
-struct guestfs_tail_args {
- string path<>;
-};
-
-struct guestfs_tail_ret {
- str lines<>;
-};
-
-struct guestfs_tail_n_args {
- int nrlines;
- string path<>;
-};
-
-struct guestfs_tail_n_ret {
- str lines<>;
-};
-
-struct guestfs_df_ret {
- string output<>;
-};
-
-struct guestfs_df_h_ret {
- string output<>;
-};
-
-struct guestfs_du_args {
- string path<>;
-};
-
-struct guestfs_du_ret {
- hyper sizekb;
-};
-
-struct guestfs_initrd_list_args {
- string path<>;
-};
-
-struct guestfs_initrd_list_ret {
- str filenames<>;
-};
-
-struct guestfs_mount_loop_args {
- string file<>;
- string mountpoint<>;
-};
-
-struct guestfs_mkswap_args {
- string device<>;
-};
-
-struct guestfs_mkswap_L_args {
- string label<>;
- string device<>;
-};
-
-struct guestfs_mkswap_U_args {
- string uuid<>;
- string device<>;
-};
-
-struct guestfs_mknod_args {
- int mode;
- int devmajor;
- int devminor;
- string path<>;
-};
-
-struct guestfs_mkfifo_args {
- int mode;
- string path<>;
-};
-
-struct guestfs_mknod_b_args {
- int mode;
- int devmajor;
- int devminor;
- string path<>;
-};
-
-struct guestfs_mknod_c_args {
- int mode;
- int devmajor;
- int devminor;
- string path<>;
-};
-
-struct guestfs_umask_args {
- int mask;
-};
-
-struct guestfs_umask_ret {
- int oldmask;
-};
-
-struct guestfs_readdir_args {
- string dir<>;
-};
-
-struct guestfs_readdir_ret {
- guestfs_int_dirent_list entries;
-};
-
-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_SH = 111,
- GUESTFS_PROC_SH_LINES = 112,
- GUESTFS_PROC_GLOB_EXPAND = 113,
- GUESTFS_PROC_SCRUB_DEVICE = 114,
- GUESTFS_PROC_SCRUB_FILE = 115,
- GUESTFS_PROC_SCRUB_FREESPACE = 116,
- GUESTFS_PROC_MKDTEMP = 117,
- GUESTFS_PROC_WC_L = 118,
- GUESTFS_PROC_WC_W = 119,
- GUESTFS_PROC_WC_C = 120,
- GUESTFS_PROC_HEAD = 121,
- GUESTFS_PROC_HEAD_N = 122,
- GUESTFS_PROC_TAIL = 123,
- GUESTFS_PROC_TAIL_N = 124,
- GUESTFS_PROC_DF = 125,
- GUESTFS_PROC_DF_H = 126,
- GUESTFS_PROC_DU = 127,
- GUESTFS_PROC_INITRD_LIST = 128,
- GUESTFS_PROC_MOUNT_LOOP = 129,
- GUESTFS_PROC_MKSWAP = 130,
- GUESTFS_PROC_MKSWAP_L = 131,
- GUESTFS_PROC_MKSWAP_U = 132,
- GUESTFS_PROC_MKNOD = 133,
- GUESTFS_PROC_MKFIFO = 134,
- GUESTFS_PROC_MKNOD_B = 135,
- GUESTFS_PROC_MKNOD_C = 136,
- GUESTFS_PROC_UMASK = 137,
- GUESTFS_PROC_READDIR = 138,
- 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>;
-};