aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2021-03-28 00:58:36 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2021-03-28 00:58:36 +0000
commit9ccb556a21f1aa2c8d08052622aa4471b7acd6a3 (patch)
tree47fbc1779312c01ed306b1685e3f4494abc0ee44
parent865ab8e10f0e1dfadc31bd27e51d4fdac1075293 (diff)
downloadsg3_utils-9ccb556a21f1aa2c8d08052622aa4471b7acd6a3.tar.gz
sg_dd: setup conditional auto rule for getrandom()
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@883 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog7
-rw-r--r--README.freebsd11
-rw-r--r--config.h.in6
-rwxr-xr-xconfigure21
-rw-r--r--configure.ac10
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg_inq.84
-rw-r--r--doc/sg_vpd.84
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_dd.c23
-rw-r--r--src/sg_inq.c4
-rw-r--r--src/sg_vpd.c4
12 files changed, 74 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index bd13fd56..cf1e95be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,20 +2,21 @@ 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 released sg3_utils-1.46 [20210321] [svn: r880]
+Changelog for released sg3_utils-1.46 [20210326] [svn: r882]
- sg_rep_pip: new utility: report provisioning initialization
pattern command
- - sg_turs: estimated time-to-ready [20-061r2]
+ - sg_turs: estimated time-to-ready [spc6r03]
- add --delay=MS option
- sg_requests: substantial cleanup
- sg_vpd: add Format presets and Concurrent positioning ranges
- - add hot-pluggable field in standard Inquiry [20-114r2]
+ - add hot-pluggable field in standard Inquiry [spc6r05]
- sg_inq: add hot-pluggable field in standard Inquiry
- sg_dd: --verify : separate category for miscompare errors
- --verify : oflag=coe continue on miscompares, counts them
- add cdl= operand for command duration limit indexes
- add oflag=nocreat and conv=nocreat : OFILE must exist
- add iflag=00, ff, random flags
+ - setup conditional auto rule for getrandom()
- add command timeout after comma in time= operand
- sg_get_elem_status: add ralwd bit sbc4r20a
- sg_write_x: add dld bits to write(32) [sbc4r19a]
diff --git a/README.freebsd b/README.freebsd
index afdd2079..aa066ef4 100644
--- a/README.freebsd
+++ b/README.freebsd
@@ -86,8 +86,13 @@ hopefully will not confuse the FreeBSD users.
Device naming
=============
In FreeBSD disks have block names like '/dev/da0' with a corresponding
-pass-through device name like '/dev/pass0'. Use this command
-"camcontrol devlist" to see that SCSI devices available.
+pass-through device name like '/dev/pass0'. Use this command:
+"camcontrol devlist" to see that SCSI devices available. To list NVMe
+devices: "nvmecontrol devlist" can be used. Any many, but not all
+contexts, the device name can be used without the '/dev/' prefix.
+FreeBSD is relatively unique in this respect and support for this
+abbreviated form has been broken in this package and fixed in
+release 1.46 .
FreeBSD installation
====================
@@ -144,4 +149,4 @@ utilities.
Douglas Gilbert
-5th June 2020
+26th March 2021
diff --git a/config.h.in b/config.h.in
index f575e87a..02d3725c 100644
--- a/config.h.in
+++ b/config.h.in
@@ -12,6 +12,9 @@
/* Define to 1 if you have the `getopt_long' function. */
#undef HAVE_GETOPT_LONG
+/* Found sys/random.h */
+#undef HAVE_GETRANDOM
+
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
@@ -69,6 +72,9 @@
/* Define to 1 if you have the `sysconf' function. */
#undef HAVE_SYSCONF
+/* Define to 1 if you have the <sys/random.h> header file. */
+#undef HAVE_SYS_RANDOM_H
+
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
diff --git a/configure b/configure
index 1c029f43..3c7f1cf4 100755
--- a/configure
+++ b/configure
@@ -13010,6 +13010,21 @@ RT_LIB=$rt_lib
printf "%s\n" "#define SG_LIB_BUILD_HOST \"${host}\"" >>confdefs.h
+check_for_getrandom() {
+ for ac_header in sys/random.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "sys/random.h" "ac_cv_header_sys_random_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_random_h" = xyes
+then :
+ printf "%s\n" "#define HAVE_SYS_RANDOM_H 1" >>confdefs.h
+
+printf "%s\n" "#define HAVE_GETRANDOM 1" >>confdefs.h
+
+fi
+
+done
+}
+
check_for_linux_nvme_headers() {
for ac_header in linux/nvme_ioctl.h
do :
@@ -13207,7 +13222,6 @@ printf "%s\n" "#define HAVE_LINUX_SG_V4_HDR 1" >>confdefs.h
fi
rm -rf conftest*
-
}
case "${host}" in
@@ -13219,6 +13233,7 @@ printf "%s\n" "#define SG_LIB_ANDROID 1" >>confdefs.h
printf "%s\n" "#define SG_LIB_LINUX 1" >>confdefs.h
check_for_linux_sg_v4_hdr
+ check_for_getrandom
check_for_linux_nvme_headers;;
*-*-freebsd*|*-*-kfreebsd*-gnu*)
@@ -13227,6 +13242,7 @@ printf "%s\n" "#define SG_LIB_FREEBSD 1" >>confdefs.h
printf "%s\n" "#define HAVE_NVME 1" >>confdefs.h
+ check_for_getrandom
LIBS="$LIBS -lcam";;
*-*-solaris*)
@@ -13244,6 +13260,7 @@ printf "%s\n" "#define SG_LIB_WIN32 1" >>confdefs.h
printf "%s\n" "#define HAVE_NVME 1" >>confdefs.h
+ check_for_getrandom
CFLAGS="$CFLAGS -Wno-char-subscripts";;
*-*-mingw*)
@@ -13256,12 +13273,14 @@ printf "%s\n" "#define SG_LIB_MINGW 1" >>confdefs.h
printf "%s\n" "#define HAVE_NVME 1" >>confdefs.h
+ check_for_getrandom
CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO";;
*-*-linux-gnu* | *-*-linux* | *)
printf "%s\n" "#define SG_LIB_LINUX 1" >>confdefs.h
check_for_linux_sg_v4_hdr
+ check_for_getrandom
check_for_linux_nvme_headers;;
esac
diff --git a/configure.ac b/configure.ac
index e15dd16a..1cb436f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,10 @@ AC_CANONICAL_HOST
AC_DEFINE_UNQUOTED(SG_LIB_BUILD_HOST, "${host}", [sg3_utils Build Host])
+check_for_getrandom() {
+ AC_CHECK_HEADERS([sys/random.h], [AC_DEFINE_UNQUOTED(HAVE_GETRANDOM, 1, [Found sys/random.h])], [], [])
+}
+
check_for_linux_nvme_headers() {
AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE_UNQUOTED(HAVE_NVME, 1, [Found NVMe])], [], [])
AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [],
@@ -67,7 +71,6 @@ check_for_linux_sg_v4_hdr() {
#endif
],
[AC_DEFINE_UNQUOTED(HAVE_LINUX_SG_V4_HDR, 1, [Have Linux sg v4 header]) ])
-
}
case "${host}" in
@@ -75,10 +78,12 @@ case "${host}" in
AC_DEFINE_UNQUOTED(SG_LIB_ANDROID, 1, [sg3_utils on android])
AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
check_for_linux_sg_v4_hdr
+ check_for_getrandom
check_for_linux_nvme_headers;;
*-*-freebsd*|*-*-kfreebsd*-gnu*)
AC_DEFINE_UNQUOTED(SG_LIB_FREEBSD, 1, [sg3_utils on FreeBSD])
AC_DEFINE_UNQUOTED(HAVE_NVME, 1, [Found NVMe])
+ check_for_getrandom
LIBS="$LIBS -lcam";;
*-*-solaris*)
AC_DEFINE_UNQUOTED(SG_LIB_SOLARIS, 1, [sg3_utils on Solaris]);;
@@ -88,16 +93,19 @@ case "${host}" in
AC_DEFINE_UNQUOTED(SG_LIB_WIN32, 1, [sg3_utils on Win32])
# AC_CHECK_HEADERS([nvme.h], [AC_DEFINE_UNQUOTED(HAVE_NVME, 1, [Found NVMe])], [], [])
AC_DEFINE_UNQUOTED(HAVE_NVME, 1, [Found NVMe])
+ check_for_getrandom
CFLAGS="$CFLAGS -Wno-char-subscripts";;
*-*-mingw*)
AC_DEFINE_UNQUOTED(SG_LIB_WIN32, 1, [sg3_utils on Win32])
AC_DEFINE_UNQUOTED(SG_LIB_MINGW, 1, [also MinGW environment])
# AC_CHECK_HEADERS([nvme.h], [AC_DEFINE_UNQUOTED(HAVE_NVME, 1, [Found NVMe])], [], [])
AC_DEFINE_UNQUOTED(HAVE_NVME, 1, [Found NVMe])
+ check_for_getrandom
CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO";;
*-*-linux-gnu* | *-*-linux* | *)
AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
check_for_linux_sg_v4_hdr
+ check_for_getrandom
check_for_linux_nvme_headers;;
esac
diff --git a/debian/changelog b/debian/changelog
index 40f57377..c2d3af15 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.46-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Sun, 21 Mar 2021 23:00:00 -0400
+ -- Douglas Gilbert <dgilbert@interlog.com> Fri, 26 Mar 2021 12:00:00 -0400
sg3-utils (1.45-0.1) unstable; urgency=low
diff --git a/doc/sg_inq.8 b/doc/sg_inq.8
index 13c41911..9c799ce9 100644
--- a/doc/sg_inq.8
+++ b/doc/sg_inq.8
@@ -1,4 +1,4 @@
-.TH SG_INQ "8" "August 2018" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_INQ "8" "March 2021" "sg3_utils\-1.46" SG3_UTILS
.SH NAME
sg_inq \- issue SCSI INQUIRY command and/or decode its response
.SH SYNOPSIS
@@ -508,7 +508,7 @@ Written by Douglas Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2001\-2018 Douglas Gilbert
+Copyright \(co 2001\-2021 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_vpd.8 b/doc/sg_vpd.8
index e167e7a2..c86311ac 100644
--- a/doc/sg_vpd.8
+++ b/doc/sg_vpd.8
@@ -1,4 +1,4 @@
-.TH SG_VPD "8" "April 2019" "sg3_utils\-1.45" SG3_UTILS
+.TH SG_VPD "8" "March 2021" "sg3_utils\-1.46" SG3_UTILS
.SH NAME
sg_vpd \- fetch SCSI VPD page and/or decode its response
.SH SYNOPSIS
@@ -321,7 +321,7 @@ Written by Douglas Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2006\-2019 Douglas Gilbert
+Copyright \(co 2006\-2021 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/sg3_utils.spec b/sg3_utils.spec
index fb2501e4..3934b608 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -84,7 +84,7 @@ fi
%{_libdir}/*.la
%changelog
-* Sun Mar 21 2021 - dgilbert at interlog dot com
+* Fri Mar 26 2021 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.46
diff --git a/src/sg_dd.c b/src/sg_dd.c
index 7d9b0edf..be90b7a0 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -42,6 +42,7 @@
#include <signal.h>
#include <ctype.h>
#include <errno.h>
+#include <time.h>
#include <limits.h>
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
@@ -50,7 +51,6 @@
#include <sys/time.h>
#include <sys/file.h>
#include <sys/sysmacros.h>
-#include <sys/random.h> /* for getrandom() system call */
#ifndef major
#include <sys/types.h>
#endif
@@ -60,6 +60,9 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#ifdef HAVE_GETRANDOM
+#include <sys/random.h> /* for getrandom() system call */
+#endif
#include "sg_lib.h"
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
@@ -67,7 +70,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "6.24 20210321";
+static const char * version_str = "6.25 20210326";
#define ME "sg_dd: "
@@ -2104,13 +2107,21 @@ main(int argc, char * argv[])
ccp = "<0xff bytes>";
cc2p = "ff";
} else if (iflag.random) {
- ssize_t ssz;
ccp = "<random>";
cc2p = "random";
- ssz = getrandom(&seed, sizeof(seed), GRND_NONBLOCK);
- if (ssz < (ssize_t)sizeof(seed))
- pr2serr("getrandom() failed, ret=%d\n", (int)ssz);
+#ifdef HAVE_GETRANDOM
+ {
+ ssize_t ssz = getrandom(&seed, sizeof(seed), GRND_NONBLOCK);
+
+ if (ssz < (ssize_t)sizeof(seed)) {
+ pr2serr("getrandom() failed, ret=%d\n", (int)ssz);
+ seed = (long)time(NULL);
+ }
+ }
+#else
+ seed = (long)time(NULL); /* use seconds since epoch as proxy */
+#endif
if (verbose > 1)
pr2serr("seed=%ld\n", seed);
srand48_r(seed, &drand);
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 546d2a65..60fcfa39 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -1,5 +1,5 @@
/* A utility program originally written for the Linux OS SCSI subsystem.
- * Copyright (C) 2000-2020 D. Gilbert
+ * Copyright (C) 2000-2021 D. Gilbert
* 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
* the Free Software Foundation; either version 2, or (at your option)
@@ -51,7 +51,7 @@
#include "sg_pt_nvme.h"
#endif
-static const char * version_str = "2.08 20201114"; /* spc6r02 + 20-0114r2 */
+static const char * version_str = "2.09 20210226"; /* spc6r05 */
/* INQUIRY notes:
* It is recommended that the initial allocation length given to a
diff --git a/src/sg_vpd.c b/src/sg_vpd.c
index 69919dec..2d699c30 100644
--- a/src/sg_vpd.c
+++ b/src/sg_vpd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2020 Douglas Gilbert.
+ * Copyright (c) 2006-2021 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -40,7 +40,7 @@
*/
-static const char * version_str = "1.61 20201114"; /* spc6r02 + sbc4r22 */
+static const char * version_str = "1.62 20210326"; /* spc6r05 + sbc4r22 */
/* standard VPD pages, in ascending page number order */
#define VPD_SUPPORTED_VPDS 0x0