From owner-freebsd-bugs@FreeBSD.ORG Wed Oct 1 02:50:02 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 95749106568E for ; Wed, 1 Oct 2008 02:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 71DD48FC12 for ; Wed, 1 Oct 2008 02:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m912o2LU077943 for ; Wed, 1 Oct 2008 02:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m912o2Xs077942; Wed, 1 Oct 2008 02:50:02 GMT (envelope-from gnats) Resent-Date: Wed, 1 Oct 2008 02:50:02 GMT Resent-Message-Id: <200810010250.m912o2Xs077942@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Cyrus Rahman Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DBD8106568D for ; Wed, 1 Oct 2008 02:47:17 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 5C32F8FC1A for ; Wed, 1 Oct 2008 02:47:17 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m912lGZ1098035 for ; Wed, 1 Oct 2008 02:47:17 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id m912lGv3098034; Wed, 1 Oct 2008 02:47:16 GMT (envelope-from nobody) Message-Id: <200810010247.m912lGv3098034@www.freebsd.org> Date: Wed, 1 Oct 2008 02:47:16 GMT From: Cyrus Rahman To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/127759: Nanobsd.sh incorrectly calculates partition sizes X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Oct 2008 02:50:02 -0000 >Number: 127759 >Category: misc >Synopsis: Nanobsd.sh incorrectly calculates partition sizes >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Oct 01 02:50:02 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Cyrus Rahman >Release: 7.1-PRERELEASE >Organization: >Environment: FreeBSD silva.signetica.com 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0: Thu Sep 25 23:49:02 MDT 2008 cr@silva.signetica.com:/usr/src/sys/amd64/compile/SIGNETICA amd64 >Description: It is possible to ask nanobsd.sh to create a 'data' partition, separate from the system or configuration partitions, and furthermore, by specifying a negative value for its size to request that it use all space unused by those partitions for its own size. Because the two lines of code that calculate how much space is available for this data partition are written in perl-like syntax, the awk code that does the processing performs the calculation incorrectly. Furthermore, a comparison later down fails to newfs the partition when the size is negative. >How-To-Repeat: Run nanobsd.sh with NANO_DATASIZE set to a negative value. >Fix: Apply the attached patch, also listed herein: --- /u/cr/sys/freebsd/nanobsd/nanobsd.sh 2008-09-29 20:59:44.000000000 -0600 +++ nanobsd.sh 2008-09-30 06:12:29.000000000 -0600 @@ -376,8 +376,8 @@ # Data partition (if any) starts at cylinder boundary. if ($7 > 0) { print "p 4 165 " c, dsl * cs - } else if ($7 < 0 && $1 > $c) { - print "p 4 165 " c, $1 - $c + } else if ($7 < 0 && $1 > c) { + print "p 4 165 " c, $1 - c } else if ($1 < c) { print "Disk space overcommitted by", \ c - $1, "sectors" > "/dev/stderr" @@ -432,7 +432,7 @@ # XXX: fill from where ? # Create Data slice, if any. - if [ $NANO_DATASIZE -gt 0 ] ; then + if [ $NANO_DATASIZE -ne 0 ] ; then newfs ${NANO_NEWFS} /dev/${MD}s4 # XXX: fill from where ? fi Patch attached with submission follows: --- /u/cr/sys/freebsd/nanobsd/nanobsd.sh 2008-09-29 20:59:44.000000000 -0600 +++ nanobsd.sh 2008-09-30 06:12:29.000000000 -0600 @@ -376,8 +376,8 @@ # Data partition (if any) starts at cylinder boundary. if ($7 > 0) { print "p 4 165 " c, dsl * cs - } else if ($7 < 0 && $1 > $c) { - print "p 4 165 " c, $1 - $c + } else if ($7 < 0 && $1 > c) { + print "p 4 165 " c, $1 - c } else if ($1 < c) { print "Disk space overcommitted by", \ c - $1, "sectors" > "/dev/stderr" @@ -432,7 +432,7 @@ # XXX: fill from where ? # Create Data slice, if any. - if [ $NANO_DATASIZE -gt 0 ] ; then + if [ $NANO_DATASIZE -ne 0 ] ; then newfs ${NANO_NEWFS} /dev/${MD}s4 # XXX: fill from where ? fi >Release-Note: >Audit-Trail: >Unformatted: