+ 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;
+}
+
+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_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);