char *mountpoint;
};
+struct drv {
+ struct drv *next;
+ char *filename;
+};
+
+static void add_drives (struct drv *drv);
static void mount_mps (struct mp *mp);
static void interactive (void);
static void shell_script (void);
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
};
+ struct drv *drvs = NULL;
+ struct drv *drv;
struct mp *mps = NULL;
struct mp *mp;
char *p;
perror (optarg);
exit (1);
}
- if (guestfs_add_drive (g, optarg) == -1)
- exit (1);
+ drv = malloc (sizeof (struct drv));
+ if (!drv) {
+ perror ("malloc");
+ exit (1);
+ }
+ drv->filename = optarg;
+ drv->next = drvs;
+ drvs = drv;
break;
case 'h':
}
}
+ /* If we've got drives to add, add them now. */
+ add_drives (drvs);
+
/* If we've got mountpoints, we must launch the guest and mount them. */
if (mps != NULL) {
if (launch (g) == -1) exit (1);
}
static void
+add_drives (struct drv *drv)
+{
+ int r;
+
+ if (drv) {
+ add_drives (drv->next);
+ if (!read_only)
+ r = guestfs_add_drive (g, drv->filename);
+ else
+ r = guestfs_add_drive_ro (g, drv->filename);
+ if (r == -1)
+ exit (1);
+ }
+}
+
+static void
interactive (void)
{
script (1);