summaryrefslogtreecommitdiffstats
path: root/usr.bin/mkimg/mkimg.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mkimg/mkimg.c')
-rw-r--r--usr.bin/mkimg/mkimg.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c
index 45d09d5..4513e66 100644
--- a/usr.bin/mkimg/mkimg.c
+++ b/usr.bin/mkimg/mkimg.c
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/uuid.h>
#include <errno.h>
#include <err.h>
#include <fcntl.h>
@@ -50,6 +51,7 @@ __FBSDID("$FreeBSD$");
struct partlisthead partlist = STAILQ_HEAD_INITIALIZER(partlist);
u_int nparts = 0;
+u_int unit_testing;
u_int verbose;
u_int ncyls = 0;
@@ -73,6 +75,8 @@ usage(const char *why)
fprintf(stderr, "\t-o <file>\t- file to write image into\n");
fprintf(stderr, "\t-p <partition>\n");
fprintf(stderr, "\t-s <scheme>\n");
+ fprintf(stderr, "\t-v\t\t- increase verbosity\n");
+ fprintf(stderr, "\t-y\t\t- [developers] enable unit test\n");
fprintf(stderr, "\t-H <num>\t- number of heads to simulate\n");
fprintf(stderr, "\t-P <num>\t- physical sector size\n");
fprintf(stderr, "\t-S <num>\t- logical sector size\n");
@@ -258,6 +262,22 @@ sparse_write(int fd, const void *ptr, size_t sz)
}
#endif /* SPARSE_WRITE */
+void
+mkimg_uuid(struct uuid *uuid)
+{
+ static uint8_t gen[sizeof(struct uuid)];
+ u_int i;
+
+ if (!unit_testing) {
+ uuidgen(uuid, 1);
+ return;
+ }
+
+ for (i = 0; i < sizeof(gen); i++)
+ gen[i]++;
+ memcpy(uuid, gen, sizeof(uuid_t));
+}
+
static void
mkimg(void)
{
@@ -337,7 +357,7 @@ main(int argc, char *argv[])
bcfd = -1;
outfd = 1; /* Write to stdout by default */
- while ((c = getopt(argc, argv, "b:f:o:p:s:vH:P:S:T:")) != -1) {
+ while ((c = getopt(argc, argv, "b:f:o:p:s:vyH:P:S:T:")) != -1) {
switch (c) {
case 'b': /* BOOT CODE */
if (bcfd != -1)
@@ -373,6 +393,9 @@ main(int argc, char *argv[])
if (error)
errc(EX_DATAERR, error, "scheme");
break;
+ case 'y':
+ unit_testing++;
+ break;
case 'v':
verbose++;
break;
OpenPOWER on IntegriCloud