Skip to content

Commit

Permalink
sg_vpd: zoned block dev char vpd: add zone alignment mode and zone st…
Browse files Browse the repository at this point in the history
…arting LBA granularity; gcc -fanalyzer fixes: in sg_pt_linux.c + sg_write_x.c

git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@914 6180dd3e-e324-4e3e-922d-17de1ae2f315
  • Loading branch information
doug-gilbert committed Sep 26, 2021
1 parent 6aa4d33 commit 20704a8
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 26 deletions.
5 changes: 4 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.

Changelog for pre-release sg3_utils-1.47 [20210912] [svn: r913]
Changelog for pre-release sg3_utils-1.47 [20210924] [svn: r914]
- transport error handling improved. To fix report of a
BAD_TARGET transport error but the utility still continued.
- introduce SG_LIB_TRANSPORT_ERROR [35] exit status
Expand All @@ -14,6 +14,8 @@ Changelog for pre-release sg3_utils-1.47 [20210912] [svn: r913]
- guard against smaller '--maxlen=' values
- sg_logs: additions to Volume statistics lpage [ssc5r05c]
- sg_vpd: fix do_hex type on some recent pages
- zoned block dev char vpd: add zone alignment mode and
zone starting LBA granularity [zbc2r11]
- sg_read_buffer: fix --length= problem
- sg_dd, sgm_dd, sgp_dd: don't close negative file descriptors
- sg_dd: srand48_r() and mrand48_r() are GNU libc specific,
Expand All @@ -34,6 +36,7 @@ Changelog for pre-release sg3_utils-1.47 [20210912] [svn: r913]
library with sg_pt_dummy.c instead of OS specific code.
For experimenting with --inhex= decoding on netbsd
- pt: add Haiku OS support
- gcc -fanalyzer fixes: in sg_pt_linux.c + sg_write_x.c
- sg_pt_dummy.c: add list of functions that a new pt
needs to define
- move some hex files from examples to inhex directory
Expand Down
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sg3-utils (1.47-0.1) unstable; urgency=low

* New upstream version

-- Douglas Gilbert <dgilbert@interlog.com> Sun, 12 Sep 2021 14:00:00 -0400
-- Douglas Gilbert <dgilbert@interlog.com> Sat, 25 Sep 2021 00:01:00 -0400

sg3-utils (1.46-0.1) unstable; urgency=low

Expand Down
2 changes: 1 addition & 1 deletion doc/sg_dd.8
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ random
this flag is only active with \fIiflag=\fR and when given replaces
\fIif=IFILE\fR. If both are given an error is generated. The input will
be a stream of pseudo random bytes. The Linux getrandom(2) system call is
used to create a seed and thereadter mrand48(3) is used to generate a
used to create a seed and there after mrand48(3) is used to generate a
pseudo random sequence, 4 bytes at a time. The quality of the randomness
can be viewed with the ent(1) utility. This is not a high quality random
number generator, it is built for speed, not quality. One application is
Expand Down
4 changes: 2 additions & 2 deletions inhex/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
========================================

The files in this folder contain hexadecimal data (in ASCII) and associated
comments (prefixed with the hash mark symbol ('#')).
comments (prefixed with the hash mark symbol: '#' ).

The utility that each hex file is associated with can be determined by
prepending "sg_" to these filenames then going to the 'src' folder (a
Expand Down Expand Up @@ -47,4 +47,4 @@ that support --inhex and don't have hex data already. Special cases are
also welcome. They help the author test this code.

Douglas Gilbert
28th August 2019
25th September 2021
25 changes: 25 additions & 0 deletions inhex/vpd_zbdc.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Zoned block device characteristics VPD page [0xb6]
# Host managed zoned block device model; pdt=0x14
14 b6 00 3c
# ZBD extension=0; AAORb=0; URSWRZ=0
00 00 00 00

# Optimal # of open sequential write preferred
00 00 00 00

# Optimal # of open non-sequentailly written sequential write preferred
00 00 00 00

# maximum # of open sequential write required
00 00 00 08

# Zone alignment mode=0 (therefore no gaps)
00 00 00 00

# Zone starting LBA granularity
00 00 00 02 00 00 00 00


# pad to total length of 64 bytes
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
1 change: 1 addition & 0 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ endif
# -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more
AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $(DBG_CPPFLAGS)
AM_CFLAGS = -Wall -W $(DBG_CFLAGS)
# AM_CFLAGS = -Wall -W $(DBG_CFLAGS) -fanalyzer
# AM_CFLAGS = -Wall -W -Wextra -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wshadow -Wjump-misses-init
# AM_CFLAGS = -Wall -W -pedantic -std=c11
# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze
Expand Down
1 change: 1 addition & 0 deletions lib/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ libsgutils2_la_SOURCES = sg_lib.c sg_lib_data.c sg_cmds_basic.c \
# -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more
AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $(DBG_CPPFLAGS)
AM_CFLAGS = -Wall -W $(DBG_CFLAGS)
# AM_CFLAGS = -Wall -W $(DBG_CFLAGS) -fanalyzer
# AM_CFLAGS = -Wall -W -Wextra -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wshadow -Wjump-misses-init
# AM_CFLAGS = -Wall -W -pedantic -std=c11
# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze
Expand Down
2 changes: 1 addition & 1 deletion lib/sg_pt_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ destruct_scsi_pt_obj(struct sg_pt_base * vp)
if ((ptp = &vp->impl)) {
if (ptp->ccb)
cam_freeccb(ptp->ccb);
free(ptp);
free(vp);
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/sg_pt_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/

/* sg_pt_linux version 1.53 20210830 */
/* sg_pt_linux version 1.54 20210923 */


#include <stdio.h>
Expand Down Expand Up @@ -439,8 +439,8 @@ destruct_scsi_pt_obj(struct sg_pt_base * vp)
ptp->free_nvme_id_ctlp = NULL;
ptp->nvme_id_ctlp = NULL;
}
if (ptp)
free(ptp);
if (vp)
free(vp);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sg3_utils.spec
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fi
%{_libdir}/*.la

%changelog
* Sun Sep 12 2021 - dgilbert at interlog dot com
* Sat Sep 25 2021 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.47

Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ endif
# -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more
AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $(DBG_CPPFLAGS)
AM_CFLAGS = -Wall -W $(DBG_CFLAGS)
# AM_CFLAGS = -Wall -W $(DBG_CFLAGS) -fanalyzer
# AM_CFLAGS = -Wall -W -Wextra -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wshadow -Wjump-misses-init
# AM_CFLAGS = -Wall -W -pedantic -std=c11
# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ sg_scan_SOURCES = $(am__append_2) $(am__append_4) $(am__append_6)
# -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more
AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $(DBG_CPPFLAGS)
AM_CFLAGS = -Wall -W $(DBG_CFLAGS)
# AM_CFLAGS = -Wall -W $(DBG_CFLAGS) -fanalyzer
# AM_CFLAGS = -Wall -W -Wextra -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wshadow -Wjump-misses-init
# AM_CFLAGS = -Wall -W -pedantic -std=c11
# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze
Expand Down
6 changes: 3 additions & 3 deletions src/sg_logs.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"

static const char * version_str = "1.85 20210802"; /* spc6r05 + sbc5r01 */
static const char * version_str = "1.86 20210924"; /* spc6r05 + sbc5r01 */

#define MX_ALLOC_LEN (0xfffc)
#define SHORT_RESP_LEN 128
Expand Down Expand Up @@ -4861,8 +4861,8 @@ static const char * bms_status[] = {
"background scan halted due to medium formatted without P-List",
"background scan halted - vendor specific cause",
"background scan halted due to temperature out of range",
"background scan enabled, none active (waiting for BMS interval timer "
"to expire)", /* 8 */
("background scan enabled, none active (waiting for BMS interval timer "
"to expire)"), /* clang warns about this, add parens to quieten */
"background scan halted - scan results list full",
"background scan halted - pre-scan time limit timer expired" /* 10 */,
};
Expand Down
3 changes: 2 additions & 1 deletion src/sg_rep_zones.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* Based on zbc2r10.pdf
*/

static const char * version_str = "1.27 20210830";
static const char * version_str = "1.28 20210922";

#define MAX_RZONES_BUFF_LEN (1024 * 1024)
#define DEF_RZONES_BUFF_LEN (1024 * 8)
Expand Down Expand Up @@ -160,6 +160,7 @@ usage(int h)
" 0x10 list zones with RWP Recommended set to true\n"
" 0x11 list zones with Non-sequential write resources "
"active set to true\n"
" 0x3e list zones except those with zone type: GAP\n"
" 0x3f list zones with a zone condition of NOT WRITE "
"POINTER\n\n");
pr2serr("Reporting options for REPORT ZONE DOMAINS:\n"
Expand Down
36 changes: 28 additions & 8 deletions src/sg_vpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/

static const char * version_str = "1.66 20210702"; /* spc6r05 + sbc5r01 */
static const char * version_str = "1.66 20210923"; /* spc6r05 + sbc5r01 */

/* standard VPD pages, in ascending page number order */
#define VPD_SUPPORTED_VPDS 0x0
Expand Down Expand Up @@ -2549,6 +2549,7 @@ static void
decode_zbdch_vpd(uint8_t * b, int len, int do_hex)
{
uint32_t u;
char d[32];

if (do_hex) {
hex2stdout(b, len, (1 == do_hex) ? 0 : -1);
Expand All @@ -2559,10 +2560,12 @@ decode_zbdch_vpd(uint8_t * b, int len, int do_hex)
"short=%d\n", len);
return;
}
printf(" Peripheral device type: %s\n",
sg_get_pdt_str(0x1f & b[0], sizeof(d), d));
printf(" Zoned block device extension: ");
switch ((b[4] >> 4) & 0xf) {
case 0:
printf("not reported\n");
printf("not reported [0]\n");
break;
case 1:
printf("host aware zone block device model\n");
Expand Down Expand Up @@ -2596,6 +2599,23 @@ decode_zbdch_vpd(uint8_t * b, int len, int do_hex)
printf("no limit\n");
else
printf("%" PRIu32 "\n", u);
printf(" Zone alignment mode: "); /* zbc2r11 */
switch (b[23] & 0xf) {
case 0:
printf("not reported [0]\n");
break;
case 1:
printf("use constant zone lengths\n");
break;
case 0x8:
printf("zone length given by REPORT ZONES\n");
break;
default:
printf("Unknown [0x%x]\n", (b[23] & 0xf));
break;
}
printf(" Zone starting LBA granularity: 0x%" PRIx64 "\n",
sg_get_unaligned_be64(b + 24));
}

/* VPD_BLOCK_LIMITS_EXT [0xb7] sbc */
Expand Down Expand Up @@ -3733,8 +3753,8 @@ svpd_examine_all(int sg_fd, struct opts_t * op)
}
if (op->do_long)
snprintf(b, sizeof(b), "[0x%x] ", k);
else
b[0] = '\0';
else
b[0] = '\0';
res = svpd_decode_t10(sg_fd, op, 0, 0, b);
if (SG_LIB_CAT_OTHER == res) {
res = svpd_decode_vendor(sg_fd, op, 0);
Expand Down Expand Up @@ -3825,11 +3845,11 @@ main(int argc, char * argv[])
MX_ALLOC_LEN);
return SG_LIB_SYNTAX_ERROR;
}
if ((op->maxlen > 0) && (op->maxlen < MIN_MAXLEN)) {
if ((op->maxlen > 0) && (op->maxlen < MIN_MAXLEN)) {
pr2serr("Warning: overriding '--maxlen' < %d, using "
"default\n", MIN_MAXLEN);
op->maxlen = 0;
}
"default\n", MIN_MAXLEN);
op->maxlen = 0;
}
break;
case 'M':
if (op->vend_prod) {
Expand Down
10 changes: 6 additions & 4 deletions src/sg_write_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"

static const char * version_str = "1.27 20210830";
static const char * version_str = "1.28 20210923";

/* Protection Information refers to 8 bytes of extra information usually
* associated with each logical block and is often abbreviated to PI while
Expand Down Expand Up @@ -803,6 +803,7 @@ build_t10_scat(const char * scat_fname, bool do_16, bool parse_one,
uint32_t * sum_num, uint32_t max_list_blen)
{
bool have_stdin = false;
bool del_fp = false;
bool bit0, ok;
int off = 0;
int in_len, k, j, m, n, res, err;
Expand Down Expand Up @@ -833,6 +834,7 @@ build_t10_scat(const char * scat_fname, bool do_16, bool parse_one,
safe_strerror(err));
return sg_convert_errno(err);
}
del_fp = true;
}
for (j = 0; j < 1024; ++j) {/* loop over lines in file */
if ((max_list_blen > 0) && ((n + lbard_sz) > max_list_blen))
Expand Down Expand Up @@ -927,15 +929,15 @@ build_t10_scat(const char * scat_fname, bool do_16, bool parse_one,
}
fini:
*num_scat_elems = (n / lbard_sz) - 1;
if (fp && (stdin != fp))
if (del_fp)
fclose(fp);
return 0;
bad_exit:
if (fp && (stdin != fp))
if (del_fp)
fclose(fp);
return SG_LIB_SYNTAX_ERROR;
bad_mem_exit:
if (fp && (stdin != fp))
if (del_fp)
fclose(fp);
return SG_LIB_CAT_NOT_READY; /* flag output buffer too small */
}
Expand Down

0 comments on commit 20704a8

Please sign in to comment.