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
--- 25 unchanged lines hidden (view full) ---
34 The Regents of the University of California. All rights reserved.\n";
35#endif /* not lint */
36
37#ifndef lint
38static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
39#endif /* not lint */
40#endif
41#include <sys/cdefs.h>
42__FBSDID("$FreeBSD: stable/10/sbin/fsck_ffs/main.c 253822 2013-07-30 22:57:12Z scottl $");
43
44#include <sys/param.h>
45#include <sys/file.h>
46#include <sys/mount.h>
47#include <sys/resource.h>
48#include <sys/stat.h>
49#include <sys/sysctl.h>
50#include <sys/uio.h>
--- 9 unchanged lines hidden (view full) ---
60#include <mntopts.h>
61#include <paths.h>
62#include <stdint.h>
63#include <string.h>
64#include <time.h>
65
66#include "fsck.h"
67
68static void usage(void) __dead2;
69static int argtoi(int flag, const char *req, const char *str, int base);
70static int checkfilesys(char *filesys);
71static int chkdoreload(struct statfs *mntp);
72static struct statfs *getmntpt(const char *);
73
74int
75main(int argc, char *argv[])
76{
77 int ch;
78 struct rlimit rlimit;
79 struct itimerval itimerval;
80 int ret = 0;
81
82 sync();
83 skipclean = 1;
84 inoopt = 0;
85 while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:nprSyZ")) != -1) {
86 switch (ch) {
87 case 'b':
88 skipclean = 0;
89 bflag = argtoi('b', "number", optarg, 10);
90 printf("Alternate super block location: %d\n", bflag);
91 break;
92
93 case 'B':
--- 39 unchanged lines hidden (view full) ---
133 case 'p':
134 preen++;
135 /*FALLTHROUGH*/
136
137 case 'C':
138 ckclean++;
139 break;
140
141 case 'r':
142 inoopt++;
143 break;
144
145 case 'S':
146 surrender = 1;
147 break;
148
--- 32 unchanged lines hidden (view full) ---
181 /*
182 * Push up our allowed memory limit so we can cope
183 * with huge file systems.
184 */
185 if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
186 rlimit.rlim_cur = rlimit.rlim_max;
187 (void)setrlimit(RLIMIT_DATA, &rlimit);
188 }
189 while (argc-- > 0)
190 (void)checkfilesys(*argv++);
191
192 if (returntosingle)
193 ret = 2;
194 exit(ret);
195}
196
197static int
198argtoi(int flag, const char *req, const char *str, int base)
--- 24 unchanged lines hidden (view full) ---
223 int iovlen;
224 int cylno;
225 intmax_t blks, files;
226 size_t size;
227
228 iov = NULL;
229 iovlen = 0;
230 errmsg[0] = '\0';
231
232 cdevname = filesys;
233 if (debug && ckclean)
234 pwarn("starting\n");
235 /*
236 * Make best effort to get the disk name. Check first to see
237 * if it is listed among the mounted file systems. Failing that
238 * check to see if it is listed in /etc/fstab.
--- 306 unchanged lines hidden (view full) ---
545
546 for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
547 if (inostathead[cylno].il_stat != NULL)
548 free((char *)inostathead[cylno].il_stat);
549 free((char *)inostathead);
550 inostathead = NULL;
551 if (fsmodified && !preen)
552 printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
553 if (rerun)
554 printf("\n***** PLEASE RERUN FSCK *****\n");
555 if (chkdoreload(mntp) != 0) {
556 if (!fsmodified)
557 return (0);
558 if (!preen)
559 printf("\n***** REBOOT NOW *****\n");
560 sync();
561 return (4);
562 }
--- 86 unchanged lines hidden (view full) ---
649static void
650usage(void)
651{
652 (void) fprintf(stderr,
653"usage: %s [-BEFfnpry] [-b block] [-c level] [-m mode] filesystem ...\n",
654 getprogname());
655 exit(1);
656}
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
--- 25 unchanged lines hidden (view full) ---
34 The Regents of the University of California. All rights reserved.\n";
35#endif /* not lint */
36
37#ifndef lint
38static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
39#endif /* not lint */
40#endif
41#include <sys/cdefs.h>
42__FBSDID("$FreeBSD: stable/10/sbin/fsck_ffs/main.c 253822 2013-07-30 22:57:12Z scottl $");
43
44#include <sys/param.h>
45#include <sys/file.h>
46#include <sys/mount.h>
47#include <sys/resource.h>
48#include <sys/stat.h>
49#include <sys/sysctl.h>
50#include <sys/uio.h>
--- 9 unchanged lines hidden (view full) ---
60#include <mntopts.h>
61#include <paths.h>
62#include <stdint.h>
63#include <string.h>
64#include <time.h>
65
66#include "fsck.h"
67
68static void usage(void) __dead2;
69static int argtoi(int flag, const char *req, const char *str, int base);
70static int checkfilesys(char *filesys);
71static int chkdoreload(struct statfs *mntp);
72static struct statfs *getmntpt(const char *);
73
74int
75main(int argc, char *argv[])
76{
77 int ch;
78 struct rlimit rlimit;
79 struct itimerval itimerval;
80 int ret = 0;
81
82 sync();
83 skipclean = 1;
84 inoopt = 0;
85 while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:nprSyZ")) != -1) {
86 switch (ch) {
87 case 'b':
88 skipclean = 0;
89 bflag = argtoi('b', "number", optarg, 10);
90 printf("Alternate super block location: %d\n", bflag);
91 break;
92
93 case 'B':
--- 39 unchanged lines hidden (view full) ---
133 case 'p':
134 preen++;
135 /*FALLTHROUGH*/
136
137 case 'C':
138 ckclean++;
139 break;
140
141 case 'r':
142 inoopt++;
143 break;
144
145 case 'S':
146 surrender = 1;
147 break;
148
--- 32 unchanged lines hidden (view full) ---
181 /*
182 * Push up our allowed memory limit so we can cope
183 * with huge file systems.
184 */
185 if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
186 rlimit.rlim_cur = rlimit.rlim_max;
187 (void)setrlimit(RLIMIT_DATA, &rlimit);
188 }
189 while (argc-- > 0)
190 (void)checkfilesys(*argv++);
191
192 if (returntosingle)
193 ret = 2;
194 exit(ret);
195}
196
197static int
198argtoi(int flag, const char *req, const char *str, int base)
--- 24 unchanged lines hidden (view full) ---
223 int iovlen;
224 int cylno;
225 intmax_t blks, files;
226 size_t size;
227
228 iov = NULL;
229 iovlen = 0;
230 errmsg[0] = '\0';
231
232 cdevname = filesys;
233 if (debug && ckclean)
234 pwarn("starting\n");
235 /*
236 * Make best effort to get the disk name. Check first to see
237 * if it is listed among the mounted file systems. Failing that
238 * check to see if it is listed in /etc/fstab.
--- 306 unchanged lines hidden (view full) ---
545
546 for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
547 if (inostathead[cylno].il_stat != NULL)
548 free((char *)inostathead[cylno].il_stat);
549 free((char *)inostathead);
550 inostathead = NULL;
551 if (fsmodified && !preen)
552 printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
553 if (rerun)
554 printf("\n***** PLEASE RERUN FSCK *****\n");
555 if (chkdoreload(mntp) != 0) {
556 if (!fsmodified)
557 return (0);
558 if (!preen)
559 printf("\n***** REBOOT NOW *****\n");
560 sync();
561 return (4);
562 }
--- 86 unchanged lines hidden (view full) ---
649static void
650usage(void)
651{
652 (void) fprintf(stderr,
653"usage: %s [-BEFfnpry] [-b block] [-c level] [-m mode] filesystem ...\n",
654 getprogname());
655 exit(1);
656}