summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ifs/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/fsck_ifs/main.c')
-rw-r--r--sbin/fsck_ifs/main.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/sbin/fsck_ifs/main.c b/sbin/fsck_ifs/main.c
index 317015b..681ee6dc 100644
--- a/sbin/fsck_ifs/main.c
+++ b/sbin/fsck_ifs/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();
OpenPOWER on IntegriCloud