From owner-svn-src-all@FreeBSD.ORG Tue Jun 16 06:33:28 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 35922106566C; Tue, 16 Jun 2009 06:33:28 +0000 (UTC) (envelope-from ulf.lilleengen@gmail.com) Received: from mail-ew0-f212.google.com (mail-ew0-f212.google.com [209.85.219.212]) by mx1.freebsd.org (Postfix) with ESMTP id 643A68FC22; Tue, 16 Jun 2009 06:33:26 +0000 (UTC) (envelope-from ulf.lilleengen@gmail.com) Received: by ewy8 with SMTP id 8so4788050ewy.43 for ; Mon, 15 Jun 2009 23:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id; bh=Uw+4VNIFLnPOwBuG4p2E1QNU6bVogW4IU7WybNPBiwc=; b=h/aw1MJo97UHGlLT1d0OMFOzF7w3HG5uA5j5+tAp+sceJ7ZiY9oKPkuO1mkxqhjl9q 08TXKfPidB5BBuk8y4sRmt9Y/AykxtoMg7N2fhERW+B1ubgTGQCPjjWfFijE6HzMCJiH 7XFr08GOI1m8i7aNNcl7dEmyD1S3AsaYP7bvk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:message-id; b=MF5XCnBKwcuDJuPlrRoqArMg68djPL1jNTbAS46+JwkkWZF8uwVeOrR8Vu5TUiaeDO 7IiZP6MqwVM3Uqf88pTlp1nwTF3fEBHPAufzuqzSFNwzZWEToPPG7fu7B/ACfV8cQ90f tIfOMGYlmkHql2S2X9UCqKSVp+dGQzm5FYWZ4= Received: by 10.210.141.19 with SMTP id o19mr9314997ebd.54.1245134006086; Mon, 15 Jun 2009 23:33:26 -0700 (PDT) Received: from carrot.geeknest.org (z032069.its-s.tudelft.nl [145.94.32.69]) by mx.google.com with ESMTPS id 10sm1311805eyd.37.2009.06.15.23.33.24 (version=SSLv3 cipher=RC4-MD5); Mon, 15 Jun 2009 23:33:25 -0700 (PDT) From: Ulf Lilleengen To: Bruce Evans Date: Tue, 16 Jun 2009 08:33:32 +0200 User-Agent: KMail/1.11.3 (FreeBSD/8.0-CURRENT; KDE/4.2.3; i386; ; ) References: <200906151618.n5FGIO0o094444@svn.freebsd.org> <4A367A11.4080202@FreeBSD.org> <20090616100938.R25672@delplex.bde.org> In-Reply-To: <20090616100938.R25672@delplex.bde.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200906160833.33576.lulf@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Marcel Moolenaar , src-committers@freebsd.org Subject: Re: svn commit: r194241 - head/lib/libdisk 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: Tue, 16 Jun 2009 06:33:28 -0000 On Tuesday 16 June 2009 03:12:58 Bruce Evans wrote: > On Mon, 15 Jun 2009, Ulf Lilleengen wrote: > > Marcel Moolenaar wrote: > >> On Jun 15, 2009, at 9:18 AM, Ulf Lilleengen wrote: > >>> Author: lulf > >>> Date: Mon Jun 15 16:18:24 2009 > >>> New Revision: 194241 > >>> URL: http://svn.freebsd.org/changeset/base/194241 > >>> > >>> Log: > >>> - Relax sanitazion requirements in libdisk, as a previous commit > >>> enabling this > >>> sanitization broke sysinstall on some disks. This was due to the > >>> disks > >>> reporting a geometry that was incorrectly sanitized by sysinstall. > >>> This makes > >>> the sanitization consistent with fdisk. > >> > >> *snip* > >> > >>> + if (disk->bios_hd > 256) > >>> sane = 0; > >> > >> The number of heads cannot exceed 255. There are only 8-bits > >> in which the number of heads is stored. This also applies to > >> PC98, BTW. > > No, the number of heads can be 256 except in certain broken APIs and > BIOSes. The broken APIs don't include fdisk tables, since the maximum > number of heads isn't stored. Only the maximum head number is stored. > Head numbers are 0-based, so their maximum is 1 less than the number > of heads. The maximum head number of 255 fits in the 8 bits in an > fdisk table. > > Most of the original int 0x13 BIOS interfaces are similar. E.g., AH = 8 > (read drive parameters) returns the maximum for each CHS value. C and > H values are 0-based, so their max is one less than their number. > S values are bogusly 1-based, so their max is the same as their total. > AH = 2 (read sectors) and AH = 3 (write sectors) naturally pass the > (current) head number (in an 8-bit register), so they never need to > represent 256 in the 8-bit register. > > The only broken API that I remember the int 0x41 and 0x46 > pseudo-interrupts. These may be only de-facto (I can't find them in the > Phoenix BIOS book copyright 1987-1991), but before about 1990 the int 0x13 > AH=8 interface was often not implemented and int 0x41 and int 0x46 worked > better. The IDT entry for ints 0x41 and 0x46 contains a pointer to a table > with the following data (0x41 for hard disk 0 and 0x46 for hard disk 1): > from the header file for Minix "wini" disk drivers: > > /* BIOS table layout. */ > typedef char wn_biosdrive[16]; > #define WN_CYLINDERS(t) (* (unsigned short *) (&(t)[0x0])) > #define WN_HEADS(t) (* (unsigned char *) (&(t)[0x2])) > #define WN_PRECOMP(t) (* (unsigned short *) (&(t)[0x5])) > #define WN_CTLBYTE(t) (* (unsigned char *) (&(t)[0x8])) > #define WN_LANDINGZONE(t) (* (unsigned short *) (&(t)[0xc])) > #define WN_SECTORS(t) (* (unsigned char *) (&(t)[0xe])) > > Many or most 1990's BIOSes present precisely this table for you to edit > in their setup. They present many possibilities for obselete (even in > 1990's) disks from arrays of this table in ROM, and at least 1 modifiable > table per disk in CMOS. > > Since the head number is for the number of heads, and the table entry > for it has type unsigned char, 256 heads does't fit, it becomes 0. > Non-broken software would unwrap 0 back to 0 256 and just work, but > having 256 (virtual) heads is not very useful so configuring it > should be avoided. > > Apparently, some newer BIOSes know that they are non-broken here (or > maybe for cylinder numbers), and default to larger numbers. Such > defaults should still be avoided in case you want to move the disk > to a machine with a BIOS that doesn't support them. > > I once tried to standardize on the maximum possible number of heads > (256), but had to switch to 255 when 256 failed on only some machines. > I still use 255 on all machines. With 2000's BIOSes this requires > ignoring BIOS defaults and/or selecting so-called LBA mode in BIOS > configurations. FreeBSD doesn't know the BIOS defaults anyway; it > gives different defaults (except in my version) which I ignore. > > Many 2000's BIOSes produce defaults for the number of sectors that can't > possibly work in fdisk tables since they significantly exceed 63. > Selecting LBA mode always avoids this for me (LBA CHS = xxx/255/63). > I don't know how misconfigurations from this are usually avoided. > > > Aha, so I should fix fdisk too then. Thanks. > > Please don't break fdisk too. There must be a way to set valid but > dangerous values, or theoretically invalid but practically working > values, if they are representable and are needed for compatibility. > > Bruce I'm a bit confused now :) Fdisk allowed 256 as a valid number of heads. Are you saying it should still be allowed? -- Ulf Lilleengen