+ int i;
+
+ printf ("pv_name: %s\n", pv->pv_name);
+ printf ("pv_uuid: ");
+ for (i = 0; i < 32; ++i)
+ printf ("%c", pv->pv_uuid[i]);
+ printf ("\n");
+ printf ("pv_fmt: %s\n", pv->pv_fmt);
+ printf ("pv_size: %" PRIu64 "\n", pv->pv_size);
+ printf ("dev_size: %" PRIu64 "\n", pv->dev_size);
+ printf ("pv_free: %" PRIu64 "\n", pv->pv_free);
+ printf ("pv_used: %" PRIu64 "\n", pv->pv_used);
+ printf ("pv_attr: %s\n", pv->pv_attr);
+ printf ("pv_pe_count: %" PRIi64 "\n", pv->pv_pe_count);
+ printf ("pv_pe_alloc_count: %" PRIi64 "\n", pv->pv_pe_alloc_count);
+ printf ("pv_tags: %s\n", pv->pv_tags);
+ printf ("pe_start: %" PRIu64 "\n", pv->pe_start);
+ printf ("pv_mda_count: %" PRIi64 "\n", pv->pv_mda_count);
+ printf ("pv_mda_free: %" PRIu64 "\n", pv->pv_mda_free);
+}
+
+static void print_pv_list (struct guestfs_lvm_pv_list *pvs)
+{
+ int i;
+
+ for (i = 0; i < pvs->len; ++i)
+ print_pv (&pvs->val[i]);
+}
+
+static void print_vg (struct guestfs_lvm_vg *vg)
+{
+ int i;
+
+ printf ("vg_name: %s\n", vg->vg_name);
+ printf ("vg_uuid: ");
+ for (i = 0; i < 32; ++i)
+ printf ("%c", vg->vg_uuid[i]);
+ printf ("\n");
+ printf ("vg_fmt: %s\n", vg->vg_fmt);
+ printf ("vg_attr: %s\n", vg->vg_attr);
+ printf ("vg_size: %" PRIu64 "\n", vg->vg_size);
+ printf ("vg_free: %" PRIu64 "\n", vg->vg_free);
+ printf ("vg_sysid: %s\n", vg->vg_sysid);
+ printf ("vg_extent_size: %" PRIu64 "\n", vg->vg_extent_size);
+ printf ("vg_extent_count: %" PRIi64 "\n", vg->vg_extent_count);
+ printf ("vg_free_count: %" PRIi64 "\n", vg->vg_free_count);
+ printf ("max_lv: %" PRIi64 "\n", vg->max_lv);
+ printf ("max_pv: %" PRIi64 "\n", vg->max_pv);
+ printf ("pv_count: %" PRIi64 "\n", vg->pv_count);
+ printf ("lv_count: %" PRIi64 "\n", vg->lv_count);
+ printf ("snap_count: %" PRIi64 "\n", vg->snap_count);
+ printf ("vg_seqno: %" PRIi64 "\n", vg->vg_seqno);
+ printf ("vg_tags: %s\n", vg->vg_tags);
+ printf ("vg_mda_count: %" PRIi64 "\n", vg->vg_mda_count);
+ printf ("vg_mda_free: %" PRIu64 "\n", vg->vg_mda_free);
+}
+
+static void print_vg_list (struct guestfs_lvm_vg_list *vgs)
+{
+ int i;
+
+ for (i = 0; i < vgs->len; ++i)
+ print_vg (&vgs->val[i]);
+}
+
+static void print_lv (struct guestfs_lvm_lv *lv)
+{
+ int i;
+
+ printf ("lv_name: %s\n", lv->lv_name);
+ printf ("lv_uuid: ");
+ for (i = 0; i < 32; ++i)
+ printf ("%c", lv->lv_uuid[i]);
+ printf ("\n");
+ printf ("lv_attr: %s\n", lv->lv_attr);
+ printf ("lv_major: %" PRIi64 "\n", lv->lv_major);
+ printf ("lv_minor: %" PRIi64 "\n", lv->lv_minor);
+ printf ("lv_kernel_major: %" PRIi64 "\n", lv->lv_kernel_major);
+ printf ("lv_kernel_minor: %" PRIi64 "\n", lv->lv_kernel_minor);
+ printf ("lv_size: %" PRIu64 "\n", lv->lv_size);
+ printf ("seg_count: %" PRIi64 "\n", lv->seg_count);
+ printf ("origin: %s\n", lv->origin);
+ if (lv->snap_percent >= 0) printf ("snap_percent: %g %%\n", lv->snap_percent);
+ else printf ("snap_percent: \n");
+ if (lv->copy_percent >= 0) printf ("copy_percent: %g %%\n", lv->copy_percent);
+ else printf ("copy_percent: \n");
+ printf ("move_pv: %s\n", lv->move_pv);
+ printf ("lv_tags: %s\n", lv->lv_tags);
+ printf ("mirror_log: %s\n", lv->mirror_log);
+ printf ("modules: %s\n", lv->modules);
+}
+
+static void print_lv_list (struct guestfs_lvm_lv_list *lvs)
+{
+ int i;
+
+ for (i = 0; i < lvs->len; ++i)
+ print_lv (&lvs->val[i]);
+}
+
+static void print_stat (struct guestfs_stat *stat)
+{
+ printf ("dev: %" PRIi64 "\n", stat->dev);
+ printf ("ino: %" PRIi64 "\n", stat->ino);
+ printf ("mode: %" PRIi64 "\n", stat->mode);
+ printf ("nlink: %" PRIi64 "\n", stat->nlink);
+ printf ("uid: %" PRIi64 "\n", stat->uid);
+ printf ("gid: %" PRIi64 "\n", stat->gid);
+ printf ("rdev: %" PRIi64 "\n", stat->rdev);
+ printf ("size: %" PRIi64 "\n", stat->size);
+ printf ("blksize: %" PRIi64 "\n", stat->blksize);
+ printf ("blocks: %" PRIi64 "\n", stat->blocks);
+ printf ("atime: %" PRIi64 "\n", stat->atime);
+ printf ("mtime: %" PRIi64 "\n", stat->mtime);
+ printf ("ctime: %" PRIi64 "\n", stat->ctime);
+}
+
+static void print_statvfs (struct guestfs_statvfs *statvfs)
+{
+ printf ("bsize: %" PRIi64 "\n", statvfs->bsize);
+ printf ("frsize: %" PRIi64 "\n", statvfs->frsize);
+ printf ("blocks: %" PRIi64 "\n", statvfs->blocks);
+ printf ("bfree: %" PRIi64 "\n", statvfs->bfree);
+ printf ("bavail: %" PRIi64 "\n", statvfs->bavail);
+ printf ("files: %" PRIi64 "\n", statvfs->files);
+ printf ("ffree: %" PRIi64 "\n", statvfs->ffree);
+ printf ("favail: %" PRIi64 "\n", statvfs->favail);
+ printf ("fsid: %" PRIi64 "\n", statvfs->fsid);
+ printf ("flag: %" PRIi64 "\n", statvfs->flag);
+ printf ("namemax: %" PRIi64 "\n", statvfs->namemax);
+}
+
+static int run_launch (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = launch (g);
+ return r;
+}
+
+static int run_kill_subprocess (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_kill_subprocess (g);
+ return r;
+}
+
+static int run_add_drive (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *filename;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ filename = argv[0];
+ r = guestfs_add_drive (g, filename);
+ return r;
+}
+
+static int run_add_cdrom (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *filename;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ filename = argv[0];
+ r = guestfs_add_cdrom (g, filename);
+ return r;
+}
+
+static int run_add_drive_ro (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *filename;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ filename = argv[0];
+ r = guestfs_add_drive_ro (g, filename);
+ return r;
+}
+
+static int run_config (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *qemuparam;
+ const char *qemuvalue;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ qemuparam = argv[0];
+ qemuvalue = strcmp (argv[1], "") != 0 ? argv[1] : NULL;
+ r = guestfs_config (g, qemuparam, qemuvalue);
+ return r;
+}
+
+static int run_set_qemu (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *qemu;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ qemu = argv[0];
+ r = guestfs_set_qemu (g, qemu);
+ return r;
+}
+
+static int run_get_qemu (const char *cmd, int argc, char *argv[])
+{
+ const char *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_get_qemu (g);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ return 0;
+}
+
+static int run_set_path (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_set_path (g, path);
+ return r;
+}
+
+static int run_get_path (const char *cmd, int argc, char *argv[])
+{
+ const char *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_get_path (g);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ return 0;
+}
+
+static int run_set_append (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *append;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ append = argv[0];
+ r = guestfs_set_append (g, append);
+ return r;
+}
+
+static int run_get_append (const char *cmd, int argc, char *argv[])
+{
+ const char *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_get_append (g);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ return 0;
+}
+
+static int run_set_autosync (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int autosync;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ autosync = is_true (argv[0]) ? 1 : 0;
+ r = guestfs_set_autosync (g, autosync);
+ return r;
+}
+
+static int run_get_autosync (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_get_autosync (g);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_set_verbose (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int verbose;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ verbose = is_true (argv[0]) ? 1 : 0;
+ r = guestfs_set_verbose (g, verbose);
+ return r;
+}
+
+static int run_get_verbose (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_get_verbose (g);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_is_ready (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_is_ready (g);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_is_config (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_is_config (g);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_is_launching (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_is_launching (g);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_is_busy (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_is_busy (g);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_get_state (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_get_state (g);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_mount (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ const char *mountpoint;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ mountpoint = argv[1];
+ r = guestfs_mount (g, device, mountpoint);
+ return r;
+}
+
+static int run_sync (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_sync (g);
+ return r;
+}
+
+static int run_touch (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_touch (g, path);
+ return r;
+}
+
+static int run_cat (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_cat (g, path);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_ll (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *directory;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ directory = argv[0];
+ r = guestfs_ll (g, directory);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_ls (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *directory;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ directory = argv[0];
+ r = guestfs_ls (g, directory);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_list_devices (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_list_devices (g);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_list_partitions (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_list_partitions (g);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_pvs (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_pvs (g);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_vgs (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_vgs (g);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_lvs (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_lvs (g);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_pvs_full (const char *cmd, int argc, char *argv[])
+{
+ struct guestfs_lvm_pv_list *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_pvs_full (g);
+ if (r == NULL) return -1;
+ print_pv_list (r);
+ guestfs_free_lvm_pv_list (r);
+ return 0;
+}
+
+static int run_vgs_full (const char *cmd, int argc, char *argv[])
+{
+ struct guestfs_lvm_vg_list *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_vgs_full (g);
+ if (r == NULL) return -1;
+ print_vg_list (r);
+ guestfs_free_lvm_vg_list (r);
+ return 0;
+}
+
+static int run_lvs_full (const char *cmd, int argc, char *argv[])
+{
+ struct guestfs_lvm_lv_list *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_lvs_full (g);
+ if (r == NULL) return -1;
+ print_lv_list (r);
+ guestfs_free_lvm_lv_list (r);
+ return 0;
+}
+
+static int run_read_lines (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_read_lines (g, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_aug_init (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *root;
+ int flags;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ root = argv[0];
+ flags = atoi (argv[1]);
+ r = guestfs_aug_init (g, root, flags);
+ return r;
+}
+
+static int run_aug_close (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_aug_close (g);
+ return r;
+}
+
+static int run_aug_defvar (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *name;
+ const char *expr;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ name = argv[0];
+ expr = strcmp (argv[1], "") != 0 ? argv[1] : NULL;
+ r = guestfs_aug_defvar (g, name, expr);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_aug_defnode (const char *cmd, int argc, char *argv[])
+{
+ struct guestfs_int_bool *r;
+ const char *name;
+ const char *expr;
+ const char *val;
+ if (argc != 3) {
+ fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ name = argv[0];
+ expr = argv[1];
+ val = argv[2];
+ r = guestfs_aug_defnode (g, name, expr, val);
+ if (r == NULL) return -1;
+ printf ("%d, %s\n", r->i,
+ r->b ? "true" : "false");
+ guestfs_free_int_bool (r);
+ return 0;
+}
+
+static int run_aug_get (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_aug_get (g, path);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_aug_set (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ const char *val;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ val = argv[1];
+ r = guestfs_aug_set (g, path, val);
+ return r;
+}
+
+static int run_aug_insert (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ const char *label;
+ int before;
+ if (argc != 3) {
+ fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ label = argv[1];
+ before = is_true (argv[2]) ? 1 : 0;
+ r = guestfs_aug_insert (g, path, label, before);
+ return r;
+}
+
+static int run_aug_rm (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_aug_rm (g, path);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_aug_mv (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_aug_mv (g, src, dest);
+ return r;
+}
+
+static int run_aug_match (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_aug_match (g, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_aug_save (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_aug_save (g);
+ return r;
+}
+
+static int run_aug_load (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_aug_load (g);
+ return r;
+}
+
+static int run_aug_ls (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_aug_ls (g, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_rm (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_rm (g, path);
+ return r;
+}
+
+static int run_rmdir (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_rmdir (g, path);
+ return r;
+}
+
+static int run_rm_rf (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_rm_rf (g, path);
+ return r;
+}
+
+static int run_mkdir (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_mkdir (g, path);
+ return r;
+}
+
+static int run_mkdir_p (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_mkdir_p (g, path);
+ return r;
+}
+
+static int run_chmod (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int mode;
+ const char *path;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ mode = atoi (argv[0]);
+ path = argv[1];
+ r = guestfs_chmod (g, mode, path);
+ return r;
+}
+
+static int run_chown (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int owner;
+ int group;
+ const char *path;
+ if (argc != 3) {
+ fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ owner = atoi (argv[0]);
+ group = atoi (argv[1]);
+ path = argv[2];
+ r = guestfs_chown (g, owner, group, path);
+ return r;
+}
+
+static int run_exists (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_exists (g, path);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_is_file (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_is_file (g, path);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_is_dir (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_is_dir (g, path);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_pvcreate (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_pvcreate (g, device);
+ return r;
+}
+
+static int run_vgcreate (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *volgroup;
+ char **physvols;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ volgroup = argv[0];
+ physvols = parse_string_list (argv[1]);
+ r = guestfs_vgcreate (g, volgroup, physvols);
+ return r;
+}
+
+static int run_lvcreate (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *logvol;
+ const char *volgroup;
+ int mbytes;
+ if (argc != 3) {
+ fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ logvol = argv[0];
+ volgroup = argv[1];
+ mbytes = atoi (argv[2]);
+ r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
+ return r;
+}
+
+static int run_mkfs (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *fstype;
+ const char *device;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ fstype = argv[0];
+ device = argv[1];
+ r = guestfs_mkfs (g, fstype, device);
+ return r;
+}
+
+static int run_sfdisk (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ int cyls;
+ int heads;
+ int sectors;
+ char **lines;
+ if (argc != 5) {
+ fprintf (stderr, "%s should have 5 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ cyls = atoi (argv[1]);
+ heads = atoi (argv[2]);
+ sectors = atoi (argv[3]);
+ lines = parse_string_list (argv[4]);
+ r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
+ return r;
+}
+
+static int run_write_file (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ const char *content;
+ int size;
+ if (argc != 3) {
+ fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ content = argv[1];
+ size = atoi (argv[2]);
+ r = guestfs_write_file (g, path, content, size);
+ return r;
+}
+
+static int run_umount (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *pathordevice;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ pathordevice = argv[0];
+ r = guestfs_umount (g, pathordevice);
+ return r;
+}
+
+static int run_mounts (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_mounts (g);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_umount_all (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_umount_all (g);
+ return r;
+}
+
+static int run_lvm_remove_all (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_lvm_remove_all (g);
+ return r;
+}
+
+static int run_file (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_file (g, path);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_command (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ char **arguments;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ arguments = parse_string_list (argv[0]);
+ r = guestfs_command (g, arguments);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_command_lines (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ char **arguments;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ arguments = parse_string_list (argv[0]);
+ r = guestfs_command_lines (g, arguments);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_stat (const char *cmd, int argc, char *argv[])
+{
+ struct guestfs_stat *r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_stat (g, path);
+ if (r == NULL) return -1;
+ print_stat (r);
+ free (r);
+ return 0;
+}
+
+static int run_lstat (const char *cmd, int argc, char *argv[])
+{
+ struct guestfs_stat *r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_lstat (g, path);
+ if (r == NULL) return -1;
+ print_stat (r);
+ free (r);
+ return 0;
+}
+
+static int run_statvfs (const char *cmd, int argc, char *argv[])
+{
+ struct guestfs_statvfs *r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_statvfs (g, path);
+ if (r == NULL) return -1;
+ print_statvfs (r);
+ free (r);
+ return 0;
+}
+
+static int run_tune2fs_l (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_tune2fs_l (g, device);
+ if (r == NULL) return -1;
+ print_table (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_blockdev_setro (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_blockdev_setro (g, device);
+ return r;
+}
+
+static int run_blockdev_setrw (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_blockdev_setrw (g, device);
+ return r;
+}
+
+static int run_blockdev_getro (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_blockdev_getro (g, device);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_blockdev_getss (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_blockdev_getss (g, device);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_blockdev_getbsz (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_blockdev_getbsz (g, device);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_blockdev_setbsz (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ int blocksize;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ blocksize = atoi (argv[1]);
+ r = guestfs_blockdev_setbsz (g, device, blocksize);
+ return r;
+}
+
+static int run_blockdev_getsz (const char *cmd, int argc, char *argv[])
+{
+ int64_t r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_blockdev_getsz (g, device);
+ if (r == -1) return -1;
+ printf ("%" PRIi64 "\n", r);
+ return 0;
+}
+
+static int run_blockdev_getsize64 (const char *cmd, int argc, char *argv[])
+{
+ int64_t r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_blockdev_getsize64 (g, device);
+ if (r == -1) return -1;
+ printf ("%" PRIi64 "\n", r);
+ return 0;
+}
+
+static int run_blockdev_flushbufs (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_blockdev_flushbufs (g, device);
+ return r;
+}
+
+static int run_blockdev_rereadpt (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_blockdev_rereadpt (g, device);
+ return r;
+}
+
+static int run_upload (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *filename;
+ const char *remotefilename;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ filename = strcmp (argv[0], "-") != 0 ? argv[0] : "/dev/stdin";
+ remotefilename = argv[1];
+ r = guestfs_upload (g, filename, remotefilename);
+ return r;
+}
+
+static int run_download (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *remotefilename;
+ const char *filename;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ remotefilename = argv[0];
+ filename = strcmp (argv[1], "-") != 0 ? argv[1] : "/dev/stdout";
+ r = guestfs_download (g, remotefilename, filename);
+ return r;
+}
+
+static int run_checksum (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *csumtype;
+ const char *path;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ csumtype = argv[0];
+ path = argv[1];
+ r = guestfs_checksum (g, csumtype, path);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_tar_in (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *tarfile;
+ const char *directory;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ tarfile = strcmp (argv[0], "-") != 0 ? argv[0] : "/dev/stdin";
+ directory = argv[1];
+ r = guestfs_tar_in (g, tarfile, directory);
+ return r;
+}
+
+static int run_tar_out (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *directory;
+ const char *tarfile;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ directory = argv[0];
+ tarfile = strcmp (argv[1], "-") != 0 ? argv[1] : "/dev/stdout";
+ r = guestfs_tar_out (g, directory, tarfile);
+ return r;
+}
+
+static int run_tgz_in (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *tarball;
+ const char *directory;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ tarball = strcmp (argv[0], "-") != 0 ? argv[0] : "/dev/stdin";
+ directory = argv[1];
+ r = guestfs_tgz_in (g, tarball, directory);
+ return r;
+}
+
+static int run_tgz_out (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *directory;
+ const char *tarball;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ directory = argv[0];
+ tarball = strcmp (argv[1], "-") != 0 ? argv[1] : "/dev/stdout";
+ r = guestfs_tgz_out (g, directory, tarball);
+ return r;
+}
+
+static int run_mount_ro (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ const char *mountpoint;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ mountpoint = argv[1];
+ r = guestfs_mount_ro (g, device, mountpoint);
+ return r;
+}
+
+static int run_mount_options (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *options;
+ const char *device;
+ const char *mountpoint;
+ if (argc != 3) {
+ fprintf (stderr, "%s should have 3 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ options = argv[0];
+ device = argv[1];
+ mountpoint = argv[2];
+ r = guestfs_mount_options (g, options, device, mountpoint);
+ return r;
+}
+
+static int run_mount_vfs (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *options;
+ const char *vfstype;
+ const char *device;
+ const char *mountpoint;
+ if (argc != 4) {
+ fprintf (stderr, "%s should have 4 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ options = argv[0];
+ vfstype = argv[1];
+ device = argv[2];
+ mountpoint = argv[3];
+ r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
+ return r;
+}
+
+static int run_debug (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *subcmd;
+ char **extraargs;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ subcmd = argv[0];
+ extraargs = parse_string_list (argv[1]);
+ r = guestfs_debug (g, subcmd, extraargs);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_lvremove (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_lvremove (g, device);
+ return r;
+}
+
+static int run_vgremove (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *vgname;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ vgname = argv[0];
+ r = guestfs_vgremove (g, vgname);
+ return r;
+}
+
+static int run_pvremove (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_pvremove (g, device);
+ return r;
+}
+
+static int run_set_e2label (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ const char *label;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ label = argv[1];
+ r = guestfs_set_e2label (g, device, label);
+ return r;
+}
+
+static int run_get_e2label (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_get_e2label (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_set_e2uuid (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ const char *uuid;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ uuid = argv[1];
+ r = guestfs_set_e2uuid (g, device, uuid);
+ return r;
+}
+
+static int run_get_e2uuid (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_get_e2uuid (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_fsck (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *fstype;
+ const char *device;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ fstype = argv[0];
+ device = argv[1];
+ r = guestfs_fsck (g, fstype, device);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_zero (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_zero (g, device);
+ return r;
+}
+
+static int run_grub_install (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *root;
+ const char *device;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ root = argv[0];
+ device = argv[1];
+ r = guestfs_grub_install (g, root, device);
+ return r;
+}
+
+static int run_cp (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_cp (g, src, dest);
+ return r;
+}
+
+static int run_cp_a (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_cp_a (g, src, dest);
+ return r;
+}
+
+static int run_mv (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_mv (g, src, dest);
+ return r;
+}
+
+static int run_drop_caches (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int whattodrop;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ whattodrop = atoi (argv[0]);
+ r = guestfs_drop_caches (g, whattodrop);
+ return r;
+}
+
+static int run_dmesg (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_dmesg (g);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_ping_daemon (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_ping_daemon (g);
+ return r;
+}
+
+static int run_equal (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *file1;
+ const char *file2;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ file1 = argv[0];
+ file2 = argv[1];
+ r = guestfs_equal (g, file1, file2);
+ if (r == -1) return -1;
+ if (r) printf ("true\n"); else printf ("false\n");
+ return 0;
+}
+
+static int run_strings (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_strings (g, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_strings_e (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *encoding;
+ const char *path;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ encoding = argv[0];
+ path = argv[1];
+ r = guestfs_strings_e (g, encoding, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_hexdump (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_hexdump (g, path);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_zerofree (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_zerofree (g, device);
+ return r;
+}
+
+static int run_pvresize (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_pvresize (g, device);
+ return r;
+}
+
+static int run_sfdisk_N (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ int partnum;
+ int cyls;
+ int heads;
+ int sectors;
+ const char *line;
+ if (argc != 6) {
+ fprintf (stderr, "%s should have 6 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ partnum = atoi (argv[1]);
+ cyls = atoi (argv[2]);
+ heads = atoi (argv[3]);
+ sectors = atoi (argv[4]);
+ line = argv[5];
+ r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
+ return r;
+}
+
+static int run_sfdisk_l (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_sfdisk_l (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_sfdisk_kernel_geometry (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_sfdisk_kernel_geometry (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_sfdisk_disk_geometry (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_sfdisk_disk_geometry (g, device);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_vg_activate_all (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int activate;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ activate = is_true (argv[0]) ? 1 : 0;
+ r = guestfs_vg_activate_all (g, activate);
+ return r;
+}
+
+static int run_vg_activate (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int activate;
+ char **volgroups;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ activate = is_true (argv[0]) ? 1 : 0;
+ volgroups = parse_string_list (argv[1]);
+ r = guestfs_vg_activate (g, activate, volgroups);
+ return r;
+}
+
+static int run_lvresize (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ int mbytes;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ mbytes = atoi (argv[1]);
+ r = guestfs_lvresize (g, device, mbytes);
+ return r;
+}
+
+static int run_resize2fs (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_resize2fs (g, device);
+ return r;
+}
+
+static int run_find (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *directory;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ directory = argv[0];
+ r = guestfs_find (g, directory);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_e2fsck_f (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_e2fsck_f (g, device);
+ return r;
+}
+
+static int run_sleep (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int secs;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ secs = atoi (argv[0]);
+ r = guestfs_sleep (g, secs);
+ return r;
+}
+
+static int run_ntfs_3g_probe (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int rw;
+ const char *device;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ rw = is_true (argv[0]) ? 1 : 0;
+ device = argv[1];
+ r = guestfs_ntfs_3g_probe (g, rw, device);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_sh (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *command;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ command = argv[0];
+ r = guestfs_sh (g, command);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_sh_lines (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *command;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ command = argv[0];
+ r = guestfs_sh_lines (g, command);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_glob_expand (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *pattern;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ pattern = argv[0];
+ r = guestfs_glob_expand (g, pattern);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_scrub_device (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_scrub_device (g, device);
+ return r;
+}
+
+static int run_scrub_file (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *file;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ file = argv[0];
+ r = guestfs_scrub_file (g, file);
+ return r;
+}
+
+static int run_scrub_freespace (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *dir;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ dir = argv[0];
+ r = guestfs_scrub_freespace (g, dir);
+ return r;
+}
+
+static int run_mkdtemp (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ const char *template;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ template = argv[0];
+ r = guestfs_mkdtemp (g, template);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_wc_l (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_wc_l (g, path);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_wc_w (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_wc_w (g, path);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_wc_c (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_wc_c (g, path);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
+static int run_head (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_head (g, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_head_n (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ int nrlines;
+ const char *path;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ nrlines = atoi (argv[0]);
+ path = argv[1];
+ r = guestfs_head_n (g, nrlines, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_tail (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_tail (g, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_tail_n (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ int nrlines;
+ const char *path;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ nrlines = atoi (argv[0]);
+ path = argv[1];
+ r = guestfs_tail_n (g, nrlines, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_df (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_df (g);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_df_h (const char *cmd, int argc, char *argv[])
+{
+ char *r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_df_h (g);
+ if (r == NULL) return -1;
+ printf ("%s\n", r);
+ free (r);
+ return 0;
+}
+
+static int run_du (const char *cmd, int argc, char *argv[])
+{
+ int64_t r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_du (g, path);
+ if (r == -1) return -1;
+ printf ("%" PRIi64 "\n", r);
+ return 0;
+}
+
+static int run_initrd_list (const char *cmd, int argc, char *argv[])
+{
+ char **r;
+ const char *path;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ path = argv[0];
+ r = guestfs_initrd_list (g, path);
+ if (r == NULL) return -1;
+ print_strings (r);
+ free_strings (r);
+ return 0;
+}
+
+static int run_mount_loop (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *file;
+ const char *mountpoint;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ file = argv[0];
+ mountpoint = argv[1];
+ r = guestfs_mount_loop (g, file, mountpoint);
+ return r;
+}
+
+int run_action (const char *cmd, int argc, char *argv[])
+{
+ if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
+ return run_launch (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "kill_subprocess") == 0 || strcasecmp (cmd, "kill-subprocess") == 0)
+ return run_kill_subprocess (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "add_drive") == 0 || strcasecmp (cmd, "add-drive") == 0 || strcasecmp (cmd, "add") == 0)
+ return run_add_drive (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "add_cdrom") == 0 || strcasecmp (cmd, "add-cdrom") == 0 || strcasecmp (cmd, "cdrom") == 0)
+ return run_add_cdrom (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "add_drive_ro") == 0 || strcasecmp (cmd, "add-drive-ro") == 0 || strcasecmp (cmd, "add-ro") == 0)
+ return run_add_drive_ro (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "config") == 0)
+ return run_config (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_qemu") == 0 || strcasecmp (cmd, "set-qemu") == 0 || strcasecmp (cmd, "qemu") == 0)
+ return run_set_qemu (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_qemu") == 0 || strcasecmp (cmd, "get-qemu") == 0)
+ return run_get_qemu (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_path") == 0 || strcasecmp (cmd, "set-path") == 0 || strcasecmp (cmd, "path") == 0)
+ return run_set_path (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_path") == 0 || strcasecmp (cmd, "get-path") == 0)
+ return run_get_path (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_append") == 0 || strcasecmp (cmd, "set-append") == 0 || strcasecmp (cmd, "append") == 0)
+ return run_set_append (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_append") == 0 || strcasecmp (cmd, "get-append") == 0)
+ return run_get_append (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0)
+ return run_set_autosync (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_autosync") == 0 || strcasecmp (cmd, "get-autosync") == 0)
+ return run_get_autosync (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_verbose") == 0 || strcasecmp (cmd, "set-verbose") == 0 || strcasecmp (cmd, "verbose") == 0)
+ return run_set_verbose (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_verbose") == 0 || strcasecmp (cmd, "get-verbose") == 0)
+ return run_get_verbose (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_ready") == 0 || strcasecmp (cmd, "is-ready") == 0)
+ return run_is_ready (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_config") == 0 || strcasecmp (cmd, "is-config") == 0)
+ return run_is_config (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_launching") == 0 || strcasecmp (cmd, "is-launching") == 0)
+ return run_is_launching (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_busy") == 0 || strcasecmp (cmd, "is-busy") == 0)
+ return run_is_busy (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_state") == 0 || strcasecmp (cmd, "get-state") == 0)
+ return run_get_state (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mount") == 0)
+ return run_mount (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sync") == 0)
+ return run_sync (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "touch") == 0)
+ return run_touch (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "cat") == 0)
+ return run_cat (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "ll") == 0)
+ return run_ll (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "ls") == 0)
+ return run_ls (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "list_devices") == 0 || strcasecmp (cmd, "list-devices") == 0)
+ return run_list_devices (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "list_partitions") == 0 || strcasecmp (cmd, "list-partitions") == 0)
+ return run_list_partitions (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "pvs") == 0)
+ return run_pvs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "vgs") == 0)
+ return run_vgs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lvs") == 0)
+ return run_lvs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "pvs_full") == 0 || strcasecmp (cmd, "pvs-full") == 0)
+ return run_pvs_full (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "vgs_full") == 0 || strcasecmp (cmd, "vgs-full") == 0)
+ return run_vgs_full (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lvs_full") == 0 || strcasecmp (cmd, "lvs-full") == 0)
+ return run_lvs_full (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "read_lines") == 0 || strcasecmp (cmd, "read-lines") == 0)
+ return run_read_lines (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_init") == 0 || strcasecmp (cmd, "aug-init") == 0)
+ return run_aug_init (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_close") == 0 || strcasecmp (cmd, "aug-close") == 0)
+ return run_aug_close (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_defvar") == 0 || strcasecmp (cmd, "aug-defvar") == 0)
+ return run_aug_defvar (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_defnode") == 0 || strcasecmp (cmd, "aug-defnode") == 0)
+ return run_aug_defnode (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_get") == 0 || strcasecmp (cmd, "aug-get") == 0)
+ return run_aug_get (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_set") == 0 || strcasecmp (cmd, "aug-set") == 0)
+ return run_aug_set (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_insert") == 0 || strcasecmp (cmd, "aug-insert") == 0)
+ return run_aug_insert (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_rm") == 0 || strcasecmp (cmd, "aug-rm") == 0)
+ return run_aug_rm (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_mv") == 0 || strcasecmp (cmd, "aug-mv") == 0)
+ return run_aug_mv (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_match") == 0 || strcasecmp (cmd, "aug-match") == 0)
+ return run_aug_match (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_save") == 0 || strcasecmp (cmd, "aug-save") == 0)
+ return run_aug_save (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_load") == 0 || strcasecmp (cmd, "aug-load") == 0)
+ return run_aug_load (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "aug_ls") == 0 || strcasecmp (cmd, "aug-ls") == 0)
+ return run_aug_ls (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "rm") == 0)
+ return run_rm (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "rmdir") == 0)
+ return run_rmdir (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "rm_rf") == 0 || strcasecmp (cmd, "rm-rf") == 0)
+ return run_rm_rf (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mkdir") == 0)
+ return run_mkdir (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mkdir_p") == 0 || strcasecmp (cmd, "mkdir-p") == 0)
+ return run_mkdir_p (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "chmod") == 0)
+ return run_chmod (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "chown") == 0)
+ return run_chown (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "exists") == 0)
+ return run_exists (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_file") == 0 || strcasecmp (cmd, "is-file") == 0)
+ return run_is_file (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "is_dir") == 0 || strcasecmp (cmd, "is-dir") == 0)
+ return run_is_dir (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "pvcreate") == 0)
+ return run_pvcreate (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "vgcreate") == 0)
+ return run_vgcreate (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lvcreate") == 0)
+ return run_lvcreate (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mkfs") == 0)
+ return run_mkfs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sfdisk") == 0)
+ return run_sfdisk (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "write_file") == 0 || strcasecmp (cmd, "write-file") == 0)
+ return run_write_file (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "umount") == 0 || strcasecmp (cmd, "unmount") == 0)
+ return run_umount (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mounts") == 0)
+ return run_mounts (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "umount_all") == 0 || strcasecmp (cmd, "umount-all") == 0 || strcasecmp (cmd, "unmount-all") == 0)
+ return run_umount_all (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lvm_remove_all") == 0 || strcasecmp (cmd, "lvm-remove-all") == 0)
+ return run_lvm_remove_all (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "file") == 0)
+ return run_file (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "command") == 0)
+ return run_command (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "command_lines") == 0 || strcasecmp (cmd, "command-lines") == 0)
+ return run_command_lines (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "stat") == 0)
+ return run_stat (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lstat") == 0)
+ return run_lstat (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "statvfs") == 0)
+ return run_statvfs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "tune2fs_l") == 0 || strcasecmp (cmd, "tune2fs-l") == 0)
+ return run_tune2fs_l (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_setro") == 0 || strcasecmp (cmd, "blockdev-setro") == 0)
+ return run_blockdev_setro (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_setrw") == 0 || strcasecmp (cmd, "blockdev-setrw") == 0)
+ return run_blockdev_setrw (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_getro") == 0 || strcasecmp (cmd, "blockdev-getro") == 0)
+ return run_blockdev_getro (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_getss") == 0 || strcasecmp (cmd, "blockdev-getss") == 0)
+ return run_blockdev_getss (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_getbsz") == 0 || strcasecmp (cmd, "blockdev-getbsz") == 0)
+ return run_blockdev_getbsz (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_setbsz") == 0 || strcasecmp (cmd, "blockdev-setbsz") == 0)
+ return run_blockdev_setbsz (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_getsz") == 0 || strcasecmp (cmd, "blockdev-getsz") == 0)
+ return run_blockdev_getsz (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_getsize64") == 0 || strcasecmp (cmd, "blockdev-getsize64") == 0)
+ return run_blockdev_getsize64 (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_flushbufs") == 0 || strcasecmp (cmd, "blockdev-flushbufs") == 0)
+ return run_blockdev_flushbufs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "blockdev_rereadpt") == 0 || strcasecmp (cmd, "blockdev-rereadpt") == 0)
+ return run_blockdev_rereadpt (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "upload") == 0)
+ return run_upload (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "download") == 0)
+ return run_download (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "checksum") == 0)
+ return run_checksum (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "tar_in") == 0 || strcasecmp (cmd, "tar-in") == 0)
+ return run_tar_in (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "tar_out") == 0 || strcasecmp (cmd, "tar-out") == 0)
+ return run_tar_out (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "tgz_in") == 0 || strcasecmp (cmd, "tgz-in") == 0)
+ return run_tgz_in (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "tgz_out") == 0 || strcasecmp (cmd, "tgz-out") == 0)
+ return run_tgz_out (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mount_ro") == 0 || strcasecmp (cmd, "mount-ro") == 0)
+ return run_mount_ro (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mount_options") == 0 || strcasecmp (cmd, "mount-options") == 0)
+ return run_mount_options (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mount_vfs") == 0 || strcasecmp (cmd, "mount-vfs") == 0)
+ return run_mount_vfs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "debug") == 0)
+ return run_debug (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lvremove") == 0)
+ return run_lvremove (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "vgremove") == 0)
+ return run_vgremove (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "pvremove") == 0)
+ return run_pvremove (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_e2label") == 0 || strcasecmp (cmd, "set-e2label") == 0)
+ return run_set_e2label (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_e2label") == 0 || strcasecmp (cmd, "get-e2label") == 0)
+ return run_get_e2label (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "set_e2uuid") == 0 || strcasecmp (cmd, "set-e2uuid") == 0)
+ return run_set_e2uuid (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_e2uuid") == 0 || strcasecmp (cmd, "get-e2uuid") == 0)
+ return run_get_e2uuid (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "fsck") == 0)
+ return run_fsck (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "zero") == 0)
+ return run_zero (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "grub_install") == 0 || strcasecmp (cmd, "grub-install") == 0)
+ return run_grub_install (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "cp") == 0)
+ return run_cp (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "cp_a") == 0 || strcasecmp (cmd, "cp-a") == 0)
+ return run_cp_a (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mv") == 0)
+ return run_mv (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "drop_caches") == 0 || strcasecmp (cmd, "drop-caches") == 0)
+ return run_drop_caches (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "dmesg") == 0)
+ return run_dmesg (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "ping_daemon") == 0 || strcasecmp (cmd, "ping-daemon") == 0)
+ return run_ping_daemon (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "equal") == 0)
+ return run_equal (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "strings") == 0)
+ return run_strings (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "strings_e") == 0 || strcasecmp (cmd, "strings-e") == 0)
+ return run_strings_e (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "hexdump") == 0)
+ return run_hexdump (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "zerofree") == 0)
+ return run_zerofree (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "pvresize") == 0)
+ return run_pvresize (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sfdisk_N") == 0 || strcasecmp (cmd, "sfdisk-N") == 0)
+ return run_sfdisk_N (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sfdisk_l") == 0 || strcasecmp (cmd, "sfdisk-l") == 0)
+ return run_sfdisk_l (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sfdisk_kernel_geometry") == 0 || strcasecmp (cmd, "sfdisk-kernel-geometry") == 0)
+ return run_sfdisk_kernel_geometry (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sfdisk_disk_geometry") == 0 || strcasecmp (cmd, "sfdisk-disk-geometry") == 0)
+ return run_sfdisk_disk_geometry (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "vg_activate_all") == 0 || strcasecmp (cmd, "vg-activate-all") == 0)
+ return run_vg_activate_all (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "vg_activate") == 0 || strcasecmp (cmd, "vg-activate") == 0)
+ return run_vg_activate (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "lvresize") == 0)
+ return run_lvresize (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "resize2fs") == 0)
+ return run_resize2fs (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "find") == 0)
+ return run_find (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "e2fsck_f") == 0 || strcasecmp (cmd, "e2fsck-f") == 0)
+ return run_e2fsck_f (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sleep") == 0)
+ return run_sleep (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "ntfs_3g_probe") == 0 || strcasecmp (cmd, "ntfs-3g-probe") == 0)
+ return run_ntfs_3g_probe (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sh") == 0)
+ return run_sh (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "sh_lines") == 0 || strcasecmp (cmd, "sh-lines") == 0)
+ return run_sh_lines (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "glob_expand") == 0 || strcasecmp (cmd, "glob-expand") == 0)
+ return run_glob_expand (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "scrub_device") == 0 || strcasecmp (cmd, "scrub-device") == 0)
+ return run_scrub_device (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "scrub_file") == 0 || strcasecmp (cmd, "scrub-file") == 0)
+ return run_scrub_file (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "scrub_freespace") == 0 || strcasecmp (cmd, "scrub-freespace") == 0)
+ return run_scrub_freespace (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mkdtemp") == 0)
+ return run_mkdtemp (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "wc_l") == 0 || strcasecmp (cmd, "wc-l") == 0)
+ return run_wc_l (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "wc_w") == 0 || strcasecmp (cmd, "wc-w") == 0)
+ return run_wc_w (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "wc_c") == 0 || strcasecmp (cmd, "wc-c") == 0)
+ return run_wc_c (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "head") == 0)
+ return run_head (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "head_n") == 0 || strcasecmp (cmd, "head-n") == 0)
+ return run_head_n (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "tail") == 0)
+ return run_tail (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "tail_n") == 0 || strcasecmp (cmd, "tail-n") == 0)
+ return run_tail_n (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "df") == 0)
+ return run_df (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "df_h") == 0 || strcasecmp (cmd, "df-h") == 0)
+ return run_df_h (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "du") == 0)
+ return run_du (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "initrd_list") == 0 || strcasecmp (cmd, "initrd-list") == 0)
+ return run_initrd_list (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mount_loop") == 0 || strcasecmp (cmd, "mount-loop") == 0)
+ return run_mount_loop (cmd, argc, argv);