From owner-freebsd-fs@FreeBSD.ORG Fri Sep 12 02:16:23 2014 Return-Path: Delivered-To: freebsd-fs@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 C70B3BCA; Fri, 12 Sep 2014 02:16:23 +0000 (UTC) Received: from mail-la0-x231.google.com (mail-la0-x231.google.com [IPv6:2a00:1450:4010:c03::231]) (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 F099C77C; Fri, 12 Sep 2014 02:16:22 +0000 (UTC) Received: by mail-la0-f49.google.com with SMTP id pv20so84974lab.22 for ; Thu, 11 Sep 2014 19:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:cc:content-type; bh=IbUNS6cZRE+p8moAtd634IoJYbKEkdbQOr+JNM2Quxg=; b=l2O1ln2pmiZe8zzAbfW1kva6i209eHrMTG5q28JUApT7/1rhEuFdyKt0VgAfaVfPtS kVQdF9SKEAj13BdKkHAz+ezPiNowgSZKXhlMr7iqaXlggdxPNTiGPEmhwvXWHArqMWL/ Ys0H3YHOX5LcdwPu7ZOZfK0Ur2nJDn/cF0N02ptIOXPWo8vCWpeEkyK63INPlYA4O1DS vggBfgVOe7EIetEjjL4vXkgdREMRinb1bCd6tigEmXwp3iHz1TdUihGlaBeIv+ApWEmt UwyWxUgEJFlZKOYVk1hvkt22tEyvUn5AJiHOqMouJZMcCYDO1wV8Emj/lvi5YrlnlUrx JeLA== MIME-Version: 1.0 X-Received: by 10.152.88.97 with SMTP id bf1mr5353961lab.58.1410488180721; Thu, 11 Sep 2014 19:16:20 -0700 (PDT) Sender: davide.italiano@gmail.com Received: by 10.25.207.194 with HTTP; Thu, 11 Sep 2014 19:16:20 -0700 (PDT) Date: Thu, 11 Sep 2014 19:16:20 -0700 X-Google-Sender-Auth: FHHIG4dV154A-Tc4KmFtYIZhN5g Message-ID: Subject: [PATCH] Unbreak makefs -M From: Davide Italiano To: freebsd-current , freebsd-fs@freebsd.org Content-Type: text/plain; charset=UTF-8 Cc: jmallett@freebsd.org X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Sep 2014 02:16:23 -0000 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) 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, -- Davide "There are no solved problems; there are only problems that are more or less solved" -- Henri Poincare