netbsd ioctl for hard disk information

436 Views Asked by At

I can't seem to find a good comprehensive list of available ioctls for netbsd.

I am looking to do some operations on harddisk (getting size, physical sector size, model). I have the code working in linux. It looks something like this, I removed errors etc to make it more compact:

   ioctl(fileno(driveptr[i]),HDIO_GET_IDENTITY,&hd);
   ioctl(fileno(driveptr[i]),BLKGETSIZE64,&drivesize[i]);
   ioctl(fileno(driveptr[i]),BLKPBSZGET,&psztemp);

Is there an equivalent to these ioctls in netbsd?

regards

1

There are 1 best solutions below

0
On

The driver source for a given type of disk interface (or any other kind of device driver) is probably the best canonical place to find device specific ioctls.

NetBSD at a systems level, like many unix-based systems, tries hard to avoid being hardware specific, even in terms of providing detailed hardware specific information to user level. The goal of unix, after all, is to provide a system that is uniform across a wide variety of hardware platorms, not to provide detailed low-level access to specific hardware. The very best you can get in terms of hardware specific details is the information printed by the drivers at boot time about the hardware as it is probed and attached.

At a more generic level you can basically only get disk and partition labels -- i.e. information pertinent to the way the system presents disk devices to userland. Unfortunately the only driver manual page that documents these is sd(4) (cd(4) has some more detail about more ioctls specific to cd-rom devices). scsi(4) documents bus-level ioctls for SCSI and ATAPI interfaces.

On x86 platforms there's "sysctl machdep.diskinfo" (and the equivalent C level interface via sysctl(3)) to get details about what the BIOS reported about the disks it knew about at boot time, but that may be incomplete.