]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - ataprint.c
adjust cciss patch and actually apply it
[mirror_smartmontools-debian.git] / ataprint.c
1 /*
2 * ataprint.c
3 *
4 * Home page of code is: http://smartmontools.sourceforge.net
5 *
6 * Copyright (C) 2002-6 Bruce Allen <smartmontools-support@lists.sourceforge.net>
7 * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * You should have received a copy of the GNU General Public License
15 * (for example COPYING); if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * This code was originally developed as a Senior Thesis by Michael Cornwell
19 * at the Concurrent Systems Laboratory (now part of the Storage Systems
20 * Research Center), Jack Baskin School of Engineering, University of
21 * California, Santa Cruz. http://ssrc.soe.ucsc.edu/
22 *
23 */
24
25 #include "config.h"
26
27 #include <ctype.h>
28 #include <stdio.h>
29 #include <string.h>
30 #ifdef HAVE_LOCALE_H
31 #include <locale.h>
32 #endif // #ifdef HAVE_LOCALE_H
33
34 #include "int64.h"
35 #include "atacmdnames.h"
36 #include "atacmds.h"
37 #include "ataprint.h"
38 #include "smartctl.h"
39 #include "extern.h"
40 #include "utility.h"
41 #include "knowndrives.h"
42
43 const char *ataprint_c_cvsid="$Id: ataprint.c,v 1.164 2006/04/12 14:54:28 ballen4705 Exp $"
44 ATACMDNAMES_H_CVSID ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
45
46 // for passing global control variables
47 extern smartmonctrl *con;
48
49 // to hold onto exit code for atexit routine
50 extern int exitstatus;
51
52 // Copies n bytes (or n-1 if n is odd) from in to out, but swaps adjacents
53 // bytes.
54 void swapbytes(char *out, const char *in, size_t n)
55 {
56 size_t i;
57
58 for (i = 0; i < n; i += 2) {
59 out[i] = in[i+1];
60 out[i+1] = in[i];
61 }
62 }
63
64 // Copies in to out, but removes leading and trailing whitespace.
65 void trim(char *out, const char *in)
66 {
67 int i, first, last;
68
69 // Find the first non-space character (maybe none).
70 first = -1;
71 for (i = 0; in[i]; i++)
72 if (!isspace((int)in[i])) {
73 first = i;
74 break;
75 }
76
77 if (first == -1) {
78 // There are no non-space characters.
79 out[0] = '\0';
80 return;
81 }
82
83 // Find the last non-space character.
84 for (i = strlen(in)-1; i >= first && isspace((int)in[i]); i--)
85 ;
86 last = i;
87
88 strncpy(out, in+first, last-first+1);
89 out[last-first+1] = '\0';
90 }
91
92 // Convenience function for formatting strings from ata_identify_device
93 void formatdriveidstring(char *out, const char *in, int n)
94 {
95 char tmp[65];
96
97 n = n > 64 ? 64 : n;
98 #ifndef __NetBSD__
99 swapbytes(tmp, in, n);
100 #else
101 strncpy(tmp, in, n); /* NetBSD delivers host byte order strings */
102 #endif
103 tmp[n] = '\0';
104 trim(out, tmp);
105 }
106
107 void infofound(char *output) {
108 if (*output)
109 pout("%s\n", output);
110 else
111 pout("[No Information Found]\n");
112 }
113
114
115 /* For the given Command Register (CR) and Features Register (FR), attempts
116 * to construct a string that describes the contents of the Status
117 * Register (ST) and Error Register (ER). The string is dynamically allocated
118 * memory and the return value is a pointer to this string. It is up to the
119 * caller to free this memory. If there is insufficient memory or if the
120 * meanings of the flags of the error register are not known for the given
121 * command then it returns NULL.
122 *
123 * The meanings of the flags of the error register for all commands are
124 * described in the ATA spec and could all be supported here in theory.
125 * Currently, only a few commands are supported (those that have been seen
126 * to produce errors). If many more are to be added then this function
127 * should probably be redesigned.
128 */
129 char *construct_st_er_desc(struct ata_smart_errorlog_struct *data) {
130 unsigned char CR=data->commands[4].commandreg;
131 unsigned char FR=data->commands[4].featuresreg;
132 unsigned char ST=data->error_struct.status;
133 unsigned char ER=data->error_struct.error_register;
134 char *s;
135 const char *error_flag[8];
136 int i, print_lba=0, print_sector=0;
137
138 // Set of character strings corresponding to different error codes.
139 // Please keep in alphabetic order if you add more.
140 const char *abrt = "ABRT"; // ABORTED
141 const char *amnf = "AMNF"; // ADDRESS MARK NOT FOUND
142 const char *ccto = "CCTO"; // COMMAND COMPLETTION TIMED OUT
143 const char *eom = "EOM"; // END OF MEDIA
144 const char *icrc = "ICRC"; // INTERFACE CRC ERROR
145 const char *idnf = "IDNF"; // ID NOT FOUND
146 const char *ili = "ILI"; // MEANING OF THIS BIT IS COMMAND-SET SPECIFIC
147 const char *mc = "MC"; // MEDIA CHANGED
148 const char *mcr = "MCR"; // MEDIA CHANGE REQUEST
149 const char *nm = "NM"; // NO MEDIA
150 const char *obs = "obs"; // OBSOLETE
151 const char *tk0nf = "TK0NF"; // TRACK 0 NOT FOUND
152 const char *unc = "UNC"; // UNCORRECTABLE
153 const char *wp = "WP"; // WRITE PROTECTED
154
155 /* If for any command the Device Fault flag of the status register is
156 * not used then used_device_fault should be set to 0 (in the CR switch
157 * below)
158 */
159 int uses_device_fault = 1;
160
161 /* A value of NULL means that the error flag isn't used */
162 for (i = 0; i < 8; i++)
163 error_flag[i] = NULL;
164
165 switch (CR) {
166 case 0x10: // RECALIBRATE
167 error_flag[2] = abrt;
168 error_flag[1] = tk0nf;
169 break;
170 case 0x20: /* READ SECTOR(S) */
171 case 0x21: // READ SECTOR(S)
172 case 0x24: // READ SECTOR(S) EXT
173 case 0xC4: /* READ MULTIPLE */
174 case 0x29: // READ MULTIPLE EXT
175 error_flag[6] = unc;
176 error_flag[5] = mc;
177 error_flag[4] = idnf;
178 error_flag[3] = mcr;
179 error_flag[2] = abrt;
180 error_flag[1] = nm;
181 error_flag[0] = amnf;
182 print_lba=1;
183 break;
184 case 0x22: // READ LONG (with retries)
185 case 0x23: // READ LONG (without retries)
186 error_flag[4] = idnf;
187 error_flag[2] = abrt;
188 error_flag[0] = amnf;
189 print_lba=1;
190 break;
191 case 0x2a: // READ STREAM DMA
192 case 0x2b: // READ STREAM PIO
193 if (CR==0x2a)
194 error_flag[7] = icrc;
195 error_flag[6] = unc;
196 error_flag[5] = mc;
197 error_flag[4] = idnf;
198 error_flag[3] = mcr;
199 error_flag[2] = abrt;
200 error_flag[1] = nm;
201 error_flag[0] = ccto;
202 print_lba=1;
203 print_sector=(int)data->error_struct.sector_count;
204 break;
205 case 0x3A: // WRITE STREAM DMA
206 case 0x3B: // WRITE STREAM PIO
207 if (CR==0x3A)
208 error_flag[7] = icrc;
209 error_flag[6] = wp;
210 error_flag[5] = mc;
211 error_flag[4] = idnf;
212 error_flag[3] = mcr;
213 error_flag[2] = abrt;
214 error_flag[1] = nm;
215 error_flag[0] = ccto;
216 print_lba=1;
217 print_sector=(int)data->error_struct.sector_count;
218 break;
219 case 0x25: /* READ DMA EXT */
220 case 0x26: // READ DMA QUEUED EXT
221 case 0xC7: // READ DMA QUEUED
222 case 0xC8: /* READ DMA */
223 case 0xC9:
224 error_flag[7] = icrc;
225 error_flag[6] = unc;
226 error_flag[5] = mc;
227 error_flag[4] = idnf;
228 error_flag[3] = mcr;
229 error_flag[2] = abrt;
230 error_flag[1] = nm;
231 error_flag[0] = amnf;
232 print_lba=1;
233 if (CR==0x25 || CR==0xC8)
234 print_sector=(int)data->error_struct.sector_count;
235 break;
236 case 0x30: /* WRITE SECTOR(S) */
237 case 0x31: // WRITE SECTOR(S)
238 case 0x34: // WRITE SECTOR(S) EXT
239 case 0xC5: /* WRITE MULTIPLE */
240 case 0x39: // WRITE MULTIPLE EXT
241 case 0xCE: // WRITE MULTIPLE FUA EXT
242 error_flag[6] = wp;
243 error_flag[5] = mc;
244 error_flag[4] = idnf;
245 error_flag[3] = mcr;
246 error_flag[2] = abrt;
247 error_flag[1] = nm;
248 print_lba=1;
249 break;
250 case 0x32: // WRITE LONG (with retries)
251 case 0x33: // WRITE LONG (without retries)
252 error_flag[4] = idnf;
253 error_flag[2] = abrt;
254 print_lba=1;
255 break;
256 case 0x3C: // WRITE VERIFY
257 error_flag[6] = unc;
258 error_flag[4] = idnf;
259 error_flag[2] = abrt;
260 error_flag[0] = amnf;
261 print_lba=1;
262 break;
263 case 0x40: // READ VERIFY SECTOR(S) with retries
264 case 0x41: // READ VERIFY SECTOR(S) without retries
265 case 0x42: // READ VERIFY SECTOR(S) EXT
266 error_flag[6] = unc;
267 error_flag[5] = mc;
268 error_flag[4] = idnf;
269 error_flag[3] = mcr;
270 error_flag[2] = abrt;
271 error_flag[1] = nm;
272 error_flag[0] = amnf;
273 print_lba=1;
274 break;
275 case 0xA0: /* PACKET */
276 /* Bits 4-7 are all used for sense key (a 'command packet set specific error
277 * indication' according to the ATA/ATAPI-7 standard), so "Sense key" will
278 * be repeated in the error description string if more than one of those
279 * bits is set.
280 */
281 error_flag[7] = "Sense key (bit 3)",
282 error_flag[6] = "Sense key (bit 2)",
283 error_flag[5] = "Sense key (bit 1)",
284 error_flag[4] = "Sense key (bit 0)",
285 error_flag[2] = abrt;
286 error_flag[1] = eom;
287 error_flag[0] = ili;
288 break;
289 case 0xA1: /* IDENTIFY PACKET DEVICE */
290 case 0xEF: /* SET FEATURES */
291 case 0x00: /* NOP */
292 case 0xC6: /* SET MULTIPLE MODE */
293 error_flag[2] = abrt;
294 break;
295 case 0x2F: // READ LOG EXT
296 error_flag[6] = unc;
297 error_flag[4] = idnf;
298 error_flag[2] = abrt;
299 error_flag[0] = obs;
300 break;
301 case 0x3F: // WRITE LOG EXT
302 error_flag[4] = idnf;
303 error_flag[2] = abrt;
304 error_flag[0] = obs;
305 break;
306 case 0xB0: /* SMART */
307 switch(FR) {
308 case 0xD0: // SMART READ DATA
309 case 0xD1: // SMART READ ATTRIBUTE THRESHOLDS
310 case 0xD5: /* SMART READ LOG */
311 error_flag[6] = unc;
312 error_flag[4] = idnf;
313 error_flag[2] = abrt;
314 error_flag[0] = obs;
315 break;
316 case 0xD6: /* SMART WRITE LOG */
317 error_flag[4] = idnf;
318 error_flag[2] = abrt;
319 error_flag[0] = obs;
320 break;
321 case 0xD2: // Enable/Disable Attribute Autosave
322 case 0xD3: // SMART SAVE ATTRIBUTE VALUES (ATA-3)
323 case 0xD8: // SMART ENABLE OPERATIONS
324 case 0xD9: /* SMART DISABLE OPERATIONS */
325 case 0xDA: /* SMART RETURN STATUS */
326 case 0xDB: // Enable/Disable Auto Offline (SFF)
327 error_flag[2] = abrt;
328 break;
329 case 0xD4: // SMART EXECUTE IMMEDIATE OFFLINE
330 error_flag[4] = idnf;
331 error_flag[2] = abrt;
332 break;
333 default:
334 return NULL;
335 break;
336 }
337 break;
338 case 0xB1: /* DEVICE CONFIGURATION */
339 switch (FR) {
340 case 0xC0: /* DEVICE CONFIGURATION RESTORE */
341 error_flag[2] = abrt;
342 break;
343 default:
344 return NULL;
345 break;
346 }
347 break;
348 case 0xCA: /* WRITE DMA */
349 case 0xCB:
350 case 0x35: // WRITE DMA EXT
351 case 0x3D: // WRITE DMA FUA EXT
352 case 0xCC: // WRITE DMA QUEUED
353 case 0x36: // WRITE DMA QUEUED EXT
354 case 0x3E: // WRITE DMA QUEUED FUA EXT
355 error_flag[7] = icrc;
356 error_flag[6] = wp;
357 error_flag[5] = mc;
358 error_flag[4] = idnf;
359 error_flag[3] = mcr;
360 error_flag[2] = abrt;
361 error_flag[1] = nm;
362 error_flag[0] = amnf;
363 print_lba=1;
364 if (CR==0x35)
365 print_sector=(int)data->error_struct.sector_count;
366 break;
367 case 0xE4: // READ BUFFER
368 case 0xE8: // WRITE BUFFER
369 error_flag[2] = abrt;
370 break;
371 default:
372 return NULL;
373 }
374
375 /* 256 bytes -- that'll be plenty (OK, this is lazy!) */
376 if (!(s = (char *)malloc(256)))
377 return s;
378
379 s[0] = '\0';
380
381 /* We ignore any status flags other than Device Fault and Error */
382
383 if (uses_device_fault && (ST & (1 << 5))) {
384 strcat(s, "Device Fault");
385 if (ST & 1) // Error flag
386 strcat(s, "; ");
387 }
388 if (ST & 1) { // Error flag
389 int count = 0;
390
391 strcat(s, "Error: ");
392 for (i = 7; i >= 0; i--)
393 if ((ER & (1 << i)) && (error_flag[i])) {
394 if (count++ > 0)
395 strcat(s, ", ");
396 strcat(s, error_flag[i]);
397 }
398 }
399
400 // If the error was a READ or WRITE error, print the Logical Block
401 // Address (LBA) at which the read or write failed.
402 if (print_lba) {
403 char tmp[128];
404 int lba;
405
406 // bits 24-27: bits 0-3 of DH
407 lba = 0xf & data->error_struct.drive_head;
408 lba <<= 8;
409 // bits 16-23: CH
410 lba |= data->error_struct.cylinder_high;
411 lba <<= 8;
412 // bits 8-15: CL
413 lba |= data->error_struct.cylinder_low;
414 lba <<= 8;
415 // bits 0-7: SN
416 lba |= data->error_struct.sector_number;
417
418 // print number of sectors, if known, and append to print string
419 if (print_sector) {
420 snprintf(tmp, 128, " %d sectors", print_sector);
421 strcat(s, tmp);
422 }
423
424 // print LBA, and append to print string
425 snprintf(tmp, 128, " at LBA = 0x%08x = %d", lba, lba);
426 strcat(s, tmp);
427 }
428
429 return s;
430 }
431
432 // This returns the capacity of a disk drive and also prints this into
433 // a string, using comma separators to make it easier to read. If the
434 // drive doesn't support LBA addressing or has no user writable
435 // sectors (eg, CDROM or DVD) then routine returns zero.
436 uint64_t determine_capacity(struct ata_identify_device *drive, char *pstring){
437
438 unsigned short command_set_2 = drive->command_set_2;
439 unsigned short capabilities_0 = drive->words047_079[49-47];
440 unsigned short sects_16 = drive->words047_079[60-47];
441 unsigned short sects_32 = drive->words047_079[61-47];
442 unsigned short lba_16 = drive->words088_255[100-88];
443 unsigned short lba_32 = drive->words088_255[101-88];
444 unsigned short lba_48 = drive->words088_255[102-88];
445 unsigned short lba_64 = drive->words088_255[103-88];
446 uint64_t capacity_short=0, capacity=0, threedigits, power_of_ten;
447 int started=0,k=1000000000;
448 char separator=',';
449
450 // get correct character to use as thousands separator
451 #ifdef HAVE_LOCALE_H
452 struct lconv *currentlocale=NULL;
453 setlocale (LC_ALL, "");
454 currentlocale=localeconv();
455 if (*(currentlocale->thousands_sep))
456 separator=*(currentlocale->thousands_sep);
457 #endif // #ifdef HAVE_LOCALE_H
458
459 // if drive supports LBA addressing, determine 32-bit LBA capacity
460 if (capabilities_0 & 0x0200) {
461 capacity_short = (unsigned int)sects_32 << 16 |
462 (unsigned int)sects_16 << 0 ;
463
464 // if drive supports 48-bit addressing, determine THAT capacity
465 if ((command_set_2 & 0xc000) == 0x4000 && (command_set_2 & 0x0400))
466 capacity = (uint64_t)lba_64 << 48 |
467 (uint64_t)lba_48 << 32 |
468 (uint64_t)lba_32 << 16 |
469 (uint64_t)lba_16 << 0 ;
470
471 // choose the larger of the two possible capacities
472 if (capacity_short>capacity)
473 capacity=capacity_short;
474 }
475
476 // turn sectors into bytes
477 capacity_short = (capacity *= 512);
478
479 // print with locale-specific separators (default is comma)
480 power_of_ten = k;
481 power_of_ten *= k;
482
483 for (k=0; k<7; k++) {
484 threedigits = capacity/power_of_ten;
485 capacity -= threedigits*power_of_ten;
486 if (started)
487 // we have already printed some digits
488 pstring += sprintf(pstring, "%c%03"PRIu64, separator, threedigits);
489 else if (threedigits || k==6) {
490 // these are the first digits that we are printing
491 pstring += sprintf(pstring, "%"PRIu64, threedigits);
492 started = 1;
493 }
494 if (k!=6)
495 power_of_ten /= 1000;
496 }
497
498 return capacity_short;
499 }
500
501 void ataPrintDriveInfo (struct ata_identify_device *drive){
502 int version, drivetype;
503 const char *description;
504 char unknown[64], timedatetz[DATEANDEPOCHLEN];
505 unsigned short minorrev;
506 char model[64], serial[64], firm[64], capacity[64];
507
508 // format drive information (with byte swapping as needed)
509 formatdriveidstring(model, (char *)drive->model,40);
510 formatdriveidstring(serial, (char *)drive->serial_no,20);
511 formatdriveidstring(firm, (char *)drive->fw_rev,8);
512
513 // print out model, serial # and firmware versions (byte-swap ASCI strings)
514 drivetype=lookupdrive(model, firm);
515
516 // Print model family if known
517 if (drivetype>=0 && knowndrives[drivetype].modelfamily)
518 pout("Model Family: %s\n", knowndrives[drivetype].modelfamily);
519
520 pout("Device Model: ");
521 infofound(model);
522 pout("Serial Number: ");
523 infofound(serial);
524 pout("Firmware Version: ");
525 infofound(firm);
526
527 if (determine_capacity(drive, capacity))
528 pout("User Capacity: %s bytes\n", capacity);
529
530 // See if drive is recognized
531 pout("Device is: %s\n", drivetype<0?
532 "Not in smartctl database [for details use: -P showall]":
533 "In smartctl database [for details use: -P show]");
534
535 // now get ATA version info
536 version=ataVersionInfo(&description,drive, &minorrev);
537
538 // unrecognized minor revision code
539 if (!description){
540 if (!minorrev)
541 sprintf(unknown, "Exact ATA specification draft version not indicated");
542 else
543 sprintf(unknown,"Not recognized. Minor revision code: 0x%02hx", minorrev);
544 description=unknown;
545 }
546
547
548 // SMART Support was first added into the ATA/ATAPI-3 Standard with
549 // Revision 3 of the document, July 25, 1995. Look at the "Document
550 // Status" revision commands at the beginning of
551 // http://www.t13.org/project/d2008r6.pdf to see this. So it's not
552 // enough to check if we are ATA-3. Version=-3 indicates ATA-3
553 // BEFORE Revision 3.
554 pout("ATA Version is: %d\n",(int)abs(version));
555 pout("ATA Standard is: %s\n",description);
556
557 // print current time and date and timezone
558 dateandtimezone(timedatetz);
559 pout("Local Time is: %s\n", timedatetz);
560
561 // Print warning message, if there is one
562 if (drivetype>=0 && knowndrives[drivetype].warningmsg)
563 pout("\n==> WARNING: %s\n\n", knowndrives[drivetype].warningmsg);
564
565 if (version>=3)
566 return;
567
568 pout("SMART is only available in ATA Version 3 Revision 3 or greater.\n");
569 pout("We will try to proceed in spite of this.\n");
570 return;
571 }
572
573
574 const char *OfflineDataCollectionStatus(unsigned char status_byte){
575 unsigned char stat=status_byte & 0x7f;
576
577 switch(stat){
578 case 0x00:
579 return "was never started";
580 case 0x02:
581 return "was completed without error";
582 case 0x03:
583 if (status_byte == 0x03)
584 return "is in progress";
585 else
586 return "is in a Reserved state";
587 case 0x04:
588 return "was suspended by an interrupting command from host";
589 case 0x05:
590 return "was aborted by an interrupting command from host";
591 case 0x06:
592 return "was aborted by the device with a fatal error";
593 default:
594 if (stat >= 0x40)
595 return "is in a Vendor Specific state\n";
596 else
597 return "is in a Reserved state\n";
598 }
599 }
600
601
602 /* prints verbose value Off-line data collection status byte */
603 void PrintSmartOfflineStatus(struct ata_smart_values *data){
604
605 pout("Offline data collection status: (0x%02x)\t",
606 (int)data->offline_data_collection_status);
607
608 // Off-line data collection status byte is not a reserved
609 // or vendor specific value
610 pout("Offline data collection activity\n"
611 "\t\t\t\t\t%s.\n", OfflineDataCollectionStatus(data->offline_data_collection_status));
612
613 // Report on Automatic Data Collection Status. Only IBM documents
614 // this bit. See SFF 8035i Revision 2 for details.
615 if (data->offline_data_collection_status & 0x80)
616 pout("\t\t\t\t\tAuto Offline Data Collection: Enabled.\n");
617 else
618 pout("\t\t\t\t\tAuto Offline Data Collection: Disabled.\n");
619
620 return;
621 }
622
623 void PrintSmartSelfExecStatus(struct ata_smart_values *data)
624 {
625 pout("Self-test execution status: ");
626
627 switch (data->self_test_exec_status >> 4)
628 {
629 case 0:
630 pout("(%4d)\tThe previous self-test routine completed\n\t\t\t\t\t",
631 (int)data->self_test_exec_status);
632 pout("without error or no self-test has ever \n\t\t\t\t\tbeen run.\n");
633 break;
634 case 1:
635 pout("(%4d)\tThe self-test routine was aborted by\n\t\t\t\t\t",
636 (int)data->self_test_exec_status);
637 pout("the host.\n");
638 break;
639 case 2:
640 pout("(%4d)\tThe self-test routine was interrupted\n\t\t\t\t\t",
641 (int)data->self_test_exec_status);
642 pout("by the host with a hard or soft reset.\n");
643 break;
644 case 3:
645 pout("(%4d)\tA fatal error or unknown test error\n\t\t\t\t\t",
646 (int)data->self_test_exec_status);
647 pout("occurred while the device was executing\n\t\t\t\t\t");
648 pout("its self-test routine and the device \n\t\t\t\t\t");
649 pout("was unable to complete the self-test \n\t\t\t\t\t");
650 pout("routine.\n");
651 break;
652 case 4:
653 pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
654 (int)data->self_test_exec_status);
655 pout("a test element that failed and the test\n\t\t\t\t\t");
656 pout("element that failed is not known.\n");
657 break;
658 case 5:
659 pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
660 (int)data->self_test_exec_status);
661 pout("the electrical element of the test\n\t\t\t\t\t");
662 pout("failed.\n");
663 break;
664 case 6:
665 pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
666 (int)data->self_test_exec_status);
667 pout("the servo (and/or seek) element of the \n\t\t\t\t\t");
668 pout("test failed.\n");
669 break;
670 case 7:
671 pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
672 (int)data->self_test_exec_status);
673 pout("the read element of the test failed.\n");
674 break;
675 case 15:
676 pout("(%4d)\tSelf-test routine in progress...\n\t\t\t\t\t",
677 (int)data->self_test_exec_status);
678 pout("%1d0%% of test remaining.\n",
679 (int)(data->self_test_exec_status & 0x0f));
680 break;
681 default:
682 pout("(%4d)\tReserved.\n",
683 (int)data->self_test_exec_status);
684 break;
685 }
686
687 }
688
689
690
691 void PrintSmartTotalTimeCompleteOffline ( struct ata_smart_values *data){
692 pout("Total time to complete Offline \n");
693 pout("data collection: \t\t (%4d) seconds.\n",
694 (int)data->total_time_to_complete_off_line);
695 }
696
697
698
699 void PrintSmartOfflineCollectCap(struct ata_smart_values *data){
700 pout("Offline data collection\n");
701 pout("capabilities: \t\t\t (0x%02x) ",
702 (int)data->offline_data_collection_capability);
703
704 if (data->offline_data_collection_capability == 0x00){
705 pout("\tOffline data collection not supported.\n");
706 }
707 else {
708 pout( "%s\n", isSupportExecuteOfflineImmediate(data)?
709 "SMART execute Offline immediate." :
710 "No SMART execute Offline immediate.");
711
712 pout( "\t\t\t\t\t%s\n", isSupportAutomaticTimer(data)?
713 "Auto Offline data collection on/off support.":
714 "No Auto Offline data collection support.");
715
716 pout( "\t\t\t\t\t%s\n", isSupportOfflineAbort(data)?
717 "Abort Offline collection upon new\n\t\t\t\t\tcommand.":
718 "Suspend Offline collection upon new\n\t\t\t\t\tcommand.");
719
720 pout( "\t\t\t\t\t%s\n", isSupportOfflineSurfaceScan(data)?
721 "Offline surface scan supported.":
722 "No Offline surface scan supported.");
723
724 pout( "\t\t\t\t\t%s\n", isSupportSelfTest(data)?
725 "Self-test supported.":
726 "No Self-test supported.");
727
728 pout( "\t\t\t\t\t%s\n", isSupportConveyanceSelfTest(data)?
729 "Conveyance Self-test supported.":
730 "No Conveyance Self-test supported.");
731
732 pout( "\t\t\t\t\t%s\n", isSupportSelectiveSelfTest(data)?
733 "Selective Self-test supported.":
734 "No Selective Self-test supported.");
735 }
736 }
737
738
739
740 void PrintSmartCapability ( struct ata_smart_values *data)
741 {
742 pout("SMART capabilities: ");
743 pout("(0x%04x)\t", (int)data->smart_capability);
744
745 if (data->smart_capability == 0x00)
746 {
747 pout("Automatic saving of SMART data\t\t\t\t\tis not implemented.\n");
748 }
749 else
750 {
751
752 pout( "%s\n", (data->smart_capability & 0x01)?
753 "Saves SMART data before entering\n\t\t\t\t\tpower-saving mode.":
754 "Does not save SMART data before\n\t\t\t\t\tentering power-saving mode.");
755
756 if ( data->smart_capability & 0x02 )
757 {
758 pout("\t\t\t\t\tSupports SMART auto save timer.\n");
759 }
760 }
761 }
762
763 void PrintSmartErrorLogCapability (struct ata_smart_values *data, struct ata_identify_device *identity)
764 {
765
766 pout("Error logging capability: ");
767
768 if ( isSmartErrorLogCapable(data, identity) )
769 {
770 pout(" (0x%02x)\tError logging supported.\n",
771 (int)data->errorlog_capability);
772 }
773 else {
774 pout(" (0x%02x)\tError logging NOT supported.\n",
775 (int)data->errorlog_capability);
776 }
777 }
778
779 void PrintSmartShortSelfTestPollingTime(struct ata_smart_values *data){
780 pout("Short self-test routine \n");
781 if (isSupportSelfTest(data))
782 pout("recommended polling time: \t (%4d) minutes.\n",
783 (int)data->short_test_completion_time);
784 else
785 pout("recommended polling time: \t Not Supported.\n");
786 }
787
788 void PrintSmartExtendedSelfTestPollingTime(struct ata_smart_values *data){
789 pout("Extended self-test routine\n");
790 if (isSupportSelfTest(data))
791 pout("recommended polling time: \t (%4d) minutes.\n",
792 (int)data->extend_test_completion_time);
793 else
794 pout("recommended polling time: \t Not Supported.\n");
795 }
796
797 void PrintSmartConveyanceSelfTestPollingTime(struct ata_smart_values *data){
798 pout("Conveyance self-test routine\n");
799 if (isSupportConveyanceSelfTest(data))
800 pout("recommended polling time: \t (%4d) minutes.\n",
801 (int)data->conveyance_test_completion_time);
802 else
803 pout("recommended polling time: \t Not Supported.\n");
804 }
805
806 // onlyfailed=0 : print all attribute values
807 // onlyfailed=1: just ones that are currently failed and have prefailure bit set
808 // onlyfailed=2: ones that are failed, or have failed with or without prefailure bit set
809 void PrintSmartAttribWithThres (struct ata_smart_values *data,
810 struct ata_smart_thresholds_pvt *thresholds,
811 int onlyfailed){
812 int i;
813 int needheader=1;
814 char rawstring[64];
815
816 // step through all vendor attributes
817 for (i=0; i<NUMBER_ATA_SMART_ATTRIBUTES; i++){
818 char *status;
819 struct ata_smart_attribute *disk=data->vendor_attributes+i;
820 struct ata_smart_threshold_entry *thre=thresholds->thres_entries+i;
821
822 // consider only valid attributes (allowing some screw-ups in the
823 // thresholds page data to slip by)
824 if (disk->id){
825 char *type, *update;
826 int failednow,failedever;
827 char attributename[64];
828
829 failednow = (disk->current <= thre->threshold);
830 failedever= (disk->worst <= thre->threshold);
831
832 // These break out of the loop if we are only printing certain entries...
833 if (onlyfailed==1 && (!ATTRIBUTE_FLAGS_PREFAILURE(disk->flags) || !failednow))
834 continue;
835
836 if (onlyfailed==2 && !failedever)
837 continue;
838
839 // print header only if needed
840 if (needheader){
841 if (!onlyfailed){
842 pout("SMART Attributes Data Structure revision number: %d\n",(int)data->revnumber);
843 pout("Vendor Specific SMART Attributes with Thresholds:\n");
844 }
845 pout("ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE\n");
846 needheader=0;
847 }
848
849 // is this Attribute currently failed, or has it ever failed?
850 if (failednow)
851 status="FAILING_NOW";
852 else if (failedever)
853 status="In_the_past";
854 else
855 status=" -";
856
857 // Print name of attribute
858 ataPrintSmartAttribName(attributename,disk->id, con->attributedefs);
859 pout("%-28s",attributename);
860
861 // printing line for each valid attribute
862 type=ATTRIBUTE_FLAGS_PREFAILURE(disk->flags)?"Pre-fail":"Old_age";
863 update=ATTRIBUTE_FLAGS_ONLINE(disk->flags)?"Always":"Offline";
864
865 pout("0x%04x %.3d %.3d %.3d %-10s%-9s%-12s",
866 (int)disk->flags, (int)disk->current, (int)disk->worst,
867 (int)thre->threshold, type, update, status);
868
869 // print raw value of attribute
870 ataPrintSmartAttribRawValue(rawstring, disk, con->attributedefs);
871 pout("%s\n", rawstring);
872
873 // print a warning if there is inconsistency here!
874 if (disk->id != thre->id){
875 char atdat[64],atthr[64];
876 ataPrintSmartAttribName(atdat, disk->id, con->attributedefs);
877 ataPrintSmartAttribName(atthr, thre->id, con->attributedefs);
878 pout("%-28s<== Data Page | WARNING: PREVIOUS ATTRIBUTE HAS TWO\n",atdat);
879 pout("%-28s<== Threshold Page | INCONSISTENT IDENTITIES IN THE DATA\n",atthr);
880 }
881 }
882 }
883 if (!needheader) pout("\n");
884 }
885
886 void ataPrintGeneralSmartValues(struct ata_smart_values *data, struct ata_identify_device *drive){
887 pout("General SMART Values:\n");
888
889 PrintSmartOfflineStatus(data);
890
891 if (isSupportSelfTest(data)){
892 PrintSmartSelfExecStatus (data);
893 }
894
895 PrintSmartTotalTimeCompleteOffline(data);
896 PrintSmartOfflineCollectCap(data);
897 PrintSmartCapability(data);
898
899 PrintSmartErrorLogCapability(data, drive);
900
901 pout( "\t\t\t\t\t%s\n", isGeneralPurposeLoggingCapable(drive)?
902 "General Purpose Logging supported.":
903 "No General Purpose Logging support.");
904
905 if (isSupportSelfTest(data)){
906 PrintSmartShortSelfTestPollingTime (data);
907 PrintSmartExtendedSelfTestPollingTime (data);
908 }
909 if (isSupportConveyanceSelfTest(data))
910 PrintSmartConveyanceSelfTestPollingTime (data);
911
912 pout("\n");
913 }
914
915 int ataPrintLogDirectory(struct ata_smart_log_directory *data){
916 int i;
917 char *name;
918
919 pout("SMART Log Directory Logging Version %d%s\n",
920 data->logversion, data->logversion==1?" [multi-sector log support]":"");
921 for (i=0; i<=255; i++){
922 int numsect;
923
924 // Directory log length
925 numsect = i? data->entry[i-1].numsectors : 1;
926
927 // If the log is not empty, what is it's name
928 if (numsect){
929 switch (i) {
930 case 0:
931 name="Log Directory"; break;
932 case 1:
933 name="Summary SMART error log"; break;
934 case 2:
935 name="Comprehensive SMART error log"; break;
936 case 3:
937 name="Extended Comprehensive SMART error log"; break;
938 case 6:
939 name="SMART self-test log"; break;
940 case 7:
941 name="Extended self-test log"; break;
942 case 9:
943 name="Selective self-test log"; break;
944 case 0x20:
945 name="Streaming performance log"; break;
946 case 0x21:
947 name="Write stream error log"; break;
948 case 0x22:
949 name="Read stream error log"; break;
950 case 0x23:
951 name="Delayed sector log"; break;
952 default:
953 if (0xa0<=i && i<=0xbf)
954 name="Device vendor specific log";
955 else if (0x80<=i && i<=0x9f)
956 name="Host vendor specific log";
957 else
958 name="Reserved log";
959 break;
960 }
961
962 // print name and length of log
963 pout("Log at address 0x%02x has %03d sectors [%s]\n",
964 i, numsect, name);
965 }
966 }
967 return 0;
968 }
969
970 // returns number of errors
971 int ataPrintSmartErrorlog(struct ata_smart_errorlog *data){
972 int k;
973
974 pout("SMART Error Log Version: %d\n", (int)data->revnumber);
975
976 // if no errors logged, return
977 if (!data->error_log_pointer){
978 pout("No Errors Logged\n\n");
979 return 0;
980 }
981 PRINT_ON(con);
982 // If log pointer out of range, return
983 if (data->error_log_pointer>5){
984 pout("Invalid Error Log index = 0x%02x (T13/1321D rev 1c "
985 "Section 8.41.6.8.2.2 gives valid range from 1 to 5)\n\n",
986 (int)data->error_log_pointer);
987 return 0;
988 }
989
990 // Some internal consistency checking of the data structures
991 if ((data->ata_error_count-data->error_log_pointer)%5 && con->fixfirmwarebug != FIX_SAMSUNG2) {
992 pout("Warning: ATA error count %d inconsistent with error log pointer %d\n\n",
993 data->ata_error_count,data->error_log_pointer);
994 }
995
996 // starting printing error log info
997 if (data->ata_error_count<=5)
998 pout( "ATA Error Count: %d\n", (int)data->ata_error_count);
999 else
1000 pout( "ATA Error Count: %d (device log contains only the most recent five errors)\n",
1001 (int)data->ata_error_count);
1002 PRINT_OFF(con);
1003 pout("\tCR = Command Register [HEX]\n"
1004 "\tFR = Features Register [HEX]\n"
1005 "\tSC = Sector Count Register [HEX]\n"
1006 "\tSN = Sector Number Register [HEX]\n"
1007 "\tCL = Cylinder Low Register [HEX]\n"
1008 "\tCH = Cylinder High Register [HEX]\n"
1009 "\tDH = Device/Head Register [HEX]\n"
1010 "\tDC = Device Command Register [HEX]\n"
1011 "\tER = Error register [HEX]\n"
1012 "\tST = Status register [HEX]\n"
1013 "Powered_Up_Time is measured from power on, and printed as\n"
1014 "DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,\n"
1015 "SS=sec, and sss=millisec. It \"wraps\" after 49.710 days.\n\n");
1016
1017 // now step through the five error log data structures (table 39 of spec)
1018 for (k = 4; k >= 0; k-- ) {
1019 char *st_er_desc;
1020
1021 // The error log data structure entries are a circular buffer
1022 int j, i=(data->error_log_pointer+k)%5;
1023 struct ata_smart_errorlog_struct *elog=data->errorlog_struct+i;
1024 struct ata_smart_errorlog_error_struct *summary=&(elog->error_struct);
1025
1026 // Spec says: unused error log structures shall be zero filled
1027 if (nonempty((unsigned char*)elog,sizeof(*elog))){
1028 // Table 57 of T13/1532D Volume 1 Revision 3
1029 char *msgstate;
1030 int bits=summary->state & 0x0f;
1031 int days = (int)summary->timestamp/24;
1032
1033 switch (bits){
1034 case 0x00: msgstate="in an unknown state";break;
1035 case 0x01: msgstate="sleeping"; break;
1036 case 0x02: msgstate="in standby mode"; break;
1037 case 0x03: msgstate="active or idle"; break;
1038 case 0x04: msgstate="doing SMART Offline or Self-test"; break;
1039 default:
1040 if (bits<0x0b)
1041 msgstate="in a reserved state";
1042 else
1043 msgstate="in a vendor specific state";
1044 }
1045
1046 // See table 42 of ATA5 spec
1047 PRINT_ON(con);
1048 pout("Error %d occurred at disk power-on lifetime: %d hours (%d days + %d hours)\n",
1049 (int)(data->ata_error_count+k-4), (int)summary->timestamp, days, (int)(summary->timestamp-24*days));
1050 PRINT_OFF(con);
1051 pout(" When the command that caused the error occurred, the device was %s.\n\n",msgstate);
1052 pout(" After command completion occurred, registers were:\n"
1053 " ER ST SC SN CL CH DH\n"
1054 " -- -- -- -- -- -- --\n"
1055 " %02x %02x %02x %02x %02x %02x %02x",
1056 (int)summary->error_register,
1057 (int)summary->status,
1058 (int)summary->sector_count,
1059 (int)summary->sector_number,
1060 (int)summary->cylinder_low,
1061 (int)summary->cylinder_high,
1062 (int)summary->drive_head);
1063 // Add a description of the contents of the status and error registers
1064 // if possible
1065 st_er_desc = construct_st_er_desc(elog);
1066 if (st_er_desc) {
1067 pout(" %s", st_er_desc);
1068 free(st_er_desc);
1069 }
1070 pout("\n\n");
1071 pout(" Commands leading to the command that caused the error were:\n"
1072 " CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name\n"
1073 " -- -- -- -- -- -- -- -- ---------------- --------------------\n");
1074 for ( j = 4; j >= 0; j--){
1075 struct ata_smart_errorlog_command_struct *thiscommand=elog->commands+j;
1076
1077 // Spec says: unused data command structures shall be zero filled
1078 if (nonempty((unsigned char*)thiscommand,sizeof(*thiscommand))) {
1079 char timestring[32];
1080
1081 // Convert integer milliseconds to a text-format string
1082 MsecToText(thiscommand->timestamp, timestring);
1083
1084 pout(" %02x %02x %02x %02x %02x %02x %02x %02x %16s %s\n",
1085 (int)thiscommand->commandreg,
1086 (int)thiscommand->featuresreg,
1087 (int)thiscommand->sector_count,
1088 (int)thiscommand->sector_number,
1089 (int)thiscommand->cylinder_low,
1090 (int)thiscommand->cylinder_high,
1091 (int)thiscommand->drive_head,
1092 (int)thiscommand->devicecontrolreg,
1093 timestring,
1094 look_up_ata_command(thiscommand->commandreg, thiscommand->featuresreg));
1095 }
1096 }
1097 pout("\n");
1098 }
1099 }
1100 PRINT_ON(con);
1101 if (con->printing_switchable)
1102 pout("\n");
1103 PRINT_OFF(con);
1104 return data->ata_error_count;
1105 }
1106
1107 void ataPrintSelectiveSelfTestLog(struct ata_selective_self_test_log *log, struct ata_smart_values *sv) {
1108 int i,field1,field2;
1109 char *msg;
1110 char tmp[64];
1111 uint64_t maxl=0,maxr=0;
1112 uint64_t current=log->currentlba;
1113 uint64_t currentend=current+65535;
1114
1115 // print data structure revision number
1116 pout("SMART Selective self-test log data structure revision number %d\n",(int)log->logversion);
1117 if (1 != log->logversion)
1118 pout("Warning: ATA Specification requires selective self-test log data structure revision number = 1\n");
1119
1120 switch((sv->self_test_exec_status)>>4){
1121 case 0:msg="Completed";
1122 break;
1123 case 1:msg="Aborted_by_host";
1124 break;
1125 case 2:msg="Interrupted";
1126 break;
1127 case 3:msg="Fatal_error";
1128 break;
1129 case 4:msg="Completed_unknown_failure";
1130 break;
1131 case 5:msg="Completed_electrical_failure";
1132 break;
1133 case 6:msg="Completed_servo/seek_failure";
1134 break;
1135 case 7:msg="Completed_read_failure";
1136 break;
1137 case 8:msg="Completed_handling_damage??";
1138 break;
1139 case 15:msg="Self_test_in_progress";
1140 break;
1141 default:msg="Unknown_status ";
1142 break;
1143 }
1144
1145 // find the number of columns needed for printing. If in use, the
1146 // start/end of span being read-scanned...
1147 if (log->currentspan>5) {
1148 maxl=current;
1149 maxr=currentend;
1150 }
1151 for (i=0; i<5; i++) {
1152 uint64_t start=log->span[i].start;
1153 uint64_t end =log->span[i].end;
1154 // ... plus max start/end of each of the five test spans.
1155 if (start>maxl)
1156 maxl=start;
1157 if (end > maxr)
1158 maxr=end;
1159 }
1160
1161 // we need at least 7 characters wide fields to accomodate the
1162 // labels
1163 if ((field1=snprintf(tmp,64, "%"PRIu64, maxl))<7)
1164 field1=7;
1165 if ((field2=snprintf(tmp,64, "%"PRIu64, maxr))<7)
1166 field2=7;
1167
1168 // now print the five test spans
1169 pout(" SPAN %*s %*s CURRENT_TEST_STATUS\n", field1, "MIN_LBA", field2, "MAX_LBA");
1170
1171 for (i=0; i<5; i++) {
1172 uint64_t start=log->span[i].start;
1173 uint64_t end=log->span[i].end;
1174
1175 if ((i+1)==(int)log->currentspan)
1176 // this span is currently under test
1177 pout(" %d %*"PRIu64" %*"PRIu64" %s [%01d0%% left] (%"PRIu64"-%"PRIu64")\n",
1178 i+1, field1, start, field2, end, msg,
1179 (int)(sv->self_test_exec_status & 0x7), current, currentend);
1180 else
1181 // this span is not currently under test
1182 pout(" %d %*"PRIu64" %*"PRIu64" Not_testing\n",
1183 i+1, field1, start, field2, end);
1184 }
1185
1186 // if we are currently read-scanning, print LBAs and the status of
1187 // the read scan
1188 if (log->currentspan>5)
1189 pout("%5d %*"PRIu64" %*"PRIu64" Read_scanning %s\n",
1190 (int)log->currentspan, field1, current, field2, currentend,
1191 OfflineDataCollectionStatus(sv->offline_data_collection_status));
1192
1193 /* Print selective self-test flags. Possible flag combinations are
1194 (numbering bits from 0-15):
1195 Bit-1 Bit-3 Bit-4
1196 Scan Pending Active
1197 0 * * Don't scan
1198 1 0 0 Will carry out scan after selective test
1199 1 1 0 Waiting to carry out scan after powerup
1200 1 0 1 Currently scanning
1201 1 1 1 Currently scanning
1202 */
1203
1204 pout("Selective self-test flags (0x%x):\n", (unsigned int)log->flags);
1205 if (log->flags & SELECTIVE_FLAG_DOSCAN) {
1206 if (log->flags & SELECTIVE_FLAG_ACTIVE)
1207 pout(" Currently read-scanning the remainder of the disk.\n");
1208 else if (log->flags & SELECTIVE_FLAG_PENDING)
1209 pout(" Read-scan of remainder of disk interrupted; will resume %d min after power-up.\n",
1210 (int)log->pendingtime);
1211 else
1212 pout(" After scanning selected spans, read-scan remainder of disk.\n");
1213 }
1214 else
1215 pout(" After scanning selected spans, do NOT read-scan remainder of disk.\n");
1216
1217 // print pending time
1218 pout("If Selective self-test is pending on power-up, resume after %d minute delay.\n",
1219 (int)log->pendingtime);
1220
1221 return;
1222 }
1223
1224 // return value is:
1225 // bottom 8 bits: number of entries found where self-test showed an error
1226 // remaining bits: if nonzero, power on hours of last self-test where error was found
1227 int ataPrintSmartSelfTestlog(struct ata_smart_selftestlog *data,int allentries){
1228 int i,j,noheaderprinted=1;
1229 int retval=0, hours=0, testno=0;
1230
1231 if (allentries)
1232 pout("SMART Self-test log structure revision number %d\n",(int)data->revnumber);
1233 if ((data->revnumber!=0x0001) && allentries && con->fixfirmwarebug != FIX_SAMSUNG)
1234 pout("Warning: ATA Specification requires self-test log structure revision number = 1\n");
1235 if (data->mostrecenttest==0){
1236 if (allentries)
1237 pout("No self-tests have been logged. [To run self-tests, use: smartctl -t]\n\n");
1238 return 0;
1239 }
1240
1241 // print log
1242 for (i=20;i>=0;i--){
1243 struct ata_smart_selftestlog_struct *log;
1244
1245 // log is a circular buffer
1246 j=(i+data->mostrecenttest)%21;
1247 log=data->selftest_struct+j;
1248
1249 if (nonempty((unsigned char*)log,sizeof(*log))){
1250 char *msgtest,*msgstat,percent[64],firstlba[64];
1251 int errorfound=0;
1252
1253 // count entry based on non-empty structures -- needed for
1254 // Seagate only -- other vendors don't have blank entries 'in
1255 // the middle'
1256 testno++;
1257
1258 // test name
1259 switch(log->selftestnumber){
1260 case 0: msgtest="Offline "; break;
1261 case 1: msgtest="Short offline "; break;
1262 case 2: msgtest="Extended offline "; break;
1263 case 3: msgtest="Conveyance offline "; break;
1264 case 4: msgtest="Selective offline "; break;
1265 case 127: msgtest="Abort offline test "; break;
1266 case 129: msgtest="Short captive "; break;
1267 case 130: msgtest="Extended captive "; break;
1268 case 131: msgtest="Conveyance captive "; break;
1269 case 132: msgtest="Selective captive "; break;
1270 default:
1271 if ( log->selftestnumber>=192 ||
1272 (log->selftestnumber>= 64 && log->selftestnumber<=126))
1273 msgtest="Vendor offline ";
1274 else
1275 msgtest="Reserved offline ";
1276 }
1277
1278 // test status
1279 switch((log->selfteststatus)>>4){
1280 case 0:msgstat="Completed without error "; break;
1281 case 1:msgstat="Aborted by host "; break;
1282 case 2:msgstat="Interrupted (host reset) "; break;
1283 case 3:msgstat="Fatal or unknown error "; errorfound=1; break;
1284 case 4:msgstat="Completed: unknown failure "; errorfound=1; break;
1285 case 5:msgstat="Completed: electrical failure"; errorfound=1; break;
1286 case 6:msgstat="Completed: servo/seek failure"; errorfound=1; break;
1287 case 7:msgstat="Completed: read failure "; errorfound=1; break;
1288 case 8:msgstat="Completed: handling damage?? "; errorfound=1; break;
1289 case 15:msgstat="Self-test routine in progress"; break;
1290 default:msgstat="Unknown/reserved test status ";
1291 }
1292
1293 retval+=errorfound;
1294 sprintf(percent,"%1d0%%",(log->selfteststatus)&0xf);
1295
1296 // T13/1321D revision 1c: (Data structure Rev #1)
1297
1298 //The failing LBA shall be the LBA of the uncorrectable sector
1299 //that caused the test to fail. If the device encountered more
1300 //than one uncorrectable sector during the test, this field
1301 //shall indicate the LBA of the first uncorrectable sector
1302 //encountered. If the test passed or the test failed for some
1303 //reason other than an uncorrectable sector, the value of this
1304 //field is undefined.
1305
1306 // This is true in ALL ATA-5 specs
1307
1308 if (!errorfound || log->lbafirstfailure==0xffffffff || log->lbafirstfailure==0x00000000)
1309 sprintf(firstlba,"%s","-");
1310 else
1311 sprintf(firstlba,"%u",log->lbafirstfailure);
1312
1313 // print out a header if needed
1314 if (noheaderprinted && (allentries || errorfound)){
1315 pout("Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error\n");
1316 noheaderprinted=0;
1317 }
1318
1319 // print out an entry, either if we are printing all entries OR
1320 // if an error was found
1321 if (allentries || errorfound)
1322 pout("#%2d %s %s %s %8d %s\n", testno, msgtest, msgstat, percent, (int)log->timestamp, firstlba);
1323
1324 // keep track of time of most recent error
1325 if (errorfound && !hours)
1326 hours=log->timestamp;
1327 }
1328 }
1329 if (!allentries && retval)
1330 pout("\n");
1331
1332 hours = hours << 8;
1333 return (retval | hours);
1334 }
1335
1336 void ataPseudoCheckSmart ( struct ata_smart_values *data,
1337 struct ata_smart_thresholds_pvt *thresholds) {
1338 int i;
1339 int failed = 0;
1340 for (i = 0 ; i < NUMBER_ATA_SMART_ATTRIBUTES ; i++) {
1341 if (data->vendor_attributes[i].id &&
1342 thresholds->thres_entries[i].id &&
1343 ATTRIBUTE_FLAGS_PREFAILURE(data->vendor_attributes[i].flags) &&
1344 (data->vendor_attributes[i].current <= thresholds->thres_entries[i].threshold) &&
1345 (thresholds->thres_entries[i].threshold != 0xFE)){
1346 pout("Attribute ID %d Failed\n",(int)data->vendor_attributes[i].id);
1347 failed = 1;
1348 }
1349 }
1350 pout("%s\n", ( failed )?
1351 "SMART overall-health self-assessment test result: FAILED!\n"
1352 "Drive failure expected in less than 24 hours. SAVE ALL DATA":
1353 "SMART overall-health self-assessment test result: PASSED");
1354 }
1355
1356
1357 // Compares failure type to policy in effect, and either exits or
1358 // simply returns to the calling routine.
1359 void failuretest(int type, int returnvalue){
1360
1361 // If this is an error in an "optional" SMART command
1362 if (type==OPTIONAL_CMD){
1363 if (con->conservative){
1364 pout("An optional SMART command failed: exiting. Remove '-T conservative' option to continue.\n");
1365 EXIT(returnvalue);
1366 }
1367 return;
1368 }
1369
1370 // If this is an error in a "mandatory" SMART command
1371 if (type==MANDATORY_CMD){
1372 if (con->permissive--)
1373 return;
1374 pout("A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.\n");
1375 EXIT(returnvalue);
1376 }
1377
1378 pout("Smartctl internal error in failuretest(type=%d). Please contact developers at " PACKAGE_HOMEPAGE "\n",type);
1379 EXIT(returnvalue|FAILCMD);
1380 }
1381
1382 // Used to warn users about invalid checksums. Action to be taken may be
1383 // altered by the user.
1384 void checksumwarning(const char *string){
1385 // user has asked us to ignore checksum errors
1386 if (con->checksumignore)
1387 return;
1388
1389 pout("Warning! %s error: invalid SMART checksum.\n",string);
1390
1391 // user has asked us to fail on checksum errors
1392 if (con->checksumfail)
1393 EXIT(FAILSMART);
1394
1395 return;
1396 }
1397
1398 // Initialize to zero just in case some SMART routines don't work
1399 struct ata_identify_device drive;
1400 struct ata_smart_values smartval;
1401 struct ata_smart_thresholds_pvt smartthres;
1402 struct ata_smart_errorlog smarterror;
1403 struct ata_smart_selftestlog smartselftest;
1404
1405 int ataPrintMain (int fd){
1406 int timewait,code;
1407 int returnval=0, retid=0, supported=0, needupdate=0;
1408
1409 // Start by getting Drive ID information. We need this, to know if SMART is supported.
1410 if ((retid=ataReadHDIdentity(fd,&drive))<0){
1411 pout("Smartctl: Device Read Identity Failed (not an ATA/ATAPI device)\n\n");
1412 failuretest(MANDATORY_CMD, returnval|=FAILID);
1413 }
1414
1415 // If requested, show which presets would be used for this drive and exit.
1416 if (con->showpresets) {
1417 showpresets(&drive);
1418 EXIT(0);
1419 }
1420
1421 // Use preset vendor attribute options unless user has requested otherwise.
1422 if (!con->ignorepresets){
1423 unsigned char *charptr;
1424 if ((charptr=con->attributedefs))
1425 applypresets(&drive, &charptr, con);
1426 else {
1427 pout("Fatal internal error in ataPrintMain()\n");
1428 EXIT(returnval|=FAILCMD);
1429 }
1430 }
1431
1432 // Print most drive identity information if requested
1433 if (con->driveinfo){
1434 pout("=== START OF INFORMATION SECTION ===\n");
1435 ataPrintDriveInfo(&drive);
1436 }
1437
1438 // Was this a packet device?
1439 if (retid>0){
1440 pout("SMART support is: Unavailable - Packet Interface Devices [this device: %s] don't support ATA SMART\n", packetdevicetype(retid-1));
1441 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1442 }
1443
1444 // if drive does not supports SMART it's time to exit
1445 supported=ataSmartSupport(&drive);
1446 if (supported != 1){
1447 if (supported==0) {
1448 pout("SMART support is: Unavailable - device lacks SMART capability.\n");
1449 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1450 pout(" Checking to be sure by trying SMART ENABLE command.\n");
1451 }
1452 else {
1453 pout("SMART support is: Ambiguous - ATA IDENTIFY DEVICE words 82-83 don't show if SMART supported.\n");
1454 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1455 pout(" Checking for SMART support by trying SMART ENABLE command.\n");
1456 }
1457
1458 if (ataEnableSmart(fd)){
1459 pout(" SMART ENABLE failed - this establishes that this device lacks SMART functionality.\n");
1460 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1461 supported=0;
1462 }
1463 else {
1464 pout(" SMART ENABLE appeared to work! Continuing.\n");
1465 supported=1;
1466 }
1467 if (!con->driveinfo) pout("\n");
1468 }
1469
1470 // Now print remaining drive info: is SMART enabled?
1471 if (con->driveinfo){
1472 int ison=ataIsSmartEnabled(&drive),isenabled=ison;
1473
1474 if (ison==-1) {
1475 pout("SMART support is: Ambiguous - ATA IDENTIFY DEVICE words 85-87 don't show if SMART is enabled.\n");
1476 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1477 // check SMART support by trying a command
1478 pout(" Checking to be sure by trying SMART RETURN STATUS command.\n");
1479 isenabled=ataDoesSmartWork(fd);
1480 }
1481 else {
1482 pout("SMART support is: Available - device has SMART capability.\n");
1483 #ifdef HAVE_ATA_IDENTIFY_IS_CACHED
1484 if (ata_identify_is_cached(fd)) {
1485 pout(" %sabled status cached by OS, trying SMART RETURN STATUS cmd.\n",
1486 (isenabled?"En":"Dis"));
1487 isenabled=ataDoesSmartWork(fd);
1488 }
1489 #endif
1490 }
1491
1492 if (isenabled)
1493 pout("SMART support is: Enabled\n");
1494 else {
1495 if (ison==-1)
1496 pout("SMART support is: Unavailable\n");
1497 else
1498 pout("SMART support is: Disabled\n");
1499 }
1500 pout("\n");
1501 }
1502
1503 // START OF THE ENABLE/DISABLE SECTION OF THE CODE
1504 if (con->smartenable || con->smartdisable ||
1505 con->smartautosaveenable || con->smartautosavedisable ||
1506 con->smartautoofflineenable || con->smartautoofflinedisable)
1507 pout("=== START OF ENABLE/DISABLE COMMANDS SECTION ===\n");
1508
1509 // Enable/Disable SMART commands
1510 if (con->smartenable){
1511 if (ataEnableSmart(fd)) {
1512 pout("Smartctl: SMART Enable Failed.\n\n");
1513 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1514 }
1515 else
1516 pout("SMART Enabled.\n");
1517 }
1518
1519 // From here on, every command requires that SMART be enabled...
1520 if (!ataDoesSmartWork(fd)) {
1521 pout("SMART Disabled. Use option -s with argument 'on' to enable it.\n");
1522 return returnval;
1523 }
1524
1525 // Turn off SMART on device
1526 if (con->smartdisable){
1527 if (ataDisableSmart(fd)) {
1528 pout( "Smartctl: SMART Disable Failed.\n\n");
1529 failuretest(MANDATORY_CMD,returnval|=FAILSMART);
1530 }
1531 pout("SMART Disabled. Use option -s with argument 'on' to enable it.\n");
1532 return returnval;
1533 }
1534
1535 // Let's ALWAYS issue this command to get the SMART status
1536 code=ataSmartStatus2(fd);
1537 if (code==-1)
1538 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1539
1540 // Enable/Disable Auto-save attributes
1541 if (con->smartautosaveenable){
1542 if (ataEnableAutoSave(fd)){
1543 pout( "Smartctl: SMART Enable Attribute Autosave Failed.\n\n");
1544 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1545 }
1546 else
1547 pout("SMART Attribute Autosave Enabled.\n");
1548 }
1549 if (con->smartautosavedisable){
1550 if (ataDisableAutoSave(fd)){
1551 pout( "Smartctl: SMART Disable Attribute Autosave Failed.\n\n");
1552 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1553 }
1554 else
1555 pout("SMART Attribute Autosave Disabled.\n");
1556 }
1557
1558 // for everything else read values and thresholds are needed
1559 if (ataReadSmartValues(fd, &smartval)){
1560 pout("Smartctl: SMART Read Values failed.\n\n");
1561 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1562 }
1563 if (ataReadSmartThresholds(fd, &smartthres)){
1564 pout("Smartctl: SMART Read Thresholds failed.\n\n");
1565 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1566 }
1567
1568 // Enable/Disable Off-line testing
1569 if (con->smartautoofflineenable){
1570 if (!isSupportAutomaticTimer(&smartval)){
1571 pout("Warning: device does not support SMART Automatic Timers.\n\n");
1572 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1573 }
1574 needupdate=1;
1575 if (ataEnableAutoOffline(fd)){
1576 pout( "Smartctl: SMART Enable Automatic Offline Failed.\n\n");
1577 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1578 }
1579 else
1580 pout("SMART Automatic Offline Testing Enabled every four hours.\n");
1581 }
1582 if (con->smartautoofflinedisable){
1583 if (!isSupportAutomaticTimer(&smartval)){
1584 pout("Warning: device does not support SMART Automatic Timers.\n\n");
1585 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1586 }
1587 needupdate=1;
1588 if (ataDisableAutoOffline(fd)){
1589 pout("Smartctl: SMART Disable Automatic Offline Failed.\n\n");
1590 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1591 }
1592 else
1593 pout("SMART Automatic Offline Testing Disabled.\n");
1594 }
1595
1596 if (needupdate && ataReadSmartValues(fd, &smartval)){
1597 pout("Smartctl: SMART Read Values failed.\n\n");
1598 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1599 }
1600
1601 // all this for a newline!
1602 if (con->smartenable || con->smartdisable ||
1603 con->smartautosaveenable || con->smartautosavedisable ||
1604 con->smartautoofflineenable || con->smartautoofflinedisable)
1605 pout("\n");
1606
1607 // START OF READ-ONLY OPTIONS APART FROM -V and -i
1608 if (con->checksmart || con->generalsmartvalues || con->smartvendorattrib || con->smarterrorlog || con->smartselftestlog)
1609 pout("=== START OF READ SMART DATA SECTION ===\n");
1610
1611 // Check SMART status (use previously returned value)
1612 if (con->checksmart){
1613 switch (code) {
1614
1615 case 0:
1616 // The case where the disk health is OK
1617 pout("SMART overall-health self-assessment test result: PASSED\n");
1618 if (ataCheckSmart(&smartval, &smartthres,0)){
1619 if (con->smartvendorattrib)
1620 pout("See vendor-specific Attribute list for marginal Attributes.\n\n");
1621 else {
1622 PRINT_ON(con);
1623 pout("Please note the following marginal Attributes:\n");
1624 PrintSmartAttribWithThres(&smartval, &smartthres,2);
1625 }
1626 returnval|=FAILAGE;
1627 }
1628 else
1629 pout("\n");
1630 break;
1631
1632 case 1:
1633 // The case where the disk health is NOT OK
1634 PRINT_ON(con);
1635 pout("SMART overall-health self-assessment test result: FAILED!\n"
1636 "Drive failure expected in less than 24 hours. SAVE ALL DATA.\n");
1637 PRINT_OFF(con);
1638 if (ataCheckSmart(&smartval, &smartthres,1)){
1639 returnval|=FAILATTR;
1640 if (con->smartvendorattrib)
1641 pout("See vendor-specific Attribute list for failed Attributes.\n\n");
1642 else {
1643 PRINT_ON(con);
1644 pout("Failed Attributes:\n");
1645 PrintSmartAttribWithThres(&smartval, &smartthres,1);
1646 }
1647 }
1648 else
1649 pout("No failed Attributes found.\n\n");
1650 returnval|=FAILSTATUS;
1651 PRINT_OFF(con);
1652 break;
1653
1654 case -1:
1655 default:
1656 // The case where something went wrong with HDIO_DRIVE_TASK ioctl()
1657 if (ataCheckSmart(&smartval, &smartthres,1)){
1658 PRINT_ON(con);
1659 pout("SMART overall-health self-assessment test result: FAILED!\n"
1660 "Drive failure expected in less than 24 hours. SAVE ALL DATA.\n");
1661 PRINT_OFF(con);
1662 returnval|=FAILATTR;
1663 returnval|=FAILSTATUS;
1664 if (con->smartvendorattrib)
1665 pout("See vendor-specific Attribute list for failed Attributes.\n\n");
1666 else {
1667 PRINT_ON(con);
1668 pout("Failed Attributes:\n");
1669 PrintSmartAttribWithThres(&smartval, &smartthres,1);
1670 }
1671 }
1672 else {
1673 pout("SMART overall-health self-assessment test result: PASSED\n");
1674 if (ataCheckSmart(&smartval, &smartthres,0)){
1675 if (con->smartvendorattrib)
1676 pout("See vendor-specific Attribute list for marginal Attributes.\n\n");
1677 else {
1678 PRINT_ON(con);
1679 pout("Please note the following marginal Attributes:\n");
1680 PrintSmartAttribWithThres(&smartval, &smartthres,2);
1681 }
1682 returnval|=FAILAGE;
1683 }
1684 else
1685 pout("\n");
1686 }
1687 PRINT_OFF(con);
1688 break;
1689 } // end of switch statement
1690
1691 PRINT_OFF(con);
1692 } // end of checking SMART Status
1693
1694 // Print general SMART values
1695 if (con->generalsmartvalues)
1696 ataPrintGeneralSmartValues(&smartval, &drive);
1697
1698 // Print vendor-specific attributes
1699 if (con->smartvendorattrib){
1700 PRINT_ON(con);
1701 PrintSmartAttribWithThres(&smartval, &smartthres,con->printing_switchable?2:0);
1702 PRINT_OFF(con);
1703 }
1704
1705 // Print SMART log Directory
1706 if (con->smartlogdirectory){
1707 struct ata_smart_log_directory smartlogdirectory;
1708 if (!isGeneralPurposeLoggingCapable(&drive)){
1709 pout("Warning: device does not support General Purpose Logging\n");
1710 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1711 }
1712 else {
1713 PRINT_ON(con);
1714 pout("Log Directory Supported\n");
1715 if (ataReadLogDirectory(fd, &smartlogdirectory)){
1716 PRINT_OFF(con);
1717 pout("Read Log Directory failed.\n\n");
1718 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1719 }
1720 else
1721 ataPrintLogDirectory( &smartlogdirectory);
1722 }
1723 PRINT_OFF(con);
1724 }
1725
1726 // Print SMART error log
1727 if (con->smarterrorlog){
1728 if (!isSmartErrorLogCapable(&smartval, &drive)){
1729 pout("Warning: device does not support Error Logging\n");
1730 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1731 }
1732 if (ataReadErrorLog(fd, &smarterror)){
1733 pout("Smartctl: SMART Error Log Read Failed\n");
1734 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1735 }
1736 else {
1737 // quiet mode is turned on inside ataPrintSmartErrorLog()
1738 if (ataPrintSmartErrorlog(&smarterror))
1739 returnval|=FAILERR;
1740 PRINT_OFF(con);
1741 }
1742 }
1743
1744 // Print SMART self-test log
1745 if (con->smartselftestlog){
1746 if (!isSmartTestLogCapable(&smartval, &drive)){
1747 pout("Warning: device does not support Self Test Logging\n");
1748 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1749 }
1750 if(ataReadSelfTestLog(fd, &smartselftest)){
1751 pout("Smartctl: SMART Self Test Log Read Failed\n");
1752 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1753 }
1754 else {
1755 PRINT_ON(con);
1756 if (ataPrintSmartSelfTestlog(&smartselftest,!con->printing_switchable))
1757 returnval|=FAILLOG;
1758 PRINT_OFF(con);
1759 pout("\n");
1760 }
1761 }
1762
1763 // Print SMART selective self-test log
1764 if (con->selectivetestlog){
1765 struct ata_selective_self_test_log log;
1766
1767 if (!isSupportSelectiveSelfTest(&smartval))
1768 pout("Device does not support Selective Self Tests/Logging\n");
1769 else if(ataReadSelectiveSelfTestLog(fd, &log)) {
1770 pout("Smartctl: SMART Selective Self Test Log Read Failed\n");
1771 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1772 }
1773 else {
1774 PRINT_ON(con);
1775 ataPrintSelectiveSelfTestLog(&log, &smartval);
1776 PRINT_OFF(con);
1777 pout("\n");
1778 }
1779 }
1780
1781 // START OF THE TESTING SECTION OF THE CODE. IF NO TESTING, RETURN
1782 if (con->testcase==-1)
1783 return returnval;
1784
1785 pout("=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===\n");
1786 // if doing a self-test, be sure it's supported by the hardware
1787 switch (con->testcase){
1788 case OFFLINE_FULL_SCAN:
1789 if (!isSupportExecuteOfflineImmediate(&smartval)){
1790 pout("Warning: device does not support Execute Offline Immediate function.\n\n");
1791 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1792 }
1793 break;
1794 case ABORT_SELF_TEST:
1795 case SHORT_SELF_TEST:
1796 case EXTEND_SELF_TEST:
1797 case SHORT_CAPTIVE_SELF_TEST:
1798 case EXTEND_CAPTIVE_SELF_TEST:
1799 if (!isSupportSelfTest(&smartval)){
1800 pout("Warning: device does not support Self-Test functions.\n\n");
1801 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1802 }
1803 break;
1804 case CONVEYANCE_SELF_TEST:
1805 case CONVEYANCE_CAPTIVE_SELF_TEST:
1806 if (!isSupportConveyanceSelfTest(&smartval)){
1807 pout("Warning: device does not support Conveyance Self-Test functions.\n\n");
1808 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1809 }
1810 break;
1811 case SELECTIVE_SELF_TEST:
1812 case SELECTIVE_CAPTIVE_SELF_TEST:
1813 if (!isSupportSelectiveSelfTest(&smartval)){
1814 pout("Warning: device does not support Selective Self-Test functions.\n\n");
1815 failuretest(MANDATORY_CMD, returnval|=FAILSMART);
1816 }
1817 break;
1818 default:
1819 pout("Internal error in smartctl: con->testcase==%d not recognized\n", (int)con->testcase);
1820 pout("Please contact smartmontools developers at %s.\n", PACKAGE_BUGREPORT);
1821 EXIT(returnval|=FAILCMD);
1822 }
1823
1824 // Now do the test. Note ataSmartTest prints its own error/success
1825 // messages
1826 if (ataSmartTest(fd, con->testcase, &smartval))
1827 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1828 else {
1829 // Tell user how long test will take to complete. This is tricky
1830 // because in the case of an Offline Full Scan, the completion
1831 // timer is volatile, and needs to be read AFTER the command is
1832 // given. If this will interrupt the Offline Full Scan, we don't
1833 // do it, just warn user.
1834 if (con->testcase==OFFLINE_FULL_SCAN){
1835 if (isSupportOfflineAbort(&smartval))
1836 pout("Note: giving further SMART commands will abort Offline testing\n");
1837 else if (ataReadSmartValues(fd, &smartval)){
1838 pout("Smartctl: SMART Read Values failed.\n");
1839 failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
1840 }
1841 }
1842
1843 // Now say how long the test will take to complete
1844 if ((timewait=TestTime(&smartval,con->testcase))){
1845 time_t t=time(NULL);
1846 if (con->testcase==OFFLINE_FULL_SCAN) {
1847 t+=timewait;
1848 pout("Please wait %d seconds for test to complete.\n", (int)timewait);
1849 } else {
1850 t+=timewait*60;
1851 pout("Please wait %d minutes for test to complete.\n", (int)timewait);
1852 }
1853 pout("Test will complete after %s\n", ctime(&t));
1854
1855 if (con->testcase!=SHORT_CAPTIVE_SELF_TEST &&
1856 con->testcase!=EXTEND_CAPTIVE_SELF_TEST &&
1857 con->testcase!=CONVEYANCE_CAPTIVE_SELF_TEST &&
1858 con->testcase!=SELECTIVE_CAPTIVE_SELF_TEST)
1859 pout("Use smartctl -X to abort test.\n");
1860 }
1861 }
1862
1863 return returnval;
1864 }