SIOC_REQSENSE

This IOCTL command returns the device sense data. If the last command resulted in an input/output error (EIO), the sense data is returned for the error. Otherwise, a new sense command is issued to the device.

The data structure is
struct request_sense
  {
      uint        valid:1,          /* sense data is valid */
                  err_code:7;       /* error code */
      uchar       segnum;           /* segment number */
      uint        fm:1,             /* filemark detected */
                  eom:1,            /* end of medium */
                  ili:1,            /* incorrect length indicator */
                  resvd1:1,         /* reserved */
                  key:4;            /* sense key */
      signed int  info;             /* information bytes */
      uchar       addlen;           /* additional sense length */
      uint        cmdinfo;          /* command specific information */
      uchar       asc;              /* additional sense code */
      uchar       ascq;             /* additional sense code qualifier */
      uchar       fru;              /* field replaceable unit code */
      uint        sksv:1,           /* sense key specific valid */
                  cd:1,             /* control/data */
                  resvd2:2,         /* reserved */
                  bpv:1,            /* bit pointer valid */
                  sim:3;            /* system information message */
      uchar       field[2];         /* field pointer */
      uchar       vendor[109];      /* vendor specific (padded to 127) */
  };
An example of the SIOC_REQSENSE command is
#include <sys/Atape.h>

  struct request_sense sense_data;

  if (!ioctl (smcfd, SIOC_REQSENSE, &sense_data))
  {
      printf ("The SIOC_REQSENSE ioctl succeeded\n");
      printf ("\nThe request sense data is:\n");
      dump_bytes ((uchar *)&sense_data, sizeof (struct request_sense));
  }
  else
  {
      perror ("The SIOC_REQSENSE ioctl failed");
  }