2014-03-29 19:03:10 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
2014-09-20 21:02:54 +00:00
|
|
|
.include <src.opts.mk>
|
|
|
|
|
2014-03-29 19:03:10 +00:00
|
|
|
PROG= mkimg
|
2014-05-15 19:19:57 +00:00
|
|
|
SRCS= format.c image.c mkimg.c scheme.c
|
2014-03-29 19:03:10 +00:00
|
|
|
MAN= mkimg.1
|
|
|
|
|
Improve performance of mking(1) by keeping a list of "chunks" in memory,
that keeps track of a particular region of the image. In particular the
image_data() function needs to return to the caller whether a region
contains data or is all zeroes. This required reading the region from
the temporary file and comparing the bytes. When image_data() is used
multiple times for the same region, this will get painful fast.
With a chunk describing a region of the image, we now also have a way
to refer to the image provided on the command line. This means we don't
need to copy the image into a temporary file. We just keep track of the
file descriptor and offset within the source file on a per-chunk basis.
For streams (pipes, sockets, fifos, etc) we now use the temporary file
as a swap file. We read from the input file and create a chunk of type
"zeroes" for each sequence of zeroes that's a multiple of the sector
size. Otherwise, we allocte from the swap file, mmap(2) it, read into
the mmap(2)'d memory and create a chunk representing data.
For regular files, we use SEEK_HOLE and SEEK_DATA to handle sparse files
eficiently and create a chunk of type zeroes for holes and a chunk of
type data for data regions. For data regions, we still compare the bytes
we read to handle differences between a file system's block size and our
sector size.
After reading all files, image_write() is used by schemes to scribble in
the reserved sectors. Since this never amounts to much, keep this data
in memory in chunks of exactly 1 sector.
The output image is created by looking using the chunk list to find the
data and write it out to the output file. For chunks of type "zeroes"
we prefer to seek, but fall back to writing zeroes to handle pipes.
For chunks of type "file" and "memoty" we simply write.
The net effect of this is that for reasonably large images the execution
time drops from 1-2 minutes to 10-20 seconds. A typical speedup is about
5 to 8 times, depending on partition sizes, output format whether in
input files are sparse or not.
Bump version to 20141001.
2014-10-01 21:03:17 +00:00
|
|
|
MKIMG_VERSION=20141001
|
2014-09-27 04:53:51 +00:00
|
|
|
CFLAGS+=-DMKIMG_VERSION=${MKIMG_VERSION}
|
2014-03-29 19:03:10 +00:00
|
|
|
CFLAGS+=-DSPARSE_WRITE
|
|
|
|
|
2014-05-15 19:19:57 +00:00
|
|
|
# List of formats to support
|
|
|
|
SRCS+= \
|
2014-09-22 15:05:28 +00:00
|
|
|
qcow.c \
|
2014-05-15 19:19:57 +00:00
|
|
|
raw.c \
|
2014-07-03 20:31:43 +00:00
|
|
|
vhd.c \
|
2014-05-15 19:19:57 +00:00
|
|
|
vmdk.c
|
|
|
|
|
2014-03-29 19:03:10 +00:00
|
|
|
# List of schemes to support
|
|
|
|
SRCS+= \
|
|
|
|
apm.c \
|
|
|
|
bsd.c \
|
|
|
|
ebr.c \
|
|
|
|
gpt.c \
|
|
|
|
mbr.c \
|
|
|
|
pc98.c \
|
|
|
|
vtoc8.c
|
|
|
|
|
|
|
|
BINDIR?=/usr/bin
|
|
|
|
|
|
|
|
DPADD= ${LIBUTIL}
|
|
|
|
LDADD= -lutil
|
|
|
|
|
|
|
|
WARNS?= 6
|
|
|
|
|
2014-09-20 21:02:54 +00:00
|
|
|
.if ${MK_TESTS} != "no"
|
|
|
|
SUBDIR+= tests
|
|
|
|
.endif
|
|
|
|
|
2014-03-29 19:03:10 +00:00
|
|
|
.include <bsd.prog.mk>
|