USB Mass Storage Client Device Driver
Purpose
Supports the Universal Serial Bus (USB) protocol for mass storage and bulk type hard disk, Removable Disk Drive (RDX), flash drives, CD-ROM, DVD-RAM, Blu-ray read-only, and read/write optical memory devices.
Syntax
#include <sys/devinfo.h>
#include <sys/scsi.h>
#include <sys/scdisk.h>
#include <sys/ide.h>
#include <sys/usb.h>
#include <sys/usbdi.h>
#include <sys/mstor.h>
Description
Typical USB hard disk, RDX,
flash drives, CD-ROM, DVD-RAM, Blu-ray read-only, and read/write optical
drive operations are implemented by using the open
, close
, read
, write
,
and ioctl
subroutines.
Device-dependent subroutines
The USB mass
storage device driver supports only the open
, close
, ioctl
,
and config
subroutines.
open and close subroutines
The openx
subroutine
is primarily used by the diagnostic commands and utilities. Appropriate
authority is required to run the subroutine. If you run the open
subroutine
without the required authority, the subroutine returns a value of
-1 and sets the errno global variable to a value
of EPERM
.
The ext parameter that is specified in the openx subroutine selects the operation to be used for the target device. The /usr/include/sys/usb.h file defines the possible values for the ext parameter.
The ext parameter can contain any logical combination of the following flag values:
Item | Description |
---|---|
SC_DIAGNOSTIC | Places the selected device in the Diagnostic mode.
This mode is singularly entrant, which means that only one process
at a time can open the device at a time. When a device is in the Diagnostic mode,
the USB devices are initialized during the open or close operations,
and error logging is disabled. In the Diagnostic mode,
only the close and ioctl subroutine
operations are accepted. All other device-supported subroutines return
a value of -1 and set the errno global variable
to a value of EACCES .A device can be opened in
the |
SC_SINGLE | Places the selected device in the Exclusive
Access mode. Only one process can open a device in the Exclusive
Access mode at a time. A device can be opened in the |
readx and writex subroutines
The readx
and writex
subroutines
are not supported on USB devices. Even if they are called, the ext parameter
is not processed.
ioctl subroutine
ioctl
subroutine
operations that are used for the usbcd
device driver
are specific to the following categories of USB devices:- Common
ioctl
operations for all USB devices - USB hard disk, flash drive, and RDX devices
- USB CD-ROM and read/write optical devices
Common ioctl operations supported for all USB devices
The
following ioctl
operations are available for hard
disk, flash drive, RDX, CD-ROM, and read/write optical devices:
Operation | Description |
---|---|
DKIORDSE | Issues a read command to the device and obtains
the target-device sense data when an error occurs. If the DKIORDSE operation
returns a value of -1 and if the status_validity field
is set to the SC_SCSI_ERROR value, valid sense data
is returned. Otherwise, target sense data is omitted.The The Note: The
CDIORDSE operation
can be substituted for the DKIORDSE operation when
the read command is issued to obtain sense data from a CD-ROM device.
The DKIORDSE operation is the recommended operation. |
DKIOCMD | When the device is successfully opened in the Normal or Diagnostic mode,
the DKIOCMD operation can issue any Small Computer
System Interface (SCSI) command to the specified device. The device
driver does not log any error recovery or failures of this operation.The
SCSI status byte and the adapter status bytes are returned through
the arg parameter that contains the address of
a The |
DKIOCMD (continued) | The following example code issues the DKIOCMD ioctl
operation to the usbms0 device to get the SCSI standard
inquiry data:
|
DKIOLCMD | When the device is successfully opened in the Normal or Diagnostic mode,
the DKIOLCMD operation can issue any SCSI command
to the specified device. The device driver does not log any error
recovery failures of this operation. This The
SCSI status byte and the adapter status bytes are returned through
the arg parameter that contains the address of
a On completion of the The |
DKIOLCMD (continued) | The following example code issues the DKIOLCMD ioctl
operation to the usbms0 device to get the SCSI standard
inquiry data:
|
DK_PASSTHRU | When the device is successfully opened, the DK_PASSTHRU operation
can issue any SCSI command to the specified device. The device driver
performs limited error recovery if this operation fails. The DK_PASSTHRU operation
differs from the DKIOCMD operation such that it does
not require an openx command with the ext argument
of the SC_DIAGNOSTIC field. Because of this, the DK_PASSTHRU operation
can be issued to devices that are in use by other operations. The
SCSI status byte and the adapter status bytes are returned through
the arg parameter that contains the address of
a If a The
version field of the
sc_passthru structure can be
set to the value of SCSI_VERSION_2 and you can specify
the following fields:
On completion of the The Note: If
you call the
DK_PASSTHRU operation as a non-root
user, the operation fails with the EACCES error value
instead of the EPERM value. |
DK_PASSTHRU (continued) | The following example code issues the DK_PASSTHRU
ioctl operation to the usbms0 device to
get the SCSI standard inquiry data:
|
ioctl operations for USB hard disk, flash drive, and RDX devices
The following ioctl
operations
are available for USB hard disk, flash drive, and RDX devices only:
Operation | Description |
---|---|
IOCINFO | Returns the devinfo structure
that is defined in the /usr/include/sys/devinfo.h file.
The IOCINFO operation is the only operation that
is defined for all device drivers that use the ioctl subroutine.
The following values are returned:
|
DKPMR | Issues an SCSI prevent media removal (PMR) command
when the device is successfully opened. This command prevents media
from being ejected until the device is closed, powered off and restarted,
or until a DKAMR operation is issued. The arg parameter
for the DKAMR operation is null. If the DKAMR operation
is successful, the subroutine returns a value of 0. If the device
is an SCSI hard disk, the DKAMR operation fails,
the subroutine returns a value of -1, and sets the errno global
variable to a value of EINVAL . If the DKAMR operation
fails for any other reason, the subroutine returns a value of -1 and
sets the errno global variable to a value of EIO .Note: This
function is provided to support the USB RDX devices that support ejecting
the media cartridges.
|
DKAMR | Issues an allow media removal (AMR) command
when the device is successfully opened. The media can then be ejected
by using either the driver's eject button or the DKEJECT operation.
The arg parameter for this ioctl operation
is null. If the DKAMR operation is successful, the
subroutine returns a value of 0. If the device is an SCSI hard disk,
the DKAMR operation fails. In addition, the subroutine
returns a value of -1 and sets the errno global
variable to a value of EINVAL . For any other cause
of failure of this operation, the subroutine returns a value of -1,
and sets the errno global variable to a value of EIO .Note: This
function is provided to support the USB RDX devices that support ejecting
the media cartridges.
|
ioctl operations for CD-ROM and read/write optical devices
The
following ioctl
operations are available for CD-ROM
and read/write optical devices:
Operation | Description |
---|---|
IOCINFO | Returns the devinfo structure
that is defined in the /usr/include/sys/devinfo.h file.
The IOCINFO operation is the only operation that
is defined for all device drivers that use the ioctl subroutine.
The following values are returned:
|
IDEPASSTHRU | Issues an AT Attachment Packet Interface (ATAPI)
command to the specified device when the device is successfully opened.
The IDEPASSTHRU operation does not require an openx command
with the ext argument of the SC_DIAGNOSTIC value.
Therefore, an IDEPASSTHRU operation can be issued
to devices that are in use by other operations. The AT Attachment
(ATA) status bytes and the ATA error bytes are returned through the arg parameter.
This parameter contains the address of an If the On
successful completion of the |
IDEPASSTHRU (continued) | The following example code issues an SCSI
inquiry command that uses the
|
DKPMR | Issues a Small Computer System Interface (SCSI)
prevent media removal command when the device is successfully opened.
This command prevents media from ejecting until the device is closed,
powered off and then powered on, or until a DKAMR operation
is issued. The arg parameter for the DKPMR operation
is null. If the DKPMR operation is successful, the
subroutine returns a value of 0. If the device is an SCSI hard disk,
the DKPMR operation fails, the subroutine returns
a value of -1, and sets the errno global variable
to a value of EINVAL . If the DKPMR operation
fails because of any other reason, the subroutine returns a value
of -1 and sets the errno global variable to a value
of EIO . |
DKAMR | Issues an allow media removal command when the
device is successfully opened. The media can be ejected by using either
the drives eject button or the DKEJECT operation.
The arg parameter for this operation is null.
If the DKAMR operation is successful, the subroutine
returns a value of 0. If the device is an SCSI hard disk, the DKAMR operation
fails, and the subroutine returns a value of -1 and sets the errno global
variable to a value of EINVAL . For any other cause
of operation failure, the subroutine returns a value of -1 and sets
the errno global variable to a value of EIO . |
DKEJECT | Issues an eject media command to the drive when
the device is successfully opened. The arg parameter
for this operation is null. If the DKEJECT operation
is successful, the subroutine returns a value of 0. If the device
is an SCSI hard disk, the DKEJECT operation fails,
the subroutine returns a value of -1, and sets the errno global
variable to a value of EINVAL . For any other cause
of operation failure, the subroutine returns a value of -1 and sets
the errno variable to a value of EIO . |
DKAUDIO | Issues a play audio command to the specified
device and controls the volume on the device's output ports. Play
audio commands can play, pause, resume, stop, determine the number
of tracks, and determine the status of a current audio operation.
The DKAUDIO operation plays audio only through the
CD-ROM drive's output ports. The arg parameter
of this operation is the address of a cd_audio_cmds structure
that is defined in the /usr/include/sys/scdisk.h file.
Exclusive access mode is required.If the |
DK_CD_MODE | Issues one of the following commands:
If a CD-ROM is not configured for different data
modes by using the mode-select density codes, and if you change the
CD-ROM data mode by setting the action field of the |
Device hardware requirements
USB hard disk, flash drive, RDX, CD-ROM, and read/write optical drives have the following hardware requirements:
- These drives must support a block size of 512 bytes per block.
- If mode sense is supported, the write-protection (WP) bit must also be supported for sequential access memory (SAM) hard disks and read/write optical drives.
- USB hard disks, flash drives, RDX, and read/write optical drives must report the hardware retry count in bytes of the request sense data for recovered errors. If the USB hard disk or read/write optical drive does not support this feature, the system error log might indicate premature drive failure.
- USB CD-ROM and read/write optical drives must support the 10-byte SCSI read command.
- USB hard disks, flash drives, RDX, and read/write optical drives must support the SCSI write and verify command and the 6-byte SCSI write command.
- The read/write optical drive must set the format options valid
(FOV) bit to 0 for the defect list header of the SCSI format unit
command to use the format command operation. If the drive does not
support this feature, you can write an application for the drive so
that it formats the media by using the
DKFORMAT
operation. - If a USB CD-ROM drive uses CD_ROM Data Mode 1 format, it must support a block size of 512 bytes per block.
- If a USB CD-ROM drive uses CD_ROM data Mode 2 Form 1 format, it must support a block size of 2048 bytes per block.
- If a USB CD-ROM drive uses CD_ROM data Mode 2 Form 2 format, it must support a block size of 2336 bytes per block.
- If a USB CD-ROM drive uses CD_DA mode, it must support a block size of 2352 bytes per block.
- To control the volume by using the
DKAUDIO
(play audio) operation, the device must support the SCSI-2 mode data page0xE
. - To use the
DKAUDIO
(play audio) operation, the device must support the following SCSI-2 optional commands:- read sub-channel
- pause resume
- play audio mail summary file (.msf)
- play audio track index
- read table of contents (TOC)
devices.usbif.08025002
# cfgmgr -l usb0
# rmdev -l usbmsn
or#rmdev –l cdn
When
a drive is in the available state, you can reconnect the drive to
the system, and the drive can be remounted or reopened. If a drive
is disconnected from a system USB port while it is still open for
a user, that drive is not reusable until you close and reopen it.AIX Version 6.1 with the 6100-06 Technology Level recognizes and configures USB attached Blu-ray drives as read-only. The AIX operating system does not support the write operation to CD, DVD, or Blu-ray media that are present in the USB Blu-ray drive. Although the write operation is not prevented (if the drive is write-capable), no support is provided for any issues that are encountered during the write operation.
The capability of the AIX operating system to operate on USB original equipment manufacturer (OEM) flash drive, Blu-ray, and optical devices is validated against a sample of industry standard OEM USB devices that are compliant with the USB standards. You might encounter issues with certain USB devices that are not compliant and the AIX operating system does not provide any support for those issues.