From owner-freebsd-hackers Thu Aug 29 07:15:31 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id HAA10041 for hackers-outgoing; Thu, 29 Aug 1996 07:15:31 -0700 (PDT) Received: from eac.iafrica.com (196-7-192-218.iafrica.com [196.7.192.218]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id HAA10026 for ; Thu, 29 Aug 1996 07:15:13 -0700 (PDT) Received: (from rnordier@localhost) by eac.iafrica.com (8.6.12/8.6.12) id QAA00992; Thu, 29 Aug 1996 16:05:20 +0200 From: Robert Nordier Message-Id: <199608291405.QAA00992@eac.iafrica.com> Subject: Re: Determining disk type & size To: bde@zeta.org.au (Bruce Evans) Date: Thu, 29 Aug 1996 16:05:18 +0200 (SAT) Cc: hackers@freebsd.org In-Reply-To: <199608290758.RAA01914@godzilla.zeta.org.au> from "Bruce Evans" at Aug 29, 96 05:58:54 pm X-Mailer: ELM [version 2.4 PL24 ME8a] Content-Type: text Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Bruce Evans wrote: > > >>./fdtest /dev/fd0 > >>sectors per cylinder: 158 [<-- 30 expected] > > >> if (ioctl(fd, DIOCGDINFO, &dl) == -1) > >> err(1, argv[1]); > >> printf("sectors per cylinder: %lu\n", dl.d_secpercyl); > > I wrote: > >DIOCGDINFO for floppies just returns whatever happens to be in the label > >area on the disk (*). The label is garbage unless the disk actually has > >a label. There is no way to tell from the ioctl() return value whether > >the label is garbage. > > Oops, DIOCGDINFO checks the label magic number and checksum, so > d_secpercyl is probably correct if the label is valid. However, > it's extremely unlikely that a DOS floppy would contain a valid label. > Sector 2 normally contains part of the FAT, and it is very unlikely that > the bytes in the FAT form a valid label. That clarifies it. Thanks. -- Robert Nordier