Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin share more code.
details: https://anonhg.NetBSD.org/src/rev/0c4d994badc7
branches: trunk
changeset: 765908:0c4d994badc7
user: christos <christos%NetBSD.org@localhost>
date: Thu Jun 09 19:57:50 2011 +0000
description:
share more code.
diffstat:
sbin/fsck/fsutil.c | 47 ++++++++++++++++++++++++++++++++++-
sbin/fsck/fsutil.h | 8 +++++-
sbin/fsck_ext2fs/extern.h | 5 +---
sbin/fsck_ext2fs/main.c | 5 ++-
sbin/fsck_ext2fs/utilities.c | 46 +---------------------------------
sbin/fsck_ffs/extern.h | 7 +---
sbin/fsck_ffs/main.c | 12 +++++---
sbin/fsck_ffs/pass1.c | 12 ++++----
sbin/fsck_ffs/pass2.c | 10 +++---
sbin/fsck_ffs/setup.c | 6 ++--
sbin/fsck_ffs/utilities.c | 57 ++++++-------------------------------------
sbin/fsck_lfs/extern.h | 5 +---
sbin/fsck_lfs/main.c | 3 +-
sbin/fsck_lfs/utilities.c | 40 +------------------------------
sbin/fsdb/fsdb.c | 5 +--
15 files changed, 96 insertions(+), 172 deletions(-)
diffs (truncated from 628 to 300 lines):
diff -r b1a37defae98 -r 0c4d994badc7 sbin/fsck/fsutil.c
--- a/sbin/fsck/fsutil.c Thu Jun 09 19:54:18 2011 +0000
+++ b/sbin/fsck/fsutil.c Thu Jun 09 19:57:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsutil.c,v 1.19 2010/02/04 23:55:42 christos Exp $ */
+/* $NetBSD: fsutil.c,v 1.20 2011/06/09 19:57:50 christos Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fsutil.c,v 1.19 2010/02/04 23:55:42 christos Exp $");
+__RCSID("$NetBSD: fsutil.c,v 1.20 2011/06/09 19:57:50 christos Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -42,6 +42,8 @@
#include <stdarg.h>
#include <errno.h>
#include <fstab.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <err.h>
#include <sys/types.h>
@@ -256,3 +258,44 @@
(void)snprintf(b, sizeof(b), "%lld ", (long long)t);
return b;
}
+
+
+void
+catch(int n)
+{
+ if (ckfinish) (*ckfinish)(0);
+ _exit(FSCK_EXIT_SIGNALLED);
+}
+
+/*
+ * When preening, allow a single quit to signal
+ * a special exit after filesystem checks complete
+ * so that reboot sequence may be interrupted.
+ */
+void
+catchquit(int n)
+{
+ static const char msg[] =
+ "returning to single-user after filesystem check\n";
+ int serrno = errno;
+
+ (void)write(STDOUT_FILENO, msg, sizeof(msg) - 1);
+ returntosingle = 1;
+ (void)signal(SIGQUIT, SIG_DFL);
+ errno = serrno;
+}
+
+/*
+ * Ignore a single quit signal; wait and flush just in case.
+ * Used by child processes in preen.
+ */
+void
+voidquit(int n)
+{
+ int serrno = errno;
+
+ sleep(1);
+ (void)signal(SIGQUIT, SIG_IGN);
+ (void)signal(SIGQUIT, SIG_DFL);
+ errno = serrno;
+}
diff -r b1a37defae98 -r 0c4d994badc7 sbin/fsck/fsutil.h
--- a/sbin/fsck/fsutil.h Thu Jun 09 19:54:18 2011 +0000
+++ b/sbin/fsck/fsutil.h Thu Jun 09 19:57:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsutil.h,v 1.15 2010/02/04 23:55:42 christos Exp $ */
+/* $NetBSD: fsutil.h,v 1.16 2011/06/09 19:57:50 christos Exp $ */
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
@@ -56,3 +56,9 @@
struct fstab;
int checkfstab(int, int, void *(*)(struct fstab *),
int (*) (const char *, const char *, const char *, void *, pid_t *));
+
+void (*ckfinish)(int);
+volatile sig_atomic_t returntosingle;
+void catch(int);
+void catchquit(int);
+void voidquit(int);
diff -r b1a37defae98 -r 0c4d994badc7 sbin/fsck_ext2fs/extern.h
--- a/sbin/fsck_ext2fs/extern.h Thu Jun 09 19:54:18 2011 +0000
+++ b/sbin/fsck_ext2fs/extern.h Thu Jun 09 19:57:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.6 2005/06/26 23:01:39 christos Exp $ */
+/* $NetBSD: extern.h,v 1.7 2011/06/09 19:57:50 christos Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@@ -71,6 +71,3 @@
void resetinodebuf(void);
int setup(const char *);
struct ext2fs_dinode * getnextinode(ino_t);
-void catch(int);
-void catchquit(int);
-void voidquit(int);
diff -r b1a37defae98 -r 0c4d994badc7 sbin/fsck_ext2fs/main.c
--- a/sbin/fsck_ext2fs/main.c Thu Jun 09 19:54:18 2011 +0000
+++ b/sbin/fsck_ext2fs/main.c Thu Jun 09 19:57:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.36 2010/01/07 01:39:56 christos Exp $ */
+/* $NetBSD: main.c,v 1.37 2011/06/09 19:57:51 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -63,7 +63,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
#else
-__RCSID("$NetBSD: main.c,v 1.36 2010/01/07 01:39:56 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.37 2011/06/09 19:57:51 christos Exp $");
#endif
#endif /* not lint */
@@ -100,6 +100,7 @@
int ch;
int ret = FSCK_EXIT_OK;
+ ckfinish = ckfini;
sync();
skipclean = 1;
while ((ch = getopt(argc, argv, "b:dfm:npPqUy")) != -1) {
diff -r b1a37defae98 -r 0c4d994badc7 sbin/fsck_ext2fs/utilities.c
--- a/sbin/fsck_ext2fs/utilities.c Thu Jun 09 19:54:18 2011 +0000
+++ b/sbin/fsck_ext2fs/utilities.c Thu Jun 09 19:57:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utilities.c,v 1.21 2010/01/07 01:39:56 christos Exp $ */
+/* $NetBSD: utilities.c,v 1.22 2011/06/09 19:57:51 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -58,7 +58,7 @@
#if 0
static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
#else
-__RCSID("$NetBSD: utilities.c,v 1.21 2010/01/07 01:39:56 christos Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.22 2011/06/09 19:57:51 christos Exp $");
#endif
#endif /* not lint */
@@ -85,8 +85,6 @@
static void rwerror(const char *, daddr_t);
-extern volatile sig_atomic_t returntosingle;
-
int
ftypeok(struct ext2fs_dinode *dp)
{
@@ -461,46 +459,6 @@
memcpy(namebuf, cp, (size_t)(&namebuf[MAXPATHLEN] - cp));
}
-void
-catch(int n)
-{
- ckfini(0);
- _exit(FSCK_EXIT_SIGNALLED);
-}
-
-/*
- * When preening, allow a single quit to signal
- * a special exit after filesystem checks complete
- * so that reboot sequence may be interrupted.
- */
-void
-catchquit(int n)
-{
- static const char msg[] =
- "returning to single-user after filesystem check\n";
- int serrno = errno;
-
- (void)write(STDOUT_FILENO, msg, sizeof(msg) - 1);
- returntosingle = 1;
- (void)signal(SIGQUIT, SIG_DFL);
- errno = serrno;
-}
-
-/*
- * Ignore a single quit signal; wait and flush just in case.
- * Used by child processes in preen.
- */
-void
-voidquit(int n)
-{
- int serrno = errno;
-
- sleep(1);
- (void)signal(SIGQUIT, SIG_IGN);
- (void)signal(SIGQUIT, SIG_DFL);
- errno = serrno;
-}
-
/*
* determine whether an inode should be fixed.
*/
diff -r b1a37defae98 -r 0c4d994badc7 sbin/fsck_ffs/extern.h
--- a/sbin/fsck_ffs/extern.h Thu Jun 09 19:54:18 2011 +0000
+++ b/sbin/fsck_ffs/extern.h Thu Jun 09 19:57:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.26 2011/03/06 17:08:16 bouyer Exp $ */
+/* $NetBSD: extern.h,v 1.27 2011/06/09 19:57:52 christos Exp $ */
/*
* Copyright (c) 1994 James A. Jegers
@@ -33,11 +33,9 @@
void bufinit(void);
void bwrite(int, char *, daddr_t, long);
void cacheino(union dinode *, ino_t);
-void catch(int);
-void catchquit(int);
int changeino(ino_t, const char *, ino_t);
int chkrange(daddr_t, int);
-void ckfini(void);
+void ckfini(int);
int ckinode(union dinode *, struct inodesc *);
int clearentry(struct inodesc *);
void clri(struct inodesc *, const char *, int);
@@ -81,7 +79,6 @@
int reply(const char *);
void setinodebuf(ino_t);
int setup(const char *, const char *);
-void voidquit(int);
ssize_t readblk(union dinode *, off_t, struct bufarea **);
struct bufarea *expandfile(union dinode *);
diff -r b1a37defae98 -r 0c4d994badc7 sbin/fsck_ffs/main.c
--- a/sbin/fsck_ffs/main.c Thu Jun 09 19:54:18 2011 +0000
+++ b/sbin/fsck_ffs/main.c Thu Jun 09 19:57:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.78 2011/03/06 17:08:16 bouyer Exp $ */
+/* $NetBSD: main.c,v 1.79 2011/06/09 19:57:52 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
#else
-__RCSID("$NetBSD: main.c,v 1.78 2011/03/06 17:08:16 bouyer Exp $");
+__RCSID("$NetBSD: main.c,v 1.79 2011/06/09 19:57:52 christos Exp $");
#endif
#endif /* not lint */
@@ -86,6 +86,8 @@
char *snap_backup = NULL;
int snap_internal = 0;
+ ckfinish = ckfini;
+
if (getrlimit(RLIMIT_DATA, &r) == 0) {
r.rlim_cur = r.rlim_max;
(void) setrlimit(RLIMIT_DATA, &r);
@@ -445,7 +447,7 @@
markclean = 0;
#if LITE2BORKEN
if (!hotroot()) {
- ckfini();
+ ckfini(1);
} else {
struct statvfs stfs_buf;
/*
@@ -457,10 +459,10 @@
flags = 0;
if (markclean)
markclean = flags & MNT_RDONLY;
- ckfini();
+ ckfini(1);
}
#else
- ckfini();
+ ckfini(1);
#endif
for (cylno = 0; cylno < sblock->fs_ncg; cylno++)
if (inostathead[cylno].il_stat != NULL)
diff -r b1a37defae98 -r 0c4d994badc7 sbin/fsck_ffs/pass1.c
--- a/sbin/fsck_ffs/pass1.c Thu Jun 09 19:54:18 2011 +0000
+++ b/sbin/fsck_ffs/pass1.c Thu Jun 09 19:57:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass1.c,v 1.47 2011/03/06 17:08:16 bouyer Exp $ */
+/* $NetBSD: pass1.c,v 1.48 2011/06/09 19:57:52 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: pass1.c,v 1.47 2011/03/06 17:08:16 bouyer Exp $");
Home |
Main Index |
Thread Index |
Old Index