Subject: ^T for fsck
To: None <tech-userlevel@netbsd.org>
From: Assar Westerlund <assar@netbsd.org>
List: tech-userlevel
Date: 03/04/2001 03:02:22
--=-=-=

I find these patches to fsck_ffs useful for us impatient persons.
Comments?

/assar


--=-=-=
Content-Disposition: attachment; filename=fsck_ffs.siginfo

Index: extern.h
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/extern.h,v
retrieving revision 1.13
diff -u -w -r1.13 extern.h
--- extern.h	2001/02/04 21:25:54	1.13
+++ extern.h	2001/03/04 01:58:08
@@ -79,3 +79,4 @@
 
 void	swap_cg __P((struct cg *, struct cg *));
 void copyback_cg __P((struct bufarea *));
+void		infohandler __P((int));
Index: fsck.h
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/fsck.h,v
retrieving revision 1.24
diff -u -w -r1.24 fsck.h
--- fsck.h	2001/02/04 21:25:54	1.24
+++ fsck.h	2001/03/04 01:58:08
@@ -216,6 +216,8 @@
 ufs_daddr_t n_blks;		/* number of blocks in use */
 ufs_daddr_t n_files;		/* number of files in use */
 
+sig_atomic_t	got_siginfo;	/* received a SIGINFO */
+
 #define	clearinode(dp)	(*(dp) = zino)
 struct	dinode zino;
 
Index: main.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/main.c,v
retrieving revision 1.39
diff -u -w -r1.39 main.c
--- main.c	2001/02/23 07:51:41	1.39
+++ main.c	2001/03/04 01:58:08
@@ -161,6 +161,7 @@
 		(void)signal(SIGINT, catch);
 	if (preen)
 		(void)signal(SIGQUIT, catchquit);
+	signal(SIGINFO, infohandler);
 
 	while (argc-- > 0)
 		(void)checkfilesys(blockcheck(*argv++), 0, 0L, 0);
Index: pass1.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/pass1.c,v
retrieving revision 1.23
diff -u -w -r1.23 pass1.c
--- pass1.c	2001/01/05 02:02:57	1.23
+++ pass1.c	2001/03/04 01:58:08
@@ -95,6 +95,12 @@
 	n_files = n_blks = 0;
 	resetinodebuf();
 	for (c = 0; c < sblock->fs_ncg; c++) {
+		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;
+		}
 		for (i = 0; i < sblock->fs_ipg; i++, inumber++) {
 			if (inumber < ROOTINO)
 				continue;
Index: pass1b.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/pass1b.c,v
retrieving revision 1.13
diff -u -w -r1.13 pass1b.c
--- pass1b.c	1998/03/18 17:01:24	1.13
+++ pass1b.c	2001/03/04 01:58:08
@@ -52,6 +52,7 @@
 
 #include "fsck.h"
 #include "extern.h"
+#include "fsutil.h"
 
 static  struct dups *duphead;
 static int pass1bcheck __P((struct inodesc *));
@@ -70,6 +71,12 @@
 	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;
Index: pass2.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/pass2.c,v
retrieving revision 1.29
diff -u -w -r1.29 pass2.c
--- pass2.c	2001/01/09 05:51:14	1.29
+++ pass2.c	2001/03/04 01:58:08
@@ -142,6 +142,13 @@
 	curino.id_func = pass2check;
 	inpend = &inpsort[inplast];
 	for (inpp = inpsort; inpp < inpend; inpp++) {
+		if (got_siginfo) {
+			printf("%s: phase 2: dir %d of %ld (%ld%%)\n",
+			       cdevname(),
+			       inpp - inpsort, inplast,
+			       (inpp - inpsort) * 100 / inplast);
+			got_siginfo = 0;
+		}
 		inp = *inpp;
 		if (inp->i_isize == 0)
 			continue;
Index: pass3.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/pass3.c,v
retrieving revision 1.12
diff -u -w -r1.12 pass3.c
--- pass3.c	2001/01/10 08:22:20	1.12
+++ pass3.c	2001/03/04 01:58:08
@@ -50,16 +50,24 @@
 
 #include "fsck.h"
 #include "extern.h"
+#include "fsutil.h"
 
 void
 pass3()
 {
-	struct inoinfo **inpp, *inp;
+	struct inoinfo*inp;
 	ino_t orphan;
-	int loopcnt;
+	int loopcnt, inpindex;
 
-	for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) {
-		inp = *inpp;
+	for (inpindex = inplast - 1; inpindex >= 0; inpindex--) {
+		if (got_siginfo) {
+			printf("%s: phase 3: dir %ld of %ld (%ld%%)\n",
+			       cdevname(),
+			       inplast - inpindex - 1, inplast,
+			       (inplast - inpindex - 1) * 100 / inplast);
+			got_siginfo = 0;
+		}
+		inp = inpsort[inpindex];
 		if (inp->i_number == ROOTINO ||
 		    !(inp->i_parent == 0 || statemap[inp->i_number] == DSTATE))
 			continue;
Index: pass4.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/pass4.c,v
retrieving revision 1.14
diff -u -w -r1.14 pass4.c
--- pass4.c	1997/09/20 06:16:32	1.14
+++ pass4.c	2001/03/04 01:58:08
@@ -69,6 +69,13 @@
 	idesc.id_type = ADDR;
 	idesc.id_func = pass4check;
 	for (inumber = ROOTINO; inumber <= lastino; inumber++) {
+		if (got_siginfo) {
+			printf("%s: phase 4: inode %u of %u (%u%%)\n",
+			       cdevname(), inumber, lastino,
+			       inumber * 100 / lastino);
+			got_siginfo = 0;
+		}
+
 		idesc.id_number = inumber;
 		switch (statemap[inumber]) {
 
Index: pass5.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/pass5.c,v
retrieving revision 1.26
diff -u -w -r1.26 pass5.c
--- pass5.c	2001/01/26 17:37:16	1.26
+++ pass5.c	2001/03/04 01:58:08
@@ -185,6 +185,12 @@
 	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, fs->fs_ncg,
+			       c * 100 / fs->fs_ncg);
+			got_siginfo = 0;
+		}
 		getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
 		memcpy(cg, cgblk.b_un.b_cg, fs->fs_cgsize);
 		if((doswap && !needswap) || (!doswap && needswap))
Index: utilities.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/fsck_ffs/utilities.c,v
retrieving revision 1.30
diff -u -w -r1.30 utilities.c
--- utilities.c	2001/02/04 21:25:54	1.30
+++ utilities.c	2001/03/04 01:58:08
@@ -694,3 +694,10 @@
 			n32[i] = bswap32(o32[i]);
 	}
 }
+
+void
+infohandler(sig)
+	int sig;
+{
+	got_siginfo = 1;
+}

--=-=-=--