United States-English |
|
|
HP-UX Reference > Aautochanger(7)HP-UX 11i Version 3: February 2007 |
|
NAMEautochanger: schgr, eschgr — SCSI interfaces for medium changer device DESCRIPTIONAn 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 ConventionThe 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 DescriptionsThe 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: schgr: crw-rw-rw- 1 root sys 231 0x015000 Apr 22 10:22 /dev/rac/c1t5d0 SCSI MEDIUM CHANGER DEVICE DRIVERThe 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:
Changer Control RequestsThe 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; };
DEFAULT CONFIGURATIONSBy default, schgr and eschgr are not included in the system configuration (/stand/system) file. EXAMPLESThe 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; } } } } } WARNINGSSome 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 | ||
|