Subject: SIGINFO in quotacheck [Re: RFC: progressbars for fsck_ffs]
To: None <tech-userlevel@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-userlevel
Date: 12/07/2002 17:45:13
--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, Dec 07, 2002 at 12:00:03PM +1100, Luke Mewburn wrote:
> SIGINFO already works;  I often hit ^T during the long fsck at boot
> after a crash to find out how far through fsck_ffs is...

BTW, this would also be usefull in quotacheck.
Does anyone see a problem with the attached patch ?
Thomas, please look at the man page changes :)

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 23 ans d'experience feront toujours la difference
--

--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

? .gdbinit
? quotacheck
? quotacheck.cat8
Index: quotacheck.8
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/quotacheck/quotacheck.8,v
retrieving revision 1.9
diff -u -r1.9 quotacheck.8
--- quotacheck.8	2002/01/19 11:45:00	1.9
+++ quotacheck.8	2002/12/07 16:43:53
@@ -135,6 +135,18 @@
 checked should be quiescent while
 .Nm
 is running.
+.Pp    
+If
+.Nm     
+receives a
+.Dv SIGINFO
+signal 
+(see the
+.Sy status
+argument for
+.Xr stty 1 ) ,
+a line will be written to the standard error output indicating
+the name of the device currently being checked and progress information.
 .Sh FILES
 .Bl -tag -width quota.group -compact
 .It Pa quota.user
Index: quotacheck.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/quotacheck/quotacheck.c,v
retrieving revision 1.22
diff -u -r1.22 quotacheck.c
--- quotacheck.c	2001/08/17 02:18:49	1.22
+++ quotacheck.c	2002/12/07 16:43:53
@@ -114,6 +114,7 @@
 static int	fi;		/* open disk file descriptor */
 static u_long	highid[MAXQUOTAS];/* highest addid()'ed identifier per type */
 static int needswap;	/* FS is in swapped order */
+static int got_siginfo = 0; /* got a siginfo signal */
 
 
 int main __P((int, char *[]));
@@ -131,6 +132,7 @@
 static void resetinodebuf __P((void));
 static void freeinodebuf __P((void));
 static void bread __P((daddr_t, char *, long));
+static void infohandler __P((int sig));
 
 int
 main(argc, argv)
@@ -305,6 +307,7 @@
 			(void)printf("%s", qfextension[GRPQUOTA]);
 		(void)printf(" quotas for %s (%s)\n", fsname, mntpt);
 	}
+	signal(SIGINFO, infohandler);
 	sync();
 	dev_bsize = 1;
 	bread(SBOFF, (char *)&sblock, (long)SBSIZE);
@@ -321,6 +324,13 @@
 	resetinodebuf();
 	for (ino = 0, cg = 0; cg < sblock.fs_ncg; cg++) {
 		for (i = 0; i < sblock.fs_ipg; i++, ino++) {
+			if (got_siginfo) {
+				fprintf(stderr,
+				    "%s: cyl group %d of %d (%d%%)\n",
+				    fsname, cg, sblock.fs_ncg,
+				    cg * 100 / sblock.fs_ncg);
+				got_siginfo = 0;
+			}
 			if (ino < ROOTINO)
 				continue;
 			if ((dp = getnextinode(ino)) == NULL)
@@ -663,3 +673,10 @@
 	    read(fi, buf, cnt) != cnt)
 		err(1, "block %d", bno);
 }
+
+void    
+infohandler(int sig)
+{
+	got_siginfo = 1;
+} 
+

--2fHTh5uZTiUOsy+g--