From 6db798cae4e1313dd0ef9b2bcaceca5ee73c75fd Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Fri, 15 Dec 2000 14:23:55 +0000 Subject: [PATCH] Add a simple SIGINFO handler to fsck_ffs. Shortly after receipt of a SIGINFO (normally via Ctrl-T), a line will be output indicating the current phase number and progress information relevant to the current phase. Approved by: mckusick --- sbin/fsck_ffs/fsck.h | 3 +++ sbin/fsck_ffs/main.c | 1 + sbin/fsck_ffs/pass1.c | 6 ++++++ sbin/fsck_ffs/pass1b.c | 6 ++++++ sbin/fsck_ffs/pass2.c | 6 ++++++ sbin/fsck_ffs/pass3.c | 6 ++++++ sbin/fsck_ffs/pass4.c | 6 ++++++ sbin/fsck_ffs/pass5.c | 6 ++++++ sbin/fsck_ffs/utilities.c | 7 +++++++ 9 files changed, 47 insertions(+) diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index a0be2a44098d..73657678ef5f 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -223,6 +223,8 @@ int lfmode; /* lost & found directory creation mode */ ufs_daddr_t n_blks; /* number of blocks in use */ ufs_daddr_t n_files; /* number of files in use */ +int got_siginfo; /* received a SIGINFO */ + #define clearinode(dp) (*(dp) = zino) struct dinode zino; @@ -280,6 +282,7 @@ struct inoinfo *getinoinfo __P((ino_t inumber)); struct dinode *getnextinode __P((ino_t inumber)); void getpathname __P((char *namebuf, ino_t curdir, ino_t ino)); struct dinode *ginode __P((ino_t inumber)); +void infohandler __P((int sig)); void inocleanup __P((void)); void inodirty __P((void)); struct inostat *inoinfo __P((ino_t inum)); diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 1e8a5b47b698..7ee4ef0b4ca6 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -140,6 +140,7 @@ main(argc, argv) (void)signal(SIGINT, catch); if (preen) (void)signal(SIGQUIT, catchquit); + signal(SIGINFO, infohandler); /* * Push up our allowed memory limit so we can cope * with huge filesystems. diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index 1045a5f0520a..e6bd215ba952 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -93,6 +93,12 @@ pass1() inumber = c * sblock.fs_ipg; setinodebuf(inumber); inosused = sblock.fs_ipg; + if (got_siginfo) { + printf("%s: phase 1: cyl group %d of %d (%d%%)\n", + cdevname, c, sblock.fs_ncg, + c * 100 / sblock.fs_ncg); + got_siginfo = 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 7ef662f27364..9a37c1d5dc4c 100644 --- a/sbin/fsck_ffs/pass1b.c +++ b/sbin/fsck_ffs/pass1b.c @@ -65,6 +65,12 @@ pass1b() duphead = duplist; inumber = 0; for (c = 0; c < sblock.fs_ncg; c++) { + if (got_siginfo) { + printf("%s: phase 1b: cyl group %d of %d (%d%%)\n", + cdevname, c, sblock.fs_ncg, + 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 088ecffb9817..cbd5d9f5a64f 100644 --- a/sbin/fsck_ffs/pass2.c +++ b/sbin/fsck_ffs/pass2.c @@ -134,6 +134,12 @@ pass2() dp = &dino; inpend = &inpsort[inplast]; for (inpp = inpsort; inpp < inpend; inpp++) { + if (got_siginfo) { + printf("%s: phase 2: dir %d of %d (%d%%)\n", cdevname, + inpp - inpsort, inplast, (inpp - inpsort) * 100 / + inplast); + got_siginfo = 0; + } inp = *inpp; if (inp->i_isize == 0) continue; diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c index 80e38e9cbf4f..730af5ff4420 100644 --- a/sbin/fsck_ffs/pass3.c +++ b/sbin/fsck_ffs/pass3.c @@ -59,6 +59,12 @@ pass3() char namebuf[MAXNAMLEN+1]; for (inpindex = inplast - 1; inpindex >= 0; inpindex--) { + if (got_siginfo) { + printf("%s: phase 3: dir %d of %d (%d%%)\n", cdevname, + inplast - inpindex - 1, inplast, + (inplast - inpindex - 1) * 100 / inplast); + got_siginfo = 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 0012c50adc7e..9e9cea57b922 100644 --- a/sbin/fsck_ffs/pass4.c +++ b/sbin/fsck_ffs/pass4.c @@ -62,6 +62,12 @@ pass4() idesc.id_type = ADDR; idesc.id_func = pass4check; for (cg = 0; cg < sblock.fs_ncg; cg++) { + if (got_siginfo) { + printf("%s: phase 4: cyl group %d of %d (%d%%)\n", + cdevname, cg, sblock.fs_ncg, + cg * 100 / sblock.fs_ncg); + got_siginfo = 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 e39562579771..5da84b873836 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -169,6 +169,12 @@ pass5() for (i = fs->fs_size; i < j; i++) setbmap(i); for (c = 0; c < fs->fs_ncg; c++) { + if (got_siginfo) { + printf("%s: phase 5: cyl group %d of %d (%d%%)\n", + cdevname, c, sblock.fs_ncg, + c * 100 / sblock.fs_ncg); + got_siginfo = 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 c77f410470f2..aee31f017851 100644 --- a/sbin/fsck_ffs/utilities.c +++ b/sbin/fsck_ffs/utilities.c @@ -101,3 +101,10 @@ blockcheck(origname) */ return (origname); } + +void +infohandler(sig) + int sig; +{ + got_siginfo = 1; +}