From nobody@www.freebsd.org  Thu Jun  6 19:17:58 2002
Return-Path: <nobody@www.freebsd.org>
Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by hub.freebsd.org (Postfix) with ESMTP id E0DFF37B40B
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  6 Jun 2002 19:17:57 -0700 (PDT)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g572HvhG089850
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 6 Jun 2002 19:17:57 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.2/8.12.2/Submit) id g572HvqS089849;
	Thu, 6 Jun 2002 19:17:57 -0700 (PDT)
Message-Id: <200206070217.g572HvqS089849@www.freebsd.org>
Date: Thu, 6 Jun 2002 19:17:57 -0700 (PDT)
From: KT Sin <ktsin@acm.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Unable to newfs vinum volumes
X-Send-Pr-Version: www-1.0

>Number:         38963
>Category:       bin
>Synopsis:       Unable to newfs vinum volumes
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 06 19:20:01 PDT 2002
>Closed-Date:    Mon Aug 26 23:16:47 MEST 2002
>Last-Modified:  Mon Aug 26 23:16:47 MEST 2002
>Originator:     KT Sin
>Release:        5.0-CURRENT
>Organization:
daddylonglegs.com
>Environment:
FreeBSD passion.daddylonglegs.com 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Mon Jun  3 22:55:19 SGT 2002     ktsin@passion.daddylonglegs.com:/usr/src/sys/i386/compile/PASSION  i386
>Description:
passion:~[624]# newfs /dev/vinum/work 
newfs: /dev/vinum/work: can't figure out filesystem partition

The attempt to remove -v flag in revision 1.60 of newfs.c broke newfs when newfsing vinum volumes.

A snippet of the diff to rev 1.59:

@@ -279,11 +274,11 @@ main(int argc, char *argv[])
 	if (lp != NULL) {
 		cp = strchr(special, '\0');
 		cp--;
-		if (!vflag && (*cp < 'a' || *cp > 'h') && !isdigit(*cp))
+		if ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))
 			errx(1, "%s: can't figure out file system partition",
 			    special);
-		if (vflag || isdigit(*cp))
-			pp = &lp->d_partitions[0];
+		if (isdigit(*cp))
+			pp = &lp->d_partitions[RAW_PART];
 		else
 			pp = &lp->d_partitions[*cp - 'a'];
 		oldpartition = *pp;


We should not have removed vflags from all conditional statements blindly. A better approach is to implicitly set vflag to 1 since we want to make -v the default behaviour.

When vflag is 1, (!vflag && (*cp < 'a' || *cp > 'h') && !isdigit(*cp)) is always false and (vflag || isdigit(*cp)) is always true.
>How-To-Repeat:
Just run newfs on a vinum volume. 8)
>Fix:
--- sbin/newfs/newfs.c.orig     Thu May 16 15:36:55 2002
+++ sbin/newfs/newfs.c  Fri Jun  7 09:52:02 2002
@@ -274,13 +274,7 @@
        if (lp != NULL) {
                cp = strchr(special, '\0');
                cp--;
-               if ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))
-                       errx(1, "%s: can't figure out filesystem partition",
-                           special);
-               if (isdigit(*cp))
-                       pp = &lp->d_partitions[RAW_PART];
-               else
-                       pp = &lp->d_partitions[*cp - 'a'];
+               pp = &lp->d_partitions[RAW_PART];
                oldpartition = *pp;
                if (pp->p_size == 0)
                        errx(1, "%s: `%c' partition is unavailable",
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: KT Sin <ktsin@acm.org>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/38963: Unable to newfs vinum volumes
Date: Fri, 7 Jun 2002 18:53:13 +1000 (EST)

 On Thu, 6 Jun 2002, KT Sin wrote:
 
 > The attempt to remove -v flag in revision 1.60 of newfs.c broke newfs when newfsing vinum volumes.
 >
 > A snippet of the diff to rev 1.59:
 >
 > @@ -279,11 +274,11 @@ main(int argc, char *argv[])
 >  	if (lp != NULL) {
 >  		cp = strchr(special, '\0');
 >  		cp--;
 > -		if (!vflag && (*cp < 'a' || *cp > 'h') && !isdigit(*cp))
 > +		if ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))
 >  			errx(1, "%s: can't figure out file system partition",
 >  			    special);
 > -		if (vflag || isdigit(*cp))
 > -			pp = &lp->d_partitions[0];
 > +		if (isdigit(*cp))
 > +			pp = &lp->d_partitions[RAW_PART];
 >  		else
 >  			pp = &lp->d_partitions[*cp - 'a'];
 >  		oldpartition = *pp;
 >
 > We should not have removed vflags from all conditional statements blindly. A better approach is to implicitly set vflag to 1 since we want to make -v the default behaviour.
 
 I think it is not so simple.  -v can't be the default behaviour, because it
 is inconsistent with the use of a partition other than RAW_PART.  This
 wasn't a problem when there was a -v flag.  You could just not use -v
 when newfs'ing a partition.
 
 > >Fix:
 > --- sbin/newfs/newfs.c.orig     Thu May 16 15:36:55 2002
 > +++ sbin/newfs/newfs.c  Fri Jun  7 09:52:02 2002
 > @@ -274,13 +274,7 @@
 >         if (lp != NULL) {
 >                 cp = strchr(special, '\0');
 >                 cp--;
 > -               if ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))
 > -                       errx(1, "%s: can't figure out filesystem partition",
 > -                           special);
 > -               if (isdigit(*cp))
 > -                       pp = &lp->d_partitions[RAW_PART];
 > -               else
 > -                       pp = &lp->d_partitions[*cp - 'a'];
 > +               pp = &lp->d_partitions[RAW_PART];
 >                 oldpartition = *pp;
 >                 if (pp->p_size == 0)
 >                         errx(1, "%s: `%c' partition is unavailable",
 
 This gives the RAW partition in all cases, so at least the check of the
 partition size is wrong if the device is a partition but not the RAW one
 (but at least this wrongness is unimportant in most cases, since we
 have checked the correct size early after getting it with DIOCMEDIASIZE).
 
 Bringing back the -v flag seems to be the best way to fix this, short of
 dropping support for partitions.
 
 Bruce
 
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Mon Aug 26 23:16:19 MEST 2002 
State-Changed-Why:  
I have fixed this in rev 1.36 of /sys/dev/vinum/vinumioctl.c. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38963 
>Unformatted:
