dkio.4

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 4 代码 · 共 166 行

4
166
字号
.\" SCCSID: @(#)dkio.4	2.1	3/10/87.TH dkio 4 VAX.SH Namedkio \- disk interface.SH Syntax\fB#include <sys/fs.h>\fR.br\fB#include <sys/ioctl.h>\fR.SH Description.NXA "disk interface" "dkio file".NXR "dkio file" "ioctl codes"This section describes the ioctl (input/output controller) codes for alldisk drivers..NXR "disk interface" "ioctl codes"The basic ioctl (input/output controller) format is:.sp.br\fB#include <sys/fs.h>\fR.br\fB#include <sys/ioctl.h>\fR.br\fBioctl\fR(\fIfildes, code, arg)\fR.br\fBstruct pt\fR *\fR\fIarg\fR;.sp The applicable \fIcodes\fR are:.IP DIOCGETPT 16Indicates to the driver to storethe information in the current partition table inthe address pointed to by \fIarg\fR.The file descriptor must be opened on the rawpartitions, \fIa\fR or \fIc\fR..IPDIOCGETPT does not change the partition table,but it does provide access to the partition table information..IP DIOCSETPTIndicates to the driver to modifythe current partition table with the informationpointed to by \fIarg\fR..IPThe file descriptor must be opened on the rawpartitions, \fIa\fR or \fIc\fR..IPIf the \fIa\fR or \fIc\fR partition is not mounted,only the partition table in the driver is modified.This temporarily modifies the partition table of the disk.The modifications are overwritten with the default tablewhen the disk is turned off and on..IPIf the \fIa\fR or \fIc\fR partition is mounted,both the partition table in the driver and the partition table inthe primary superblock are modified.This permanently modifies the partition table of the disk.This is not recommended.To change a partition table permanently,use the .MS chpt 8command..IP DIOCDGTPTIndicates to the driver to storethe \fIdefault\fR information of the current partition table inthe address pointed to by \fIarg\fR.The file descriptor must be opened on the rawpartitions, \fIa\fR or \fIc\fR..IPDIOCGETPT does not change the partition table,but it does provide access to the partition table information..IP DKIOCGETAllows the user to receive generic disk information as defined in.PN <sys/devio.h> .I struct devget..IP DKIOCACCThis code is defined in .PN <sys/bbr.h>.For an MSCP class disk, the driver performsone of the following functions:.RS 18.IP ACC_REVEC 11Forces revector of a specified disk block..IP ACC_SCANScans an area of the disk reporting any forced errorsfound and revectoring any bad blocks found..RE.IP DKIOCEXCLThis command is used to set and clear the exclusive access attributeon controllers that provide multihost support.  In this case \fIarg\fRis an integer pointer.  If the value of \fIarg\fR is 0 the exclusive accessattribute will be cleared.  If the value of \fIarg\fR is nonzero theexclusive access attribute will be set.  The exclusive access attributeis set on a per-drive basis and can not be used selectively on individualpartitions..IPAttempts to clear the exclusive attribute will fail if the drive is notcurrently set exclusive access to the issuing host or the underlyingcontroller or driver does not support multihost exclusive access.Attempts to set the exclusive attribute will fail if the drive is alreadyexclusively associated with another host or the underlyingcontroller or driver does not support multihost exclusive access..SH ExamplesThis example shows how to use the DIOGETPT ioctl code toprint the length and offset of the \fIa\fR partition of an RA81 disk:.NXR(e) "disk interface" "DIOGETPT and".EX 0#include <sys/types.h>#include <sys/param.h>#include <sys/fs.h>#include <sys/ioctl.h>main(){	struct pt arg;	int fd, i;	/* Open the "a" partition of the disk you want to see */	if ( (fd = open("/dev/rra0a",0)) < 0 ) {		printf("Unable to open device\\n");		exit(2);	}	/* Get the partition information */	if ( ioctl(fd,DIOCGETPT,&arg) < 0 )		printf("Error in ioctl\\n");	printf("Length\\t\\tOffset\\n");	for ( i = 0; i <= 7; i++ ) {		printf("%d\\t\\t%d\\n",arg.pt_part[i].pi_nblocks,				  arg.pt_part[i].pi_blkoff );	}}.EE.SH Restrictions.NXR "disk interface" "restricted"These restrictions apply when using the DIOCSETPT ioctl code:.IP \(bu 4You must have superuser privileges..IP \(buYou cannot shrink or change the offset of a partitionwith a file system mounted on itor with an open file descriptor on the entire partition..IP \(buYou cannot change the offset of the \fIa\fR partition..IP \(buThe exclusive access ioctl DKIOCEXCL is only supported on HSC version V5.00or later..SH Files.PN /dev/{r}ra???.br.PN /dev/{r}hp???.br.PN /dev/{r}rb???.br.PN /dev/{r}rd???.br.PN /dev/{r}rk???.br.PN /dev/{r}rl???.br.PN /dev/{r}rx???.SH See Alsohp(4), ra(4), rb(4), rd(4), rk(4), rl(4), rx(4), disktab(5), fstab(5), chpt(8), diskpart(8), fsck(8), MAKEDEV(8), mkfs(8), tunefs(8)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?