sg_rep_pip.c (sg3_utils-1.47r908.tgz) | : | sg_rep_pip.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 | |||
*/ | */ | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <stdio.h> | #include <stdio.h> | |||
skipping to change at line 42 | skipping to change at line 42 | |||
#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 REPORT PROVISIONING INITIALIZATION PATTERN | * This program issues the SCSI REPORT PROVISIONING INITIALIZATION PATTERN | |||
* command to the given SCSI device and outputs the response. Based on | * command to the given SCSI device and outputs the response. Based on | |||
* sbc4r21.pdf | * sbc4r21.pdf | |||
*/ | */ | |||
static const char * version_str = "1.01 20200605"; | static const char * version_str = "1.02 20210830"; | |||
#define MAX_RPIP_BUFF_LEN (1024 * 1024) | #define MAX_RPIP_BUFF_LEN (1024 * 1024) | |||
#define DEF_RPIP_BUFF_LEN 512 | #define DEF_RPIP_BUFF_LEN 512 | |||
#define SG_MAINT_IN_CMDLEN 12 | #define SG_MAINT_IN_CMDLEN 12 | |||
#define REPORT_PROVISIONING_INITIALIZATION_PATTERN_SA 0x1d | #define REPORT_PROVISIONING_INITIALIZATION_PATTERN_SA 0x1d | |||
#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 */ | |||
skipping to change at line 124 | skipping to change at line 124 | |||
ptvp = construct_scsi_pt_obj(); | ptvp = construct_scsi_pt_obj(); | |||
if (NULL == ptvp) { | if (NULL == ptvp) { | |||
pr2serr("%s: out of memory\n", __func__); | pr2serr("%s: out of memory\n", __func__); | |||
return -1; | return -1; | |||
} | } | |||
set_scsi_pt_cdb(ptvp, rz_cdb, sizeof(rz_cdb)); | set_scsi_pt_cdb(ptvp, rz_cdb, sizeof(rz_cdb)); | |||
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); | set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b)); | |||
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len); | set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len); | |||
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, rpip_s, res, noisy, verbose, &sense_cat); | ret = sg_cmds_process_resp(ptvp, rpip_s, 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; | |||
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 |