diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | config.h.in | 3 | ||||
-rwxr-xr-x | configure | 7 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | lib/sg_pt_freebsd.c | 7 | ||||
-rw-r--r-- | sg3_utils.spec | 2 | ||||
-rw-r--r-- | src/sg_dd.c | 13 | ||||
-rw-r--r-- | testing/sg_mrq_dd.cpp | 17 | ||||
-rw-r--r-- | testing/sgh_dd.cpp | 13 |
10 files changed, 60 insertions, 11 deletions
@@ -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 [20210903] [svn: r912] +Changelog for pre-release sg3_utils-1.47 [20210912] [svn: r913] - 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 @@ -16,8 +16,8 @@ Changelog for pre-release sg3_utils-1.47 [20210903] [svn: r912] - sg_vpd: fix do_hex type on some recent pages - sg_read_buffer: fix --length= problem - sg_dd, sgm_dd, sgp_dd: don't close negative file descriptors - - sg_dd: don't use srand48_r() and mrand48_r() as they are - GNU extensions. Use the non-reentrant versions instead + - sg_dd: srand48_r() and mrand48_r() are GNU libc specific, + put conditional in so non-reentrant version used otherwise - sg_xcopy: tweak CSCD identification descriptor - sg_get_elem_status: fix issue with '--maxlen=' option - add 2 depopulation revocation health attributes [sbc5r01] diff --git a/config.h.in b/config.h.in index ea454245..80117652 100644 --- a/config.h.in +++ b/config.h.in @@ -54,6 +54,9 @@ /* Define to 1 if you have the `pthread_kill' function. */ #undef HAVE_PTHREAD_KILL +/* Define to 1 if you have the `srand48_r' function. */ +#undef HAVE_SRAND48_R + /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H @@ -12863,6 +12863,13 @@ then : fi +ac_fn_c_check_func "$LINENO" "srand48_r" "ac_cv_func_srand48_r" +if test "x$ac_cv_func_srand48_r" = xyes +then : + printf "%s\n" "#define HAVE_SRAND48_R 1" >>confdefs.h + +fi + SAVED_LIBS=$LIBS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5 printf %s "checking for library containing pthread_create... " >&6; } diff --git a/configure.ac b/configure.ac index b00d167f..f928f43a 100644 --- a/configure.ac +++ b/configure.ac @@ -27,6 +27,7 @@ AC_CHECK_FUNCS(posix_memalign) AC_CHECK_FUNCS(gettimeofday) AC_CHECK_FUNCS(sysconf) AC_CHECK_FUNCS(lseek64) +AC_CHECK_FUNCS(srand48_r) SAVED_LIBS=$LIBS AC_SEARCH_LIBS([pthread_create], [pthread]) # AC_SEARCH_LIBS adds libraries at the start of $LIBS so remove $SAVED_LIBS diff --git a/debian/changelog b/debian/changelog index 58bc639d..acbc2ef4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,7 @@ sg3-utils (1.47-0.1) unstable; urgency=low * New upstream version - -- Douglas Gilbert <dgilbert@interlog.com> Mon, 30 Aug 2021 17:00:00 -0400 + -- Douglas Gilbert <dgilbert@interlog.com> Sun, 12 Sep 2021 14:00:00 -0400 sg3-utils (1.46-0.1) unstable; urgency=low diff --git a/lib/sg_pt_freebsd.c b/lib/sg_pt_freebsd.c index ad25e8ca..47eaf7c4 100644 --- a/lib/sg_pt_freebsd.c +++ b/lib/sg_pt_freebsd.c @@ -7,7 +7,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -/* sg_pt_freebsd version 1.45 20210731 */ +/* sg_pt_freebsd version 1.46 20210912 */ #include <stdio.h> #include <stdlib.h> @@ -318,9 +318,12 @@ scsi_pt_open_flags(const char * device_name, int oflags, int vb) case PROTO_ATAPI: case PROTO_SATAPM: case PROTO_SEMB: /* SATA Enclosure Management bridge */ - if (vb) + if (vb) { pr2ws("%s: ATA and derivative devices not supported\n", __func__); + if (vb > 2) + pr2ws(" ... FreeBSD doesn't have a SAT in its kernel\n"); + } ret = -EINVAL; break; #if __FreeBSD_version > 1200058 diff --git a/sg3_utils.spec b/sg3_utils.spec index 346d7e01..fd1b26ea 100644 --- a/sg3_utils.spec +++ b/sg3_utils.spec @@ -84,7 +84,7 @@ fi %{_libdir}/*.la %changelog -* Mon Aug 30 2021 - dgilbert at interlog dot com +* Sun Sep 12 2021 - dgilbert at interlog dot com - track t10 changes * sg3_utils-1.47 diff --git a/src/sg_dd.c b/src/sg_dd.c index 26a4b4db..7c7823b7 100644 --- a/src/sg_dd.c +++ b/src/sg_dd.c @@ -70,7 +70,7 @@ #include "sg_unaligned.h" #include "sg_pr2serr.h" -static const char * version_str = "6.28 20210816"; +static const char * version_str = "6.29 20210906"; #define ME "sg_dd: " @@ -176,6 +176,9 @@ static uint8_t * free_zeros_buff = NULL; static int read_long_blk_inc = READ_LONG_DEF_BLK_INC; static long seed; +#ifdef HAVE_SRAND48_R /* gcc extension. N.B. non-reentrant version slower */ +static struct drand48_data drand;/* opaque, used by srand48_r and mrand48_r */ +#endif static const char * proc_allow_dio = "/proc/scsi/sg/allow_dio"; @@ -2123,7 +2126,11 @@ main(int argc, char * argv[]) #endif if (verbose > 1) pr2serr("seed=%ld\n", seed); +#ifdef HAVE_SRAND48_R + srand48_r(seed, &drand); +#else srand48(seed); +#endif } else if (iflag.zero) { ccp = "<zero bytes>"; cc2p = "00"; @@ -2400,7 +2407,11 @@ main(int argc, char * argv[]) for (kk = 0; kk < blocks; ++kk, bp += blk_sz) { for (j = 0; j < blk_sz; j += jbump) { /* mrand48 takes uniformly from [-2^31, 2^31) */ +#ifdef HAVE_SRAND48_R + mrand48_r(&drand, &rn); +#else rn = mrand48(); +#endif *((uint32_t *)(bp + j)) = (uint32_t)rn; } } diff --git a/testing/sg_mrq_dd.cpp b/testing/sg_mrq_dd.cpp index 42613256..b554614a 100644 --- a/testing/sg_mrq_dd.cpp +++ b/testing/sg_mrq_dd.cpp @@ -30,7 +30,7 @@ * */ -static const char * version_str = "1.35 20210816"; +static const char * version_str = "1.36 20210906"; #define _XOPEN_SOURCE 600 #ifndef _GNU_SOURCE @@ -348,6 +348,9 @@ typedef struct request_element int out_local_partial; int in_resid_bytes; long seed; +#ifdef HAVE_SRAND48_R /* gcc extension. N.B. non-reentrant version slower */ + struct drand48_data drand;/* opaque, used by srand48_r and mrand48_r */ +#endif } Rq_elem; /* Additional parameters for sg_start_io() and sg_finish_io() */ @@ -1656,7 +1659,11 @@ read_write_thread(struct global_collection * clp, int thr_idx, int slice_idx, #endif if (vb > 1) pr2serr_lk("[%d] %s: seed=%ld\n", thr_idx, __func__, rep->seed); +#ifdef HAVE_SRAND48_R + srand48_r(rep->seed, &rep->drand); +#else srand48(rep->seed); +#endif } if (in_is_sg && inf.size()) { @@ -1895,8 +1902,12 @@ normal_in_rd(Rq_elem * rep, int64_t lba, int blocks, int d_boff) bp = rep->buffp + d_boff; for (k = 0; k < blocks; ++k, bp += clp->bs) { for (j = 0; j < clp->bs; j += jbump) { - /* mrand48 takes uniformly from [-2^31, 2^31) */ + /* mrand48 takes uniformly from [-2^31, 2^31) */ +#ifdef HAVE_SRAND48_R + mrand48_r(&rep->drand, &rn); +#else rn = mrand48(); +#endif *((uint32_t *)(bp + j)) = (uint32_t)rn; } } @@ -3385,6 +3396,8 @@ process_flags(const char * arg, struct flags_t * fp) fp->masync = true; else if (0 == strcmp(cp, "mmap")) ++fp->mmap; /* mmap > 1 stops munmap() being called */ + else if (0 == strcmp(cp, "nocreat")) + fp->nocreat = true; else if (0 == strcmp(cp, "nodur")) fp->no_dur = true; else if (0 == strcmp(cp, "no_dur")) diff --git a/testing/sgh_dd.cpp b/testing/sgh_dd.cpp index 483dfce2..bc98de43 100644 --- a/testing/sgh_dd.cpp +++ b/testing/sgh_dd.cpp @@ -36,7 +36,7 @@ * renamed [20181221] */ -static const char * version_str = "2.15 20210816"; +static const char * version_str = "2.16 20210906"; #define _XOPEN_SOURCE 600 #ifndef _GNU_SOURCE @@ -317,6 +317,9 @@ typedef struct request_element uint32_t in_mrq_q_blks; uint32_t out_mrq_q_blks; long seed; +#ifdef HAVE_SRAND48_R /* gcc extension. N.B. non-reentrant version slower */ + struct drand48_data drand;/* opaque, used by srand48_r and mrand48_r */ +#endif pthread_t mrq_abort_thread_id; Mrq_abort_info mai; } Rq_elem; @@ -1536,7 +1539,11 @@ read_write_thread(void * v_tip) #endif if (vb > 1) pr2serr_lk("thread=%d: seed=%ld\n", rep->id, rep->seed); +#ifdef HAVE_SRAND48_R + srand48_r(rep->seed, &rep->drand); +#else srand48(rep->seed); +#endif } if (clp->in_flags.same_fds || clp->out_flags.same_fds) ; @@ -1857,7 +1864,11 @@ normal_in_rd(Rq_elem * rep, int blocks) for (k = 0, bp = rep->buffp; k < blocks; ++k, bp += clp->bs) { for (j = 0; j < clp->bs; j += jbump) { /* mrand48 takes uniformly from [-2^31, 2^31) */ +#ifdef HAVE_SRAND48_R + mrand48_r(&rep->drand, &rn); +#else rn = mrand48(); +#endif *((uint32_t *)(bp + j)) = (uint32_t)rn; } } |