X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=os_openbsd.cpp;h=eef9f358dd907006340515d0094e0371d1814954;hb=HEAD;hp=e0d572073d4b1209ad4050e622f296399f5dacc7;hpb=2127e1931eec4a688d41baf253744fc48ed8c989;p=mirror_smartmontools-debian.git diff --git a/os_openbsd.cpp b/os_openbsd.cpp index e0d5720..eef9f35 100644 --- a/os_openbsd.cpp +++ b/os_openbsd.cpp @@ -1,38 +1,29 @@ /* * os_openbsd.c * - * Home page of code is: http://smartmontools.sourceforge.net + * Home page of code is: http://www.smartmontools.org * - * Copyright (C) 2004-8 David Snyder + * Copyright (C) 2004-10 David Snyder * - * Derived from os_netbsd.cpp by Sergey Svishchev , Copyright (C) 2003-8 - * - * 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. + * Derived from os_netbsd.cpp by Sergey Svishchev, Copyright (C) 2003-8 * + * SPDX-License-Identifier: GPL-2.0-or-later */ #include "config.h" -#include "int64.h" + #include "atacmds.h" #include "scsicmds.h" #include "utility.h" #include "os_openbsd.h" -const char *os_XXXX_c_cvsid = "$Id: os_openbsd.cpp,v 1.17 2008/06/12 21:46:31 ballen4705 Exp $" \ -ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_OPENBSD_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID; +#include -/* global variable holding byte count of allocated memory */ -extern long long bytes; +const char * os_openbsd_cpp_cvsid = "$Id: os_openbsd.cpp 4842 2018-12-02 16:07:26Z chrfranke $" + OS_OPENBSD_H_CVSID; enum warnings { - BAD_SMART, NO_3WARE, NO_ARECA, MAX_MSG + BAD_SMART, MAX_MSG }; /* Utility function for printing warnings */ @@ -42,7 +33,7 @@ printwarning(int msgNo, const char *extra) static int printed[] = {0, 0}; static const char *message[] = { "Error: SMART Status command failed.\nPlease get assistance from \n" PACKAGE_HOMEPAGE "\nRegister values returned from SMART Status command are:\n", - PACKAGE_STRING " does not currentlly support twe(4) devices (3ware Escalade)\n", + PACKAGE_STRING " does not currently support twe(4) devices (3ware Escalade)\n", }; if (msgNo >= 0 && msgNo <= MAX_MSG) { @@ -121,18 +112,26 @@ get_dev_names(char ***names, const char *prefix) if (strncmp(p, prefix, strlen(prefix))) { continue; } + char * u = strchr(p, ':'); + if (u) + *u = 0; mp[n] = (char *)malloc(strlen(net_dev_prefix) + strlen(p) + 2); if (!mp[n]) { pout("Out of memory constructing scan device list\n"); return -1; } sprintf(mp[n], "%s%s%c", net_dev_prefix, p, 'a' + getrawpartition()); - bytes += strlen(mp[n]) + 1; n++; } - mp = (char **)realloc(mp, n * (sizeof(char *))); - bytes += (n) * (sizeof(char *)); + char ** tmp = (char **)realloc(mp, n * (sizeof(char *))); + if (NULL == tmp) { + pout("Out of memory constructing scan device list\n"); + free(mp); + return -1; + } + else + mp = tmp; *names = mp; return n; } @@ -168,14 +167,6 @@ deviceclose(int fd) return close(fd); } -int -marvell_command_interface(int fd, smart_command_set command, int select, char *data) -{ return -1; } - -int -highpoint_command_interface(int fd, smart_command_set command, int select, char *data) -{ return -1; } - int ata_command_interface(int fd, smart_command_set command, int select, char *data) { @@ -319,7 +310,8 @@ ata_command_interface(int fd, smart_command_set command, int select, char *data) unsigned const short normal = WDSMART_CYL, failed = 0x2cf4; - if ((retval = ioctl(fd, ATAIOCCOMMAND, &req))) { + retval = ioctl(fd, ATAIOCCOMMAND, &req); + if (retval < 0) { perror("Failed command"); return -1; } @@ -354,20 +346,6 @@ ata_command_interface(int fd, smart_command_set command, int select, char *data) return 0; } -int -escalade_command_interface(int fd, int disknum, int escalade_type, smart_command_set command, int select, char *data) -{ - printwarning(NO_3WARE, NULL); - return -1; -} - -int -areca_command_interface(int fd, int disknum, smart_command_set command, int select, char *data) -{ - printwarning(NO_ARECA, NULL); - return -1; -} - int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report) { @@ -434,9 +412,8 @@ print_smartctl_examples() char p; p = 'a' + getrawpartition(); - printf("=================================================== SMARTCTL EXAMPLES =====\n\n"); -#ifdef HAVE_GETOPT_LONG printf( + "=================================================== SMARTCTL EXAMPLES =====\n\n" " smartctl -a /dev/wd0%c (Prints all SMART information)\n\n" " smartctl --smart=on --offlineauto=on --saveauto=on /dev/wd0%c\n" " (Enables SMART on first disk)\n\n" @@ -445,15 +422,5 @@ print_smartctl_examples() " (Prints Self-Test & Attribute errors)\n", p, p, p, p ); -#else - printf( - " smartctl -a /dev/wd0%c (Prints all SMART information)\n" - " smartctl -s on -o on -S on /dev/wd0%c (Enables SMART on first disk)\n" - " smartctl -t long /dev/wd0%c (Executes extended disk self-test)\n" - " smartctl -A -l selftest -q errorsonly /dev/wd0%c" - " (Prints Self-Test & Attribute errors)\n", - p, p, p, p - ); -#endif return; }