From owner-svn-src-all@FreeBSD.ORG Thu Jun 11 18:15:04 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C0E510656C2; Thu, 11 Jun 2009 18:15:04 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 398C98FC0C; Thu, 11 Jun 2009 18:15:04 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5BIF4AE056348; Thu, 11 Jun 2009 18:15:04 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5BIF4Ti056347; Thu, 11 Jun 2009 18:15:04 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <200906111815.n5BIF4Ti056347@svn.freebsd.org> From: Andriy Gapon Date: Thu, 11 Jun 2009 18:15:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194032 - stable/7/sbin/newfs_msdos X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jun 2009 18:15:05 -0000 Author: avg Date: Thu Jun 11 18:15:03 2009 New Revision: 194032 URL: http://svn.freebsd.org/changeset/base/194032 Log: MFC r189112: newfs_msdos: work with media that doesn't have any CHS params Approved by: jhb (mentor) Modified: stable/7/sbin/newfs_msdos/ (props changed) stable/7/sbin/newfs_msdos/newfs_msdos.c Modified: stable/7/sbin/newfs_msdos/newfs_msdos.c ============================================================================== --- stable/7/sbin/newfs_msdos/newfs_msdos.c Thu Jun 11 18:10:17 2009 (r194031) +++ stable/7/sbin/newfs_msdos/newfs_msdos.c Thu Jun 11 18:15:03 2009 (r194032) @@ -739,13 +739,25 @@ getdiskinfo(int fd, const char *fname, c /* 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;