SET_LOGICAL_BLOCK_PROTECTION

The IOCTL enables or disables Logical Block Protection, sets up what method is used, and where the protection information is included.

The lbp_capable field is ignored in this IOCTL by the Atape driver. If the lbp_method field is 0 (LBP_DISABLE), all other fields are ignored and not used. When the lbp_method field is set to a valid non-zero method, all other fields are used to specify the setup for LBP.

The data structure that is used with this IOCTL is
struct logical_block_protection
{
   uchar lbp_capable;    /* [OUTPUT] the capability of lbp for QUERY ioctl only */
   uchar lbp_method;     /* lbp method used for QUERY [OUTPUT] and SET [INPUT] ioctls */
     #define  LBP_DISABLE           0x00
     #define  REED_SOLOMON_CRC      0x01
   uchar lbp_info_length;  /* lbp info length for QUERY [OUTPUT] and SET [INPUT] ioctls */
   uchar lbp_w;          /* protection info included in write data */
                         /* a boolean for QUERY [OUTPUT] and SET [INPUT] ioctls */ 
   uchar lbp_r;          /* protection info included in read data */
                         /* a boolean for QUERY [OUTPUT] and SET [INPUT] ioctls */
   uchar rbdp;           /* protection info included in recover buffer data */ 
                         /* a boolean for QUERY [OUTPUT] and SET [INPUT] ioctls */
   uchar reserved[26];   
};
Examples of the SET_LOGICAL_BLOCK_PROTECTION IOCTL
#include <sys/Atape.h>

 int rc; 
  struct logical_block_protection lbp_protect;

  printf("Setting Logical Block Protection....\n\n");

  printf ("Enter Logical Block Protection method:      ");
  gets (buf);
  lbp_protect.lbp_method= atoi(buf);
  printf ("Enter Logical Block Protection Info Length: ");
  gets (buf);
  lbp_protect.lbp_info_length= atoi(buf);
  printf ("Enter Logical Block Protection for Write:   ");
  gets (buf);
  lbp_protect.lbp_w= atoi(buf);
  printf ("Enter Logical Block Protection for Read:    ");
  gets (buf);
  lbp_protect.lbp_r= atoi(buf);
  printf ("Enter Logical Block Protection for RBDP:    ");
  gets (buf);
  lbp_protect.rbdp= atoi(buf);

  rc = ioctl(fd, SET_LOGICAL_BLOCK_PROTECTION, &lbp_protect);

  if (rc)
     printf ("Set Logical Block Protection Fails (rc %d)",rc);
  else
     printf ("Set Logical Block Protection Succeeds");
Note:
  1. The drive always expects a CRC attached with a data block when LBP is enabled for lbp_r and lbp_w. Without the CRC bytes attachment, the drive fails the Read and Write command. To prevent the CRC block transfer between the drive and application, the maximum block size limit must be determined by application. Call the STIOCQRYP IOCTL and get the system maximum block size limit. Call the Read Block Limits command to get the drive maximum block size limit. Then, use the minimum of the two limits.
  2. When a unit attention with a power-on and device reset (Sense key/Asc-Ascq x6/x2900) occurs, the LBP enable bits (lbp_w, lbp_r, and rbdp) are reset to OFF by default. Atape tape driver returns EIO for an IOCTL call in this situation. Once the application determines it is a reset unit attention in the sense data, it responses to query LBP setup and reissues this IOCTL to set up LBP properly.
  3. The LBP setting is controlled by the application and not the device driver. If an application enables LBP, it must also disable LBP when it closes the drive, as this action is not done by the device driver.