Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Feb 2009 17:40:02 GMT
From:      dfilter@FreeBSD.ORG (dfilter service)
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/121182: commit references a PR
Message-ID:  <200902271740.n1RHe2n6063237@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/121182; it has been noted by GNATS.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/121182: commit references a PR
Date: Fri, 27 Feb 2009 17:30:08 +0000 (UTC)

 Author: avg
 Date: Fri Feb 27 17:29:48 2009
 New Revision: 189112
 URL: http://svn.freebsd.org/changeset/base/189112
 
 Log:
   newfs_msdos: allow to work with media that doesn't have any CHS params
   
   Either use parameters provided by user or make them up.
   The code for faking CHS params is borrowed from disklabel code.
   The logic for using user-provided and auto-guessed parameters is not
   perfect, so to speak.
   
   PR:		bin/121182
   Approved by:	jhb (mentor)
 
 Modified:
   head/sbin/newfs_msdos/newfs_msdos.c
 
 Modified: head/sbin/newfs_msdos/newfs_msdos.c
 ==============================================================================
 --- head/sbin/newfs_msdos/newfs_msdos.c	Fri Feb 27 17:29:31 2009	(r189111)
 +++ head/sbin/newfs_msdos/newfs_msdos.c	Fri Feb 27 17:29:48 2009	(r189112)
 @@ -793,13 +793,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;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902271740.n1RHe2n6063237>