summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1999-03-01 07:45:19 +0000
committerDavid Leonard <d@cvs.openbsd.org>1999-03-01 07:45:19 +0000
commitb49f418ba660f4a5e53a938510851a21454f0335 (patch)
tree774fcfaf0f1886a41b15811b93b092acb49baa0a /sbin
parenta77a300b0493552bdceff598f141c91679002dd7 (diff)
SIGINFO support
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck_ffs/extern.h3
-rw-r--r--sbin/fsck_ffs/fsck.h5
-rw-r--r--sbin/fsck_ffs/main.c6
-rw-r--r--sbin/fsck_ffs/pass1.c21
-rw-r--r--sbin/fsck_ffs/pass1b.c19
-rw-r--r--sbin/fsck_ffs/pass2.c33
-rw-r--r--sbin/fsck_ffs/pass3.c19
-rw-r--r--sbin/fsck_ffs/pass4.c19
-rw-r--r--sbin/fsck_ffs/pass5.c23
-rw-r--r--sbin/fsck_ffs/utilities.c40
10 files changed, 167 insertions, 21 deletions
diff --git a/sbin/fsck_ffs/extern.h b/sbin/fsck_ffs/extern.h
index 4c8bb497d90..cda19a371ba 100644
--- a/sbin/fsck_ffs/extern.h
+++ b/sbin/fsck_ffs/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.3 1996/10/20 08:36:31 tholo Exp $ */
+/* $OpenBSD: extern.h,v 1.4 1999/03/01 07:45:17 d Exp $ */
/* $NetBSD: extern.h,v 1.6 1996/09/27 22:45:12 christos Exp $ */
/*
@@ -73,3 +73,4 @@ struct dinode * getnextinode __P((ino_t));
void catch __P((int));
void catchquit __P((int));
void voidquit __P((int));
+void catchinfo __P((int));
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index 52a0f91a39d..1583fcd1905 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fsck.h,v 1.6 1997/10/06 20:22:32 deraadt Exp $ */
+/* $OpenBSD: fsck.h,v 1.7 1999/03/01 07:45:17 d Exp $ */
/* $NetBSD: fsck.h,v 1.13 1996/10/11 20:15:46 thorpej Exp $ */
/*
@@ -216,3 +216,6 @@ struct dinode *ginode __P((ino_t));
struct inoinfo *getinoinfo __P((ino_t));
void getblk __P((struct bufarea *, daddr_t, long));
ino_t allocino __P((ino_t, int));
+
+int (*info_fn)(char *, int);
+char *info_filesys;
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 7b8d060b8b0..597a442852e 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.14 1998/02/05 03:22:18 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.15 1999/03/01 07:45:17 d Exp $ */
/* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.14 1998/02/05 03:22:18 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.15 1999/03/01 07:45:17 d Exp $";
#endif
#endif /* not lint */
@@ -138,6 +138,7 @@ main(argc, argv)
(void)signal(SIGINT, catch);
if (preen)
(void)signal(SIGQUIT, catchquit);
+ (void)signal(SIGINFO, catchinfo);
if (argc)
while (argc-- > 0)
@@ -208,6 +209,7 @@ checkfilesys(filesys, mntpt, auxdata, child)
case -1:
return (0);
}
+ info_filesys = filesys;
/*
* 1: scan inodes tallying blocks used
*/
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index 181006e8b82..27faa9ee01a 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass1.c,v 1.6 1997/10/06 20:22:34 deraadt Exp $ */
+/* $OpenBSD: pass1.c,v 1.7 1999/03/01 07:45:17 d Exp $ */
/* $NetBSD: pass1.c,v 1.16 1996/09/27 22:45:15 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: pass1.c,v 1.6 1997/10/06 20:22:34 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: pass1.c,v 1.7 1999/03/01 07:45:17 d Exp $";
#endif
#endif /* not lint */
@@ -60,12 +60,23 @@ static daddr_t badblk;
static daddr_t dupblk;
static void checkinode __P((ino_t, struct inodesc *));
+static ino_t info_inumber;
+
+static int
+pass1_info(buf, buflen)
+ char * buf;
+ int buflen;
+{
+ return snprintf(buf, buflen, "phase 1, inode %d/%d",
+ info_inumber, sblock.fs_ipg * sblock.fs_ncg);
+}
+
void
pass1()
{
+ struct inodesc idesc;
ino_t inumber;
int c, i, cgd;
- struct inodesc idesc;
/*
* Set file system reserved blocks in used block map.
@@ -92,13 +103,17 @@ pass1()
inumber = 0;
n_files = n_blks = 0;
resetinodebuf();
+ info_inumber = 0;
+ info_fn = pass1_info;
for (c = 0; c < sblock.fs_ncg; c++) {
for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
+ info_inumber = inumber;
if (inumber < ROOTINO)
continue;
checkinode(inumber, &idesc);
}
}
+ info_fn = NULL;
freeinodebuf();
}
diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c
index 0624180bfdd..88d69f53a29 100644
--- a/sbin/fsck_ffs/pass1b.c
+++ b/sbin/fsck_ffs/pass1b.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass1b.c,v 1.3 1996/10/20 08:36:37 tholo Exp $ */
+/* $OpenBSD: pass1b.c,v 1.4 1999/03/01 07:45:18 d Exp $ */
/* $NetBSD: pass1b.c,v 1.10 1996/09/23 16:18:37 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: pass1b.c,v 1.3 1996/10/20 08:36:37 tholo Exp $";
+static char rcsid[] = "$OpenBSD: pass1b.c,v 1.4 1999/03/01 07:45:18 d Exp $";
#endif
#endif /* not lint */
@@ -47,6 +47,7 @@ static char rcsid[] = "$OpenBSD: pass1b.c,v 1.3 1996/10/20 08:36:37 tholo Exp $"
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
+#include <stdio.h>
#include <string.h>
#include "fsck.h"
#include "extern.h"
@@ -54,6 +55,17 @@ static char rcsid[] = "$OpenBSD: pass1b.c,v 1.3 1996/10/20 08:36:37 tholo Exp $"
static int pass1bcheck __P((struct inodesc *));
static struct dups *duphead;
+static ino_t info_inumber;
+
+static int
+pass1b_info(buf, buflen)
+ char * buf;
+ int buflen;
+{
+ return snprintf(buf, buflen, "phase 1b, inode %d/%d",
+ info_inumber, sblock.fs_ipg * sblock.fs_ncg);
+}
+
void
pass1b()
{
@@ -67,8 +79,10 @@ pass1b()
idesc.id_func = pass1bcheck;
duphead = duplist;
inumber = 0;
+ info_fn = pass1b_info;
for (c = 0; c < sblock.fs_ncg; c++) {
for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
+ info_inumber = inumber;
if (inumber < ROOTINO)
continue;
dp = ginode(inumber);
@@ -80,6 +94,7 @@ pass1b()
return;
}
}
+ info_fn = NULL;
}
static int
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index c687a30c4b0..de08a8c5fd3 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass2.c,v 1.6 1997/10/06 20:22:35 deraadt Exp $ */
+/* $OpenBSD: pass2.c,v 1.7 1999/03/01 07:45:18 d Exp $ */
/* $NetBSD: pass2.c,v 1.17 1996/09/27 22:45:15 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pass2.c 8.6 (Berkeley) 10/27/94";
#else
-static char rcsid[] = "$OpenBSD: pass2.c,v 1.6 1997/10/06 20:22:35 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: pass2.c,v 1.7 1999/03/01 07:45:18 d Exp $";
#endif
#endif /* not lint */
@@ -61,6 +61,27 @@ static char rcsid[] = "$OpenBSD: pass2.c,v 1.6 1997/10/06 20:22:35 deraadt Exp $
static int pass2check __P((struct inodesc *));
static int blksort __P((const void *, const void *));
+static int info_max;
+static int info_pos;
+
+static int
+pass2_info1(buf, buflen)
+ char *buf;
+ int buflen;
+{
+ return snprintf(buf, buflen, "phase 2, directory %d/%d",
+ info_pos, info_max);
+}
+
+static int
+pass2_info2(buf, buflen)
+ char *buf;
+ int buflen;
+{
+ return snprintf(buf, buflen, "phase 2, parent directory %d/%d",
+ info_pos, info_max);
+}
+
void
pass2()
{
@@ -131,8 +152,12 @@ pass2()
curino.id_type = DATA;
curino.id_func = pass2check;
inpend = &inpsort[inplast];
+ info_pos = 0;
+ info_max = inpend - inpsort;
+ info_fn = pass2_info1;
for (inpp = inpsort; inpp < inpend; inpp++) {
inp = *inpp;
+ info_pos ++;
if (inp->i_isize == 0)
continue;
if (inp->i_isize < MINDIRSIZE) {
@@ -168,8 +193,11 @@ pass2()
* Now that the parents of all directories have been found,
* make another pass to verify the value of `..'
*/
+ info_pos = 0;
+ info_fn = pass2_info2;
for (inpp = inpsort; inpp < inpend; inpp++) {
inp = *inpp;
+ info_pos++;
if (inp->i_parent == 0 || inp->i_isize == 0)
continue;
if (inp->i_dotdot == inp->i_parent ||
@@ -193,6 +221,7 @@ pass2()
inp->i_dotdot = inp->i_parent;
(void)changeino(inp->i_number, "..", inp->i_parent);
}
+ info_fn = NULL;
/*
* Mark all the directories that can be found from the root.
*/
diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c
index 2cfd61e9a00..2c7903649ae 100644
--- a/sbin/fsck_ffs/pass3.c
+++ b/sbin/fsck_ffs/pass3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass3.c,v 1.2 1996/06/23 14:30:32 deraadt Exp $ */
+/* $OpenBSD: pass3.c,v 1.3 1999/03/01 07:45:18 d Exp $ */
/* $NetBSD: pass3.c,v 1.8 1995/03/18 14:55:54 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: pass3.c,v 1.2 1996/06/23 14:30:32 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: pass3.c,v 1.3 1999/03/01 07:45:18 d Exp $";
#endif
#endif /* not lint */
@@ -46,9 +46,21 @@ static char rcsid[] = "$OpenBSD: pass3.c,v 1.2 1996/06/23 14:30:32 deraadt Exp $
#include <sys/time.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
+#include <stdio.h>
#include "fsck.h"
#include "extern.h"
+static int info_pos;
+
+static int
+pass3_info(buf, buflen)
+ char *buf;
+ int buflen;
+{
+ return snprintf(buf, buflen, "phase 3, directory %d/%d",
+ info_pos, inplast);
+}
+
void
pass3()
{
@@ -56,7 +68,9 @@ pass3()
ino_t orphan;
int loopcnt;
+ info_fn = pass3_info;
for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) {
+ info_pos++;
inp = *inpp;
if (inp->i_number == ROOTINO ||
!(inp->i_parent == 0 || statemap[inp->i_number] == DSTATE))
@@ -77,4 +91,5 @@ pass3()
statemap[orphan] = DFOUND;
propagate();
}
+ info_fn = NULL;
}
diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c
index 4c931c7f143..7111d0ad59b 100644
--- a/sbin/fsck_ffs/pass4.c
+++ b/sbin/fsck_ffs/pass4.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass4.c,v 1.3 1996/10/20 08:36:39 tholo Exp $ */
+/* $OpenBSD: pass4.c,v 1.4 1999/03/01 07:45:18 d Exp $ */
/* $NetBSD: pass4.c,v 1.11 1996/09/27 22:45:17 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: pass4.c,v 1.3 1996/10/20 08:36:39 tholo Exp $";
+static char rcsid[] = "$OpenBSD: pass4.c,v 1.4 1999/03/01 07:45:18 d Exp $";
#endif
#endif /* not lint */
@@ -46,6 +46,7 @@ static char rcsid[] = "$OpenBSD: pass4.c,v 1.3 1996/10/20 08:36:39 tholo Exp $";
#include <sys/time.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -53,6 +54,17 @@ static char rcsid[] = "$OpenBSD: pass4.c,v 1.3 1996/10/20 08:36:39 tholo Exp $";
#include "fsck.h"
#include "extern.h"
+static ino_t info_inumber;
+
+static int
+pass4_info(buf, buflen)
+ char * buf;
+ int buflen;
+{
+ return snprintf(buf, buflen, "phase 4, inode %d/%d",
+ info_inumber, lastino);
+}
+
void
pass4()
{
@@ -65,7 +77,9 @@ pass4()
memset(&idesc, 0, sizeof(struct inodesc));
idesc.id_type = ADDR;
idesc.id_func = pass4check;
+ info_fn = pass4_info;
for (inumber = ROOTINO; inumber <= lastino; inumber++) {
+ info_inumber = inumber;
idesc.id_number = inumber;
switch (statemap[inumber]) {
@@ -110,6 +124,7 @@ pass4()
statemap[inumber], inumber);
}
}
+ info_fn = NULL;
}
int
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
index dbfbe4a9f6d..08b510c2d6b 100644
--- a/sbin/fsck_ffs/pass5.c
+++ b/sbin/fsck_ffs/pass5.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass5.c,v 1.6 1997/11/09 19:53:17 millert Exp $ */
+/* $OpenBSD: pass5.c,v 1.7 1999/03/01 07:45:18 d Exp $ */
/* $NetBSD: pass5.c,v 1.16 1996/09/27 22:45:18 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pass5.c 8.6 (Berkeley) 11/30/94";
#else
-static char rcsid[] = "$OpenBSD: pass5.c,v 1.6 1997/11/09 19:53:17 millert Exp $";
+static char rcsid[] = "$OpenBSD: pass5.c,v 1.7 1999/03/01 07:45:18 d Exp $";
#endif
#endif /* not lint */
@@ -46,16 +46,28 @@ static char rcsid[] = "$OpenBSD: pass5.c,v 1.6 1997/11/09 19:53:17 millert Exp $
#include <sys/time.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
+#include <stdio.h>
#include <string.h>
#include "fsutil.h"
#include "fsck.h"
#include "extern.h"
+static int info_cg;
+static int info_maxcg;
+
+static int
+pass5_info(buf, buflen)
+ char *buf;
+ int buflen;
+{
+ return snprintf(buf, buflen, "phase 5, cg %d/%d", info_cg, info_maxcg);
+}
+
void
pass5()
{
- int c, blk, frags, basesize, sumsize, mapsize, savednrpos;
+ int c, blk, frags, basesize, sumsize, mapsize, savednrpos=0;
register struct fs *fs = &sblock;
register struct cg *cg = &cgrp;
daddr_t dbase, dmax;
@@ -167,7 +179,11 @@ pass5()
j = blknum(fs, fs->fs_size + fs->fs_frag - 1);
for (i = fs->fs_size; i < j; i++)
setbmap(i);
+ info_cg = 0;
+ info_maxcg = fs->fs_ncg;
+ info_fn = pass5_info;
for (c = 0; c < fs->fs_ncg; c++) {
+ info_cg = c;
getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
if (!cg_chkmagic(cg))
pfatal("CG %d: BAD MAGIC NUMBER\n", c);
@@ -321,6 +337,7 @@ pass5()
cgdirty();
}
}
+ info_fn = NULL;
if (fs->fs_postblformat == FS_42POSTBLFMT)
fs->fs_nrpos = savednrpos;
if (memcmp(&cstotal, &fs->fs_cstotal, sizeof *cs) != 0
diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c
index 643ac2a1c65..ac235020145 100644
--- a/sbin/fsck_ffs/utilities.c
+++ b/sbin/fsck_ffs/utilities.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utilities.c,v 1.6 1997/10/06 20:22:37 deraadt Exp $ */
+/* $OpenBSD: utilities.c,v 1.7 1999/03/01 07:45:18 d Exp $ */
/* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */
/*
@@ -38,12 +38,14 @@
#if 0
static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: utilities.c,v 1.6 1997/10/06 20:22:37 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: utilities.c,v 1.7 1999/03/01 07:45:18 d Exp $";
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/uio.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
#include <ufs/ffs/fs.h>
@@ -52,6 +54,8 @@ static char rcsid[] = "$OpenBSD: utilities.c,v 1.6 1997/10/06 20:22:37 deraadt E
#include <string.h>
#include <ctype.h>
#include <unistd.h>
+#include <fcntl.h>
+#include <paths.h>
#include "fsutil.h"
#include "fsck.h"
@@ -490,7 +494,7 @@ void
catchquit(n)
int n;
{
- extern returntosingle;
+ extern int returntosingle;
printf("returning to single-user after filesystem check\n");
returntosingle = 1;
@@ -551,3 +555,33 @@ dofix(idesc, msg)
}
/* NOTREACHED */
}
+
+int (* info_fn)(char *, int) = NULL;
+char *info_filesys = "?";
+
+void
+catchinfo(n)
+ int n;
+{
+ char buf[1024];
+ struct iovec iov[4];
+ int fd;
+
+ if (info_fn != NULL && info_fn(buf, sizeof buf)) {
+ fd = open(_PATH_TTY, O_WRONLY);
+ if (fd >= 0) {
+ iov[0].iov_base = info_filesys;
+ iov[0].iov_len = strlen(info_filesys);
+ iov[1].iov_base = ": ";
+ iov[1].iov_len = sizeof ": " - 1;
+ iov[2].iov_base = buf;
+ iov[2].iov_len = strlen(buf);
+ iov[3].iov_base = "\n";
+ iov[3].iov_len = sizeof "\n" - 1;
+
+ writev(fd, iov, 4);
+ close(fd);
+ }
+ }
+}
+