Date: Sat, 23 Jan 1999 01:19:07 +0200 (SAT) From: Robert Nordier <rnordier@nordier.com> To: jplevyak@inktomi.com (John Plevyak) Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: raw devices and disk geometry Message-ID: <199901222319.BAA02045@ceia.nordier.com> In-Reply-To: <19990122124309.C11064@proxydev.inktomi.com> from John Plevyak at "Jan 22, 99 12:43:09 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
John Plevyak wrote: > I am trying to find the disk of a raw disk partition (/dev/rwd2c). > > I have noticed the following in 3.0-CURRENT Jan 12: > > 1) DIOCGPART does not seem to return valid pointers: > > 2) lseek on raw disks does not seem to produce an error > when the size is exceeded. In fact, it acts very > oddly when given SEEK_END > 3) lseek followed by read *can* be used to determine the size of > the partition of course this requires a binary search. > > Are these known issues? Is there a better way of determining > the size of a partition from a program? DIOCGPART is for internal use and not used outside the kernel. You can't necessarily rely on lseek() when applied to a device. However, what you want to do seems fairly simple: if (ioctl(fd, DIOCGDINFO, &dl) == -1) errx(1, "%s: IOCTL(DIOCGDINFO)", argv[1]); for (i = 0; i < dl.d_npartitions; i++) printf("%c: %u\n", 'a' + i, dl.d_partitions[i].p_size); With sample output: /dev/rwd0: a: 0 b: 0 c: 8438850 d: 0 e: 0 f: 0 g: 0 h: 0 /dev/rwd0c: a: 65536 b: 282304 c: 4305357 d: 0 e: 65536 f: 3891981 g: 0 h: 0 The 'c' (raw) partitions give, respectively, the size of the whole disk, and of the FreeBSD slice ("fdisk partition"). -- Robert Nordier To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901222319.BAA02045>