DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

vtoc(7)


vtoc -- fdisk disk partition and UnixWare slices

Description

The first level of organization of the disk by vtoc is the partition table. The partition table divides the disk into pieces (called partitions) that serve as logical disks. There are a maximum of four partitions for each disk. A partition has four characteristics:

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:


Slice 0
The whole UNIX partition; it has the same start and length as the UNIX partition.

Slice 7
The boot slice that contains UNIX boot code (if it is the boot disk), the VTOC information, and the PDINFO (described later). This slice occupies sector 1 through 34 of UNIX partition.

Slice 8
The alternates slice, containing the table of remapped sectors, sectors that have been remapped, sectors that have read-errors but which have not yet been remapped, and spare sectors available for remapping.

This slice is optional, and may not be present.


Slice 9
Used in SVR4.0 and earlier UNIX releases additionally as the alternate track area. The alternates mechanism was consolidated beginning with SVR4.2 to use one slice. Therefore, Slice 9 can be used for any purpose.

On the boot disk there are additional slices that have required definitions:


Slice 1
the root file system

Slice 2
the swap slice

Slice 10
the boot slice which is organized as a BFS filesystem

On a boot disk optional filesystems are organized as follows:


Slice 3
the /home filesystem

Slice 4
the /home2 filesystem

Slice 5
currently unused

Slice 6
the dump slice (holds memory dumps)

Slice 9
currently unused

Slice 11
the /var filesystem

Slice 12
the /home2 filesystem

Slice 13
the /tmp filesystem

Slice 14
the Volume Management public slice

Slice 15
the Volume Management private slice

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.


NOTE: Access to the active UNIX partition is prohibited if you specify the slice in the form pP. Also the vtoc driver map report a bad block residing in a non-UNIX system (for example, MS-DOS) partition of the disk.

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.

ioctl calls

The ioctl calls used by the vtoc driver to control the reading and writing of data to disk are as follows:

VTOC_NBLK
Returns the number of logical (512-byte) blocks per physical block.

V_CONFIG
Used to modify the parameters (cylinders and heads) of a disk device. Its usage is not recommended and it is no longer used in any of the system commands. The argument to the ioctl is the address of one of the following structures, defined in sys/vtoc.h, containing the new configuration parameters:
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.

V_REMOUNT
Forces vtoc to re-read the VTOC on the next open operation of the drive. It fails if any slice other than slice 0 is currently open, because the VTOC information cannot be updated while a process is using a slice. This is used by disksetup(1M) when it changes the VTOC to signal vtoc to update its internal tables. This call will not work with a disk that does not have a UNIX partition.

V_GETPARMS
Gets information about the current drive configuration. The argument to the ioctl is the address of the following structure, defined in sys/vtoc.h, which is filled in by the ioctl:
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 */
}

/* 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 */

For SCSI disks the disk type is DPT_SCSI_HD. For ESDI, ST506, and IDE disks, the disk type is DPT_WINI.


NOTE: To support disks with more than 65535 cylinders, the definition of the 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.


V_PDLOC
Returns the logical sector address of the pdinfo structure. The value is returned in pdloc:
unsigned long	pdloc;
This call will not work with a disk that does not have a UNIX partition.

V_RDABS and V_WRABS
Used as a means for reading and writing any sector on the hard disk. Only users with root privilege can freely access any sector. The absolute physical sector address to be written to is placed in abs_sec. The data for the sector is read to or written from abs_buf. The size of abs_buf should be 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 */
};

V_PREAD and V_PWRITE
Used to read or write one or more sectors. Data size must be a multiple sector size. Only users with root privilege can use these calls. The starting physical sector address to be written to or read from is placed in sectst, the number of bytes to be transferred is placed in datasz, the data to be transferred is placed in memaddr, and the phyio structure is defined in sys/vtoc.h:
struct phyio {
	int         retval;        /* Return value */
	unsigned    long sectst;   /* Sector address */
	unsigned    long memaddr;  /* Buffer address */
	unsigned    long datasz;   /* Transfer size in bytes */
};

V_PDREAD and V_PDWRITE
Used to read or write the Physical Description sector on the disk, regardless of this sector's location. Only users with root privilege can use these calls. The starting logical sector address to be written to or read from is assigned by the vtoc driver, the physical sector size of the disk must be placed in datasz, the data to be transferred is placed in memaddr, and the phyio structure is defined in sys/vtoc.h.

SD_PDLOC
Returns the physical sector address of the pdinfo structure. The value is returned in pdloc:
unsigned long	pdloc;

SDI_RELEASE
Releases a SCSI disk from a processor.

Four ioctl commands provide access to the pdinfo, VTOC, and VTOC extension information:


V_READ_VTOC and V_WRITE_VTOC
Used to read or write a VTOC for a drive. The argument to the call is the address of the following structure defined in sys/vtoc.h.
struct vtoc_ioctl {
	int v_nslices;				/* number of slices */
	struct partition v_slices[V_NUMSLICES];	/* slice headers */
};

V_READ_PDINFO and V_WRITE_PDINFO
Used to read or write a Physical Descriptor Information (PDINFO) structure that is stored in the boot slice of the disk. The PDINFO is kept as a sanity check against those found at driver init time. The pdinfo structure is defined in sys/vtoc.h:
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*/ };

Usage

The vtoc disk target driver allows access to non-UNIX partitions on a disk, even if there is no UnixWare partition or VTOC. It does so by using the information in the fdisk(1M) table and the /dsk/cCbBtTdDp[0-4] special device nodes.

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.

Files


/dev/dsk/*

/dev/rdsk/*

/usr/include/sys/scsi.h

/usr/include/sys/sdi.h

/usr/include/sys/sdi_edt.h

/usr/include/sys/vtoc.h

References

disksetup(1M), edvtoc(1M), fdisk(1M), intro(7), ioctl(2) mount(1M), prtvtoc(1M), sc01(7), sd01(7), sdi(7), st01(7), sw01(7),
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004