From: Richard W.M. Jones Date: Thu, 2 Jul 2009 10:38:36 +0000 (+0100) Subject: Remove generated code from git. X-Git-Tag: 1.0.55~19 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=b3cb0b04eb2d38ba32c160a83d8e3894b376907b;p=libguestfs.git Remove generated code from git. Git users now require the OCaml compiler in order to regenerate the generated code after a checkout. Generated code will remain in the tarball, so users of the source tarball will not need the OCaml compiler. --- diff --git a/.gitignore b/.gitignore index fbb723f..4655de5 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ autom4te.cache capitests/test-command capitests/test*.img capitests/test*.tmp +capitests/tests.c capitests/tests compile config.h @@ -44,17 +45,26 @@ config.sub 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 @@ -74,7 +84,16 @@ initramfs.timestamp 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 @@ -88,17 +107,24 @@ m4/ltsugar.m4 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 @@ -107,9 +133,20 @@ po/remove-potcdate.sed 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 diff --git a/capitests/tests.c b/capitests/tests.c deleted file mode 100644 index 9124ea9..0000000 --- a/capitests/tests.c +++ /dev/null @@ -1,20465 +0,0 @@ -/* libguestfs generated file - * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. - * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. - * - * Copyright (C) 2009 Red Hat Inc. - * - * This 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 -#include -#include -#include -#include -#include - -#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); -} diff --git a/daemon/actions.h b/daemon/actions.h deleted file mode 100644 index 9eaf87b..0000000 --- a/daemon/actions.h +++ /dev/null @@ -1,161 +0,0 @@ -/* libguestfs generated file - * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. - * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. - * - * Copyright (C) 2009 Red Hat Inc. - * - * This 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); diff --git a/daemon/stubs.c b/daemon/stubs.c deleted file mode 100644 index 9c2bfef..0000000 --- a/daemon/stubs.c +++ /dev/null @@ -1,4857 +0,0 @@ -/* libguestfs generated file - * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. - * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. - * - * Copyright (C) 2009 Red Hat Inc. - * - * This 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 - -#include -#include -#include -#include -#include -#include -#include - -#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; -} diff --git a/fish/cmds.c b/fish/cmds.c deleted file mode 100644 index 9b8dfbb..0000000 --- a/fish/cmds.c +++ /dev/null @@ -1,3859 +0,0 @@ -/* libguestfs generated file - * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. - * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. - * - * Copyright (C) 2009 Red Hat Inc. - * - * This 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 -#include -#include -#include - -#include -#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 / help 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.\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 \n\nThis function adds a virtual machine disk image C to the\nguest. The first time you call this function, the disk appears as IDE\ndisk 0 (C) in the guest, the second time as C, 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. This\nstops you from specifying other types of drive which are supported\nby qemu such as C and C URLs. To specify those, use\nthe general C 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 \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. This\nstops you from specifying other types of drive which are supported\nby qemu such as C and C URLs. To specify those, use\nthe general C 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 \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. This\nstops you from specifying other types of drive which are supported\nby qemu such as C and C URLs. To specify those, use\nthe general C 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 \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 string must be a C<-> (dash).\n\nC 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 \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\nenvironment variable.\n\nSetting C to C 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 \n\nSet the path that libguestfs searches for kernel and initrd.img.\n\nThe default is C<$libdir/guestfs> unless overridden by setting\nC environment variable.\n\nSetting C to C 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 \n\nThis function is used to add additional options to the\nguest kernel command line.\n\nThe default is C unless overridden by setting\nC environment variable.\n\nSetting C to C means I 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 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 \n\nIf C is true, this enables autosync. Libguestfs will make a\nbest effort attempt to run C followed by\nC 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 \n\nIf C is true, this turns on verbose messages (to C).\n\nVerbose messages are disabled unless the environment variable\nC 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 state).\n\nFor more information on states, see L."); - 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 state).\n\nFor more information on states, see L."); - 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 state).\n\nFor more information on states, see L."); - 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 state).\n\nFor more information on states, see L."); - 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."); - 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 \n\nThis sets the memory size in megabytes allocated to the\nqemu subprocess. This only has any effect if called before\nC.\n\nYou can also change this by setting the environment\nvariable C before the handle is\ncreated.\n\nFor more information on the architecture of libguestfs,\nsee L.\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 was not called\non this handle, and if C was not set,\nthen this returns the compiled-in default value for memsize.\n\nFor more information on the architecture of libguestfs,\nsee L."); - else - if (strcasecmp (cmd, "mount") == 0) - pod2text ("mount - mount a guest disk at a position in the filesystem", " mount \n\nMount a guest disk at a position in the filesystem. Block devices\nare named C, C and so on, as they were added to\nthe guest. If those block devices contain partitions, they will have\nthe usual names (eg. C). Also LVM C-style\nnames can be used.\n\nThe rules are the same as for L: 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 and C 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 \n\nTouch acts like the L 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 \n\nReturn the contents of the file named C.\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\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 \n\nList the files in C (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 intended that you try to parse the output string."); - else - if (strcasecmp (cmd, "ls") == 0) - pod2text ("ls - list the files in a directory", " ls \n\nList the files in C (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 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"); - 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\n\nThis does not return logical volumes. For that you will need to\ncall C."); - 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 command.\n\nThis returns a list of just the device names that contain\nPVs (eg. C).\n\nSee also C."); - 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 command.\n\nThis returns a list of just the volume group names that were\ndetected (eg. C).\n\nSee also C."); - 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 command.\n\nThis returns a list of the logical volume device names\n(eg. C).\n\nSee also C."); - 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 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 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 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 \n\nReturn the contents of the file named C.\n\nThe file contents are returned as a list of lines. Trailing\nC and C character sequences are I 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\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 \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\ncommands.\n\nC is the filesystem root. C must not be NULL,\nuse C instead.\n\nThe flags are the same as the flags defined in\nEaugeas.hE, the logical I of the following\nintegers:\n\n=over 4\n\n=item C = 1\n\nKeep the original file with a C<.augsave> extension.\n\n=item C = 2\n\nSave changes into a file with extension C<.augnew>, and\ndo not overwrite original. Overrides C.\n\n=item C = 4\n\nTypecheck lenses (can be expensive).\n\n=item C = 8\n\nDo not use standard load path for modules.\n\n=item C = 16\n\nMake save a no-op, just record what would have been changed.\n\n=item C = 32\n\nDo not load the tree in C.\n\n=back\n\nTo close the handle, you can call C.\n\nTo find out more about Augeas, see L."); - 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 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 \n\nDefines an Augeas variable C whose value is the result\nof evaluating C. If C is NULL, then C is\nundefined.\n\nOn success this returns the number of nodes in C, or\nC<0> if C 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 \n\nDefines a variable C whose value is the result of\nevaluating C.\n\nIf C evaluates to an empty nodeset, a node is created,\nequivalent to calling C C, C.\nC 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 \n\nLook up the value associated with C. If C\nmatches exactly one node, the C is returned."); - else - if (strcasecmp (cmd, "aug_set") == 0 || strcasecmp (cmd, "aug-set") == 0) - pod2text ("aug-set - set Augeas path to value", " aug-set \n\nSet the value associated with C to C."); - else - if (strcasecmp (cmd, "aug_insert") == 0 || strcasecmp (cmd, "aug-insert") == 0) - pod2text ("aug-insert - insert a sibling Augeas node", " aug-insert