[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4 Files Reference

rhdisk Special File

Purpose

Provides raw I/O access to the physical volumes (fixed-disk) device driver.

Description

The rhdisk special file provides raw I/O access and control functions to physical-disk device drivers for physical disks. Raw I/O access is provided through the /dev/rhdisk0, /dev/rhdisk1, ..., character special files.

Direct access to physical disks through block special files should be avoided. Such access can impair performance and also cause data consistency problems between data in the block I/O buffer cache and data in system pages. The /dev/hdisk block special files are reserved for system use in managing file systems, paging devices and logical volumes.

The r prefix on the special file name indicates that the drive is to be accessed as a raw device rather than a block device. Performing raw I/O with a fixed disk requires that all data transfers be in multiples of the disk block size. Also, all lseek subroutines that are made to the raw disk device driver must result in a file-pointer value that is a multiple of the disk-block size.

Usage Considerations

Attention: Data corruption, loss of data, or loss of system integrity (system crashes) will occur if devices supporting paging, logical volumes, or mounted file systems are accessed using block special files. Block special files are provided for logical volumes and disk devices on the operating system and are solely for system use in managing file systems, paging devices, and logical volumes. They should not be used for other purposes.
open and close Subroutines

The openx subroutine provides additional functions to the open sequence. This subroutine requires appropriate permission to execute. Attempting to do so without the proper permission results in a return value of -1, with the errno global variable set to EPERM.

read and write Subroutines

The readx and writex subroutines provide for additional parameters affecting the raw data transfer. The ext parameter specifies certain options that apply to the request being made. The options are constructed by logically ORing zero or more of the following values.

Note: The following operations can be used only with the writex subroutine.
WRITEV Perform physical write verification on this request.
HWRELOC Perform hardware relocation of the specified block before the block is written. This is done only if the drive supports safe relocation. Safe relocation ensures that once the relocation is started, it will complete safely regardless of power outages.
UNSAFEREL Perform hardware relocation of the specified block before the block is written. This is done if the drive supports any kind of relocation (safe or unsafe).
ioctl Subroutine

Only one ioctl operation, IOCINFO, is defined for all device drivers that use the ioctl subroutine. The remaining ioctl operations are all specific to physical-disk devices. Diagnostic mode is not required for the IOCINFO operation.

The IOCINFO ioctl operation returns a structure for a device type of DD_DISK. This structure is defined in the /usr/include/sys/devinfo.h file.

Error Codes

In addition to the errors listed for the ioctl, open, read, and write subroutines, the following other error codes are also possible:

EACCES An open subroutine call has been made to a device in Diagnostic mode.
EACCES A diagnostic openx subroutine call has been made to a device already opened.
EACCES A diagnostic ioctl operation has been attempted when not in Diagnostic mode.
EINVAL An nbyte parameter to a read or write subroutine is not a multiple of the disk block size.
EINVAL An unsupported ioctl operation has been attempted.
EINVAL An unsupported readx or writex subroutine has been attempted.
EMEDIA The target device has indicated an unrecovered media error.
ENXIO A parameter to the ioctl subroutine is invalid.
ENXIO A read or write subroutine has been attempted beyond the end of the disk.
EIO The target device cannot be located or is not responding.
EIO The target device has indicated an unrecovered hardware error.
EMFILE An open subroutine has been attempted for an adapter that already has the maximum permissible number of opened devices.
EPERM The caller lacks the appropriate privilege.

Implementation Specifics

The rhdisk special file is part of Base Operating System (BOS) Runtime.

Files

/dev/hdisk0, /dev/hdisk1, ... /dev/hdiskn Provide block I/O access to the physical volumes (fixed-disk) device driver.

Related Information

Special Files Overview.

The close subroutine, ioctl subroutine, lseek subroutine, open subroutine, read subroutine, write subroutine.

Direct Access Storage Device (DASD) Overview in AIX Kernel Extensions and Device Support Programming Concepts.

SCSI Subsystem Overview in AIX Kernel Extensions and Device Support Programming Concepts.

scdisk SCSI Device Driver in AIX Technical Reference: Kernel and Subsystems Volume 1.

Serial DASD Subsystem Device Driver in AIX Technical Reference: Kernel and Subsystems Volume 1.


[ Previous | Next | Contents | Glossary | Home | Search ]