"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/sg_xcopy.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_xcopy.c  (sg3_utils-1.47r908.tgz):sg_xcopy.c  (sg3_utils-1.47r915.tar.xz)
/* A utility program for copying files. Similar to 'dd' but using /* A utility program for copying files. Similar to 'dd' but using
* the 'Extended Copy' command. * the 'Extended Copy' command.
* *
* Copyright (c) 2011-2020 Hannes Reinecke, SUSE Labs * Copyright (c) 2011-2021 Hannes Reinecke, SUSE Labs
* *
* Largely taken from 'sg_dd', which has the * Largely taken from 'sg_dd', which has the
* *
* Copyright (C) 1999 - 2010 D. Gilbert and P. Allworth * Copyright (C) 1999 - 2010 D. Gilbert and P. Allworth
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option) * the Free Software Foundation; either version 2, or (at your option)
* any later version. * any later version.
* *
* SPDX-License-Identifier: GPL-2.0-or-later * SPDX-License-Identifier: GPL-2.0-or-later
skipping to change at line 72 skipping to change at line 72
#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_cmds_extra.h" #include "sg_cmds_extra.h"
#include "sg_io_linux.h" #include "sg_io_linux.h"
#include "sg_unaligned.h" #include "sg_unaligned.h"
#include "sg_pr2serr.h" #include "sg_pr2serr.h"
static const char * version_str = "0.71 20200510"; static const char * version_str = "0.72 20210902";
#define ME "sg_xcopy: " #define ME "sg_xcopy: "
#define STR_SZ 1024 #define STR_SZ 1024
#define INOUTF_SZ 512 #define INOUTF_SZ 512
#define EBUFF_SZ 1024 #define EBUFF_SZ 1024
#define DEF_BLOCK_SIZE 512 #define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128 #define DEF_BLOCKS_PER_TRANSFER 128
#define MAX_BLOCKS_PER_TRANSFER 65535 #define MAX_BLOCKS_PER_TRANSFER 65535
skipping to change at line 1075 skipping to change at line 1075
pr2serr(" VPD page error: designator length %d longer " pr2serr(" VPD page error: designator length %d longer "
"than\n remaining response length=%d\n", i_len, "than\n remaining response length=%d\n", i_len,
(len - off)); (len - off));
return SG_LIB_CAT_MALFORMED; return SG_LIB_CAT_MALFORMED;
} }
assoc = ((bp[1] >> 4) & 0x3); assoc = ((bp[1] >> 4) & 0x3);
desig = (bp[1] & 0xf); desig = (bp[1] & 0xf);
if (verbose > 2) if (verbose > 2)
pr2serr(" Desc %d: assoc %u desig %u len %d\n", off, assoc, pr2serr(" Desc %d: assoc %u desig %u len %d\n", off, assoc,
desig, i_len); desig, i_len);
/* Descriptor must be less than 16 bytes */ /* Identification descriptor's Designator length must be <= 20. */
if (i_len > 16) if (i_len > 20)
continue; continue;
if (desig == 3) { if (desig == /*NAA=*/3) {
best = bp; best = bp;
best_len = i_len; best_len = i_len;
break; break;
} }
if (desig == 2) { if (desig == /*EUI64=*/2) {
if (!best || f_desig < 2) { if (!best || f_desig < 2) {
best = bp; best = bp;
best_len = i_len; best_len = i_len;
f_desig = 2; f_desig = 2;
} }
} else if (desig == 1) { } else if (desig == /*T10*/1) {
if (!best || f_desig == 0) { if (!best || f_desig == 0) {
best = bp; best = bp;
best_len = i_len; best_len = i_len;
f_desig = desig; f_desig = desig;
} }
} else if (desig == 0) { } else if (desig == /*vend.spec.=*/0) {
if (!best) { if (!best) {
best = bp; best = bp;
best_len = i_len; best_len = i_len;
f_desig = desig; f_desig = desig;
} }
} }
} }
if (best) { if (best) {
if (verbose) if (verbose)
decode_designation_descriptor(best, best_len); decode_designation_descriptor(best, best_len);
if (best_len + 4 < desc_len) { if (best_len + 4 < desc_len) {
memset(desc, 0, 32); memset(desc, 0, 32);
desc[0] = 0xe4; desc[0] = 0xe4; /* Identification Descriptor */
memcpy(desc + 4, best, best_len + 4); memcpy(desc + 4, best, best_len + 4);
desc[4] &= 0x1f; desc[4] &= 0x0f; /* code set */
desc[5] &= 0x3f; /* association and designator type */
if (pad) if (pad)
desc[28] = 0x4; desc[28] = 0x4;
sg_put_unaligned_be24((uint32_t)block_size, desc + 29); sg_put_unaligned_be24((uint32_t)block_size, desc + 29);
if (verbose > 3) { if (verbose > 3) {
pr2serr("Descriptor in hex (bs %d):\n", block_size); pr2serr("Descriptor in hex (bs %d):\n", block_size);
hex2stderr(desc, 32, 1); hex2stderr(desc, 32, 1);
} }
return 32; return 32;
} }
return best_len + 8; return best_len + 8;
 End of changes. 9 change blocks. 
10 lines changed or deleted 11 lines changed or added

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