disk(7) disk(7)
NAME
disk - physical disk structures and I/O controls
SYNOPSIS
#include <sys/vtoc.h>
#include <sys/extbus.h>
DESCRIPTION
System V release 4 supports a general administration interface for
disks. The interface is most often used by the utilities
format (1M),
setvtoc (1M) and
prtvtoc.
The disk-specific information is stored on the disk in several data
structures that are manipulated using the I/O controls.
The ioctls to the disk are issued in the following manner:
ioctl(fd, command, ioarg);
int fd;
int command;
struct ioarg *ioarg;
The ioarg structure is provided as an interface structure which
contains a pointer to and the size of the structure the user wishes
to manipulate. For example, if the user wished to read the physical
disk description sector (pdsector), the following would have to be
set up before issuing the ioctl:
struct pdsector pd;
struct ioarg ioarg;
ioarg.sectst = 0;
ioarg.memaddr = (unsigned long) &pd;
ioarg.datasz = sizeof(struct pdsector);
ioarg.retval = 0;
The ioctl can then be issued. It is always advisable to test the
value returned in ioarg.retval as this also holds a return value. An
ioctl to read the pdsector would for example be issued in the
following way:
if ((ioctl(fd, VPDREAD, &ioarg) < 0) || (ioarg.retval))
If any of the conditions were met then the ioctl would have failed.
The ioctls to manipulate a given disk are (most of the ioctls require
super-user privileges) :
7/91 Page 1
disk(7) disk(7)
VPREAD
This command does a physical read of a specific block on the
disk. When issued the ioarg.sectst is set to the sector number
where the read should begin.
VPWRITE
This command does a physical write of a specific block on the
disk. When issued the ioarg.sectst is set to the sector number
where the write should begin.
VPDREAD
Read the physical description area (pdsector).
VPDWRITE
Write a new physical description area (pdsector) to the disk.
VGETSSZ
Get the sector size of media.
VRVTOC
Read the volume table of contents (VTOC - partition table)
VWVTOC
Write the volume table of contents to the disk.
VDRVTYPE
Return information about the disk drive, ie model and serial
number (see struct diskdetails defined in vtoc.h).
VBADMEDIA
Write media error information to the disk.
VSPARE
Maps spare blocks on the disk to bad blocks.
VPDSET
Set the physical description area (pdsector) in core only.
VFORMAT
Issue a format command to the disk.
VPDSYNC
Write the incore physical description area (pdsector) to the
disk.
VSCSI
Perform an individual SCSI command ie a mode sense. This
command is only relevant to disks on a SCSI bus.
Page 2 7/91
disk(7) disk(7)
Another important ioctl that does not take a third argument of struct
ioarg *ioarg is:
BGETTYPE
This ioctl takes an argument of struct bustype *bustype and
is used to determine the controller/bus on the machine (see
extbus.h).
Most disk device drivers will only support a subset of these ioctls,
because some overlap or are not required for a particular hardware
implementation.
The error codes returned in ioarg.retval are : VBADREAD and
VBADWRITE
SEE ALSO
format (1M), setvtoc (1M), prtvtoc (1M).
7/91 Page 3