fish: Make type == drv_N field private to guestfish.

The -N option / drv_N type only makes sense when we are compiling
guestfish, and just serves to complicate non-guestfish code.
This commit is contained in:
Richard W.M. Jones
2012-11-29 11:44:50 +00:00
parent 9e7daf2ee8
commit 380ce2eeaa
4 changed files with 12 additions and 2 deletions

View File

@@ -325,7 +325,6 @@ single_drive_display_name (struct drv *drvs)
case drv_d:
name = drvs->d.guest;
break;
case drv_N:
default:
abort ();
}

View File

@@ -120,6 +120,7 @@ cmds-gperf.c: cmds-gperf.gperf
mv $@-t $@
guestfish_CFLAGS = \
-DCOMPILING_GUESTFISH=1 \
-DGUESTFS_WARN_DEPRECATED=1 \
-I$(top_srcdir)/src -I$(top_builddir)/src \
-I$(top_srcdir)/fish -I$(top_builddir)/fish \

View File

@@ -79,6 +79,7 @@ add_drives (struct drv *drv, char next_drive)
next_drive += r;
break;
#if COMPILING_GUESTFISH
case drv_N:
/* guestfs_add_drive (ie. autodetecting) should be safe here
* since we have just created the prepared disk. At the moment
@@ -93,6 +94,7 @@ add_drives (struct drv *drv, char next_drive)
drv->nr_drives = 1;
next_drive++;
break;
#endif
default: /* keep GCC happy */
abort ();
@@ -181,10 +183,12 @@ free_drives (struct drv *drv)
switch (drv->type) {
case drv_a: /* a.filename and a.format are optargs, don't free them */ break;
case drv_d: /* d.filename is optarg, don't free it */ break;
#if COMPILING_GUESTFISH
case drv_N:
free (drv->N.filename);
drv->N.data_free (drv->N.data);
break;
#endif
default: ; /* keep GCC happy */
}
free (drv);

View File

@@ -80,7 +80,13 @@ struct drv {
*/
int nr_drives; /* number of drives for this guest */
enum { drv_a, drv_d, drv_N } type;
enum {
drv_a, /* -a option */
drv_d, /* -d option */
#if COMPILING_GUESTFISH
drv_N, /* -N option (guestfish only) */
#endif
} type;
union {
struct {
char *filename; /* disk filename */