diff options
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/mkubootimage/mkubootimage.1 | 7 | ||||
| -rw-r--r-- | usr.bin/mkubootimage/mkubootimage.c | 19 |
2 files changed, 20 insertions, 6 deletions
diff --git a/usr.bin/mkubootimage/mkubootimage.1 b/usr.bin/mkubootimage/mkubootimage.1 index 0329095c432..6771e734514 100644 --- a/usr.bin/mkubootimage/mkubootimage.1 +++ b/usr.bin/mkubootimage/mkubootimage.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: mkubootimage.1,v 1.12 2018/02/04 15:44:51 jmcneill Exp $ +.\" $NetBSD: mkubootimage.1,v 1.12.6.1 2019/12/09 15:19:30 martin Exp $ .\" .\" Copyright (c) 2012 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 4, 2018 +.Dd December 4, 2019 .Dt MKUBOOTIMAGE 1 .Os .Sh NAME @@ -46,6 +46,7 @@ .Fl n Ar image .Op Fl O Po freebsd Ns | Ns linux Ns | Ns netbsd Ns | Ns openbsd Pc .Fl T No ( fs Ns | Ns kernel Ns | Ns kernel_noload Ns | Ns ramdisk Ns | Ns standalone ) +.Op Fl u .Ar source destination .\" .Sh DESCRIPTION @@ -124,6 +125,8 @@ Defines the image type. This is required for .Qq uimg format images. +.It Fl u +Update the header in an existing file instead of creating a new one. .El .Pp The required diff --git a/usr.bin/mkubootimage/mkubootimage.c b/usr.bin/mkubootimage/mkubootimage.c index 79a0dce79a2..f7419d2a6a3 100644 --- a/usr.bin/mkubootimage/mkubootimage.c +++ b/usr.bin/mkubootimage/mkubootimage.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkubootimage.c,v 1.24 2018/02/04 17:33:34 jmcneill Exp $ */ +/* $NetBSD: mkubootimage.c,v 1.24.6.1 2019/12/09 15:19:30 martin Exp $ */ /*- * Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca> @@ -30,7 +30,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: mkubootimage.c,v 1.24 2018/02/04 17:33:34 jmcneill Exp $"); +__RCSID("$NetBSD: mkubootimage.c,v 1.24.6.1 2019/12/09 15:19:30 martin Exp $"); #include <sys/mman.h> #include <sys/stat.h> @@ -74,6 +74,7 @@ static uint32_t image_entrypoint = 0; static char *image_name; static uint32_t image_magic = IH_MAGIC; static enum image_format image_format = FMT_UIMG; +static int update_image = 0; static const struct uboot_image_format { enum image_format format; @@ -269,7 +270,7 @@ usage(void) fprintf(stderr, " -O <openbsd|netbsd|freebsd|linux>"); fprintf(stderr, " -T <standalone|kernel|kernel_noload|ramdisk|fs|script>"); fprintf(stderr, " -a <addr> [-e <ep>] [-m <magic>] -n <name>"); - fprintf(stderr, " [-f <uimg|arm64>]"); + fprintf(stderr, " [-f <uimg|arm64>] [-u]"); fprintf(stderr, " <srcfile> <dstfile>\n"); exit(EXIT_FAILURE); @@ -431,6 +432,13 @@ write_image(void *hdr, size_t hdrlen, int kernel_fd, int image_fd) } } + if (update_image) { + if (lseek(kernel_fd, hdrlen, SEEK_SET) != (off_t)hdrlen) { + perror("seek failed"); + return errno; + } + } + while ((rlen = read(kernel_fd, buf, sizeof(buf))) > 0) { wlen = write(image_fd, buf, rlen); if (wlen != rlen) { @@ -453,7 +461,7 @@ main(int argc, char *argv[]) int ch; unsigned long long num; - while ((ch = getopt(argc, argv, "A:C:E:O:T:a:e:f:hm:n:")) != -1) { + while ((ch = getopt(argc, argv, "A:C:E:O:T:a:e:f:hm:n:u")) != -1) { switch (ch) { case 'A': /* arch */ image_arch = get_arch(optarg); @@ -504,6 +512,9 @@ main(int argc, char *argv[]) case 'n': /* name */ image_name = strdup(optarg); break; + case 'u': /* update image */ + update_image = 1; + break; case 'h': default: usage(); |
