svn commit: r265626 - user/marcel/mkimg

Marcel Moolenaar marcel at FreeBSD.org
Thu May 8 01:43:34 UTC 2014


Author: marcel
Date: Thu May  8 01:43:33 2014
New Revision: 265626
URL: http://svnweb.freebsd.org/changeset/base/265626

Log:
  Add the -f option for specifying the output format. Update the manpage
  accordingly. Print the scheme and the format when running verbose.

Modified:
  user/marcel/mkimg/mkimg.1
  user/marcel/mkimg/mkimg.c

Modified: user/marcel/mkimg/mkimg.1
==============================================================================
--- user/marcel/mkimg/mkimg.1	Thu May  8 01:13:18 2014	(r265625)
+++ user/marcel/mkimg/mkimg.1	Thu May  8 01:43:33 2014	(r265626)
@@ -37,6 +37,7 @@
 .Op Fl S Ar secsz
 .Op Fl T Ar tracksz
 .Op Fl b Ar bootcode
+.Op Fl f Ar format
 .Op Fl o Ar outfile
 .Op Fl v
 .Fl s Ar scheme
@@ -56,6 +57,10 @@ The disk image is written to
 by default or the file specified with the
 .Ar outfile
 argument.
+The image file is a raw disk image by default, but the format of the
+image file can be specified with the
+.Ar format
+argument.
 .Pp
 The disk image can be made bootable by specifying the scheme-specific boot
 block contents with the
@@ -106,8 +111,8 @@ option increases the level of output tha
 .Nm
 utility prints.
 .Pp
-For a complete list of supported partitioning schemes or for a detailed
-description of how to specify partitions, run the
+For a complete list of supported partitioning schemes or supported output
+format, or for a detailed description of how to specify partitions, run the
 .Nm
 utility without any arguments.
 .Sh EXAMPLES

Modified: user/marcel/mkimg/mkimg.c
==============================================================================
--- user/marcel/mkimg/mkimg.c	Thu May  8 01:13:18 2014	(r265625)
+++ user/marcel/mkimg/mkimg.c	Thu May  8 01:43:33 2014	(r265626)
@@ -69,6 +69,7 @@ usage(const char *why)
 
 	fprintf(stderr, "    options:\n");
 	fprintf(stderr, "\t-b <file>\t-  file containing boot code\n");
+	fprintf(stderr, "\t-f <format>\n");
 	fprintf(stderr, "\t-o <file>\t-  file to write image into\n");
 	fprintf(stderr, "\t-p <partition>\n");
 	fprintf(stderr, "\t-s <scheme>\n");
@@ -326,7 +327,7 @@ main(int argc, char *argv[])
 
 	bcfd = -1;
 	outfd = 1;	/* Write to stdout by default */
-	while ((c = getopt(argc, argv, "b:o:p:s:vH:P:S:T:")) != -1) {
+	while ((c = getopt(argc, argv, "b:f:o:p:s:vH:P:S:T:")) != -1) {
 		switch (c) {
 		case 'b':	/* BOOT CODE */
 			if (bcfd != -1)
@@ -335,6 +336,13 @@ main(int argc, char *argv[])
 			if (bcfd == -1)
 				err(EX_UNAVAILABLE, "%s", optarg);
 			break;
+		case 'f':	/* OUTPUT FORMAT */
+			if (format_selected() != NULL)
+				usage("multiple formats given");
+			error = format_select(optarg);
+			if (error)
+				errc(EX_DATAERR, error, "format");
+			break;
 		case 'o':	/* OUTPUT FILE */
 			if (outfd != 1)
 				usage("multiple output files given");
@@ -409,6 +417,9 @@ main(int argc, char *argv[])
 		errx(EX_DATAERR, "%d partitions supported; %d given",
 		    scheme_max_parts(), nparts);
 
+	if (format_selected() == NULL)
+		format_select("raw");
+
 	if (bcfd != -1) {
 		error = scheme_bootcode(bcfd);
 		close(bcfd);
@@ -421,6 +432,12 @@ main(int argc, char *argv[])
 		fprintf(stderr, "Physical block size: %u\n", blksz);
 		fprintf(stderr, "Sectors per track:   %u\n", nsecs);
 		fprintf(stderr, "Number of heads:     %u\n", nheads);
+		fputc('\n', stderr);
+		fprintf(stderr, "Partitioning scheme: %s\n",
+		    scheme_selected()->name);
+		fprintf(stderr, "Output file format:  %s\n",
+		    format_selected()->name);
+		fputc('\n', stderr);
 	}
 
 	error = image_init();
@@ -429,8 +446,10 @@ main(int argc, char *argv[])
 
 	mkimg();
 
-	if (verbose)
+	if (verbose) {
+		fputc('\n', stderr);
 		fprintf(stderr, "Number of cylinders: %u\n", ncyls);
+	}
 
 	error = image_copyout(outfd);
 	if (error)


More information about the svn-src-user mailing list