"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/sg_pt_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_pt_linux.c  (sg3_utils-1.47r908.tgz):sg_pt_linux.c  (sg3_utils-1.47r915.tar.xz)
/* /*
* Copyright (c) 2005-2021 Douglas Gilbert. * Copyright (c) 2005-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
*/ */
/* sg_pt_linux version 1.52 20210423 */ /* sg_pt_linux version 1.54 20210923 */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
skipping to change at line 71 skipping to change at line 71
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" /* 0xd */, "DID_IMM_RETRY", "DID_REQUEUE" /* 0xd */,
"DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST",
"DID_TARGET_FAILURE" /* 0x10 */, "DID_TARGET_FAILURE" /* 0x10 */,
"DID_NEXUS_FAILURE (reservation conflict)", "DID_NEXUS_FAILURE (reservation conflict)",
"DID_ALLOC_FAILURE", "DID_ALLOC_FAILURE",
"DID_MEDIUM_ERROR", "DID_MEDIUM_ERROR",
"DID_TRANSPORT_MARGINAL", /*0x14 */
}; };
/* 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
static const char * linux_driver_suggests[] = { static const char * linux_driver_suggests[] = {
"SUGGEST_OK", "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_OK", "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP",
skipping to change at line 432 skipping to change at line 435
if (NULL == vp) if (NULL == vp)
pr2ws(">>>>>>> Warning: %s called with NULL pointer\n", __func__); pr2ws(">>>>>>> Warning: %s called with NULL pointer\n", __func__);
else { else {
struct sg_pt_linux_scsi * ptp = &vp->impl; struct sg_pt_linux_scsi * ptp = &vp->impl;
if (ptp->free_nvme_id_ctlp) { if (ptp->free_nvme_id_ctlp) {
free(ptp->free_nvme_id_ctlp); free(ptp->free_nvme_id_ctlp);
ptp->free_nvme_id_ctlp = NULL; ptp->free_nvme_id_ctlp = NULL;
ptp->nvme_id_ctlp = NULL; ptp->nvme_id_ctlp = NULL;
} }
if (ptp) if (vp)
free(ptp); free(vp);
} }
} }
/* Remembers previous device file descriptor */ /* Remembers previous device file descriptor */
void void
clear_scsi_pt_obj(struct sg_pt_base * vp) clear_scsi_pt_obj(struct sg_pt_base * vp)
{ {
struct sg_pt_linux_scsi * ptp = &vp->impl; struct sg_pt_linux_scsi * ptp = &vp->impl;
if (ptp) { if (ptp) {
skipping to change at line 949 skipping to change at line 952
else else
n = snprintf(cp, m, "Host_status=0x%02x [%s]\n", hs, n = snprintf(cp, m, "Host_status=0x%02x [%s]\n", hs,
linux_host_bytes[hs]); linux_host_bytes[hs]);
} }
m -= n; m -= n;
if (m < 1) { if (m < 1) {
b[max_b_len - 1] = '\0'; b[max_b_len - 1] = '\0';
return b; return b;
} }
cp += n; cp += n;
driv = ds & SG_LIB_DRIVER_MASK; if (ds) {
if (driv < (int)SG_ARRAY_SIZE(linux_driver_bytes)) driv = ds & SG_LIB_DRIVER_MASK;
driv_cp = linux_driver_bytes[driv]; if (driv < (int)SG_ARRAY_SIZE(linux_driver_bytes))
#if 0 driv_cp = linux_driver_bytes[driv];
sugg = (ds & SG_LIB_SUGGEST_MASK) >> 4; n = snprintf(cp, m, "Driver_status=0x%02x [%s]\n", ds, driv_cp);
if (sugg < SG_ARRAY_SIZE(linux_driver_suggests) m -= n;
sugg_cp = linux_driver_suggests[sugg]; }
#endif
n = snprintf(cp, m, "Driver_status=0x%02x [%s]\n", ds, driv_cp);
m -= n;
if (m < 1) if (m < 1)
b[max_b_len - 1] = '\0'; b[max_b_len - 1] = '\0';
return b; return b;
} }
int int
get_scsi_pt_result_category(const struct sg_pt_base * vp) get_scsi_pt_result_category(const struct sg_pt_base * vp)
{ {
const struct sg_pt_linux_scsi * ptp = &vp->impl; const struct sg_pt_linux_scsi * ptp = &vp->impl;
int dr_st = ptp->io_hdr.driver_status & SG_LIB_DRIVER_MASK; int dr_st = ptp->io_hdr.driver_status & SG_LIB_DRIVER_MASK;
 End of changes. 5 change blocks. 
13 lines changed or deleted 13 lines changed or added

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