sg_reset_wp.c (sg3_utils-1.47r908.tgz) | : | sg_reset_wp.c (sg3_utils-1.47r915.tar.xz) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright (c) 2014-2019 Douglas Gilbert. | * Copyright (c) 2014-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 <unistd.h> | #include <unistd.h> | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <stdio.h> | #include <stdio.h> | |||
skipping to change at line 40 | skipping to change at line 40 | |||
#include "sg_unaligned.h" | #include "sg_unaligned.h" | |||
#include "sg_pr2serr.h" | #include "sg_pr2serr.h" | |||
/* A utility program originally written for the Linux OS SCSI subsystem. | /* A utility program originally written for the Linux OS SCSI subsystem. | |||
* | * | |||
* | * | |||
* This program issues the SCSI RESET WRITE POINTER command to the given SCSI | * This program issues the SCSI RESET WRITE POINTER command to the given SCSI | |||
* device. Based on zbc-r04c.pdf . | * device. Based on zbc-r04c.pdf . | |||
*/ | */ | |||
static const char * version_str = "1.14 20191220"; | static const char * version_str = "1.15 20210830"; | |||
#define SG_ZONING_OUT_CMDLEN 16 | #define SG_ZONING_OUT_CMDLEN 16 | |||
#define RESET_WRITE_POINTER_SA 0x4 | #define RESET_WRITE_POINTER_SA 0x4 | |||
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ | #define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ | |||
#define DEF_PT_TIMEOUT 60 /* 60 seconds */ | #define DEF_PT_TIMEOUT 60 /* 60 seconds */ | |||
static struct option long_options[] = { | static struct option long_options[] = { | |||
{"all", no_argument, 0, 'a'}, | {"all", no_argument, 0, 'a'}, | |||
{"count", required_argument, 0, 'C'}, | {"count", required_argument, 0, 'C'}, | |||
skipping to change at line 114 | skipping to change at line 114 | |||
ptvp = construct_scsi_pt_obj(); | ptvp = construct_scsi_pt_obj(); | |||
if (NULL == ptvp) { | if (NULL == ptvp) { | |||
pr2serr("Reset write pointer: out of memory\n"); | pr2serr("Reset write pointer: out of memory\n"); | |||
return -1; | return -1; | |||
} | } | |||
set_scsi_pt_cdb(ptvp, rwp_cdb, sizeof(rwp_cdb)); | set_scsi_pt_cdb(ptvp, rwp_cdb, sizeof(rwp_cdb)); | |||
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); | set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); | |||
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); | res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose); | |||
ret = sg_cmds_process_resp(ptvp, "reset write pointer", res, noisy, | ret = sg_cmds_process_resp(ptvp, "reset write pointer", res, noisy, | |||
verbose, &sense_cat); | verbose, &sense_cat); | |||
if (-1 == ret) | if (-1 == ret) { | |||
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp)); | if (get_scsi_pt_transport_err(ptvp)) | |||
else if (-2 == ret) { | ret = SG_LIB_TRANSPORT_ERROR; | |||
else | ||||
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp)); | ||||
} else if (-2 == ret) { | ||||
switch (sense_cat) { | switch (sense_cat) { | |||
case SG_LIB_CAT_RECOVERED: | case SG_LIB_CAT_RECOVERED: | |||
case SG_LIB_CAT_NO_SENSE: | case SG_LIB_CAT_NO_SENSE: | |||
ret = 0; | ret = 0; | |||
break; | break; | |||
default: | default: | |||
ret = sense_cat; | ret = sense_cat; | |||
break; | break; | |||
} | } | |||
} else | } else | |||
End of changes. 3 change blocks. | ||||
5 lines changed or deleted | 8 lines changed or added |