STIOC_GET DENSITY and STIOC_SET_DENSITY
The STIOC_GET_DENSITY IOCTL is used to query the current write density format settings on the tape drive. The current density code from the drive Mode Sense header, the Read/Write Control Mode page default density and pending density are returned.
The STIOC_SET_DENSITY IOCTL is used to set a new write density format on the tape drive by using the default and pending density fields. The density code field is not used and ignored on this IOCTL. The application can specify a new write density for the current loaded tape only or as a default for all tapes. Refer to the examples below.
The application must get the current density settings first before the current settings are modified. If the application specifies a new density for the current loaded tape only, then the application must issue another set density IOCTL after the current tape is unloaded and the next tape is loaded to either the default maximum density or a new density to ensure the tape drive uses the correct density. If the application specifies a new default density for all tapes, the setting remains in effect until changed by another set density IOCTL or the tape drive is closed by the application.
struct density_data_t
{
char density_code; /* mode sense header density code */
char default_density; /* default write density */
char pending_density; /* pending write density */
char reserved[9];
};
- These IOCTLs are supported only on tape drives that can write multiple density formats. Refer to the Hardware Reference for the specific tape drive to determine whether multiple write densities are supported. If the tape drive does not support these IOCTLs, errno EINVAL is returned.
- The device driver always sets the default maximum write density for the tape drive on every open system call. Any previous STIOC_SET_DENSITY IOCTL values from the last open are not used.
- If the tape drive detects an invalid density code or cannot run the operation on the STIOC_SET_DENSITY IOCTL, the errno is returned and the current drive density settings before the IOCTL are restored.
- The struct density_data_t defined in the header file is used for both IOCTLs. The density_code field is not used and ignored on the STIOC_SET_DENSITY IOCTL.
Examples
struct density_data_t data;
/* open the tape drive */
/* get current density settings */
rc = ioctl(fd, STIOC_GET_DENSITY, %data);
/* set 3592 J1A density format for current loaded tape only */
data.default_density = 0x7F;
data.pending_density = 0x51;
rc = ioctl(fd, STIOC_SET_DENSITY, %data);
/* unload tape */
/* load next tape */
/* set 3592 E05 density format for current loaded tape only */
data.default_density = 0x7F;
data.pending_density = 0x52;
rc = ioctl(fd, STIOC_SET_DENSITY, %data);
/* unload tape */
/* load next tape */
/* set default maximum density for current loaded tape */
data.default_density = 0;
data.pending_density = 0;
rc = ioctl(fd, STIOC_SET_DENSITY, %data);
/* close the tape drive */
/* open the tape drive */
/* set 3592 J1A density format for current loaded tape and all subsequent tapes */
data.default_density = 0x51;
data.pending_density = 0x51;
rc = ioctl(fd, STIOC_SET_DENSITY, %data);