summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorscottl <scottl@FreeBSD.org>2004-02-28 07:50:42 +0000
committerscottl <scottl@FreeBSD.org>2004-02-28 07:50:42 +0000
commitd9a0004b62fe76e69cb6f4ac21d673a03e1b97fe (patch)
tree54f005956185a8047740cf2432ee3919ed1ebc7c /sbin
parentf9390aef0d6f1aa5e2e8a5caaa474a78f16eda0f (diff)
downloadFreeBSD-src-d9a0004b62fe76e69cb6f4ac21d673a03e1b97fe.zip
FreeBSD-src-d9a0004b62fe76e69cb6f4ac21d673a03e1b97fe.tar.gz
In the case of a background fsck, periodically update the process title
with a progress update.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck_ffs/fsck.h2
-rw-r--r--sbin/fsck_ffs/main.c9
-rw-r--r--sbin/fsck_ffs/pass1.c5
-rw-r--r--sbin/fsck_ffs/pass1b.c5
-rw-r--r--sbin/fsck_ffs/pass2.c5
-rw-r--r--sbin/fsck_ffs/pass3.c5
-rw-r--r--sbin/fsck_ffs/pass4.c5
-rw-r--r--sbin/fsck_ffs/pass5.c5
-rw-r--r--sbin/fsck_ffs/utilities.c6
9 files changed, 47 insertions, 0 deletions
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index fb30c36..3f23154 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -258,6 +258,7 @@ ufs2_daddr_t n_blks; /* number of blocks in use */
ino_t n_files; /* number of files in use */
int got_siginfo; /* received a SIGINFO */
+int got_sigalarm; /* received a SIGALRM */
#define clearinode(dp) \
if (sblock.fs_magic == FS_UFS1_MAGIC) { \
@@ -324,6 +325,7 @@ union dinode *getnextinode(ino_t inumber);
void getpathname(char *namebuf, ino_t curdir, ino_t ino);
union dinode *ginode(ino_t inumber);
void infohandler(int sig);
+void alarmhandler(int sig);
void inocleanup(void);
void inodirty(void);
struct inostat *inoinfo(ino_t inum);
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 06b4540..1202b53 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -78,6 +78,7 @@ main(int argc, char *argv[])
{
int ch;
struct rlimit rlimit;
+ struct itimerval itimerval;
int ret = 0;
sync();
@@ -150,6 +151,14 @@ main(int argc, char *argv[])
if (preen)
(void)signal(SIGQUIT, catchquit);
signal(SIGINFO, infohandler);
+ if (bkgrdflag) {
+ signal(SIGALRM, alarmhandler);
+ itimerval.it_interval.tv_sec = 5;
+ itimerval.it_interval.tv_usec = 0;
+ itimerval.it_value.tv_sec = 5;
+ itimerval.it_value.tv_usec = 0;
+ setitimer(ITIMER_REAL, &itimerval, NULL);
+ }
/*
* Push up our allowed memory limit so we can cope
* with huge file systems.
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index 341d027..258aeee 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -107,6 +107,11 @@ pass1(void)
c * 100 / sblock.fs_ncg);
got_siginfo = 0;
}
+ if (got_sigalarm) {
+ setproctitle("%s p1 %d%%", cdevname,
+ c * 100 / sblock.fs_ncg);
+ got_sigalarm = 0;
+ }
/*
* If we are using soft updates, then we can trust the
* cylinder group inode allocation maps to tell us which
diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c
index d302952..21eaf69 100644
--- a/sbin/fsck_ffs/pass1b.c
+++ b/sbin/fsck_ffs/pass1b.c
@@ -71,6 +71,11 @@ pass1b(void)
c * 100 / sblock.fs_ncg);
got_siginfo = 0;
}
+ if (got_sigalarm) {
+ setproctitle("%s p1b %d%%", cdevname,
+ c * 100 / sblock.fs_ncg);
+ got_siginfo = 0;
+ }
for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
if (inumber < ROOTINO)
continue;
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index 470f986..9f9e01a 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -140,6 +140,11 @@ pass2(void)
(int)((inpp - inpsort) * 100 / inplast));
got_siginfo = 0;
}
+ if (got_sigalarm) {
+ setproctitle("%s p2 %d%%", cdevname,
+ (int)((inpp - inpsort) * 100 / inplast));
+ got_sigalarm = 0;
+ }
inp = *inpp;
if (inp->i_isize == 0)
continue;
diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c
index 0ae3267..925d880 100644
--- a/sbin/fsck_ffs/pass3.c
+++ b/sbin/fsck_ffs/pass3.c
@@ -65,6 +65,11 @@ pass3(void)
(int)((inplast - inpindex - 1) * 100 / inplast));
got_siginfo = 0;
}
+ if (got_sigalarm) {
+ setproctitle("%s p3 %d%%", cdevname,
+ (int)((inplast - inpindex - 1) * 100 / inplast));
+ got_sigalarm = 0;
+ }
inp = inpsort[inpindex];
state = inoinfo(inp->i_number)->ino_state;
if (inp->i_number == ROOTINO ||
diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c
index 847dd97..53132a6 100644
--- a/sbin/fsck_ffs/pass4.c
+++ b/sbin/fsck_ffs/pass4.c
@@ -68,6 +68,11 @@ pass4(void)
cg * 100 / sblock.fs_ncg);
got_siginfo = 0;
}
+ if (got_sigalarm) {
+ setproctitle("%s p4 %d%%", cdevname,
+ cg * 100 / sblock.fs_ncg);
+ got_sigalarm = 0;
+ }
inumber = cg * sblock.fs_ipg;
for (i = 0; i < inostathead[cg].il_numalloced; i++, inumber++) {
if (inumber < ROOTINO)
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
index 6dbde11..a2e7587 100644
--- a/sbin/fsck_ffs/pass5.c
+++ b/sbin/fsck_ffs/pass5.c
@@ -157,6 +157,11 @@ pass5(void)
c * 100 / sblock.fs_ncg);
got_siginfo = 0;
}
+ if (got_sigalarm) {
+ setproctitle("%s p5 %d%%\n", cdevname,
+ c * 100 / sblock.fs_ncg);
+ got_sigalarm = 0;
+ }
getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
if (!cg_chkmagic(cg))
pfatal("CG %d: BAD MAGIC NUMBER\n", c);
diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c
index 441fd93..e6c9f80 100644
--- a/sbin/fsck_ffs/utilities.c
+++ b/sbin/fsck_ffs/utilities.c
@@ -117,3 +117,9 @@ infohandler(int sig __unused)
{
got_siginfo = 1;
}
+
+void
+alarmhandler(int sig __unused)
+{
+ got_sigalarm = 1;
+}
OpenPOWER on IntegriCloud