"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/sg_io_linux.c" between
sg3_utils-1.47r908.tgz and sg3_utils-1.47r915.tar.xz

About: sg3_utils contains utilities that send SCSI commands to devices. Beta version.

sg_io_linux.c  (sg3_utils-1.47r908.tgz):sg_io_linux.c  (sg3_utils-1.47r915.tar.xz)
/* /*
* Copyright (c) 1999-2020 Douglas Gilbert. * Copyright (c) 1999-2021 Douglas Gilbert.
* All rights reserved. * All rights reserved.
* Use of this source code is governed by a BSD-style * Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file. * license that can be found in the BSD_LICENSE file.
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
skipping to change at line 26 skipping to change at line 26
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#ifdef SG_LIB_LINUX #ifdef SG_LIB_LINUX
#include "sg_io_linux.h" #include "sg_io_linux.h"
#include "sg_pr2serr.h" #include "sg_pr2serr.h"
/* Version 1.11 20200401 */ /* Version 1.13 20210831 */
void void
sg_print_masked_status(int masked_status) sg_print_masked_status(int masked_status)
{ {
int scsi_status = (masked_status << 1) & 0x7e; int scsi_status = (masked_status << 1) & 0x7e;
sg_print_scsi_status(scsi_status); sg_print_scsi_status(scsi_status);
} }
/* host_bytes: DID_* are Linux SCSI result (a 32 bit variable) bits 16:23 */ /* host_bytes: DID_* are Linux SCSI result (a 32 bit variable) bits 16:23 */
static const char * linux_host_bytes[] = { static const char * linux_host_bytes[] = {
"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT",
"DID_BAD_TARGET", "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_BAD_TARGET", "DID_ABORT", "DID_PARITY", "DID_ERROR",
"DID_RESET", "DID_BAD_INTR", "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_RESET", "DID_BAD_INTR", "DID_PASSTHROUGH", "DID_SOFT_ERROR",
"DID_IMM_RETRY", "DID_REQUEUE", "DID_TRANSPORT_DISRUPTED", "DID_IMM_RETRY", "DID_REQUEUE", "DID_TRANSPORT_DISRUPTED",
"DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE", "DID_NEXUS_FAILURE", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE", "DID_NEXUS_FAILURE",
"DID_ALLOC_FAILURE", "DID_MEDIUM_ERROR", "DID_ALLOC_FAILURE", "DID_MEDIUM_ERROR", "DID_TRANSPORT_MARGINAL",
}; };
void void
sg_print_host_status(int host_status) sg_print_host_status(int host_status)
{ {
pr2ws("Host_status=0x%02x ", host_status); pr2ws("Host_status=0x%02x ", host_status);
if ((host_status < 0) || if ((host_status < 0) ||
(host_status >= (int)SG_ARRAY_SIZE(linux_host_bytes))) (host_status >= (int)SG_ARRAY_SIZE(linux_host_bytes)))
pr2ws("is invalid "); pr2ws("is invalid ");
else else
pr2ws("[%s] ", linux_host_bytes[host_status]); pr2ws("[%s] ", linux_host_bytes[host_status]);
} }
/* DRIVER_* are Linux SCSI result (a 32 bit variable) bits 24:27 */ /* DRIVER_* are Linux SCSI result (a 32 bit variable) bits 24:27 .
* These where made obsolete around lk 5.12.0 . Only DRIVER_SENSE [0x8] is
* defined in scsi/sg.h for backward comaptibility */
static const char * linux_driver_bytes[] = { static const char * linux_driver_bytes[] = {
"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA",
"DRIVER_ERROR", "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_ERROR", "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD",
"DRIVER_SENSE", "DRIVER_SENSE",
}; };
#if 0 #if 0
/* SUGGEST_* are Linux SCSI result (a 32 bit variable) bits 28:31 */ /* SUGGEST_* are Linux SCSI result (a 32 bit variable) bits 28:31 */
skipping to change at line 86 skipping to change at line 87
void void
sg_print_driver_status(int driver_status) sg_print_driver_status(int driver_status)
{ {
int driv; int driv;
const char * driv_cp = "invalid"; const char * driv_cp = "invalid";
driv = driver_status & SG_LIB_DRIVER_MASK; driv = driver_status & SG_LIB_DRIVER_MASK;
if (driv < (int)SG_ARRAY_SIZE(linux_driver_bytes)) if (driv < (int)SG_ARRAY_SIZE(linux_driver_bytes))
driv_cp = linux_driver_bytes[driv]; driv_cp = linux_driver_bytes[driv];
#if 0
sugg = (driver_status & SG_LIB_SUGGEST_MASK) >> 4;
if (sugg < (int)SG_ARRAY_SIZE(linux_driver_suggests))
sugg_cp = linux_driver_suggests[sugg];
#endif
pr2ws("Driver_status=0x%02x", driver_status); pr2ws("Driver_status=0x%02x", driver_status);
pr2ws(" [%s] ", driv_cp); pr2ws(" [%s] ", driv_cp);
} }
/* Returns 1 if no errors found and thus nothing printed; otherwise /* Returns 1 if no errors found and thus nothing printed; otherwise
* prints error/warning (prefix by 'leadin') to stderr (pr2ws) and * prints error/warning (prefix by 'leadin') to stderr (pr2ws) and
* returns 0. */ * returns 0. */
int int
sg_linux_sense_print(const char * leadin, int scsi_status, int host_status, sg_linux_sense_print(const char * leadin, int scsi_status, int host_status,
int driver_status, const uint8_t * sense_buffer, int driver_status, const uint8_t * sense_buffer,
 End of changes. 5 change blocks. 
10 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)