From 5b45043e8cc72285f5f7077ae65e0ac98f40ec58 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 19 Aug 2010 14:58:03 +0100 Subject: [PATCH] Add -f option for selecting the output format. Only -f cpio is permitted by this commit. --- helper/febootstrap-supermin-helper.pod | 5 +++++ helper/main.c | 25 ++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/helper/febootstrap-supermin-helper.pod b/helper/febootstrap-supermin-helper.pod index 29f4b95..6a2551b 100644 --- a/helper/febootstrap-supermin-helper.pod +++ b/helper/febootstrap-supermin-helper.pod @@ -33,6 +33,11 @@ booting the appliance, and should be deleted straight afterwards. =over 4 +=item B<-f cpio> | B<--format cpio> + +Select the output format. The default, and only possible output +format, is C (ie. a Linux initramfs). + =item B<-k file> | B<--kmods file> If this option is specified, then C should be a list of diff --git a/helper/main.c b/helper/main.c index a448b9e..f5a06cc 100644 --- a/helper/main.c +++ b/helper/main.c @@ -36,11 +36,14 @@ struct timeval start_t; int verbose = 0; +static const char *format = "cpio"; + enum { HELP_OPTION = CHAR_MAX + 1 }; -static const char *options = "k:vV"; +static const char *options = "f:k:vV"; static const struct option long_options[] = { { "help", 0, 0, HELP_OPTION }, + { "format", required_argument, 0, 'f' }, { "kmods", required_argument, 0, 'k' }, { "verbose", 0, 0, 'v' }, { "version", 0, 0, 'V' }, @@ -68,6 +71,8 @@ usage (const char *progname) "Options:\n" " --help\n" " Display this help text and exit.\n" + " -f cpio | --format cpio\n" + " Specify output format (default: cpio).\n" " -k file | --kmods file\n" " Specify kernel module whitelist.\n" " --verbose | -v\n" @@ -95,6 +100,10 @@ main (int argc, char *argv[]) usage (argv[0]); exit (EXIT_SUCCESS); + case 'f': + format = optarg; + break; + case 'k': whitelist = optarg; break; @@ -113,6 +122,17 @@ main (int argc, char *argv[]) } } + /* Select the correct writer module. */ + struct writer *writer; + + if (strcmp (format, "cpio") == 0) + writer = &cpio_writer; + else { + fprintf (stderr, "%s: incorrect output format (-f): must be cpio\n", + argv[0]); + exit (EXIT_FAILURE); + } + char **inputs = &argv[optind]; int nr_inputs = argc - optind - 3; @@ -152,8 +172,7 @@ main (int argc, char *argv[]) print_timestamped_message ("finished creating kernel"); /* Create the appliance. */ - create_appliance (inputs, nr_inputs, whitelist, modpath, appliance, - &cpio_writer); + create_appliance (inputs, nr_inputs, whitelist, modpath, appliance, writer); if (verbose) print_timestamped_message ("finished creating appliance"); -- 1.8.3.1