Date: Sun, 22 Feb 2015 01:20:50 +0000 (UTC) From: Marcel Moolenaar <marcel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279128 - head/usr.bin/mkimg Message-ID: <201502220120.t1M1Ko8S096107@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcel Date: Sun Feb 22 01:20:49 2015 New Revision: 279128 URL: https://svnweb.freebsd.org/changeset/base/279128 Log: Don't require a scheme if no partitions are given. Change the code to handle that case. Note that we still require partitions, so the change is effectively a no-op. Modified: head/usr.bin/mkimg/mkimg.c head/usr.bin/mkimg/scheme.c Modified: head/usr.bin/mkimg/mkimg.c ============================================================================== --- head/usr.bin/mkimg/mkimg.c Sun Feb 22 01:15:09 2015 (r279127) +++ head/usr.bin/mkimg/mkimg.c Sun Feb 22 01:20:49 2015 (r279128) @@ -541,7 +541,7 @@ main(int argc, char *argv[]) if (argc > optind) usage("trailing arguments"); - if (scheme_selected() == NULL) + if (scheme_selected() == NULL && nparts > 0) usage("no scheme"); if (nparts == 0) usage("no partitions"); @@ -577,8 +577,9 @@ main(int argc, char *argv[]) fprintf(stderr, "Sectors per track: %u\n", nsecs); fprintf(stderr, "Number of heads: %u\n", nheads); fputc('\n', stderr); - fprintf(stderr, "Partitioning scheme: %s\n", - scheme_selected()->name); + if (scheme_selected()) + fprintf(stderr, "Partitioning scheme: %s\n", + scheme_selected()->name); fprintf(stderr, "Output file format: %s\n", format_selected()->name); fputc('\n', stderr); Modified: head/usr.bin/mkimg/scheme.c ============================================================================== --- head/usr.bin/mkimg/scheme.c Sun Feb 22 01:15:09 2015 (r279127) +++ head/usr.bin/mkimg/scheme.c Sun Feb 22 01:20:49 2015 (r279128) @@ -31,8 +31,10 @@ __FBSDID("$FreeBSD$"); #include <sys/linker_set.h> #include <sys/queue.h> #include <sys/stat.h> +#include <assert.h> #include <err.h> #include <errno.h> +#include <limits.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -104,7 +106,7 @@ scheme_bootcode(int fd) { struct stat sb; - if (scheme->bootcode == 0) + if (scheme == NULL || scheme->bootcode == 0) return (ENXIO); if (fstat(fd, &sb) == -1) @@ -130,6 +132,8 @@ scheme_check_part(struct part *p) struct mkimg_alias *iter; enum alias alias; + assert(scheme != NULL); + /* Check the partition type alias */ alias = scheme_parse_alias(p->alias); if (alias == ALIAS_NONE) @@ -158,28 +162,26 @@ u_int scheme_max_parts(void) { - return (scheme->nparts); + return ((scheme == NULL) ? 0 : scheme->nparts); } u_int scheme_max_secsz(void) { - return (scheme->maxsecsz); + return ((scheme == NULL) ? INT_MAX+1U : scheme->maxsecsz); } lba_t scheme_metadata(u_int where, lba_t start) { - return (scheme->metadata(where, start)); + return ((scheme == NULL) ? start : scheme->metadata(where, start)); } int scheme_write(lba_t end) { - int error; - error = scheme->write(end, bootcode); - return (error); + return ((scheme == NULL) ? 0 : scheme->write(end, bootcode)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502220120.t1M1Ko8S096107>