Subject: Re: disklabeling a 5 TB partition!?
To: None <current-users@NetBSD.org>
From: Pavel Cahyna <pavel@NetBSD.org>
List: current-users
Date: 08/08/2006 19:35:05
On Fri, Aug 04, 2006 at 07:58:45PM -0500, Jonathan A. Kollasch wrote:
> I also have a struct disklabel-dependent port of (FreeBSD|OS X)'s
> gpt(8), and a utility to print out the GPT structures.  This thread
> made me realize that using the DIOCGDINFO ioctl to obtain the size
> of the disk is horribly deficient.
> 
> Perhaps we could have something similar to FreeBSD's DIOCGSECTORSIZE
> and DIOCGMEDIASIZE (both return the number of bytes, I believe the
> latter should be number of sectors instead).  Or, maybe something
> like Solaris's struct dk_geom and related ioctls.  However, I'm not
> the one who should be making this choice.

The canonical way to obtain disk device size seems to be to open it and
call fstat(). See sbin/newfs/newfs.c for an example.

> I also have a simplistic man page for dk(4).  Perhaps I should submit
> this someday.  A dk(9) page may also be useful, but I don't think I
> understand the API well enough to document it.

Please do, the dk(4) manpage is missing. Thanks for looking at this.

Pavel