From 380ce2eeaab5d37e5343aa2ba1fcde755ecefa23 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 29 Nov 2012 11:44:50 +0000 Subject: 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. --- df/main.c | 1 - fish/Makefile.am | 1 + fish/options.c | 4 ++++ fish/options.h | 8 +++++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/df/main.c b/df/main.c index 1ed27056..ce32a37a 100644 --- a/df/main.c +++ b/df/main.c @@ -325,7 +325,6 @@ single_drive_display_name (struct drv *drvs) case drv_d: name = drvs->d.guest; break; - case drv_N: default: abort (); } diff --git a/fish/Makefile.am b/fish/Makefile.am index aa1b0980..b0bf6581 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -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 \ diff --git a/fish/options.c b/fish/options.c index 0db790e1..40671b5f 100644 --- a/fish/options.c +++ b/fish/options.c @@ -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); diff --git a/fish/options.h b/fish/options.h index 29117f64..137b2d72 100644 --- a/fish/options.h +++ b/fish/options.h @@ -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 */ -- cgit