diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2021-08-16 21:08:44 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2021-08-16 21:08:44 +0000 |
commit | 5fbd329cbcb0078fc787467703a2581935405b7e (patch) | |
tree | 7a876c5b4c3deaa01e0747d3a78c83d0424dfe0b | |
parent | cbde70fafd0ab9353e79b708621adf73420fdded (diff) | |
download | sg3_utils-5fbd329cbcb0078fc787467703a2581935405b7e.tar.gz |
sg_dd: don't use srand48_r() and mrand48_r() as they are GNU extensions. Use the non-reentrant versions instead
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@909 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/sg_dd.8 | 4 | ||||
-rw-r--r-- | sg3_utils.spec | 2 | ||||
-rw-r--r-- | src/sg_dd.c | 7 | ||||
-rw-r--r-- | testing/sg_mrq_dd.cpp | 11 | ||||
-rw-r--r-- | testing/sgh_dd.cpp | 7 |
7 files changed, 18 insertions, 19 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 [20210804] [svn: r908] +Changelog for pre-release sg3_utils-1.47 [20210816] [svn: r909] - sg_rep_zones: add support for REPORT ZONE DOMAINS and REPORT REALMS in this utility - sg_raw: fix prints of NVMe NVM command names @@ -13,6 +13,8 @@ Changelog for pre-release sg3_utils-1.47 [20210804] [svn: r908] - 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 - several utilities: override '--maxlen=LEN' when LEN is < 16 (or 4), take default (or 4) instead - sg_lib: add sg_scsi_status_is_good(), diff --git a/debian/changelog b/debian/changelog index ccb66f63..69bbf786 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> Wed, 04 Aug 2021 11:00:00 -0400 + -- Douglas Gilbert <dgilbert@interlog.com> Mon, 16 Aug 2021 17:00:00 -0400 sg3-utils (1.46-0.1) unstable; urgency=low diff --git a/doc/sg_dd.8 b/doc/sg_dd.8 index 7d931b6d..23c3246e 100644 --- a/doc/sg_dd.8 +++ b/doc/sg_dd.8 @@ -1,4 +1,4 @@ -.TH SG_DD "8" "April 2021" "sg3_utils\-1.47" SG3_UTILS +.TH SG_DD "8" "August 2021" "sg3_utils\-1.47" SG3_UTILS .SH NAME sg_dd \- copy data to and from files and devices, especially SCSI devices @@ -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_r(3) is used to generate a +used to create a seed and thereadter 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 diff --git a/sg3_utils.spec b/sg3_utils.spec index 61b5a927..5e5dbc69 100644 --- a/sg3_utils.spec +++ b/sg3_utils.spec @@ -84,7 +84,7 @@ fi %{_libdir}/*.la %changelog -* Wed Aug 04 2021 - dgilbert at interlog dot com +* Mon Aug 16 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 4266972f..26a4b4db 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.27 20210601"; +static const char * version_str = "6.28 20210816"; #define ME "sg_dd: " @@ -176,7 +176,6 @@ static uint8_t * free_zeros_buff = NULL; static int read_long_blk_inc = READ_LONG_DEF_BLK_INC; static long seed; -static struct drand48_data drand;/* opaque, used by srand48_r and mrand48_r */ static const char * proc_allow_dio = "/proc/scsi/sg/allow_dio"; @@ -2124,7 +2123,7 @@ main(int argc, char * argv[]) #endif if (verbose > 1) pr2serr("seed=%ld\n", seed); - srand48_r(seed, &drand); + srand48(seed); } else if (iflag.zero) { ccp = "<zero bytes>"; cc2p = "00"; @@ -2401,7 +2400,7 @@ 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) */ - mrand48_r(&drand, &rn); + rn = mrand48(); *((uint32_t *)(bp + j)) = (uint32_t)rn; } } diff --git a/testing/sg_mrq_dd.cpp b/testing/sg_mrq_dd.cpp index 65dc27fe..42613256 100644 --- a/testing/sg_mrq_dd.cpp +++ b/testing/sg_mrq_dd.cpp @@ -30,7 +30,7 @@ * */ -static const char * version_str = "1.34 20210801"; +static const char * version_str = "1.35 20210816"; #define _XOPEN_SOURCE 600 #ifndef _GNU_SOURCE @@ -348,7 +348,6 @@ typedef struct request_element int out_local_partial; int in_resid_bytes; long seed; - struct drand48_data drand; /* opaque, used by srand48_r and mrand48_r */ } Rq_elem; /* Additional parameters for sg_start_io() and sg_finish_io() */ @@ -1506,8 +1505,8 @@ sig_listen_thread(struct global_collection * clp) raise(SIGINT); break; } - if (SIGUSR2 == sig_number) - break; + if (SIGUSR2 == sig_number) + break; if (shutting_down) break; } /* end of while loop */ @@ -1657,7 +1656,7 @@ 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); - srand48_r(rep->seed, &rep->drand); + srand48(rep->seed); } if (in_is_sg && inf.size()) { @@ -1897,7 +1896,7 @@ normal_in_rd(Rq_elem * rep, int64_t lba, int blocks, int 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_r(&rep->drand, &rn); + rn = mrand48(); *((uint32_t *)(bp + j)) = (uint32_t)rn; } } diff --git a/testing/sgh_dd.cpp b/testing/sgh_dd.cpp index c421eb93..483dfce2 100644 --- a/testing/sgh_dd.cpp +++ b/testing/sgh_dd.cpp @@ -36,7 +36,7 @@ * renamed [20181221] */ -static const char * version_str = "2.14 20210801"; +static const char * version_str = "2.15 20210816"; #define _XOPEN_SOURCE 600 #ifndef _GNU_SOURCE @@ -317,7 +317,6 @@ typedef struct request_element uint32_t in_mrq_q_blks; uint32_t out_mrq_q_blks; long seed; - struct drand48_data drand; /* opaque, used by srand48_r and mrand48_r */ pthread_t mrq_abort_thread_id; Mrq_abort_info mai; } Rq_elem; @@ -1537,7 +1536,7 @@ read_write_thread(void * v_tip) #endif if (vb > 1) pr2serr_lk("thread=%d: seed=%ld\n", rep->id, rep->seed); - srand48_r(rep->seed, &rep->drand); + srand48(rep->seed); } if (clp->in_flags.same_fds || clp->out_flags.same_fds) ; @@ -1858,7 +1857,7 @@ 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) */ - mrand48_r(&rep->drand, &rn); + rn = mrand48(); *((uint32_t *)(bp + j)) = (uint32_t)rn; } } |