diff options
author | julian <julian@FreeBSD.org> | 1998-12-03 02:27:35 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1998-12-03 02:27:35 +0000 |
commit | c1ef9f83c919949e90841ae0990aa9a0273d6490 (patch) | |
tree | 766d55719160577172499b05ce54cc96670cf3c4 /sbin/fsck_ffs/main.c | |
parent | 1a5eceeafeb45fc95a5c9fe1830e0d3e349ec69a (diff) | |
download | FreeBSD-src-c1ef9f83c919949e90841ae0990aa9a0273d6490.zip FreeBSD-src-c1ef9f83c919949e90841ae0990aa9a0273d6490.tar.gz |
Reviewed by: Don Lewis <Don.Lewis@tsc.tdk.com>
Submitted by: Kirk McKusick <mckusick@McKusick.COM>
Obtained from: Mckusick, BSDI and a host of others
This exactly matches Kirks sources imported under the
Tag MCKUSICK2. These are as supplied by kirk with one small
change needed to compile under freeBSD.
Some FreeBSD patches will be added back, though many have been
added to Kirk's sources already.
Diffstat (limited to 'sbin/fsck_ffs/main.c')
-rw-r--r-- | sbin/fsck_ffs/main.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 317015b..681ee6dc 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -38,11 +38,7 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -#if 0 -static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95"; -#endif -static const char rcsid[] = - "$Id: main.c,v 1.14 1998/06/15 07:07:16 charnier Exp $"; +static const char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95"; #endif /* not lint */ #include <sys/param.h> @@ -56,11 +52,10 @@ static const char rcsid[] = #include <err.h> #include <fstab.h> +#include <string.h> #include "fsck.h" -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, @@ -74,12 +69,8 @@ main(argc, argv) { int ch; int ret, maxrun = 0; - struct rlimit rlim; + struct rlimit rlimit; - if (getrlimit(RLIMIT_DATA, &rlim) == 0) { - rlim.rlim_cur = rlim.rlim_max; - (void) setrlimit(RLIMIT_DATA, &rlim); - } sync(); while ((ch = getopt(argc, argv, "dfpnNyYb:c:l:m:")) != -1) { switch (ch) { @@ -137,9 +128,24 @@ main(argc, argv) (void)signal(SIGINT, catch); if (preen) (void)signal(SIGQUIT, catchquit); + /* + * Push up our allowed memory limit so we can cope + * with huge filesystems. + */ + if (getrlimit(RLIMIT_DATA, &rlimit) == 0) { + rlimit.rlim_cur = rlimit.rlim_max; + (void)setrlimit(RLIMIT_DATA, &rlimit); + } if (argc) { - while (argc-- > 0) - (void)checkfilesys(blockcheck(*argv++), 0, 0L, 0); + while (argc-- > 0) { + char *path = blockcheck(*argv); + + if (path == NULL) + pfatal("Can't check %s\n", *argv); + else + (void)checkfilesys(path, 0, 0L, 0); + ++argv; + } exit(0); } ret = checkfstab(preen, maxrun, docheck, checkfilesys); @@ -203,16 +209,10 @@ checkfilesys(filesys, mntpt, auxdata, child) case 0: if (preen) pfatal("CAN'T CHECK FILE SYSTEM."); - return (0); + /* fall through */ case -1: - pwarn("clean, %ld free ", sblock.fs_cstotal.cs_nffree + - sblock.fs_frag * sblock.fs_cstotal.cs_nbfree); - printf("(%d frags, %d blocks, %.1f%% fragmentation)\n", - sblock.fs_cstotal.cs_nffree, sblock.fs_cstotal.cs_nbfree, - sblock.fs_cstotal.cs_nffree * 100.0 / sblock.fs_dsize); return (0); } - /* * Cleared if any questions answered no. Used to decide if * the superblock should be marked clean. @@ -304,7 +304,7 @@ checkfilesys(filesys, mntpt, auxdata, child) muldup = (struct dups *)0; inocleanup(); if (fsmodified) { - (void)time(&sblock.fs_time); + sblock.fs_time = time(NULL); sbdirty(); } if (cvtlevel && sblk.b_dirty) { @@ -329,12 +329,13 @@ checkfilesys(filesys, mntpt, auxdata, child) resolved = 0; } ckfini(resolved); - free(blockmap); - free(statemap); - free((char *)lncntp); - if (!fsmodified) - return (0); - if (!preen) + + for (cylno = 0; cylno < sblock.fs_ncg; cylno++) + if (inostathead[cylno].il_stat != NULL) + free((char *)inostathead[cylno].il_stat); + free((char *)inostathead); + inostathead = NULL; + if (fsmodified && !preen) printf("\n***** FILE SYSTEM WAS MODIFIED *****\n"); if (rerun) printf("\n***** PLEASE RERUN FSCK *****\n"); @@ -354,6 +355,8 @@ checkfilesys(filesys, mntpt, auxdata, child) if (ret == 0) return (0); } + if (!fsmodified) + return (0); if (!preen) printf("\n***** REBOOT NOW *****\n"); sync(); |