bin/121182: newfs_msdos should supports devices without CHS
characteristics
Andriy Gapon
avg at icyb.net.ua
Thu Feb 28 19:40:02 UTC 2008
>Number: 121182
>Category: bin
>Synopsis: newfs_msdos should supports devices without CHS characteristics
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Feb 28 19:40:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Andriy Gapon
>Release: FreeBSD 7.0-RC1 i386
>Organization:
>Environment:
System: FreeBSD 7.0-RC1 i386
>Description:
Currently newfs_msdos strictly requires that a device provides CHS characteristics.
And this is the case even if a user provided values for those parameters via
command line options.
First, in a modern world CHS requirements are no longer valid.
Second, user-provided overrides should be honored and undoubted.
>How-To-Repeat:
Try to format a DVD-RAM disk to FAT, e.g. FAT32:
newfs_msdos -F 32 /dev/acd1
>Fix:
The logic for faking CHS parameters is borrowed from bsdlabel code.
--- newfs-chs.patch begins here ---
--- newfs_msdos.c.orig 2008-02-21 21:35:00.000000000 +0200
+++ newfs_msdos.c 2008-02-21 21:56:13.000000000 +0200
@@ -739,13 +739,25 @@
/* Maybe it's a fixed drive */
if (lp == NULL) {
if (ioctl(fd, DIOCGDINFO, &dlp) == -1) {
- if (ioctl(fd, DIOCGSECTORSIZE, &dlp.d_secsize) == -1)
+ if (bpb->bps == 0 && ioctl(fd, DIOCGSECTORSIZE, &dlp.d_secsize) == -1)
errx(1, "Cannot get sector size, %s", strerror(errno));
- if (ioctl(fd, DIOCGFWSECTORS, &dlp.d_nsectors) == -1)
- errx(1, "Cannot get number of sectors, %s", strerror(errno));
- if (ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks)== -1)
- errx(1, "Cannot get number of heads, %s", strerror(errno));
+
+ /* XXX Should we use bpb->bps if it's set? */
dlp.d_secperunit = ms / dlp.d_secsize;
+
+ if (bpb->spt == 0 && ioctl(fd, DIOCGFWSECTORS, &dlp.d_nsectors) == -1) {
+ warnx("Cannot get number of sectors per track, %s", strerror(errno));
+ dlp.d_nsectors = 63;
+ }
+ if (bpb->hds == 0 && ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) {
+ warnx("Cannot get number of heads, %s", strerror(errno));
+ if (dlp.d_secperunit <= 63*1*1024)
+ dlp.d_ntracks = 1;
+ else if (dlp.d_secperunit <= 63*16*1024)
+ dlp.d_ntracks = 16;
+ else
+ dlp.d_ntracks = 255;
+ }
}
hs = (ms / dlp.d_secsize) - dlp.d_secperunit;
--- newfs-chs.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list