The extended open operation

An extended open operation is also supported on the device. This operation allows special types of processing during the opening and subsequent closing of the tape device. The Extended Open command is
tapefd=openx("/dev/rmt0",O_FLAGS,NULL,E_FLAGS);
smcfd=openx("/dev/smc0",O_FLAGS,NULL,E_FLAGS);

The O_FLAGS parameter provides the same options that are described in Opening the special file for I/O. The third parameter is always NULL. The E_FLAGS parameter provides the extended options. The E_FLAGS values can be combined during an open operation or they can be used with an OR operation.

The E_FLAGS parameter has the following flags.
  • SC_RETAIN_RESERVATION

    This flag prevents the SCSI Release command from being sent during a close operation.

  • SC_FORCED_OPEN

    The flag forces the release of any current reservation on the device by an initiator. The reservation can either be a SCSI Reserve or SCSI Persistent Reserve.

  • SC_KILL_OPEN

    This flag kills all currently open processes and then exits the open with errno EINPROGRESS returned.

  • SC_PR_SHARED_REGISTER

    This flag overrides the configuration reservation type attribute whether it was set to reserve_6 or persistent. It sets the device driver to use Persistent Reserve while the device is open until closed. The configuration reservation type attribute is not changed and the next open without using this flag uses the configuration reservation type. The device driver also registers the host reservation key on the device. This flag can be used with the other extended flags.

  • SC_DIAGNOSTIC

    The device is opened in diagnostic mode, and no SCSI commands are sent to the device during an open operation or a close operation. All operations (such as reserve and mode select) must be processed by the application.

  • SC_NO_RESERVE

    This flag prevents the SCSI Reserve command from being sent during an open operation.

  • SC_PASSTHRU

    No SCSI commands are sent to the device during an open operation or a close operation. All operations (such as reserve the device, release the device, and set the tape parameters) must be processed explicitly by the application. This flag is the same as the SC_DIAGNOSTIC flag. The exception is that a SCSI Test Unit Unit Ready command is issued to the device during an open operation to clear any unit attentions.

  • SC_FEL

    This flag turns on the forced error logging in the tape device for read and write operations.

  • SC_NO_ERRORLOG

    This flag turns off the AIX® error logging for all read, write, or IOCTL operations.

  • SC_TMCP

    This flag allows up to eight processes to concurrently open a device when the device is already open by another process. There is no restriction for medium changer IOCTL commands that can be issued when this flag is used. However, for tape devices only a limited set of IOCTL commands can be issued. If an IOCTL command cannot be used with this flag, then errno EINVAL is returned.

    If another process already has the device open with this flag, the open fails, and the errno is set to EAGAIN.

If the open system call fails, the errno value contains the error code. See Return codes for a description of the errno values.