From owner-freebsd-current@FreeBSD.ORG Fri Sep 12 02:30:09 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 493471CA for ; Fri, 12 Sep 2014 02:30:09 +0000 (UTC) Received: from mail-lb0-x22d.google.com (mail-lb0-x22d.google.com [IPv6:2a00:1450:4010:c04::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B272689A for ; Fri, 12 Sep 2014 02:30:08 +0000 (UTC) Received: by mail-lb0-f173.google.com with SMTP id w7so95514lbi.18 for ; Thu, 11 Sep 2014 19:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clockworksquid.com; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=TxoZSwR6PnILR/uRVhvltcAMeAHJdnwzMNglsPuD1C0=; b=TNxh6R6H5UKQbebm/l/uipYT+Yydu3BOl+XqK0gRupEMC+IqO0F0GYkF+VA+mHRj7O RkfuFSIe+yXDr5lnRa8Lz/Xbl7dpx59bVDzjmxRB/suNCWX0eE3LU5p3jFCYgCgnnzi4 ca2AMQTxL5cFnDpSAE2FT24TqQwDPawV3986w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type; bh=TxoZSwR6PnILR/uRVhvltcAMeAHJdnwzMNglsPuD1C0=; b=QsAmIAOqL/wvx8lRZneIT7wDkyKuDW+0ZRDo9F6O9zT/btuzNEnlW5wQl920X3CkzW r9wOyFj+ktCz1yC0r4owpYi7AtN++iHZHuSN3dNr+0UKok2emnU7NbEbhSMEs/JzkVGn hPPmAh2hy9ZfL0t0O0WXVs+Z495i2fJPywEQM6XlRDu+LLVjPPAAXnLKCIyHLTSKklZi Y7oUJwWMZTDA0qEJR5zTAx9qfVNZf1ZGkDO3xSQcP6O6EnKRwmriwbIEBKyq9YUNvbqM HJrFmHLOEg+9rtZZ9dOtzPLgAr4AdLh3yABIdpngTdCMcFrNhUgaRSzse8MNJ+iiZz4y 1vag== X-Gm-Message-State: ALoCoQmhfDqw5Vwp5xar6rDL9h5b4hl/eGAY5bBwBBOS8FY2KutQl0dhSMTPD/zqxGKqhUoGHIxY X-Received: by 10.112.44.129 with SMTP id e1mr5193710lbm.78.1410489006637; Thu, 11 Sep 2014 19:30:06 -0700 (PDT) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.152.6.72 with HTTP; Thu, 11 Sep 2014 19:29:46 -0700 (PDT) In-Reply-To: References: From: Juli Mallett Date: Thu, 11 Sep 2014 19:29:46 -0700 X-Google-Sender-Auth: _AR2CszTUByP0E4yvvcE1fkqpVc Message-ID: Subject: Re: [PATCH] Unbreak makefs -M To: Garrett Cooper Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: Davide Italiano , "freebsd-fs@freebsd.org" , freebsd-current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Sep 2014 02:30:09 -0000 On Thu, Sep 11, 2014 at 7:26 PM, Garrett Cooper wrote: > On Thu, Sep 11, 2014 at 7:16 PM, Davide Italiano > wrote: > > r258695 introduces a sanity check for makefs in order to verify that > > minimum image size specified is always less than maximum image size. > > > > If makefs(1) is invoked specifying minimum image size, but not maximum > > one, the program exits with an error. Example: > > > > # sudo -E makefs -M 538968064 -B be /home/davide/disk.img $DESTDIR > > makefs: `/home/davide/tftproot/mips' minsize of 538968064 rounded up > > to ffs bsize of 8192 exceeds maxsize 0. Lower bsize, or round the > > minimum and maximum sizes to bsize. > > > > I guess it's meaningful to assert that minsize < maxsize iff maxsize > > is actually specified. The following patch tries to fix the problem. > > Visual inspection of code also shows that maxsize == 0 is treated as > > maxsize not specified. I'm not by any means familiar with makefs(1) > > code, so I may miss something here. > > > > % git diff > > diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c > > index 92d5508..83e9eae 100644 > > --- a/usr.sbin/makefs/ffs.c > > +++ b/usr.sbin/makefs/ffs.c > > @@ -361,7 +361,8 @@ ffs_validate(const char *dir, fsnode *root, > > fsinfo_t *fsopts) > > if (ffs_opts->avgfpdir == -1) > > ffs_opts->avgfpdir = AFPDIR; > > > > - if (roundup(fsopts->minsize, ffs_opts->bsize) > fsopts->maxsize) > > + if (fsopts->maxsize > 0 > > + && roundup(fsopts->minsize, ffs_opts->bsize) > > fsopts->maxsize) > > - Should roundup be used with fsopts->maxsize) ? > No. Maxsize is a hard limit, while minsize is always rounded up to at least the bsize. If you attempt to specify an improperly-rounded quantity as both the minimum and the maximum (for instance, because the bsize makefs decides to use has increased between executions), you'll always produce an image which is too large. That's exactly what this check was added to catch (and make less obtuse.) > - style(9): put the `&&` on the previous line. > > > errx(1, "`%s' minsize of %lld rounded up to ffs bsize of > %d " > > "exceeds maxsize %lld. Lower bsize, or round the > minimum " > > "and maximum sizes to bsize.", dir, > > This (and the other rev) should really be pushed back to NetBSD.. > > Thanks! > -Garrett >