Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Nov 1996 13:33:31 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        bde@zeta.org.au (Bruce Evans)
Cc:        rgrimes@GndRsh.aac.dev.com, terry@lambert.org, current@freefall.freebsd.org, darrylo@sr.hp.com, jkh@time.cdrom.com
Subject:   Re: 2.2-ALPHA install failure
Message-ID:  <199611262033.NAA25507@phaeton.artisoft.com>
In-Reply-To: <199611260520.QAA26908@godzilla.zeta.org.au> from "Bruce Evans" at Nov 26, 96 04:20:06 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> >> Or atleast make size == cyl * sec * head  (ie 1024*64*255 == 16711680)
> >> my reasoning is that any third party fdisk program that sees the current
> >> bogus table likes to try and ``fix it'' and usually ends up doing quite
> >> the wrong thing : -(.
> >
> >This is bogus.
> >
> >Why can't I just ioctl the (unpartitioned) raw disk device and ask it?
> 
> Because the driver doesn't know anything about the BIOS geometry.
> For SCSI drives, the ioctl returns the geometry reported by the SCSI
> MODE_SENSE command.  This has nothing to do with the BIOS geometry,
> and can't be the same as the BIOS geometry even by accident for modern
> drives with an average of >= 64 sectors/track.
> 
> The driver doesn't know anything about the BIOS geometry because it
> doesn't know the correspondence between BIOS drive numbers and FreeBSD
> drive numbers.  The BIOS numbers depend on the POST order (see many old
> postings by Terry :-).

Yes, but...

If you are going to present fake geometry numbers, they should percoalte
up from where the real geometry numbers are coming from.

I'm still enamored of the idea of using directory hierarchy to indicate
device layering for stacking of partiton schemes:


main()
{
	char	buf[ 128];

	printf( "Device name> ");
	if( gets( buf) != NULL) {
		dump_partinfo( buf, 0);
	}
}

char *spaces = "                                                ";

dump_partinfo( char *devname, int indent)
{
	struct ld_geom		geom;		/* logical device geometry*/
	struct ld_part_desc	pdesc;		/* partition descriptor*/
	struct ld_part_rec	prec;		/* prec records*/

	char *sp;

	sp = &spaces[ strlen( spaces) - indent];

	/* Open device*/
	fd = open( devname, O_RDWR, 0);

	printf( "%sDevice:   %s\n", sp, devname);
	ioctl( fd, LDGETGEOM, &geom);			/* get geometry*/
	printf( "%s-Type:    %s\n", sp, (geom.g_flags & LD_GEO_PHYS) ?
			"PHYSICAL" : "LOGICAL");
	printf( "%s-Mapping: %s\n", sp, (geom.g_flags & LD_GEO_LINEAR) ?
			"LINEAR" : "NONLINEAR");
	printf( "%s-Size:    %d blocks\n", sp, geom.g_size);
						
	ioctl( fd, LDGETPDESC, &pdesc);			/* get descriptor*/
	if( pdesc.pd_type[ 0]) {
		/*
		 * hey! has parititioning
		 */
		printf( "%s-Partitioning present, type = %s\n",
				sp, pdesc.pd_type);
		for( i = 0; i< MAX; i++) {
			prec.pr_index = i;
			ioctl( fd, LDGETPREC, &prec);
			if( !( prec.pr_flags & LD_PR_VALID))
				continue;
			printf( "%s-Partition #%d\n", sp, i);
			printf( "  %s-Start:  %d\n", sp, prec.pr_start);
			printf( "  %s-Length: %d\n", sp, prec.pr_len);
			dump_partinfo( prec.pr_devname, indent + 2);
		}
	} else {
		printf( "%s-No partitioning (may contain file system)\n", sp);
	close( fd);
}


Output:

Device name> /dev/disk/d0
Device:   /dev/disk/d0
-Type:    PHYSICAL
-Mapping: LINEAR
-Size:    256000 blocks
-Partitioning present, type = MSDOS PRIMARY PARTITION TABLE
-Partition #0
  -Start:  32
  -Length: 117000
  Device:   /dev/disk/d0/p0
  -Type:    LOGICAL
  -Mapping: LINEAR
  -Size:    117000 blocks
  -Partitioning present, type = BSD DISKLABEL PARTITIONING
  -Partition #0
    -Start:  16
    -Length: 60000
    Device:   /dev/disk/d0/p1/p0
    -Type:    LOGICAL
    -Mapping: LINEAR
    -Size:    60000 blocks
    -No partitioning (may contain file system)
  -Partition #1
    -Start:  60016
    -Length: 30000
    Device:   /dev/disk/d0/p1/p1
    -Type:    LOGICAL
    -Mapping: LINEAR
    -Size:    30000 blocks
    -No partitioning (may contain file system)
  -Partition #2
    -Start:  90016
    -Length: 26984
    Device:   /dev/disk/d0/p1/p2
    -Type:    LOGICAL
    -Mapping: LINEAR
    -Size:    26984 blocks
    -No partitioning (may contain file system)
-Partition #1
  -Start:  117032
  -Length: 138968
  Device:   /dev/disk/d0/p1
  -Type:    LOGICAL
  -Mapping: LINEAR
  -Size:    138968 blocks
  -No partitioning (may contain file system)


NONLINEAR mapping would indicate that the sector number must go through
a translation function to get the "real" sector on the underlying device
(ie: ccd, bad144, etc., etc.).  LINEAR mapping can be collapsed to a
decriptor that coeleses all intervening mappings to the physical device
(or the firs NONLINEAR device) in the chain.


					Regards,
					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



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