From 2bb823d2b9013b29e374b2d6f57062c5a9886590 Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Sat, 16 Feb 2002 21:05:16 +0000 Subject: [PATCH] Supply progress information in dump's process title, which is useful for monitoring automated backups. This is based on a patch by Mikhail Teterin, with some changes to make its operation clearer and to update the proctitle more frequently. PR: bin/32138 --- sbin/dump/dump.h | 1 + sbin/dump/main.c | 8 ++++++++ sbin/dump/optr.c | 19 ++++++++++++------- sbin/dump/tape.c | 1 + 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h index d9bff13ed9b7..e3cc7c2cd925 100644 --- a/sbin/dump/dump.h +++ b/sbin/dump/dump.h @@ -83,6 +83,7 @@ int blockswritten; /* number of blocks written on current tape */ int tapeno; /* current tape number */ time_t tstart_writing; /* when started writing the first tape block */ time_t tend_writing; /* after writing the last tape block */ +int passno; /* current dump pass number */ struct fs *sblock; /* the file system super block */ char sblock_buf[MAXBSIZE]; long dev_bsize; /* block size of underlying disk device */ diff --git a/sbin/dump/main.c b/sbin/dump/main.c index 392fa7022e96..666b65f41b00 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -362,9 +362,13 @@ main(argc, argv) nonodump = spcl.c_level < honorlevel; + passno = 1; + setproctitle("%s: pass 1: regular files", disk); msg("mapping (Pass I) [regular files]\n"); anydirskipped = mapfiles(maxino, &tapesize); + passno = 2; + setproctitle("%s: pass 2: directories", disk); msg("mapping (Pass II) [directories]\n"); while (anydirskipped) { anydirskipped = mapdirs(maxino, &tapesize); @@ -427,6 +431,8 @@ main(argc, argv) (void)time((time_t *)&(tstart_writing)); dumpmap(usedinomap, TS_CLRI, maxino - 1); + passno = 3; + setproctitle("%s: pass 3: directories", disk); msg("dumping (Pass III) [directories]\n"); dirty = 0; /* XXX just to get gcc to shut up */ for (map = dumpdirmap, ino = 1; ino < maxino; ino++) { @@ -445,6 +451,8 @@ main(argc, argv) (void)dumpino(dp, ino); } + passno = 4; + setproctitle("%s: pass 4: regular files", disk); msg("dumping (Pass IV) [regular files]\n"); for (map = dumpinomap, ino = 1; ino < maxino; ino++) { int mode; diff --git a/sbin/dump/optr.c b/sbin/dump/optr.c index a35b550a903f..f13e7d683f72 100644 --- a/sbin/dump/optr.c +++ b/sbin/dump/optr.c @@ -193,20 +193,25 @@ time_t tschedule = 0; void timeest() { + double percent; time_t tnow; - int deltat; + int deltat, hours, mins; (void) time(&tnow); + deltat = (blockswritten == 0) ? 0 : tstart_writing - tnow + + (double)(tnow - tstart_writing) / blockswritten * tapesize; + percent = (blockswritten * 100.0) / tapesize; + hours = deltat / 3600; + mins = (deltat % 3600) / 60; + + setproctitle("%s: pass %d: %3.2f%% done, finished in %d:%02d", + disk, passno, percent, hours, mins); if (tnow >= tschedule) { tschedule = tnow + 300; if (blockswritten < 500) return; - deltat = tstart_writing - tnow + - (1.0 * (tnow - tstart_writing)) - / blockswritten * tapesize; - msg("%3.2f%% done, finished in %d:%02d\n", - (blockswritten * 100.0) / tapesize, - deltat / 3600, (deltat % 3600) / 60); + msg("%3.2f%% done, finished in %d:%02d\n", percent, hours, + mins); } } diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c index 25c97630f774..809756554bd9 100644 --- a/sbin/dump/tape.c +++ b/sbin/dump/tape.c @@ -527,6 +527,7 @@ startnewtape(top) /* * All signals are inherited... */ + setproctitle(NULL); /* Restore the proctitle. */ childpid = fork(); if (childpid < 0) { msg("Context save fork fails in parent %d\n", parentpid);