Index: usr.bin/mkubootimage/mkubootimage.c =================================================================== RCS file: /cvsroot/src/usr.bin/mkubootimage/mkubootimage.c,v retrieving revision 1.7 diff -u -r1.7 mkubootimage.c --- usr.bin/mkubootimage/mkubootimage.c 8 Jun 2011 05:54:38 -0000 1.7 +++ usr.bin/mkubootimage/mkubootimage.c 1 Aug 2011 04:29:30 -0000 @@ -60,6 +60,7 @@ static uint32_t image_loadaddr = 0; static uint32_t image_entrypoint = 0; static char *image_name; +static uint32_t image_magic = IH_MAGIC; struct uboot_os { enum uboot_image_os os; @@ -211,7 +212,7 @@ fprintf(stderr, " -C "); fprintf(stderr, " -O "); fprintf(stderr, " -T "); - fprintf(stderr, " -a [-e ] -n "); + fprintf(stderr, " -a [-e ] [-m ] -n "); fprintf(stderr, " \n"); exit(EXIT_FAILURE); @@ -268,7 +269,7 @@ munmap(p, st.st_size); memset(hdr, 0, sizeof(*hdr)); - hdr->ih_magic = htonl(IH_MAGIC); + hdr->ih_magic = htonl(image_magic); hdr->ih_time = htonl(st.st_mtime); hdr->ih_size = htonl(st.st_size); hdr->ih_load = htonl(image_loadaddr); @@ -320,7 +321,7 @@ int ch; unsigned long num; - while ((ch = getopt(argc, argv, "A:C:O:T:a:e:hn:")) != -1) { + while ((ch = getopt(argc, argv, "A:C:O:T:a:e:hm:n:")) != -1) { switch (ch) { case 'A': /* arch */ image_arch = get_arch(optarg); @@ -350,6 +351,13 @@ errx(1, "illegal number -- %s", optarg); image_entrypoint = (uint32_t)num; break; + case 'm': /* magic */ + errno = 0; + num = strtoul(optarg, &ep, 0); + if (*ep != '\0' || (errno == ERANGE && + (num == ULONG_MAX || num == 0))) + errx(1, "illegal number -- %s", optarg); + image_magic = (uint32_t)num; case 'n': /* name */ image_name = strdup(optarg); break;