Date: Mon, 8 Mar 2010 12:56:43 +0100 From: Gary Jennejohn <gary.jennejohn@freenet.de> To: "Jayachandran C." <c.jayachandran@gmail.com> Cc: FreeBSD Current <freebsd-current@freebsd.org> Subject: Re: newfs broken in -CURRENT after 204654 Message-ID: <20100308125643.1ac0be0f@ernst.jennejohn.org> In-Reply-To: <4b94b8d8.c501be0a.4ce5.760a@mx.google.com> References: <98a59be81003040504x6e97fbaeqeb10f8ea7bedb7b9@mail.gmail.com> <4b94b8d8.c501be0a.4ce5.760a@mx.google.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 8 Mar 2010 14:17:17 +0530 "Jayachandran C." <c.jayachandran@gmail.com> wrote: > On Thu, Mar 04, 2010 at 06:34:03PM +0530, C. Jayachandran wrote: > > I'm testing this on the mips platform, but I think there is an issue > > with change that made sectorsize int64_t, because the ioctl > > DIOCGSECTORSIZE used to read sector size seems to take u_int. This > > quick change fixes it for me (sample patch - may be whitespace > > damaged). > > 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. > > The patch below (updated from the previous one) fixes it, please review and > apply if correct. > > Thanks, > JC. > > Index: sbin/newfs/newfs.c > =================================================================== > --- sbin/newfs/newfs.c (revision 204701) > +++ 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 */ > > @@ -327,9 +328,12 @@ > mediasize = st.st_size; > /* set fssize from the partition */ > } else { > - if (sectorsize == 0) > - if (ioctl(disk.d_fd, DIOCGSECTORSIZE, §orsize) == -1) > + if (sectorsize == 0) { > + if (ioctl(disk.d_fd, DIOCGSECTORSIZE, &tsecsize) == -1) > sectorsize = 0; /* back out on error for safety */ > + else > + sectorsize = tsecsize; > + } > if (sectorsize && ioctl(disk.d_fd, DIOCGMEDIASIZE, &mediasize) != -1) > getfssize(&fssize, special, mediasize / sectorsize, reserved); > } > 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; --- Gary Jennejohn
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100308125643.1ac0be0f>