30const char *
os_XXXX_c_cvsid=
"$Id: os_os2.cpp 5376 2022-05-01 12:49:30Z chrfranke $" \
40 printf(
"=================================================== SMARTCTL EXAMPLES =====\n\n"
41 " smartctl -a hd0 (Prints all SMART information)\n\n"
42 " smartctl --smart=on --offlineauto=on --saveauto=on hd0\n"
43 " (Enables SMART on first disk)\n\n"
44 " smartctl -t long hd0 (Executes extended disk self-test)\n\n"
45 " smartctl --attributes --log=selftest --quietmode=errorsonly hd0\n"
46 " (Prints Self-Test & Attribute errors)\n"
53 return (!strncmp(
s,
"/dev/", 5) ?
s + 5 :
s);
62 if (!strncmp(dev_name,
"hd", 2) || !strncmp(dev_name,
"ahci", 4))
63 return CONTROLLER_ATA;
64 return CONTROLLER_UNKNOWN;
78 const int max_dev = 32;
81 if (strcmp (name,
"ATA") != 0)
87 HFILE danisDev, ahciDev;
88 bool is_danis = 0, is_ahci = 0;
90 rc = DosOpen ((
const char unsigned *)
danisdev, &danisDev, &ActionTaken, 0, FILE_SYSTEM,
91 OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE |
92 OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY, NULL);
96 rc = DosOpen ((
const char unsigned *)
ahcidev, &ahciDev, &ActionTaken, 0, FILE_SYSTEM,
97 OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE |
98 OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY, NULL);
110 for(
int i = 0; i < max_dev; i++) {
114 (PVOID)&Parms, PLen, &PLen, (PVOID)&Id, IDLen, &IDLen);
120 (PVOID)&Parms, PLen, &PLen, (PVOID)&Id, IDLen, &IDLen);
124 *devlist = (
char**)calloc (result,
sizeof (
char *));
130 for(
int i = 0; i < max_dev; i++) {
134 (PVOID)&Parms, PLen, &PLen, (PVOID)&Id, IDLen, &IDLen);
136 asprintf(&(*devlist)[index],
"ahci%d", i);
137 if (! (*devlist)[index])
145 (PVOID)&Parms, PLen, &PLen, (PVOID)&Id, IDLen, &IDLen);
147 asprintf(&(*devlist)[index],
"hd%d", i);
148 if (! (*devlist)[index])
166 for (index = 0; index < result; index++)
167 if ((*devlist)[index])
168 free ((*devlist)[index]);
192 char * activedev = NULL;
198 fd = strtol(pathname + strlen(
danispref), NULL, 10) + 0x80;
202 if(strlen(pathname) > strlen(
ahcipref)
204 fd = strtol(pathname + strlen(
ahcipref), NULL, 10);
209 pout(
"Error: please specify hdX or ahciX device name\n");
213 rc = DosOpen ((
const char unsigned *)activedev, &
hDevice, &ActionTaken, 0, FILE_SYSTEM,
214 OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE |
215 OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY, NULL);
218 snprintf(errmsg,256,
"Smartctl open driver %s failed (%lu)", activedev, rc);
242 unsigned char* buff = (
unsigned char*) arg;
255 (PVOID)&Parms, PLen, &PLen, (UCHAR *)arg+4, DLen, &DLen);
258 printf (
"DANIS506 ATA DSKSP_GET_INQUIRY_DATA failed (%lu)\n", rc);
265 DLen =
sizeof(value);
269 (PVOID)&Parms, PLen, &PLen, (PVOID)&value, DLen, &DLen);
272 printf (
"DANIS506 ATA GET SMART_STATUS failed (%lu)\n", rc);
275 buff[4] = (
unsigned char)value;
279 (PVOID)&Parms, PLen, &PLen, (UCHAR *)arg+4, DLen, &DLen);
282 printf (
"DANIS506 ATA GET DSKSP_SMART_GET_ATTRIBUTES failed (%lu)\n", rc);
288 (PVOID)&Parms, PLen, &PLen, (UCHAR *)arg+4, DLen, &DLen);
291 printf (
"DANIS506 ATA GET DSKSP_SMART_GET_THRESHOLDS failed (%lu)\n", rc);
298 (PVOID)&Parms, PLen, &PLen, (UCHAR *)arg+4, DLen, &DLen);
301 printf (
"DANIS506 ATA GET DSKSP_SMART_GET_LOG failed (%lu)\n", rc);
309 (PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
311 printf (
"DANIS506 ATA GET DSKSP_SMART_ONOFF failed (%lu)\n", rc);
319 (PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
321 printf (
"DANIS506 ATA GET DSKSP_SMART_ONOFF failed (%lu)\n", rc);
330 (PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
332 printf (
"DANIS506 ATA GET DSKSP_SMART_ONOFF failed (%lu)\n", rc);
341 (PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
343 printf (
"DANIS506 ATA DSKSP_SMART_AUTOSAVE_ONOFF failed (%lu)\n", rc);
351 (PVOID)&Parms, PLen, &PLen, (PVOID)buff, DLen, &DLen);
353 printf (
"DANIS506 ATA GET DSKSP_SMART_EXEC_OFFLINE failed (%lu)\n", rc);
359 fprintf( stderr,
"device %d, arg[0] 0x%x, arg[2] 0x%x\n", device, buff[0], buff[2]);
360 fprintf( stderr,
"unknown ioctl\n");
368 fprintf( stderr,
"unknown ioctl\n");
397#define STRANGE_BUFFER_LENGTH (4+512*0xf8)
405 const int HDIO_DRIVE_CMD_OFFSET = 4;
487 pout(
"Unrecognized command %d in linux_ata_command_interface()\n"
488 "Please contact " PACKAGE_BUGREPORT
"\n", command);
510 syserror(
"Error SMART Status command failed");
511 pout(
"Please get assistance from " PACKAGE_URL
"\n");
518 buff[HDIO_DRIVE_CMD_OFFSET]=buff[2];
522 memcpy(
data, buff+HDIO_DRIVE_CMD_OFFSET, copydata);
529 pout(
"SCSI interface is not implemented\n");
#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
int deviceopen(const char *pathname, char *)
int make_device_names(char ***devlist, const char *name)
int ata_command_interface(int device, smart_command_set command, int select, char *data)
int guess_device_type(const char *dev_name)
const char * os_XXXX_c_cvsid
static int dani_ioctl(int device, void *arg)
void print_smartctl_examples()
#define STRANGE_BUFFER_LENGTH
int do_scsi_cmnd_io(int, struct scsi_cmnd_io *, int)
static const char * skipdev(const char *s)
#define DSKSP_SMART_GET_LOG
#define DSKSP_SMART_ONOFF
#define DSKSP_CAT_GENERIC
#define DSKSP_GET_INQUIRY_DATA
#define DSKSP_SMART_AUTOSAVE_ONOFF
#define DSKSP_SMART_AUTO_OFFLINE
#define DSKSP_SMART_GET_ATTRIBUTES
#define DSKSP_SMART_EXEC_OFFLINE
#define DSKSP_SMART_GET_THRESHOLDS
#define DSKSP_SMART_GETSTATUS
void pout(const char *fmt,...)
void syserror(const char *message)