In the case of a background fsck, periodically update the process title

with a progress update.
This commit is contained in:
scottl 2004-02-28 07:50:42 +00:00
parent f9390aef0d
commit d9a0004b62
9 changed files with 47 additions and 0 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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 ||

View File

@ -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)

View File

@ -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);

View File

@ -117,3 +117,9 @@ infohandler(int sig __unused)
{
got_siginfo = 1;
}
void
alarmhandler(int sig __unused)
{
got_sigalarm = 1;
}