summaryrefslogtreecommitdiffstats
path: root/usr.bin/mkimg/mkimg.c
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2014-07-28 02:07:16 +0000
committermarcel <marcel@FreeBSD.org>2014-07-28 02:07:16 +0000
commit37a9f7be2fd32cf24c75d466cacac9ce83a3766b (patch)
tree66e64f422d8c9a6302c783fe4783cf8ee5e22044 /usr.bin/mkimg/mkimg.c
parent920342975e733e6db05ffe8353ba9a3d29fffb23 (diff)
downloadFreeBSD-src-37a9f7be2fd32cf24c75d466cacac9ce83a3766b.zip
FreeBSD-src-37a9f7be2fd32cf24c75d466cacac9ce83a3766b.tar.gz
MFC r268236,268264,268524,268646,268802,269021:
This brings VHD support to mkimg(1); both dynamic and fixed file formats. Dynamic VHD and VMDK file images are now sparsely written, meaning that "free" sectors do not occupy space. Relnotes: yes
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