From owner-freebsd-current@FreeBSD.ORG Fri Sep 12 02:26:51 2014 Return-Path: Delivered-To: freebsd-current@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 A0318F7E; Fri, 12 Sep 2014 02:26:51 +0000 (UTC) Received: from mail-ie0-x235.google.com (mail-ie0-x235.google.com [IPv6:2607:f8b0:4001:c03::235]) (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 5302886F; Fri, 12 Sep 2014 02:26:51 +0000 (UTC) Received: by mail-ie0-f181.google.com with SMTP id lx4so112302iec.26 for ; Thu, 11 Sep 2014 19:26:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+IPGGKUx7DJdoSJpfwe7G75RyUBaNLvSSarUmeD87c0=; b=ZmS4UTbtxssFInkk9iERMkYDeDyWsTTr5M91ndrgZ2pSjfw024XqYUY8nhSaDX89Lw sP7VVhGa0UePIA3JpfMjbtkEmBSzqG5SR8c7wRoLkqONoI8qMGApA8zk1g+yJXJz+ZVB 3uV5EycA1uADAqL9tdC0MsJ/Bf2K/Yr+I5mg79BU0TiJKBEZ71Uvtjg7cEn8Al+ovXAk nZDOWOa1rKceRuLTEICkBMSioRV7wPDRwqKB7y9bDkR1lZ2tcp/RsQhCgHPH+HKdyTnE YFC5dWfpL0MzpM0ulQFWFep6EZbSFdW0gTwqo0vBZiA+L7pVXF2Hdu6+JwQEm3bH/ruC BmUg== MIME-Version: 1.0 X-Received: by 10.50.127.145 with SMTP id ng17mr6727501igb.26.1410488810294; Thu, 11 Sep 2014 19:26:50 -0700 (PDT) Received: by 10.50.72.69 with HTTP; Thu, 11 Sep 2014 19:26:50 -0700 (PDT) In-Reply-To: References: Date: Thu, 11 Sep 2014 19:26:50 -0700 Message-ID: Subject: Re: [PATCH] Unbreak makefs -M From: Garrett Cooper To: Davide Italiano Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-fs@freebsd.org" , jmallett@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:26:51 -0000 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) ? - 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