summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2014-11-18 14:35:21 +0100
committerKarel Zak2014-11-18 14:35:21 +0100
commit700031ade7cbcdcecf1205f98f50ed0da57c7493 (patch)
tree4ff850a1015129cb448577dd1c4d9ca461cbb041 /sys-utils
parentuuidd: Fixed a typo in daemon logging message (diff)
downloadkernel-qcow2-util-linux-700031ade7cbcdcecf1205f98f50ed0da57c7493.tar.gz
kernel-qcow2-util-linux-700031ade7cbcdcecf1205f98f50ed0da57c7493.tar.xz
kernel-qcow2-util-linux-700031ade7cbcdcecf1205f98f50ed0da57c7493.zip
misc: use monotonic time rater than gettimeofday
Based on patch Alexander Samilovskih <alexsamilovskih@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/blkdiscard.c7
-rw-r--r--sys-utils/eject.c5
2 files changed, 7 insertions, 5 deletions
diff --git a/sys-utils/blkdiscard.c b/sys-utils/blkdiscard.c
index 92ca52ae4..094f4e2ff 100644
--- a/sys-utils/blkdiscard.c
+++ b/sys-utils/blkdiscard.c
@@ -42,6 +42,7 @@
#include "strutils.h"
#include "c.h"
#include "closestream.h"
+#include "timeutils.h"
#ifndef BLKDISCARD
#define BLKDISCARD _IO(0x12,119)
@@ -80,7 +81,7 @@ int main(int argc, char **argv)
int c, fd, verbose = 0, secure = 0, secsize;
uint64_t end, blksize, step, range[2], stats[2];
struct stat sb;
- struct timespec now, last;
+ struct timeval now, last;
static const struct option longopts[] = {
{ "help", 0, 0, 'h' },
@@ -178,7 +179,7 @@ int main(int argc, char **argv)
"to sector size %i"), path, range[1], secsize);
stats[0] = range[0], stats[1] = 0;
- clock_gettime(CLOCK_MONOTONIC, &last);
+ gettime_monotonic(&last);
for (range[0] = range[0]; range[0] < end; range[0] += range[1]) {
if (range[0] + range[1] > end)
@@ -194,7 +195,7 @@ int main(int argc, char **argv)
/* reporting progress */
if (verbose && step) {
- clock_gettime(CLOCK_MONOTONIC, &now);
+ gettime_monotonic(&now);
if (last.tv_sec < now.tv_sec) {
print_stats(path, stats);
stats[0] = range[0], stats[1] = 0;
diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index 860610f5a..5a181644d 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -52,6 +52,7 @@
#include "xalloc.h"
#include "pathnames.h"
#include "sysfs.h"
+#include "timeutils.h"
/*
* sg_io_hdr_t driver_status -- see kernel include/scsi/scsi.h
@@ -462,7 +463,7 @@ static void toggle_tray(int fd)
* needed. In my experience the function needs less than 0.05
* seconds if the tray was already open, and at least 1.5 seconds
* if it was closed. */
- gettimeofday(&time_start, NULL);
+ gettime_monotonic(&time_start);
/* Send the CDROMEJECT command to the device. */
if (!eject_cdrom(fd))
@@ -470,7 +471,7 @@ static void toggle_tray(int fd)
/* Get the second timestamp, to measure the time needed to open
* the tray. */
- gettimeofday(&time_stop, NULL);
+ gettime_monotonic(&time_stop);
time_elapsed = (time_stop.tv_sec * 1000000 + time_stop.tv_usec) -
(time_start.tv_sec * 1000000 + time_start.tv_usec);