"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/sg_compare_and_write.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_compare_and_write.c  (sg3_utils-1.47r908.tgz):sg_compare_and_write.c  (sg3_utils-1.47r915.tar.xz)
/* /*
* Copyright (c) 2012-2020, Kaminario Technologies LTD * Copyright (c) 2012-2021, Kaminario Technologies LTD
* All rights reserved. * All rights reserved.
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright * * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the * * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
skipping to change at line 59 skipping to change at line 59
#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_cmds_basic.h" #include "sg_cmds_basic.h"
#include "sg_pt.h" #include "sg_pt.h"
#include "sg_unaligned.h" #include "sg_unaligned.h"
#include "sg_pr2serr.h" #include "sg_pr2serr.h"
static const char * version_str = "1.29 20200509"; static const char * version_str = "1.30 20210830";
#define DEF_BLOCK_SIZE 512 #define DEF_BLOCK_SIZE 512
#define DEF_NUM_BLOCKS (1) #define DEF_NUM_BLOCKS (1)
#define DEF_BLOCKS_PER_TRANSFER 8 #define DEF_BLOCKS_PER_TRANSFER 8
#define DEF_TIMEOUT_SECS 60 #define DEF_TIMEOUT_SECS 60
#define COMPARE_AND_WRITE_OPCODE (0x89) #define COMPARE_AND_WRITE_OPCODE (0x89)
#define COMPARE_AND_WRITE_CDB_SIZE (16) #define COMPARE_AND_WRITE_CDB_SIZE (16)
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */ #define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
skipping to change at line 294 skipping to change at line 294
op->device_name = argv[optind]; op->device_name = argv[optind];
++optind; ++optind;
} }
if (optind < argc) { if (optind < argc) {
for (; optind < argc; ++optind) for (; optind < argc; ++optind)
pr2serr("Unexpected extra argument: %s\n", pr2serr("Unexpected extra argument: %s\n",
argv[optind]); argv[optind]);
goto out_err; goto out_err;
} }
} }
if (op->version_given && (! op->verbose_given)) if (op->version_given && (! op->verbose_given))
return 0; return 0;
if (NULL == op->device_name) { if (NULL == op->device_name) {
pr2serr("missing device name!\n"); pr2serr("missing device name!\n");
goto out_err; goto out_err;
} }
if (! if_given) { if (! if_given) {
pr2serr("missing input file\n"); pr2serr("missing input file\n");
goto out_err; goto out_err;
} }
if (! lba_given) { if (! lba_given) {
pr2serr("missing lba\n"); pr2serr("missing lba\n");
skipping to change at line 387 skipping to change at line 387
sg_get_command_str(cawCmd, COMPARE_AND_WRITE_CDB_SIZE, false, sg_get_command_str(cawCmd, COMPARE_AND_WRITE_CDB_SIZE, false,
sizeof(b), b)); sizeof(b), b));
} }
if ((verbose > 2) && (xfer_len > 0)) { if ((verbose > 2) && (xfer_len > 0)) {
pr2serr(" Data-out buffer contents:\n"); pr2serr(" Data-out buffer contents:\n");
hex2stderr(buff, xfer_len, 1); hex2stderr(buff, xfer_len, 1);
} }
res = do_scsi_pt(ptvp, sg_fd, DEF_TIMEOUT_SECS, verbose); res = do_scsi_pt(ptvp, sg_fd, DEF_TIMEOUT_SECS, verbose);
ret = sg_cmds_process_resp(ptvp, "COMPARE AND WRITE", res, ret = sg_cmds_process_resp(ptvp, "COMPARE AND WRITE", res,
noisy, verbose, &sense_cat); noisy, verbose, &sense_cat);
if (-1 == ret) if (-1 == ret) {
if (get_scsi_pt_transport_err(ptvp))
ret = SG_LIB_TRANSPORT_ERROR;
else
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp)); ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) { } 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: case SG_LIB_CAT_MEDIUM_HARD:
slen = get_scsi_pt_sense_len(ptvp); slen = get_scsi_pt_sense_len(ptvp);
valid = sg_get_sense_info_fld(sense_b, slen, valid = sg_get_sense_info_fld(sense_b, slen,
&ull); &ull);
if (valid) if (valid)
 End of changes. 5 change blocks. 
6 lines changed or deleted 9 lines changed or added

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