From owner-freebsd-current@FreeBSD.ORG Mon Mar 8 12:34:56 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70EAB106564A for ; Mon, 8 Mar 2010 12:34:56 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-gy0-f182.google.com (mail-gy0-f182.google.com [209.85.160.182]) by mx1.freebsd.org (Postfix) with ESMTP id 28BD58FC17 for ; Mon, 8 Mar 2010 12:34:55 +0000 (UTC) Received: by gyg8 with SMTP id 8so1408560gyg.13 for ; Mon, 08 Mar 2010 04:34:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=UIMZZO4ueUW7QIE2hiVI4XB0YeRSFAUd4OerXr3IAyA=; b=qR/yoo/JHgiCaLjNs7GpN9Nxf0DAZm2GxRhZNzli5+phU+0+SSAjY9ntl3+y/WlWAT TIdUW+aoUr4JxjV/wmleNDhFWe3WHFAUPtgImQ7sQlX8VWE4RJIv/IM+vlkk27ShwIzf YYs2Er3usQFLQZU65lq59mMxe/BbZq/SqHPXE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=cEXvTF/chZsU+hEvHb9mxY5JrqKad/r87TkoK4Tyq5SdY481nQWVBRNbx45FbwbcTd pUrJbvDvPBKp0zZImt2655CXgdnrLAHRcD+al4NEMqTg7kMtEZMvx6x9fmOapLwKsQA2 5u8mvZrog+aqNDvD30EqZBhNXE5GcdmCBOXyY= Received: by 10.150.169.1 with SMTP id r1mr4130681ybe.216.1268051695223; Mon, 08 Mar 2010 04:34:55 -0800 (PST) Received: from jayachandranc@netlogicmicro.com ([203.92.57.132]) by mx.google.com with ESMTPS id 21sm439840yxe.57.2010.03.08.04.34.52 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 08 Mar 2010 04:34:54 -0800 (PST) Date: Mon, 8 Mar 2010 18:08:05 +0530 From: "Jayachandran C." To: Poul-Henning Kamp Message-ID: <4b94eeee.1502be0a.2a7b.2a5c@mx.google.com> References: <20100308125643.1ac0be0f@ernst.jennejohn.org> <51125.1268049519@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51125.1268049519@critter.freebsd.dk> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: FreeBSD Current Subject: Re: newfs broken in -CURRENT after 204654 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 08 Mar 2010 12:34:56 -0000 On Mon, Mar 08, 2010 at 11:58:39AM +0000, Poul-Henning Kamp wrote: > In message <20100308125643.1ac0be0f@ernst.jennejohn.org>, Gary Jennejohn writes > : > >On Mon, 8 Mar 2010 14:17:17 +0530 > > >> I'm trying this one more time, since the issue is still unresolved. > >> > >> newfs(8) broke for big-endian systems since revision 204654. This change > >> made sectorsize variable int64_t, and now it cannot be passed to the ioctl > >> DIOCGSECTORSIZE. > > This patch is correct, DIOCGSECTORSIZE takes an unsigned argument, see > : > > #define DIOCGSECTORSIZE _IOR('d', 128, u_int) > /*- > * Get the sectorsize of the device in bytes. The sectorsize is the > * smallest unit of data which can be transfered from this device. > * Usually this is a power of two but it may not be. (ie: CDROM audio) > */ > > > >I can't say whether this is correct, but the logic could definitely be > >simplified like this, since sectorsize is known to be 0 already: > > if (sectorsize == 0) > > if (ioctl(disk.d_fd, DIOCGSECTORSIZE, &tsecsize) >= 0) > > sectorsize = tsecsize; > > I'm not sure that is a valid assumption. I think I missed this one. Probably we could do ioctl(...) != -1 and be equivalent. Thanks for the comments. New patch below. Index: sbin/newfs/newfs.c =================================================================== --- sbin/newfs/newfs.c (revision 204858) +++ sbin/newfs/newfs.c (working copy) @@ -132,6 +132,7 @@ char *cp, *special; intmax_t reserved; int ch, i, rval; + u_int tsecsize; off_t mediasize; char part_name; /* partition name, default to full disk */ @@ -328,8 +329,8 @@ /* set fssize from the partition */ } else { if (sectorsize == 0) - if (ioctl(disk.d_fd, DIOCGSECTORSIZE, §orsize) == -1) - sectorsize = 0; /* back out on error for safety */ + if (ioctl(disk.d_fd, DIOCGSECTORSIZE, &tsecsize) != -1) + sectorsize = tsecsize; if (sectorsize && ioctl(disk.d_fd, DIOCGMEDIASIZE, &mediasize) != -1) getfssize(&fssize, special, mediasize / sectorsize, reserved); } Regards, JC.