summaryrefslogtreecommitdiffstats
path: root/bin/dd/misc.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2016-02-28 10:27:12 +0000
committertrasz <trasz@FreeBSD.org>2016-02-28 10:27:12 +0000
commit5050f4bc8348f5b3dce257e767153950360d4b3f (patch)
tree233da3f0cc2462266ddb07aecfa08135640ca7fa /bin/dd/misc.c
parentd887d37a7a4f3942aa978daad85a76d2f066923e (diff)
downloadFreeBSD-src-5050f4bc8348f5b3dce257e767153950360d4b3f.zip
FreeBSD-src-5050f4bc8348f5b3dce257e767153950360d4b3f.tar.gz
Add speed limit to dd(1). This is useful for testing RCTL disk io limits
(when they actually get committed, that is), and might also come in handy in other situations. Reviewed by: wblock@ (man page) MFC after: 1 month Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'bin/dd/misc.c')
-rw-r--r--bin/dd/misc.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/bin/dd/misc.c b/bin/dd/misc.c
index eb1227b..ea0f8d3 100644
--- a/bin/dd/misc.c
+++ b/bin/dd/misc.c
@@ -54,15 +54,12 @@ __FBSDID("$FreeBSD$");
#include "dd.h"
#include "extern.h"
-void
-summary(void)
+double
+secs_elapsed(void)
{
struct timespec end, ts_res;
double secs, res;
- if (ddflags & C_NOINFO)
- return;
-
if (clock_gettime(CLOCK_MONOTONIC, &end))
err(1, "clock_gettime");
if (clock_getres(CLOCK_MONOTONIC, &ts_res))
@@ -72,6 +69,20 @@ summary(void)
res = ts_res.tv_sec + ts_res.tv_nsec * 1e-9;
if (secs < res)
secs = res;
+
+ return (secs);
+}
+
+void
+summary(void)
+{
+ double secs;
+
+ if (ddflags & C_NOINFO)
+ return;
+
+ secs = secs_elapsed();
+
(void)fprintf(stderr,
"%ju+%ju records in\n%ju+%ju records out\n",
st.in_full, st.in_part, st.out_full, st.out_part);
OpenPOWER on IntegriCloud