aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ifs/main.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1997-03-11 12:20:21 +0000
committerPeter Wemm <peter@FreeBSD.org>1997-03-11 12:20:21 +0000
commit780a5c1ec16f889d55914a09fbcde7ff7b2cfcca (patch)
tree1eaf4d253b6a6dc9330595ee6ef3e9b9aba85422 /sbin/fsck_ifs/main.c
parent82b49328cdd209c28fbd5b289ce1987f9d3f7c71 (diff)
Merge from Lite2. Note that Lite2 has it's own filesystem clean check
skipping code that overrides ours sooner. One should be eliminated, but for now it works.
Notes
Notes: svn path=/head/; revision=23675
Diffstat (limited to 'sbin/fsck_ifs/main.c')
-rw-r--r--sbin/fsck_ifs/main.c80
1 files changed, 50 insertions, 30 deletions
diff --git a/sbin/fsck_ifs/main.c b/sbin/fsck_ifs/main.c
index 363bba76ee78..b6588310ca11 100644
--- a/sbin/fsck_ifs/main.c
+++ b/sbin/fsck_ifs/main.c
@@ -38,25 +38,35 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
+static const char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/proc.h>
#include <sys/mount.h>
+
#include <ufs/ufs/dinode.h>
+#include <ufs/ufs/ufsmount.h>
#include <ufs/ffs/fs.h>
+
+#include <ctype.h>
+#include <err.h>
#include <fstab.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
+
#include "fsck.h"
-static int argtoi __P((int flag, char *req, char *str, int base));
-static int docheck __P((struct fstab *fsp));
-static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
- int child));
+
+int returntosingle;
+
+static int argtoi __P((int flag, char *req, char *str, int base));
+static int docheck __P((struct fstab *fsp));
+static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
+ int child));
+int main __P((int argc, char *argv[]));
int
main(argc, argv)
@@ -99,7 +109,7 @@ main(argc, argv)
case 'm':
lfmode = argtoi('m', "mode", optarg, 8);
if (lfmode &~ 07777)
- errexit("bad mode to -m: %o\n", lfmode);
+ errx(EEXIT, "bad mode to -m: %o", lfmode);
printf("** lost+found creation mode %o\n", lfmode);
break;
@@ -116,7 +126,7 @@ main(argc, argv)
break;
default:
- errexit("%c option?\n", ch);
+ errx(EEXIT, "%c option?", ch);
}
}
argc -= optind;
@@ -136,7 +146,7 @@ main(argc, argv)
exit(ret);
}
-int
+static int
argtoi(flag, req, str, base)
int flag;
char *req, *str;
@@ -147,14 +157,14 @@ argtoi(flag, req, str, base)
ret = (int)strtol(str, &cp, base);
if (cp == str || *cp)
- errexit("-%c flag requires a %s\n", flag, req);
+ errx(EEXIT, "-%c flag requires a %s", flag, req);
return (ret);
}
/*
* Determine whether a filesystem should be checked.
*/
-int
+static int
docheck(fsp)
register struct fstab *fsp;
{
@@ -171,25 +181,28 @@ docheck(fsp)
* Check the specified filesystem.
*/
/* ARGSUSED */
-int
+static int
checkfilesys(filesys, mntpt, auxdata, child)
char *filesys, *mntpt;
long auxdata;
int child;
{
- daddr_t n_ffree, n_bfree;
+ ufs_daddr_t n_ffree, n_bfree;
struct dups *dp;
struct zlncnt *zlnp;
- int cylno;
+ int cylno, flags;
if (preen && child)
(void)signal(SIGQUIT, voidquit);
cdevname = filesys;
if (debug && preen)
pwarn("starting\n");
- if (setup(filesys) == 0) {
+ switch (setup(filesys)) {
+ case 0:
if (preen)
pfatal("CAN'T CHECK FILE SYSTEM.");
+ /* fall through */
+ case -1:
return (0);
}
@@ -302,7 +315,19 @@ checkfilesys(filesys, mntpt, auxdata, child)
bwrite(fswritefd, (char *)&sblock,
fsbtodb(&sblock, cgsblock(&sblock, cylno)), SBSIZE);
}
- ckfini();
+ if (!hotroot) {
+ ckfini(1);
+ } else {
+ struct statfs stfs_buf;
+ /*
+ * Check to see if root is mounted read-write.
+ */
+ if (statfs("/", &stfs_buf) == 0)
+ flags = stfs_buf.f_flags;
+ else
+ flags = 0;
+ ckfini(flags & MNT_RDONLY);
+ }
free(blockmap);
free(statemap);
free((char *)lncntp);
@@ -313,25 +338,20 @@ checkfilesys(filesys, mntpt, auxdata, child)
if (rerun)
printf("\n***** PLEASE RERUN FSCK *****\n");
if (hotroot) {
- struct statfs stfs_buf;
+ struct ufs_args args;
+ int ret;
/*
* We modified the root. Do a mount update on
* it, unless it is read-write, so we can continue.
*/
- if (statfs("/", &stfs_buf) == 0) {
- long flags = stfs_buf.f_flags;
- struct ufs_args args;
- int ret;
-
- if (flags & MNT_RDONLY) {
- args.fspec = 0;
- args.export.ex_flags = 0;
- args.export.ex_root = 0;
- flags |= MNT_UPDATE | MNT_RELOAD;
- ret = mount(MOUNT_UFS, "/", flags, &args);
- if (ret == 0)
- return(0);
- }
+ if (flags & MNT_RDONLY) {
+ args.fspec = 0;
+ args.export.ex_flags = 0;
+ args.export.ex_root = 0;
+ flags |= MNT_UPDATE | MNT_RELOAD;
+ ret = mount("ufs", "/", flags, &args);
+ if (ret == 0)
+ return (0);
}
if (!preen)
printf("\n***** REBOOT NOW *****\n");