X-Git-Url: https://git.proxmox.com/?p=mirror_smartmontools-debian.git;a=blobdiff_plain;f=os_solaris.cpp;h=e70afe784ba337baaf62c363e93d7643ac57a3a0;hp=13dcd7f229c78bedb9b98a07eedad601666d6ca9;hb=HEAD;hpb=34ad0c5ffe435e24270dc422f957585c31be5ec5 diff --git a/os_solaris.cpp b/os_solaris.cpp index 13dcd7f..9ac8f2f 100644 --- a/os_solaris.cpp +++ b/os_solaris.cpp @@ -1,20 +1,12 @@ /* * os_solaris.c * - * Home page of code is: http://smartmontools.sourceforge.net + * Home page of code is: http://www.smartmontools.org * - * Copyright (C) 2003-8 SAWADA Keiji - * Copyright (C) 2003-8 Casper Dik - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * You should have received a copy of the GNU General Public License - * (for example COPYING); if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Copyright (C) 2003-08 SAWADA Keiji + * Copyright (C) 2003-15 Casper Dik * + * SPDX-License-Identifier: GPL-2.0-or-later */ #include @@ -27,7 +19,7 @@ // These are needed to define prototypes for the functions defined below #include "config.h" -#include "int64.h" + #include "atacmds.h" #include "scsicmds.h" #include "utility.h" @@ -37,12 +29,8 @@ #define ARGUSED(x) ((void)(x)) -extern long long bytes; - -static const char *filenameandversion="$Id: os_solaris.cpp,v 1.30 2008/03/04 22:09:47 ballen4705 Exp $"; - -const char *os_XXXX_c_cvsid="$Id: os_solaris.cpp,v 1.30 2008/03/04 22:09:47 ballen4705 Exp $" \ -ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_SOLARIS_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID; +const char *os_XXXX_c_cvsid="$Id: os_solaris.cpp 4805 2018-10-09 19:34:46Z chrfranke $" \ +ATACMDS_H_CVSID CONFIG_H_CVSID OS_SOLARIS_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID; // The printwarning() function warns about unimplemented functions int printedout[2]; @@ -74,9 +62,7 @@ int printwarning(int which){ // print examples for smartctl void print_smartctl_examples(){ - printf("=================================================== SMARTCTL EXAMPLES =====\n\n"); -#ifdef HAVE_GETOPT_LONG - printf( + printf("=================================================== SMARTCTL EXAMPLES =====\n\n" " smartctl -a /dev/rdsk/c0t0d0s0 (Prints all SMART information)\n\n" " smartctl --smart=on --offlineauto=on --saveauto=on /dev/rdsk/c0t0d0s0\n" " (Enables SMART on first disk)\n\n" @@ -84,21 +70,13 @@ void print_smartctl_examples(){ " smartctl --attributes --log=selftest --quietmode=errorsonly /dev/rdsk/c0t0d0s0\n" " (Prints Self-Test & Attribute errors)\n" ); -#else - printf( - " smartctl -a /dev/rdsk/c0t0d0s0 (Prints all SMART information)\n" - " smartctl -s on -o on -S on /dev/rdsk/c0t0d0s0 (Enables SMART on first disk)\n" - " smartctl -t long /dev/rdsk/c0t0d0s0 (Executes extended disk self-test)\n" - " smartctl -A -l selftest -q errorsonly /dev/rdsk/c0t0d0s0\n" - " (Prints Self-Test & Attribute errors)\n" - ); -#endif return; } static const char *uscsidrvrs[] = { "sd", "ssd", + "disk", // SATA devices "st" }; @@ -166,9 +144,8 @@ addpath(const char *path, struct pathlist *res) res->names = static_cast(realloc(res->names, res->maxnames * sizeof (char *))); if (res->names == NULL) return -1; - bytes += 16*sizeof(char *); } - if (!(res->names[res->nnames-1] = CustomStrDup((char *)path, 1, __LINE__, filenameandversion))) + if (!(res->names[res->nnames-1] = strdup(path))) return -1; return 0; } @@ -248,7 +225,6 @@ int make_device_names (char*** devlist, const char* name) { // shrink array to min possible size res.names = static_cast(realloc(res.names, res.nnames * sizeof (char *))); - bytes -= sizeof(char *)*(res.maxnames-res.nnames); // pass list back *devlist = res.names; @@ -271,7 +247,7 @@ int deviceclose(int fd){ return close(fd); } -#if defined(__sparc) +#if defined(WITH_SOLARIS_SPARC_ATA) // swap each 2-byte pairs in a sector static void swap_sector(void *p) { @@ -285,19 +261,8 @@ static void swap_sector(void *p) #endif // Interface to ATA devices. See os_linux.c -int marvell_command_interface(int fd, smart_command_set command, int select, char *data){ - ARGUSED(fd); ARGUSED(command); ARGUSED(select); ARGUSED(data); - return -1; -} - -int highpoint_command_interface(int fd, smart_command_set command, int select, char *data) -{ - ARGUSED(fd); ARGUSED(command); ARGUSED(select); ARGUSED(data); - return -1; -} - int ata_command_interface(int fd, smart_command_set command, int select, char *data){ -#if defined(__sparc) +#if defined(WITH_SOLARIS_SPARC_ATA) int err; switch (command){ @@ -336,10 +301,10 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d return smart_status_check(fd); default: pout("Unrecognized command %d in ata_command_interface() of os_solaris.c\n", command); - exit(1); - break; + errno = EINVAL; + return -1; } -#else /* __sparc */ +#else /* WITH_SOLARIS_SPARC_ATA */ ARGUSED(fd); ARGUSED(command); ARGUSED(select); ARGUSED(data); /* Above smart_* routines uses undocumented ioctls of "dada" @@ -352,16 +317,6 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d return -1; } -// Interface to ATA devices behind 3ware escalade RAID controller cards. See os_linux.c -int escalade_command_interface(int fd, int disknum, int escalade_type, smart_command_set command, int select, char *data){ - ARGUSED(fd); ARGUSED(disknum); ARGUSED(escalade_type); - ARGUSED(command); ARGUSED(select); ARGUSED(data); - - if (printwarning(1)) - return -1; - return -1; -} - #include #include #include @@ -389,7 +344,7 @@ int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report) pout(" Outgoing data, len=%d%s:\n", (int)iop->dxfer_len, (trunc ? " [only first 256 bytes shown]" : "")); - dStrHex((char *)iop->dxferp, (trunc ? 256 : iop->dxfer_len) , 1); + dStrHex(iop->dxferp, (trunc ? 256 : iop->dxfer_len) , 1); } } memset(&uscsi, 0, sizeof (uscsi)); @@ -416,7 +371,7 @@ int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report) default: return -EINVAL; } - uscsi.uscsi_flags |= (USCSI_ISOLATE | USCSI_RQENABLE); + uscsi.uscsi_flags |= (USCSI_ISOLATE | USCSI_RQENABLE | USCSI_SILENT); if (ioctl(fd, USCSICMD, &uscsi)) { int err = errno; @@ -436,13 +391,18 @@ int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report) if ((SCSI_STATUS_CHECK_CONDITION == iop->scsi_status) && iop->sensep && (len > 3)) { - pout(" status=0x%x: sense_key=0x%x asc=0x%x ascq=0x%x\n", - iop->scsi_status, iop->sensep[2] & 0xf, - iop->sensep[12], iop->sensep[13]); + if ((iop->sensep[0] & 0x7f) > 0x71) + pout(" status=%x: [desc] sense_key=%x asc=%x ascq=%x\n", + iop->scsi_status, iop->sensep[1] & 0xf, + iop->sensep[2], iop->sensep[3]); + else + pout(" status=%x: sense_key=%x asc=%x ascq=%x\n", + iop->scsi_status, iop->sensep[2] & 0xf, + iop->sensep[12], iop->sensep[13]); if (report > 1) { pout(" >>> Sense buffer, len=%d:\n", len); - dStrHex((const char *)iop->sensep, ((len > 252) ? 252 : len) , 1); - } + dStrHex(iop->sensep, ((len > 252) ? 252 : len) , 1); + } } else if (iop->scsi_status) pout(" status=%x\n", iop->scsi_status); if (iop->resid) @@ -453,7 +413,7 @@ int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report) trunc = (len > 256) ? 1 : 0; pout(" Incoming data, len=%d%s:\n", len, (trunc ? " [only first 256 bytes shown]" : "")); - dStrHex((char *)iop->dxferp, (trunc ? 256 : len) , 1); + dStrHex(iop->dxferp, (trunc ? 256 : len) , 1); } } }