29const char *
os_XXXX_c_cvsid=
"$Id: os_qnxnto.cpp 4842 2018-12-02 16:07:26Z chrfranke $" \
35#define ARGUSED(x) ((void)(x))
39static int ata_sense_data(
void *sdata,
int *error,
int *key,
int *asc,
int *ascq);
40static int ata_interpret_sense(
struct cam_pass_thru *cpt,
void *sense,
int *status,
int rcount);
47 printf(
"=================================================== SMARTCTL EXAMPLES =====\n\n"
48 " smartctl -a /dev/hd0 (Prints all SMART information)\n\n"
49 " smartctl --smart=on --offlineauto=on --saveauto=on /dev/hd0\n"
50 " (Enables SMART on first disk)\n\n"
51 " smartctl -t long /dev/hd0 (Executes extended disk self-test)\n\n"
52 " smartctl --attributes --log=selftest --quietmode=errorsonly /dev/hd0\n"
53 " (Prints Self-Test & Attribute errors)\n"
54 " smartctl -a --device=3ware,2 /dev/sda\n"
55 " (Prints all SMART info for 3rd ATA disk on 3ware RAID controller)\n"
67int len,dev_prefix_len;
69 if(!dev_name||!(len=strlen(dev_name)))
70 return(CONTROLLER_UNKNOWN);
73 if(len<=dev_prefix_len)
74 return(CONTROLLER_UNKNOWN);
76 dev_name += dev_prefix_len;
79 return(CONTROLLER_ATA);
80 return(CONTROLLER_UNKNOWN);
103 if(!strcmp(type,
"ATA"))
104 return(open(pathname,O_RDWR|O_NONBLOCK));
133struct cam_pass_thru cpt;
137 memset(&cpt,0x00,
sizeof(
struct cam_pass_thru));
143 cpt.cam_flags = CAM_DIR_IN;
144 cpt.cam_cdb_len = 16;
145 cpt.cam_dxfer_len = 512;
146 cpt.cam_data_ptr = (uint32_t)
data;
147 cpt.cam_sense_len =
sizeof(sense);
148 cpt.cam_sense_ptr = (uint32_t)&sense;
158 cpt.cam_flags = CAM_DIR_IN;
159 cpt.cam_cdb_len = 16;
160 cpt.cam_dxfer_len = 512;
161 cpt.cam_data_ptr = (uint32_t)
data;
162 cpt.cam_sense_len =
sizeof(sense);
163 cpt.cam_sense_ptr = (uint32_t)&sense;
173 cpt.cam_flags = CAM_DIR_IN;
174 cpt.cam_cdb_len = 16;
175 cpt.cam_dxfer_len = 512;
176 cpt.cam_data_ptr = (uint32_t)
data;
177 cpt.cam_sense_len =
sizeof(sense);
178 cpt.cam_sense_ptr = (uint32_t)&sense;
184 cdb->ata_pass_thru.sector_count= 1;
185 cdb->ata_pass_thru.lba_low = select;
193 cpt.cam_flags = CAM_DIR_IN;
194 cpt.cam_cdb_len = 16;
195 cpt.cam_dxfer_len = 512;
196 cpt.cam_data_ptr = (uint32_t)
data;
197 cpt.cam_sense_len =
sizeof(sense);
198 cpt.cam_sense_ptr = (uint32_t)&sense;
205 cpt.cam_flags = CAM_DIR_IN;
206 cpt.cam_cdb_len = 16;
207 cpt.cam_dxfer_len = 512;
208 cpt.cam_data_ptr = (uint32_t)
data;
209 cpt.cam_sense_len =
sizeof(sense);
210 cpt.cam_sense_ptr = (uint32_t)&sense;
217 cpt.cam_flags = CAM_DIR_NONE;
218 cpt.cam_cdb_len = 16;
219 cpt.cam_sense_len =
sizeof(sense);
220 cpt.cam_sense_ptr = (uint32_t)&sense;
229 cpt.cam_flags = CAM_DIR_NONE;
230 cpt.cam_cdb_len = 16;
231 cpt.cam_sense_len =
sizeof(sense);
232 cpt.cam_sense_ptr = (uint32_t)&sense;
242 cpt.cam_flags = CAM_DIR_NONE;
243 cpt.cam_cdb_len = 16;
244 cpt.cam_sense_len =
sizeof(sense);
245 cpt.cam_sense_ptr = (uint32_t)&sense;
250 cdb->ata_pass_thru.lba_low = select;
255 cpt.cam_flags = CAM_DIR_NONE;
256 cpt.cam_cdb_len = 16;
257 cpt.cam_sense_len =
sizeof(sense);
258 cpt.cam_sense_ptr = (uint32_t)&sense;
263 cdb->ata_pass_thru.sector_count= select;
269 cpt.cam_flags = CAM_DIR_NONE;
270 cpt.cam_cdb_len = 16;
271 cpt.cam_sense_len =
sizeof(sense);
272 cpt.cam_sense_ptr = (uint32_t)&sense;
277 cdb->ata_pass_thru.lba_low = select;
284 cpt.cam_flags = CAM_DIR_NONE;
285 cpt.cam_cdb_len = 16;
286 cpt.cam_sense_len =
sizeof(sense);
287 cpt.cam_sense_ptr = (uint32_t)&sense;
297 cpt.cam_flags = CAM_DIR_NONE;
298 cpt.cam_cdb_len = 16;
299 cpt.cam_sense_len =
sizeof(sense);
300 cpt.cam_sense_ptr = (uint32_t)&sense;
307 pout(
"Unrecognized command %d in ata_command_interface()\n", command);
315 if(cpt.cam_status!=CAM_REQ_CMP)
319 rc=((sense.desc.lba_high<<8)|sense.desc.lba_mid)==
ATA_SMART_SIG?0:1;
323 data[0]=
cdb->ata_pass_thru.sector_count;
369 if(cpt->cam_status&CAM_AUTOSNS_VALID)
457 switch(cpt->cam_status&CAM_STATUS_MASK)
459 case CAM_REQ_CMP_ERR:
466 case CAM_REQ_INVALID:
467 case CAM_PATH_INVALID:
468 case CAM_DEV_NOT_THERE:
469 case CAM_SEL_TIMEOUT:
470 case CAM_LUN_INVALID:
471 case CAM_TID_INVALID:
475 case CAM_CMD_TIMEOUT:
476 *status=rcount?EAGAIN:EIO;
478 case CAM_MSG_REJECT_REC:
479 case CAM_SCSI_BUS_RESET:
480 case CAM_UNCOR_PARITY:
481 case CAM_AUTOSENSE_FAIL:
483 case CAM_DATA_RUN_ERR:
487 case CAM_UNEXP_BUSFREE:
488 case CAM_SEQUENCE_FAIL:
491 case CAM_PROVIDE_FAIL:
495 case CAM_CCB_LEN_ERR:
498 case CAM_FUNC_NOTAVAIL:
500 case CAM_IID_INVALID:
519struct cam_pass_thru cpt;
522 SETIOV(&iov[0],&cpt,
sizeof(cpt));
523 cpt.cam_timeout=cpt.cam_timeout?cpt.cam_timeout:CAM_TIME_DEFAULT;
524 if(cpt.cam_sense_len)
526 SETIOV(&iov[1],(
void *)cpt.cam_sense_ptr,cpt.cam_sense_len);
527 cpt.cam_sense_ptr=
sizeof(cpt);
530 if(cpt.cam_dxfer_len)
532 SETIOV(&iov[2],(
void *)cpt.cam_data_ptr,cpt.cam_dxfer_len);
533 cpt.cam_data_ptr=(paddr_t)
sizeof(cpt)+cpt.cam_sense_len;
536 if((status=devctlv(fd,DCMD_CAM_PASS_THRU,icnt,icnt,iov,iov,NULL)))
537 pout(
"ata_pass_thru devctl: %s\n",strerror(status));
538 pcpt->cam_status=cpt.cam_status;
539 pcpt->cam_scsi_status=cpt.cam_scsi_status;
#define ATA_SMART_AUTO_OFFLINE
#define ATA_IDENTIFY_DEVICE
#define ATA_IDENTIFY_PACKET_DEVICE
#define ATA_SMART_READ_VALUES
#define ATA_SMART_READ_THRESHOLDS
#define ATA_SMART_READ_LOG_SECTOR
#define ATA_SMART_IMMEDIATE_OFFLINE
#define ATA_SMART_AUTOSAVE
#define ATA_SMART_DISABLE
#define ATA_CHECK_POWER_MODE
static const char * net_dev_prefix
int ata_command_interface(int fd, smart_command_set command, int select, char *data)
int make_device_names(char ***devlist, const char *name)
static const char * net_dev_ata_disk
int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io *iop, int report)
int deviceopen(const char *pathname, char *type)
int guess_device_type(const char *dev_name)
const char * os_XXXX_c_cvsid
static int ata_interpret_sense(struct cam_pass_thru *cpt, void *sense, int *status, int rcount)
void print_smartctl_examples()
static int ata_pass_thru(int fd, struct cam_pass_thru *pcpt)
static int ata_sense_data(void *sdata, int *error, int *key, int *asc, int *ascq)
#define ASC_MEDIA_NOT_PRESENT
#define SENSE_DATA_FMT_DESCRIPTOR
#define ASCQ_CAUSE_NOT_REPORTABLE
#define ATA_SMART_LBA_MID_SIG
#define ATA_SMART_LBA_HI_SIG
#define ASC_ATA_PASS_THRU
#define ASCQ_BECOMING_READY
#define ASC_MEDIUM_CHANGED
#define ASCQ_ATA_PASS_THRU_INFO_AVAIL
#define ATA_FLG_TLEN_STPSIU
#define ATA_PROTO_PIO_DATA_IN
#define OS_QNXNTO_H_CVSID
#define ATA_PROTO_DATA_NONE
void pout(const char *fmt,...)