summaryrefslogtreecommitdiffstats
path: root/disk-utils/fsck.c
diff options
context:
space:
mode:
authorKarel Zak2012-03-06 13:36:28 +0100
committerKarel Zak2012-03-20 11:22:09 +0100
commit0556def4cd12ad6407232022a37e7788743bd4fe (patch)
tree8ab9e2fdc23d6e5e0443063bbae8d057d3488c32 /disk-utils/fsck.c
parentfsck: Add a -r option to report memory and runtime statistics (diff)
downloadkernel-qcow2-util-linux-0556def4cd12ad6407232022a37e7788743bd4fe.tar.gz
kernel-qcow2-util-linux-0556def4cd12ad6407232022a37e7788743bd4fe.tar.xz
kernel-qcow2-util-linux-0556def4cd12ad6407232022a37e7788743bd4fe.zip
fsck: use gettimeofday() for real elapsed time statistic
and use shorter "rss" rather than "maxrss" keyword in stats output Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/fsck.c')
-rw-r--r--disk-utils/fsck.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index 040f6f8e0..ff16ebcf1 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -44,6 +44,7 @@
#include <signal.h>
#include <dirent.h>
#include <sys/resource.h>
+#include <sys/time.h>
#include <blkid.h>
#include <libmount.h>
@@ -102,8 +103,8 @@ struct fsck_instance {
int flags; /* FLAG_{DONE|PROGRESS} */
int lock; /* flock()ed whole disk file descriptor or -1 */
int exit_status;
- time_t start_time;
- time_t end_time;
+ struct timeval start_time;
+ struct timeval end_time;
char * prog;
char * type;
@@ -500,18 +501,20 @@ static int progress_active(void)
*/
static void print_stats(struct fsck_instance *inst)
{
- time_t time_diff;
+ double time_diff;
if (!inst || !report_stats || noexecute)
return;
- time_diff = inst->end_time - inst->start_time;
- fprintf(stdout, "%s: status %d, maxrss %ld, "
- "real %d, user %d.%06d, sys %d.%06d\n",
+ time_diff = (inst->end_time.tv_sec - inst->start_time.tv_sec)
+ + (inst->end_time.tv_usec - inst->start_time.tv_usec) / 1E6;
+
+ fprintf(stdout, "%s: status %d, rss %ld, "
+ "real %f, user %d.%06d, sys %d.%06d\n",
fs_get_device(inst->fs),
inst->exit_status,
inst->rusage.ru_maxrss,
- (int)time_diff,
+ time_diff,
(int)inst->rusage.ru_utime.tv_sec,
(int)inst->rusage.ru_utime.tv_usec,
(int)inst->rusage.ru_stime.tv_sec,
@@ -603,7 +606,7 @@ static int execute(const char *type, struct libmnt_fs *fs, int interactive)
inst->pid = pid;
inst->prog = xstrdup(prog);
inst->type = xstrdup(type);
- inst->start_time = time(0);
+ gettimeofday(&inst->start_time, NULL);
inst->next = NULL;
/*
@@ -716,7 +719,7 @@ static struct fsck_instance *wait_one(int flags)
inst->exit_status = status;
inst->flags |= FLAG_DONE;
- inst->end_time = time(0);
+ gettimeofday(&inst->end_time, NULL);
memcpy(&inst->rusage, &rusage, sizeof(struct rusage));
if (progress && (inst->flags & FLAG_PROGRESS) &&
@@ -734,7 +737,7 @@ static struct fsck_instance *wait_one(int flags)
* bit before sending the kill, to give it
* time to set up the signal handler
*/
- if (inst2->start_time < time(0)+2) {
+ if (inst2->start_time.tv_sec < time(0) + 2) {
if (fork() == 0) {
sleep(1);
kill(inst2->pid, SIGUSR1);