coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] maint: avoid reading lots of data from /dev/urandom


From: Pádraig Brady
Subject: [PATCH] maint: avoid reading lots of data from /dev/urandom
Date: Mon, 23 Apr 2012 10:20:58 +0100

On Solaris 10 at least you need to use dd iflag=fullblock
to avoid short reads.  Also it's relatively slow when
you just want non NUL data as opposed to pseudo random data.

* cp/fiemap-empty: Convert /dev/zero rather than using /dev/urandom.
* dd/sparse: Likewise.
---
 tests/cp/fiemap-empty |    2 +-
 tests/dd/sparse       |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/cp/fiemap-empty b/tests/cp/fiemap-empty
index 4ba4ee3..81926f3 100755
--- a/tests/cp/fiemap-empty
+++ b/tests/cp/fiemap-empty
@@ -64,7 +64,7 @@ rm empty.big cp.test
 # Note until we support fallocate, we will not maintain
 # the file allocation.  FIXME: amend this test when fallocate is supported.
 fallocate -l 10MiB -n unwritten.withdata || framework_failure_
-dd count=10 if=/dev/urandom conv=notrunc iflag=fullblock of=unwritten.withdata
+dd count=10 if=/dev/zero | tr '\0' '1' | dd conv=notrunc of=unwritten.withdata
 cp unwritten.withdata cp.test || fail=1
 test $(stat -c %s unwritten.withdata) = $(stat -c %s cp.test) || fail=1
 cmp unwritten.withdata cp.test || fail=1
diff --git a/tests/dd/sparse b/tests/dd/sparse
index 35ddda9..f132924 100755
--- a/tests/dd/sparse
+++ b/tests/dd/sparse
@@ -45,8 +45,8 @@ cmp file.in file.out || fail=1
 # Setup for block size tests: create a 3MiB file with a 1MiB
 # stretch of NUL bytes in the middle.
 rm -f file.in
-dd if=/dev/urandom of=file.in bs=1M count=3 iflag=fullblock || fail=1
-dd if=/dev/zero    of=file.in bs=1M count=1 seek=1 conv=notrunc || fail=1
+dd if=/dev/zero bs=1M count=3 | tr '\0' '1' | dd of=file.in || fail=1
+dd if=/dev/zero of=file.in bs=1M count=1 seek=1 conv=notrunc || fail=1
 
 kb_alloc() { du -k "$1"|cut -f1; }
 
-- 
1.7.6.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]