sg_write_verify.c (sg3_utils-1.47r908.tgz) | : | sg_write_verify.c (sg3_utils-1.47r915.tar.xz) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright (c) 2014-2020 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 | |||
* | * | |||
* This program issues the SCSI command WRITE AND VERIFY to a given SCSI | * This program issues the SCSI command WRITE AND VERIFY to a given SCSI | |||
* device. It sends the command with the logical block address passed as the | * device. It sends the command with the logical block address passed as the | |||
* LBA argument, for the given number of blocks. The number of bytes sent is | * LBA argument, for the given number of blocks. The number of bytes sent is | |||
* supplied separately, either by the size of the given file (IF) or | * supplied separately, either by the size of the given file (IF) or | |||
skipping to change at line 43 | skipping to change at line 43 | |||
#ifdef HAVE_CONFIG_H | #ifdef HAVE_CONFIG_H | |||
#include "config.h" | #include "config.h" | |||
#endif | #endif | |||
#include "sg_lib.h" | #include "sg_lib.h" | |||
#include "sg_pt.h" | #include "sg_pt.h" | |||
#include "sg_cmds_basic.h" | #include "sg_cmds_basic.h" | |||
#include "sg_unaligned.h" | #include "sg_unaligned.h" | |||
#include "sg_pr2serr.h" | #include "sg_pr2serr.h" | |||
static const char * version_str = "1.18 20200430"; | static const char * version_str = "1.19 20210830"; | |||
#define ME "sg_write_verify: " | #define ME "sg_write_verify: " | |||
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ | #define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ | |||
#define WRITE_VERIFY10_CMD 0x2e | #define WRITE_VERIFY10_CMD 0x2e | |||
#define WRITE_VERIFY10_CMDLEN 10 | #define WRITE_VERIFY10_CMDLEN 10 | |||
#define WRITE_VERIFY16_CMD 0x8e | #define WRITE_VERIFY16_CMD 0x8e | |||
#define WRITE_VERIFY16_CMDLEN 16 | #define WRITE_VERIFY16_CMDLEN 16 | |||
skipping to change at line 153 | skipping to change at line 153 | |||
ptvp = construct_scsi_pt_obj(); | ptvp = construct_scsi_pt_obj(); | |||
if (NULL == ptvp) { | if (NULL == ptvp) { | |||
pr2serr("%s: out of memory\n", b); | pr2serr("%s: out of memory\n", b); | |||
return -1; | return -1; | |||
} | } | |||
set_scsi_pt_cdb(ptvp, cdbp, cdb_len); | set_scsi_pt_cdb(ptvp, cdbp, cdb_len); | |||
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); | set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); | |||
set_scsi_pt_data_out(ptvp, dop, do_len); | set_scsi_pt_data_out(ptvp, dop, do_len); | |||
res = do_scsi_pt(ptvp, sg_fd, timeout, verbose); | res = do_scsi_pt(ptvp, sg_fd, timeout, verbose); | |||
ret = sg_cmds_process_resp(ptvp, b, res, noisy, verbose, &sense_cat); | ret = sg_cmds_process_resp(ptvp, b, res, noisy, 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; | |||
case SG_LIB_CAT_MEDIUM_HARD: /* write or verify failed */ | case SG_LIB_CAT_MEDIUM_HARD: /* write or verify failed */ | |||
{ | { | |||
bool valid; | bool valid; | |||
int slen; | int slen; | |||
uint64_t ull = 0; | uint64_t ull = 0; | |||
End of changes. 3 change blocks. | ||||
5 lines changed or deleted | 8 lines changed or added |