From owner-svn-src-user@FreeBSD.ORG Thu Mar 27 20:14:41 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 961208D4; Thu, 27 Mar 2014 20:14:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 82E12F09; Thu, 27 Mar 2014 20:14:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2RKEfBK059550; Thu, 27 Mar 2014 20:14:41 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2RKEfWt059548; Thu, 27 Mar 2014 20:14:41 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201403272014.s2RKEfWt059548@svn.freebsd.org> From: Marcel Moolenaar Date: Thu, 27 Mar 2014 20:14:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r263831 - user/marcel/mkimg X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Mar 2014 20:14:41 -0000 Author: marcel Date: Thu Mar 27 20:14:40 2014 New Revision: 263831 URL: http://svnweb.freebsd.org/changeset/base/263831 Log: 1. Add -v option to increase vebosity levels 2. Fix copy-paste bug -- acrually check secsz for being a power of 2 3. Check secsz and blksz parameters 4. Print the sector and block size when -v is given Modified: user/marcel/mkimg/mkimg.c user/marcel/mkimg/mkimg.h Modified: user/marcel/mkimg/mkimg.c ============================================================================== --- user/marcel/mkimg/mkimg.c Thu Mar 27 20:13:53 2014 (r263830) +++ user/marcel/mkimg/mkimg.c Thu Mar 27 20:14:40 2014 (r263831) @@ -50,11 +50,13 @@ __FBSDID("$FreeBSD$"); struct partlisthead partlist = STAILQ_HEAD_INITIALIZER(partlist); u_int nparts = 0; +u_int verbose; + u_int ncyls = 0; u_int nheads = 1; u_int nsecs = 1; u_int secsz = 512; -u_int blksz = 512; +u_int blksz = 0; static int bcfd = -1; static int outfd = 0; @@ -270,10 +272,6 @@ mkimg(int bfd) off_t bytesize; int error, fd; - if (nparts > scheme_max_parts()) - errc(EX_DATAERR, ENOSPC, "only %d partitions are supported", - scheme_max_parts()); - error = scheme_bootcode(bfd); if (error) errc(EX_DATAERR, error, "boot code"); @@ -325,7 +323,7 @@ main(int argc, char *argv[]) { int c, error; - while ((c = getopt(argc, argv, "b:o:p:s:zH:P:S:T:")) != -1) { + while ((c = getopt(argc, argv, "b:o:p:s:vzH:P:S:T:")) != -1) { switch (c) { case 'b': /* BOOT CODE */ if (bcfd != -1) @@ -354,6 +352,9 @@ main(int argc, char *argv[]) if (error) errc(EX_DATAERR, error, "scheme"); break; + case 'v': + verbose++; + break; case 'z': /* SPARSE OUTPUT */ break; case 'H': /* GEOMETRY: HEADS */ @@ -370,7 +371,7 @@ main(int argc, char *argv[]) break; case 'S': /* GEOMETRY: LOGICAL SECTOR SIZE */ error = parse_number(&secsz, 512, INT_MAX + 1, optarg); - if (error == 0 && !pwr_of_two(blksz)) + if (error == 0 && !pwr_of_two(secsz)) error = EINVAL; if (error) errc(EX_DATAERR, error, "logical sector size"); @@ -384,6 +385,7 @@ main(int argc, char *argv[]) usage("unknown option"); } } + if (argc > optind) usage("trailing arguments"); if (scheme_selected() == NULL) @@ -391,6 +393,21 @@ main(int argc, char *argv[]) if (nparts == 0) usage("no partitions"); + if (secsz > blksz) { + if (blksz != 0) + errx(EX_DATAERR, "the physical block size cannot " + "be smaller than the sector size"); + blksz = secsz; + } + + if (secsz > scheme_max_secsz()) + errx(EX_DATAERR, "maximum sector size supported is %u; " + "size specified is %u", scheme_max_secsz(), secsz); + + if (nparts > scheme_max_parts()) + errx(EX_DATAERR, "%d partitions supported; %d given", + scheme_max_parts(), nparts); + if (outfd == 0) { if (atexit(cleanup) == -1) err(EX_OSERR, "cannot register cleanup function"); @@ -401,6 +418,11 @@ main(int argc, char *argv[]) } else tmpfd = outfd; + if (verbose) { + printf("Logical sector size: %u\n", secsz); + printf("Physical block size: %u\n", blksz); + } + mkimg(bcfd); if (tmpfd != outfd) { Modified: user/marcel/mkimg/mkimg.h ============================================================================== --- user/marcel/mkimg/mkimg.h Thu Mar 27 20:13:53 2014 (r263830) +++ user/marcel/mkimg/mkimg.h Thu Mar 27 20:14:40 2014 (r263831) @@ -52,6 +52,8 @@ struct part { extern STAILQ_HEAD(partlisthead, part) partlist; extern u_int nparts; +extern u_int verbose; + extern u_int ncyls; extern u_int nheads; extern u_int nsecs;