Date: Thu, 29 Aug 1996 16:50:35 +1000 From: Bruce Evans <bde@zeta.org.au> To: hackers@FreeBSD.org, rnordier@iafrica.com Subject: Re: Determining disk type & size Message-ID: <199608290650.QAA31554@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>Could anyone tell me if there is a quick and easy way to do the >following: >For a given (block special) device, determine whether it represents > > (1) a floppy disk > (2) a hard disk slice that contains a filesystem (probably not ufs) > (3) anything else (not interested, but could be cdrom, tape, etc) >and, given this info, the size (in bytes or 512-byte sectors) of the >disk or slice itself. For example: > > device blocks > ---------- ------ > /dev/fd1 2400 > /dev/wd0s1 65457 > /dev/wd0 (error) No easy way. Perhaps no way. >./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); 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. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608290650.QAA31554>