|
|
A valid partition has at least the first three fields defined. A bootable valid partition has all four fields defined or on.
The partition table is maintained by the fdisk(1M) command. The vtoc target driver searches the partition table for UNIX partitions. The active flag is used not only to indicate that a partition on the boot disk is bootable, but also to indicate whether it is accessible (a UNIX partition on the second disk that is not active cannot be accessed). The vtoc target driver also allows access to non-UNIX partitions on a disk, even if there is no UNIX partition, and thus no Volume Table of Contents (VTOC). This method uses the information on the fdisk table.
The second level of organization of the disk is the slice. A slice is a contiguous section of a partition. These slices are defined by the VTOC and they provide a way to better manage the space, to differentiate slices for special purposes, and to allow protection. vtoc allows for a maximum of 184 UNIX slices per UNIX disk partition. A slice also has four characteristics:
A slice can contain a filesystem, can be used as swap space for paging, or left to be organized by an application such as a database.
Some slices have required definitions:
This slice is optional, and may not be present.
On the boot disk there are additional slices that have required definitions:
On a boot disk optional filesystems are organized as follows:
The slices of a disk are represented by device nodes, which have a minor number pointing to one of the slices. There are a maximum of 184 UNIX slices and five special partitions (one for each entry in the fdisk(1M) partition table) for each disk.
The system supports 256 slices (minor numbers) per disk. Minor numbers for the first disk on the system are numbered 0 through 255; a second disk's minor numbers would start at 256 and continue through 511; and so on for third and subsequent disks (in blocks of 256 minor numbers per disk). The following paragraphs show minor number usage relative to the first disk (numbers 0-255); a subsequent disk has the same slices in the same relative positions within the minor number range for that disk.
Minor numbers 0-15 are for standard slices (see above), 16-183 are for extended slices, 184 represents the whole disk, and 185-188 represent the fdisk table partitions.
When the disk device is opened, the partition table and the VTOC are read by vtoc to fill out its tables of partitions and UNIX slices. Device nodes are always created for slices 0-15 and 184-188. Nodes are created for extended slices only when the slice is used.
The vtoc driver receives command requests from the kernel through the Input/Output (I/O) control call ioctl(2). The vtoc driver generates the requested commands and passes them through the I/O stack. When command execution is complete, the host adapter driver notifies the vtoc driver through an interrupt.
The files in the /dev/dsk directory access the disk through the system's normal buffering mechanism, and may be read and written without regard to physical disk records.
There is also a raw interface (specified with an ``r'' in the name) that provides for direct access between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation. Therefore, raw I/O is considerably more efficient for large transfers. The names of the raw disk files contain /dev/rdsk and have the same form as the /dev/dsk files.
In raw I/O, the buffer must begin on a 512-byte boundary, and transfer counts must be integral multiples of 512 bytes.
The special device filenames associated with
the vtoc disk driver have either of the two following forms:
/dev/[r]dsk/cCbBtTdDsS
/dev/[r]dsk/cCbBtTdDpP
More information can be found on the disk(7) manual page.
If the disk does not contain a UNIX partition, there will be no VTOC or PDINFO on the disk. You will, however, be able to access other partitions through the special p1-p4 nodes, and the whole disk through the p0 node.
The disk parameters -- number of cylinders, heads, and sectors per track -- are obtained at driver initialization (init) time. If the disk is an ESDI, ST506, or IDE drive, the CMOS contains parameters for the first two disks. For SCSI disks, a read capacity command is issued, and the disk parameters are calculated based on a disk geometry of 32 sectors-per-track and 64 heads. This geometry is for drives with 512-byte sectors. It is adjusted if the number of bytes per sector changes. The disk parameters are stored in Physical Descriptor Information (PDINFO) structure which is stored in the boot slice of the disk. The PDINFO is kept as a sanity check against those found at driver init time.
When the machine is booted, the primary boot code (BIOS) looks in the fdisk table for the active partition and jumps to sector 0 of that partition to find the first-stage bootstrap. If the first-stage bootstrap is over one sector in length, it is the responsibility of the first-stage bootstrap to understand this. The boot code will read in the VTOC to locate the BFS filesystem. It will then load the kernel and begin executing the kernel.
union io_arg { struct { ushort ncyl; /* Number of cylinders */ unchar nhead; /* Heads/cylinder */ unchar nsec; /* Sectors/track */ ushort secsiz; /* Bytes/sector */ } ia_cd; }It is not possible to change the sector size on the hard disk with this ioctl. An attempt to do so results in the ioctl failing, with errno set to EINVAL. This call is provided for backward compatibility with any commands that use it. This call will not work with a disk that does not have a UNIX partition. This call should no longer be used and will be removed in the future.
struct disk_parms { char dp_type; /* Disk type (see below) */ unchar dp_heads; /* No. of heads */ ulong dp_cyls; /* No. of cylinders */ unchar dp_sectors; /* No. of sectors/track */ ushort dp_secsiz; /* No. of bytes/sector */ ushort dp_ptag; /* Currently not used */ ushort dp_pflag; /* Currently not used */ daddr_t dp_pstartsec; /* Starting abs. sector no. */ daddr_t dp_pnumsec; /* Currently not used */ }For SCSI disks the disk type is DPT_SCSI_HD. For ESDI, ST506, and IDE disks, the disk type is DPT_WINI./* Disk types */ #define DPT_NOTDISK 0 /* Not a disk device */ #define DPT_WINI 1 /* Winchester disk */ #define DPT_FLOPPY 2 /* Floppy */ #define DPT_OTHER 3 /* Other type of disk */ #define DPT_SCSI_HD 4 /* SCSI hard disk */ #define DPT_SCSI_OD 5 /* SCSI optical disk */
/* Partition tag */ #define V_BOOT 1 /* Bootable partition */ #define V_ROOT 2 /* Root filesystem */ #define V_SWAP 3 /* Swap slice */ #define V_USR 4 /* User filesystem */ #define V_BACKUP 5 /* Entire disk */ #define V_ALTS 6 /* Alternate sectors (SVR4.0 and earlier) */ #define V_OTHER 7 /* Non-UNIX System partition */ #define V_ALTTRK 8 /* Alternate tracks (SVR4.0 and earlier) */ #define V_STAND 9 /* stand (BFS) filesystem */ #define V_VAR 0A /* Var filesystem */ #define V_HOME 0B /* Home filesystem */ #define V_DUMP 0C /* Dump slice */ #define V_ALTSCTR 0D /* Alternate sectors (SVR4.2) */
/* Partition flag */ #define V_UNMNT 0x001 /* Unmountable partition */ #define V_RONLY 0x010 /* Read only partition */ #define V_OPEN 0x100 /* Partition open */ #define V_VALID 0x200 /* Partition valid to use */
dp_cyls
member has been changed from a
ushort to a ulong in UnixWare® 7.
Consequently, legacy applications that use the V_GETPARMS
ioctl or the disk_parms
structure will need to be recompiled to run on UnixWare 7 and
later releases.
unsigned long pdloc;This call will not work with a disk that does not have a UNIX partition.
disk_parms.dp_secsize
for the current drive.
Note that both the first cylinder (containing the
fdisk(1M)
table, first-stage bootstrap and VTOC) and the first
track of the active
partition (containing the first-stage bootstrap)
can only be accessed using
partition 0, since these tracks are
normally not considered part of any
other partition in the VTOC.
The absio structure is defined in sys/vtoc.h:
struct absio { daddr_t abs_sec; /* Absolute sector no. (from 0) */ char *abs_buf; /* Sector buffer */ };
struct phyio { int retval; /* Return value */ unsigned long sectst; /* Sector address */ unsigned long memaddr; /* Buffer address */ unsigned long datasz; /* Transfer size in bytes */ };
unsigned long pdloc;
Four ioctl commands provide access to the pdinfo, VTOC, and VTOC extension information:
struct vtoc_ioctl { int v_nslices; /* number of slices */ struct partition v_slices[V_NUMSLICES]; /* slice headers */ };
struct pdinfo { unsigned long driveid; /*identifies the device type*/ unsigned long sanity; /*verifies device sanity*/ unsigned long version; /*version number*/ char serial[12]; /*serial number of the device*/ unsigned long cyls; /*number of cylinders per drive*/ unsigned long tracks; /*number tracks per cylinder*/ unsigned long sectors; /*number sectors per track*/ unsigned long bytes; /*number of bytes per sector*/ unsigned long logicalst; /*sector address of logical sector 0*/ unsigned long errlogst; /*sector address of error log area*/ unsigned long errlogsz; /*size in bytes of error log area*/ unsigned long mfgst; /*sector address of mfg. defect info*/ unsigned long mfgsz; /*size in bytes of mfg. defect info*/ unsigned long defectst; /*sector address of the defect map*/ unsigned long defectsz; /*size in bytes of defect map*/ unsigned long relno; /*number of relocation areas*/ unsigned long relst; /*sector address of relocation area*/ unsigned long relsz; /*size in sectors of relocation area*/ unsigned long relnext; /*address of next avail reloc sector*//* the previous items are left intact from AT&T's 3b2 pdinfo. Following are added for the 80386 port */
unsigned long vtoc_ptr; /*byte offset of vtoc block*/ unsigned short vtoc_len; /*byte length of vtoc block*/ unsigned short vtoc_pad; /*pad for 16-bit machine alignment*/ unsigned long alt_ptr; /*byte offset of alternates table*/ unsigned short alt_len; /*byte length of alternates table*/
/* new in version 3 */
unsigned long pcyls; /*physical cylinders per drive*/ unsigned long ptracks; /*physical tracks per cylinder*/ unsigned long psectors; /*physical sectors per track*/ unsigned long pbytes; /*physical bytes per sector*/ unsigned long secovhd; /*sector overhead bytes per sector*/ unsigned short interleave; /*interleave factor*/ unsigned short skew; /*skew factor*/ unsigned long pad[8]; /*space for more stuff*/ };
The nodes called /dev/[r]dsk/1s[0-9] will exist only when there is actually a second disk on the system. In the past, these nodes were always created. It is no longer possible to create these nodes when the second disk does not exist because it is not possible to predict the correct minor number for them.