Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > A


HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


autochanger: schgr, eschgr — SCSI interfaces for medium changer device


An autochanger is a SCSI mass storage device, consisting of a mechanical changer device, one or more data transfer devices (such as optical disk drives), and media (such as optical disks) for data storage. The mechanical changer moves media between storage and usage locations within the autochanger.

Two medium changer drivers (schgr or eschgr) provide access to the medium changer device; eschgr is the current preferred method of access and schgr is provided for legacy compatibility. The mechanical changer device can be accessed via these drivers directly to move media within the autochanger.

The schgr and eschgr medium changer device drivers follow the SCSI specification for medium changer devices to provide a generic medium changer interface, making it feasible to construct an application level driver for any mechanical changer, jukebox, library, or autochanger device (MO, tape, CD-ROM).

Device Naming Convention

The device naming convention for the autochanger driver enables accessing the changer device.

Legacy character device file names reside in /dev/rac. Within this directory, names are derived from the c#t#d# device naming convention (explained in intro(7)). Unique legacy device names are determined by the card instance, target address of the SCSI changer device and LUN of the SCSI changer device.

Persistent device file names have the form /dev/rchgr/autochx for character devices. The card instance, target address and LUN are no longer encoded in the persistent device file name itself (see intro(7)).

Major and Minor Number Descriptions

The following shows the bit assignments (dev_t format) used by the schgr changer driver to access the changer device using legacy device files:


MAJOR is the major number of the appropriate driver, INSTANCE is the card instance of the SCSI interface to which the changer device is attached, TARGET is the SCSI target address of the changer device, LUN is the SCSI LUN of the changer device.

All fields in the device number are specified in hexadecimal notation. Note that there is no support for hard partitions (sections) in this minor number. If desired, partitioning can be achieved via LVM soft-partitioning schemes.

Note: The major numbers used by the changer drivers are dynamically assigned starting with release HP-UX 11i v3.

Following is a long listing showing the major and minor numbers associated with the device special file name of the changer:


crw-rw-rw- 1 root sys 231 0x015000 Apr 22 10:22 /dev/rac/c1t5d0


The SCSI medium changer device driver performs moves between different media locations within an autochanger. Each potential media location has a specific element address and is one of the following element types:


A location to hold a unit of media not currently in use. Typically most media will be located in this type of element.


A location for inserting and removing media from the device. Movement of a unit of media to this type of location is in effect an eject operation. Movement of a unit of media from this type of location is a load operation.

data transfer

A location for accessing media data. This is generally the location of a device that reads and/or writes data on the media being handled by the media changer device. Movement to this type of location is a physical-media-mount operation. Movement from this type of location is a physical-media-unmount operation.

media transport

A location for media movement. Media is generally temporarily located in this type of element only during actual media movement.

Changer Control Requests

The following ioctl functions and structure definitions are included from <sys/scsi.h>:

#define SIOC_INIT_ELEM_STAT _IO('S', 51) #define SIOC_ELEMENT_ADDRESSES _IOW('S', 52, struct element_addresses) #define SIOC_ELEMENT_STATUS _IOWR('S', 53, struct element_status) #define SIOC_RESERVE _IOW('S', 54, struct reservation_parms) #define SIOC_RELEASE _IOW('S', 55, struct reservation_parms) #define SIOC_MOVE_MEDIUM _IOW('S', 56, struct move_medium_parms) #define SIOC_EXCHANGE_MEDIUM _IOW('S', 57, struct exchange_medium_parms) /* structure for SIOC_ELEMENT_ADDRESSES ioctl */ struct element_addresses { unsigned short first_transport; unsigned short num_transports; unsigned short first_storage; unsigned short num_storages; unsigned short first_import_export; unsigned short num_import_exports; unsigned short first_data_transfer; unsigned short num_data_transfers; }; /* structure for SIOC_ELEMENT_STATUS ioctl */ struct element_status { unsigned short element; /* element address */ unsigned int resv1:2; unsigned int import_enable:1; /* allows media insertion (load) */ unsigned int export_enable:1; /* allows media removal (eject) */ unsigned int access:1; /* transport element accessible */ unsigned int except:1; /* is in an abnormal state */ unsigned int operatr:1; /* medium positioned by operator */ unsigned int full:1; /* holds a a unit of media */ unsigned char resv2; unsigned char sense_code; /* info. about abnormal state */ unsigned char sense_qualifier; /* info. about abnormal state */ unsigned int not_bus:1; /* transfer device SCSI bus differs */ unsigned int resv3:1; unsigned int id_valid:1; /* bus_address is valid */ unsigned int lu_valid:1; /* lun is valid */ unsigned int sublu_valid:1; /* sub_lun is valid */ unsigned int lun:3; /* transfer device SCSI LUN */ unsigned char bus_address; /* transfer device SCSI address */ unsigned char sub_lun; /* sub-logical unit number */ unsigned int source_valid:1; /* source_element is valid */ unsigned int invert:1; /* media in element was inverted */ unsigned int resv4:6; unsigned short source_element; /* last storage medium location */ char pri_vol_tag[36]; /* volume tag (device optional) */ char alt_vol_tag[36]; /* volume tag (device optional) */ unsigned char misc_bytes[168]; /* device specific */ }; /* structure for SIOC_RESERVE and SIOC_RELEASE ioctls */ struct reservation_parms { unsigned short element; unsigned char identification; unsigned char all_elements; }; /* structure for SIOC_MOVE_MEDIUM ioctl */ struct move_medium_parms { unsigned short transport; unsigned short source; unsigned short destination; unsigned char invert; }; /* structure for SIOC_EXCHANGE_MEDIUM ioctl */ struct exchange_medium_parms { unsigned short transport; unsigned short source; unsigned short first_destination; unsigned short second_destination; unsigned char invert_first; unsigned char invert_second; };


Cause the media changer device to take inventory. As a result, the media changer device determines the status of each and every element address, including the presence or absence of a unit of media. This is a mechanical operation which can take time. This function only necessary in the event of a severe error of the media changer.


Determine the element addresses supported by a media changer device. The first valid element address and the number of elements is indicated for each element type. These element addresses may be used as source and destination location arguments.


Determine the status of an element. The element address for which status information is requested is specified via the element field. The resulting status data indicates the presence or absence of a unit of media in that element address as well as other information about the element address.


Control access to element addresses. Depending on the device, reservations may limit operator control of those element addresses in the media changer device. Specific element addresses can be reserved to handle interlocking between multiple requesters if each requester has a unique reservation identification. The value zero in the all_elements field specifies that a single element address should be reserved or released. An element address reserved in this manner can not be reserved by another single element address reservation using a different reservation identification. The reservation field specifies the reservation identification. The element field specifies the element address to be reserved.

The value "1" in the all_elements field indicates that all element addresses should be reserved. The reservation and element fields should contain the value zero since these fields are not meaningful when reserving all element addresses. Reserving all element addresses is primarily useful for limiting operator control.


Reposition unit(s) of media. Depending on the source and destination element types, this may result in a media load, eject, or simple repositioning. Media can be "flipped" using values of "1" in the invert, invert_first, or invert_second fields. The SIOC_EXCHANGE_MEDIUM ioctl repositions two different units of media. One unit of media is moved from the element specified by the source field to the element specified by the first_destination field. A second unit of media is moved from the element specified by the first_destination field to the element specified by the second_destination field. In an autochanger with multiple changer mechanisms, or a media staging area, an exchange occurs if the source and second_destination fields are the same.


By default, schgr and eschgr are not included in the system configuration (/stand/system) file.


The following example uses the SIOC_ELEMENT_ADDRESSES and SIOC_ELEMENT_STATUS ioctl functions to get bus address information about the drives in an autochanger device:

int last_drive_el; struct element_addresses el_addrs; struct element_status el_stat; drive[1024]; int fd = -1, error = 0, i = 0; fd = open("/dev/rchgr/autoch0",O_RDWR); if ((error = ioctl(fd, SIOC_ELEMENT_ADDRESSES, &el_addrs)) != 0) { perror("ioctl: SIOC_ELEMENT_ADDRESSES"); return -1; } else { last_drive_el = el_addrs.first_data_transfer + el_addrs.num_data_transfers - 1; for (i = el_addrs.first_data_transfer; i <= last_drive_el; i++) { el_stat.element = i; if ((error = ioctl(fd, SIOC_ELEMENT_STATUS, &el_stat)) != 0) { perror("ioctl: SIOC_ELEMENT_ADDRESSES"); return -1; } else { /* * You may wish to also check some of the other fields * in the el_stat structure to verify that the data is * valid. Fields: el_stat.access (ac accessible), * el_stat.except (exception). */ if (! el_stat.not_bus && el_stat.id_valid) { drive[i].bus_address = el_stat.bus_address; if (! el_stat.lu_valid) { drive[i].lun = 0; } else { drive[i].lun = el_stat.lun; } } } } }


Some non-HP media changer devices do not support the SIOC_INIT_ELEM_STAT and SIOC_ELEMENT_STATUS ioctls.

Some older media changer devices do not support the SIOC_EXCHANGE_MEDIUM ioctl. For these devices, multiple SIOC_MOVE_MEDIUM ioctl operations may be used to accomplish the same results, provided a suitable temporary element address may be found.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.