Deleted Added
full compact
main.c (76143) main.c (86514)
1/*
2 * Copyright (c) 1980, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 28 unchanged lines hidden (view full) ---

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
43#endif
44static const char rcsid[] =
1/*
2 * Copyright (c) 1980, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 28 unchanged lines hidden (view full) ---

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
43#endif
44static const char rcsid[] =
45 "$FreeBSD: head/sbin/fsck_ffs/main.c 76143 2001-04-30 05:36:32Z mckusick $";
45 "$FreeBSD: head/sbin/fsck_ffs/main.c 86514 2001-11-17 23:48:21Z iedowse $";
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/stat.h>
50#include <sys/file.h>
51#include <sys/time.h>
52#include <sys/mount.h>
53#include <sys/resource.h>
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/stat.h>
50#include <sys/file.h>
51#include <sys/time.h>
52#include <sys/mount.h>
53#include <sys/resource.h>
54#include <sys/sysctl.h>
54
55#include <ufs/ufs/dinode.h>
56#include <ufs/ufs/ufsmount.h>
57#include <ufs/ffs/fs.h>
58
59#include <err.h>
60#include <errno.h>
61#include <fstab.h>
62#include <paths.h>
55
56#include <ufs/ufs/dinode.h>
57#include <ufs/ufs/ufsmount.h>
58#include <ufs/ffs/fs.h>
59
60#include <err.h>
61#include <errno.h>
62#include <fstab.h>
63#include <paths.h>
64#include <string.h>
63
64#include "fsck.h"
65
66static void usage __P((void));
67static int argtoi __P((int flag, char *req, char *str, int base));
65
66#include "fsck.h"
67
68static void usage __P((void));
69static int argtoi __P((int flag, char *req, char *str, int base));
68static int docheck __P((struct fstab *fsp));
69static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
70 int child));
70static int checkfilesys __P((char *filesys));
71static struct statfs *getmntpt __P((const char *));
72int main __P((int argc, char *argv[]));
73
74int
75main(argc, argv)
76 int argc;
77 char *argv[];
78{

--- 72 unchanged lines hidden (view full) ---

151 * Push up our allowed memory limit so we can cope
152 * with huge filesystems.
153 */
154 if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
155 rlimit.rlim_cur = rlimit.rlim_max;
156 (void)setrlimit(RLIMIT_DATA, &rlimit);
157 }
158 while (argc-- > 0)
71static struct statfs *getmntpt __P((const char *));
72int main __P((int argc, char *argv[]));
73
74int
75main(argc, argv)
76 int argc;
77 char *argv[];
78{

--- 72 unchanged lines hidden (view full) ---

151 * Push up our allowed memory limit so we can cope
152 * with huge filesystems.
153 */
154 if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
155 rlimit.rlim_cur = rlimit.rlim_max;
156 (void)setrlimit(RLIMIT_DATA, &rlimit);
157 }
158 while (argc-- > 0)
159 (void)checkfilesys(*argv++, 0, 0L, 0);
159 (void)checkfilesys(*argv++);
160
161 if (returntosingle)
162 ret = 2;
163 exit(ret);
164}
165
166static int
167argtoi(flag, req, str, base)

--- 10 unchanged lines hidden (view full) ---

178 return (ret);
179}
180
181/*
182 * Check the specified filesystem.
183 */
184/* ARGSUSED */
185static int
160
161 if (returntosingle)
162 ret = 2;
163 exit(ret);
164}
165
166static int
167argtoi(flag, req, str, base)

--- 10 unchanged lines hidden (view full) ---

178 return (ret);
179}
180
181/*
182 * Check the specified filesystem.
183 */
184/* ARGSUSED */
185static int
186checkfilesys(filesys, mntpt, auxdata, child)
187 char *filesys, *mntpt;
188 long auxdata;
189 int child;
186checkfilesys(filesys)
187 char *filesys;
190{
191 ufs_daddr_t n_ffree, n_bfree;
192 struct ufs_args args;
193 struct dups *dp;
194 struct statfs *mntp;
195 struct zlncnt *zlnp;
196 ufs_daddr_t blks;
197 ufs_daddr_t files;
198 int cylno, size;
199
188{
189 ufs_daddr_t n_ffree, n_bfree;
190 struct ufs_args args;
191 struct dups *dp;
192 struct statfs *mntp;
193 struct zlncnt *zlnp;
194 ufs_daddr_t blks;
195 ufs_daddr_t files;
196 int cylno, size;
197
200 if (preen && child)
201 (void)signal(SIGQUIT, voidquit);
202 cdevname = filesys;
203 if (debug && preen)
204 pwarn("starting\n");
205 /*
206 * Make best effort to get the disk name. Check first to see
207 * if it is listed among the mounted filesystems. Failing that
208 * check to see if it is listed in /etc/fstab.
209 */

--- 84 unchanged lines hidden (view full) ---

294
295 switch (setup(filesys)) {
296 case 0:
297 if (preen)
298 pfatal("CAN'T CHECK FILE SYSTEM.");
299 return (0);
300 case -1:
301 clean:
198 cdevname = filesys;
199 if (debug && preen)
200 pwarn("starting\n");
201 /*
202 * Make best effort to get the disk name. Check first to see
203 * if it is listed among the mounted filesystems. Failing that
204 * check to see if it is listed in /etc/fstab.
205 */

--- 84 unchanged lines hidden (view full) ---

290
291 switch (setup(filesys)) {
292 case 0:
293 if (preen)
294 pfatal("CAN'T CHECK FILE SYSTEM.");
295 return (0);
296 case -1:
297 clean:
302 pwarn("clean, %ld free ", sblock.fs_cstotal.cs_nffree +
303 sblock.fs_frag * sblock.fs_cstotal.cs_nbfree);
298 pwarn("clean, %ld free ", (long)(sblock.fs_cstotal.cs_nffree +
299 sblock.fs_frag * sblock.fs_cstotal.cs_nbfree));
304 printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
305 sblock.fs_cstotal.cs_nffree, sblock.fs_cstotal.cs_nbfree,
306 sblock.fs_cstotal.cs_nffree * 100.0 / sblock.fs_dsize);
307 return (0);
308 }
309
310 /*
311 * Cleared if any questions answered no. Used to decide if

--- 57 unchanged lines hidden (view full) ---

369 files = maxino - ROOTINO - sblock.fs_cstotal.cs_nifree - n_files;
370 blks = n_blks +
371 sblock.fs_ncg * (cgdmin(&sblock, 0) - cgsblock(&sblock, 0));
372 blks += cgsblock(&sblock, 0) - cgbase(&sblock, 0);
373 blks += howmany(sblock.fs_cssize, sblock.fs_fsize);
374 blks = maxfsblock - (n_ffree + sblock.fs_frag * n_bfree) - blks;
375 if (bkgrdflag && (files > 0 || blks > 0)) {
376 countdirs = sblock.fs_cstotal.cs_ndir - countdirs;
300 printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
301 sblock.fs_cstotal.cs_nffree, sblock.fs_cstotal.cs_nbfree,
302 sblock.fs_cstotal.cs_nffree * 100.0 / sblock.fs_dsize);
303 return (0);
304 }
305
306 /*
307 * Cleared if any questions answered no. Used to decide if

--- 57 unchanged lines hidden (view full) ---

365 files = maxino - ROOTINO - sblock.fs_cstotal.cs_nifree - n_files;
366 blks = n_blks +
367 sblock.fs_ncg * (cgdmin(&sblock, 0) - cgsblock(&sblock, 0));
368 blks += cgsblock(&sblock, 0) - cgbase(&sblock, 0);
369 blks += howmany(sblock.fs_cssize, sblock.fs_fsize);
370 blks = maxfsblock - (n_ffree + sblock.fs_frag * n_bfree) - blks;
371 if (bkgrdflag && (files > 0 || blks > 0)) {
372 countdirs = sblock.fs_cstotal.cs_ndir - countdirs;
377 pwarn("Reclaimed: %d directories, %d files, %d fragments\n",
378 countdirs, files - countdirs, blks);
373 pwarn("Reclaimed: %ld directories, %ld files, %d fragments\n",
374 countdirs, (long)files - countdirs, blks);
379 }
380 pwarn("%ld files, %ld used, %ld free ",
375 }
376 pwarn("%ld files, %ld used, %ld free ",
381 n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree);
377 (long)n_files, (long)n_blks, (long)(n_ffree +
378 sblock.fs_frag * n_bfree));
382 printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
383 n_ffree, n_bfree, n_ffree * 100.0 / sblock.fs_dsize);
384 if (debug) {
385 if (files < 0)
386 printf("%d inodes missing\n", -files);
387 if (blks < 0)
388 printf("%d blocks missing\n", -blks);
389 if (duplist != NULL) {

--- 128 unchanged lines hidden ---
379 printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
380 n_ffree, n_bfree, n_ffree * 100.0 / sblock.fs_dsize);
381 if (debug) {
382 if (files < 0)
383 printf("%d inodes missing\n", -files);
384 if (blks < 0)
385 printf("%d blocks missing\n", -blks);
386 if (duplist != NULL) {

--- 128 unchanged lines hidden ---