aboutsummaryrefslogtreecommitdiff
path: root/src/sgp_dd.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-02-19 05:55:24 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-02-19 05:55:24 +0000
commit39ea1b548f21c006c311ace897b221b100bfa88d (patch)
tree764ecee434b161b62c41182a6bc09ce950b85258 /src/sgp_dd.c
parent5bdce507b09d32f452a390c22cb98ae7f840c151 (diff)
downloadsg3_utils-39ea1b548f21c006c311ace897b221b100bfa88d.tar.gz
sg_raw: add --raw option (for CF in binary); sg_lib: add sg_get_nvme_opcode_name() and sg_is_aligned(); sg_vpd: fully implement Device Constituents vpage
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@753 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src/sgp_dd.c')
-rw-r--r--src/sgp_dd.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index ecc853e5..e919dbf2 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -60,7 +60,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "5.60 20180102";
+static const char * version_str = "5.61 20180217";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -520,7 +520,6 @@ read_write_thread(void * v_clp)
Rq_coll * clp;
Rq_elem rel;
Rq_elem * rep = &rel;
- size_t psz = 0;
int sz;
volatile bool stop_after_write = false;
int64_t seek_skip;
@@ -530,16 +529,11 @@ read_write_thread(void * v_clp)
sz = clp->bpt * clp->bs;
seek_skip = clp->seek - clp->skip;
memset(rep, 0, sizeof(Rq_elem));
-#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
- psz = sysconf(_SC_PAGESIZE); /* POSIX.1 (was getpagesize()) */
-#else
- psz = 4096; /* give up, pick likely figure */
-#endif
- if (NULL == (rep->alloc_bp = (unsigned char *)malloc(sz + psz)))
+ rep->buffp = sg_memalign(sz, 0 /* page align */, &rep->alloc_bp, false);
+ if (NULL == rep->buffp)
err_exit(ENOMEM, "out of memory creating user buffers\n");
- rep->buffp = (unsigned char *)(((sg_uintptr_t)rep->alloc_bp + psz - 1) &
- (~(psz - 1)));
- /* Follow clp members are constant during lifetime of thread */
+
+ /* Following clp members are constant during lifetime of thread */
rep->bs = clp->bs;
rep->infd = clp->infd;
rep->outfd = clp->outfd;
@@ -630,7 +624,8 @@ read_write_thread(void * v_clp)
break;
pthread_cond_broadcast(&clp->out_sync_cv);
} /* end of while loop */
- if (rep->alloc_bp) free(rep->alloc_bp);
+ if (rep->alloc_bp)
+ free(rep->alloc_bp);
status = pthread_mutex_lock(&clp->in_mutex);
if (0 != status) err_exit(status, "lock in_mutex");
if (! clp->in_stop)