- if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
- return run_launch (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "kill_subprocess") == 0 || strcasecmp (cmd, "kill-subprocess") == 0)
- return run_kill_subprocess (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "add_drive") == 0 || strcasecmp (cmd, "add-drive") == 0 || strcasecmp (cmd, "add") == 0)
- return run_add_drive (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "add_cdrom") == 0 || strcasecmp (cmd, "add-cdrom") == 0 || strcasecmp (cmd, "cdrom") == 0)
- return run_add_cdrom (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "config") == 0)
- return run_config (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_path") == 0 || strcasecmp (cmd, "set-path") == 0 || strcasecmp (cmd, "path") == 0)
- return run_set_path (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_path") == 0 || strcasecmp (cmd, "get-path") == 0)
- return run_get_path (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0)
- return run_set_autosync (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_autosync") == 0 || strcasecmp (cmd, "get-autosync") == 0)
- return run_get_autosync (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "set_verbose") == 0 || strcasecmp (cmd, "set-verbose") == 0 || strcasecmp (cmd, "verbose") == 0)
- return run_set_verbose (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_verbose") == 0 || strcasecmp (cmd, "get-verbose") == 0)
- return run_get_verbose (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_ready") == 0 || strcasecmp (cmd, "is-ready") == 0)
- return run_is_ready (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_config") == 0 || strcasecmp (cmd, "is-config") == 0)
- return run_is_config (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_launching") == 0 || strcasecmp (cmd, "is-launching") == 0)
- return run_is_launching (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_busy") == 0 || strcasecmp (cmd, "is-busy") == 0)
- return run_is_busy (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "get_state") == 0 || strcasecmp (cmd, "get-state") == 0)
- return run_get_state (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mount") == 0)
- return run_mount (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "sync") == 0)
- return run_sync (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "touch") == 0)
- return run_touch (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "cat") == 0)
- return run_cat (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "ll") == 0)
- return run_ll (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "ls") == 0)
- return run_ls (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "list_devices") == 0 || strcasecmp (cmd, "list-devices") == 0)
- return run_list_devices (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "list_partitions") == 0 || strcasecmp (cmd, "list-partitions") == 0)
- return run_list_partitions (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "pvs") == 0)
- return run_pvs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "vgs") == 0)
- return run_vgs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lvs") == 0)
- return run_lvs (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "pvs_full") == 0 || strcasecmp (cmd, "pvs-full") == 0)
- return run_pvs_full (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "vgs_full") == 0 || strcasecmp (cmd, "vgs-full") == 0)
- return run_vgs_full (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lvs_full") == 0 || strcasecmp (cmd, "lvs-full") == 0)
- return run_lvs_full (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "read_lines") == 0 || strcasecmp (cmd, "read-lines") == 0)
- return run_read_lines (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_init") == 0 || strcasecmp (cmd, "aug-init") == 0)
- return run_aug_init (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_close") == 0 || strcasecmp (cmd, "aug-close") == 0)
- return run_aug_close (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_defvar") == 0 || strcasecmp (cmd, "aug-defvar") == 0)
- return run_aug_defvar (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_defnode") == 0 || strcasecmp (cmd, "aug-defnode") == 0)
- return run_aug_defnode (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_get") == 0 || strcasecmp (cmd, "aug-get") == 0)
- return run_aug_get (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_set") == 0 || strcasecmp (cmd, "aug-set") == 0)
- return run_aug_set (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_insert") == 0 || strcasecmp (cmd, "aug-insert") == 0)
- return run_aug_insert (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_rm") == 0 || strcasecmp (cmd, "aug-rm") == 0)
- return run_aug_rm (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_mv") == 0 || strcasecmp (cmd, "aug-mv") == 0)
- return run_aug_mv (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_match") == 0 || strcasecmp (cmd, "aug-match") == 0)
- return run_aug_match (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_save") == 0 || strcasecmp (cmd, "aug-save") == 0)
- return run_aug_save (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_load") == 0 || strcasecmp (cmd, "aug-load") == 0)
- return run_aug_load (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "aug_ls") == 0 || strcasecmp (cmd, "aug-ls") == 0)
- return run_aug_ls (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "rm") == 0)
- return run_rm (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "rmdir") == 0)
- return run_rmdir (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "rm_rf") == 0 || strcasecmp (cmd, "rm-rf") == 0)
- return run_rm_rf (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkdir") == 0)
- return run_mkdir (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkdir_p") == 0 || strcasecmp (cmd, "mkdir-p") == 0)
- return run_mkdir_p (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "chmod") == 0)
- return run_chmod (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "chown") == 0)
- return run_chown (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "exists") == 0)
- return run_exists (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_file") == 0 || strcasecmp (cmd, "is-file") == 0)
- return run_is_file (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "is_dir") == 0 || strcasecmp (cmd, "is-dir") == 0)
- return run_is_dir (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "pvcreate") == 0)
- return run_pvcreate (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "vgcreate") == 0)
- return run_vgcreate (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "lvcreate") == 0)
- return run_lvcreate (cmd, argc, argv);
- else
- if (strcasecmp (cmd, "mkfs") == 0)
+ int r;
+ const char *device;
+ const char *mountpoint;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ mountpoint = argv[1];
+ r = guestfs_mount_ro (g, device, mountpoint);
+ return r;
+}
+
+static int run_mount_options (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *options;
+ const char *device;
+ const char *mountpoint;
+ if (argc != 3) {
+ fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ options = argv[0];
+ device = argv[1];
+ mountpoint = argv[2];
+ r = guestfs_mount_options (g, options, device, mountpoint);
+ return r;
+}
+
+static int run_mount_vfs (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *options;
+ const char *vfstype;
+ const char *device;
+ const char *mountpoint;
+ if (argc != 4) {
+ fprintf (stderr, "%s should have 4 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ options = argv[0];
+ vfstype = argv[1];
+ device = argv[2];
+ mountpoint = argv[3];
+ r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
+ return r;
+}
+
+static int run_debug (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *subcmd;
+ char **extraargs;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ subcmd = argv[0];
+ extraargs = parse_string_list (argv[1]);
+ r = guestfs_debug (g, subcmd, extraargs);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_lvremove (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_lvremove (g, device);
+ return r;
+}
+
+static int run_vgremove (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *vgname;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ vgname = argv[0];
+ r = guestfs_vgremove (g, vgname);
+ return r;
+}
+
+static int run_pvremove (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_pvremove (g, device);
+ return r;
+}
+
+static int run_set_e2label (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ const char *label;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ label = argv[1];
+ r = guestfs_set_e2label (g, device, label);
+ return r;
+}
+
+static int run_get_e2label (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_get_e2label (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_set_e2uuid (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ const char *uuid;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ uuid = argv[1];
+ r = guestfs_set_e2uuid (g, device, uuid);
+ return r;
+}
+
+static int run_get_e2uuid (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_get_e2uuid (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_fsck (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *fstype;
+ const char *device;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ fstype = argv[0];
+ device = argv[1];
+ r = guestfs_fsck (g, fstype, device);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_zero (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_zero (g, device);
+ return r;
+}
+
+static int run_grub_install (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *root;
+ const char *device;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ root = argv[0];
+ device = argv[1];
+ r = guestfs_grub_install (g, root, device);
+ return r;
+}
+
+static int run_cp (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_cp (g, src, dest);
+ return r;
+}
+
+static int run_cp_a (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_cp_a (g, src, dest);
+ return r;
+}
+
+static int run_mv (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_mv (g, src, dest);
+ return r;
+}
+
+static int run_drop_caches (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int whattodrop;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ whattodrop = atoi (argv[0]);
+ r = guestfs_drop_caches (g, whattodrop);
+ return r;
+}
+
+static int run_dmesg (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_dmesg (g);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_ping_daemon (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_ping_daemon (g);
+ return r;
+}
+
+static int run_equal (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *file1;
+ const char *file2;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ file1 = argv[0];
+ file2 = argv[1];
+ r = guestfs_equal (g, file1, file2);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_strings (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_strings (g, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_strings_e (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *encoding;
+ const char *path;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ encoding = argv[0];
+ path = argv[1];
+ r = guestfs_strings_e (g, encoding, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_hexdump (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_hexdump (g, path);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_zerofree (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_zerofree (g, device);
+ return r;
+}
+
+static int run_pvresize (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_pvresize (g, device);
+ return r;
+}
+
+static int run_sfdisk_N (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ int n;
+ int cyls;
+ int heads;
+ int sectors;
+ const char *line;
+ if (argc != 6) {
+ fprintf (stderr, "%s should have 6 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ n = atoi (argv[1]);
+ cyls = atoi (argv[2]);
+ heads = atoi (argv[3]);
+ sectors = atoi (argv[4]);
+ line = argv[5];
+ r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line);
+ return r;
+}
+
+static int run_sfdisk_l (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_sfdisk_l (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_sfdisk_kernel_geometry (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_sfdisk_kernel_geometry (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_sfdisk_disk_geometry (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_sfdisk_disk_geometry (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_vg_activate_all (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int activate;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ activate = is_true (argv[0]) ? 1 : 0;
+ r = guestfs_vg_activate_all (g, activate);
+ return r;
+}
+
+static int run_vg_activate (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int activate;
+ char **volgroups;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ activate = is_true (argv[0]) ? 1 : 0;
+ volgroups = parse_string_list (argv[1]);
+ r = guestfs_vg_activate (g, activate, volgroups);
+ return r;
+}
+
+static int run_lvresize (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ int mbytes;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ mbytes = atoi (argv[1]);
+ r = guestfs_lvresize (g, device, mbytes);
+ return r;
+}
+
+static int run_resize2fs (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_resize2fs (g, device);
+ return r;
+}
+
+static int run_find (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *directory;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ directory = argv[0];
+ r = guestfs_find (g, directory);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+int run_action (const char *cmd, int argc, char *argv[])
+{
+ if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
+ return run_launch (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "kill_subprocess") == 0 || strcasecmp (cmd, "kill-subprocess") == 0)
+ return run_kill_subprocess (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "add_drive") == 0 || strcasecmp (cmd, "add-drive") == 0 || strcasecmp (cmd, "add") == 0)
+ return run_add_drive (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "add_cdrom") == 0 || strcasecmp (cmd, "add-cdrom") == 0 || strcasecmp (cmd, "cdrom") == 0)
+ return run_add_cdrom (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "config") == 0)
+ return run_config (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_qemu") == 0 || strcasecmp (cmd, "set-qemu") == 0 || strcasecmp (cmd, "qemu") == 0)
+ return run_set_qemu (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_qemu") == 0 || strcasecmp (cmd, "get-qemu") == 0)
+ return run_get_qemu (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_path") == 0 || strcasecmp (cmd, "set-path") == 0 || strcasecmp (cmd, "path") == 0)
+ return run_set_path (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_path") == 0 || strcasecmp (cmd, "get-path") == 0)
+ return run_get_path (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_append") == 0 || strcasecmp (cmd, "set-append") == 0 || strcasecmp (cmd, "append") == 0)
+ return run_set_append (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_append") == 0 || strcasecmp (cmd, "get-append") == 0)
+ return run_get_append (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0)
+ return run_set_autosync (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_autosync") == 0 || strcasecmp (cmd, "get-autosync") == 0)
+ return run_get_autosync (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_verbose") == 0 || strcasecmp (cmd, "set-verbose") == 0 || strcasecmp (cmd, "verbose") == 0)
+ return run_set_verbose (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_verbose") == 0 || strcasecmp (cmd, "get-verbose") == 0)
+ return run_get_verbose (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_ready") == 0 || strcasecmp (cmd, "is-ready") == 0)
+ return run_is_ready (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_config") == 0 || strcasecmp (cmd, "is-config") == 0)
+ return run_is_config (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_launching") == 0 || strcasecmp (cmd, "is-launching") == 0)
+ return run_is_launching (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_busy") == 0 || strcasecmp (cmd, "is-busy") == 0)
+ return run_is_busy (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_state") == 0 || strcasecmp (cmd, "get-state") == 0)
+ return run_get_state (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mount") == 0)
+ return run_mount (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sync") == 0)
+ return run_sync (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "touch") == 0)
+ return run_touch (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "cat") == 0)
+ return run_cat (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "ll") == 0)
+ return run_ll (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "ls") == 0)
+ return run_ls (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "list_devices") == 0 || strcasecmp (cmd, "list-devices") == 0)
+ return run_list_devices (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "list_partitions") == 0 || strcasecmp (cmd, "list-partitions") == 0)
+ return run_list_partitions (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "pvs") == 0)
+ return run_pvs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "vgs") == 0)
+ return run_vgs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lvs") == 0)
+ return run_lvs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "pvs_full") == 0 || strcasecmp (cmd, "pvs-full") == 0)
+ return run_pvs_full (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "vgs_full") == 0 || strcasecmp (cmd, "vgs-full") == 0)
+ return run_vgs_full (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lvs_full") == 0 || strcasecmp (cmd, "lvs-full") == 0)
+ return run_lvs_full (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "read_lines") == 0 || strcasecmp (cmd, "read-lines") == 0)
+ return run_read_lines (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_init") == 0 || strcasecmp (cmd, "aug-init") == 0)
+ return run_aug_init (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_close") == 0 || strcasecmp (cmd, "aug-close") == 0)
+ return run_aug_close (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_defvar") == 0 || strcasecmp (cmd, "aug-defvar") == 0)
+ return run_aug_defvar (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_defnode") == 0 || strcasecmp (cmd, "aug-defnode") == 0)
+ return run_aug_defnode (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_get") == 0 || strcasecmp (cmd, "aug-get") == 0)
+ return run_aug_get (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_set") == 0 || strcasecmp (cmd, "aug-set") == 0)
+ return run_aug_set (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_insert") == 0 || strcasecmp (cmd, "aug-insert") == 0)
+ return run_aug_insert (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_rm") == 0 || strcasecmp (cmd, "aug-rm") == 0)
+ return run_aug_rm (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_mv") == 0 || strcasecmp (cmd, "aug-mv") == 0)
+ return run_aug_mv (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_match") == 0 || strcasecmp (cmd, "aug-match") == 0)
+ return run_aug_match (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_save") == 0 || strcasecmp (cmd, "aug-save") == 0)
+ return run_aug_save (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_load") == 0 || strcasecmp (cmd, "aug-load") == 0)
+ return run_aug_load (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_ls") == 0 || strcasecmp (cmd, "aug-ls") == 0)
+ return run_aug_ls (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "rm") == 0)
+ return run_rm (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "rmdir") == 0)
+ return run_rmdir (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "rm_rf") == 0 || strcasecmp (cmd, "rm-rf") == 0)
+ return run_rm_rf (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mkdir") == 0)
+ return run_mkdir (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mkdir_p") == 0 || strcasecmp (cmd, "mkdir-p") == 0)
+ return run_mkdir_p (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "chmod") == 0)
+ return run_chmod (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "chown") == 0)
+ return run_chown (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "exists") == 0)
+ return run_exists (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_file") == 0 || strcasecmp (cmd, "is-file") == 0)
+ return run_is_file (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_dir") == 0 || strcasecmp (cmd, "is-dir") == 0)
+ return run_is_dir (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "pvcreate") == 0)
+ return run_pvcreate (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "vgcreate") == 0)
+ return run_vgcreate (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lvcreate") == 0)
+ return run_lvcreate (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mkfs") == 0)