Deleted Added
full compact
main.c (256281) main.c (260178)
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>
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 $");
42__FBSDID("$FreeBSD: stable/10/sbin/fsck_ffs/main.c 260178 2014-01-02 01:44:14Z 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
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
68int restarts;
69
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;
70static void usage(void) __dead2;
71static int argtoi(int flag, const char *req, const char *str, int base);
72static int checkfilesys(char *filesys);
73static int chkdoreload(struct statfs *mntp);
74static struct statfs *getmntpt(const char *);
75
76int
77main(int argc, char *argv[])
78{
79 int ch;
80 struct rlimit rlimit;
81 struct itimerval itimerval;
82 int ret = 0;
83
84 sync();
85 skipclean = 1;
86 inoopt = 0;
85 while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:nprSyZ")) != -1) {
87 while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:npRrSyZ")) != -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
88 switch (ch) {
89 case 'b':
90 skipclean = 0;
91 bflag = argtoi('b', "number", optarg, 10);
92 printf("Alternate super block location: %d\n", bflag);
93 break;
94
95 case 'B':

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

135 case 'p':
136 preen++;
137 /*FALLTHROUGH*/
138
139 case 'C':
140 ckclean++;
141 break;
142
143 case 'R':
144 wantrestart = 1;
145 break;
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 }
146 case 'r':
147 inoopt++;
148 break;
149
150 case 'S':
151 surrender = 1;
152 break;
153

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

186 /*
187 * Push up our allowed memory limit so we can cope
188 * with huge file systems.
189 */
190 if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
191 rlimit.rlim_cur = rlimit.rlim_max;
192 (void)setrlimit(RLIMIT_DATA, &rlimit);
193 }
189 while (argc-- > 0)
190 (void)checkfilesys(*argv++);
194 while (argc > 0) {
195 if (checkfilesys(*argv) == ERESTART)
196 continue;
197 argc--;
198 argv++;
199 }
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';
200
201 if (returntosingle)
202 ret = 2;
203 exit(ret);
204}
205
206static int
207argtoi(int flag, const char *req, const char *str, int base)

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

232 int iovlen;
233 int cylno;
234 intmax_t blks, files;
235 size_t size;
236
237 iov = NULL;
238 iovlen = 0;
239 errmsg[0] = '\0';
240 fsutilinit();
241 fsckinit();
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");
242
243 cdevname = filesys;
244 if (debug && ckclean)
245 pwarn("starting\n");
246 /*
247 * Make best effort to get the disk name. Check first to see
248 * if it is listed among the mounted file systems. Failing that
249 * check to see if it is listed in /etc/fstab.

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

556
557 for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
558 if (inostathead[cylno].il_stat != NULL)
559 free((char *)inostathead[cylno].il_stat);
560 free((char *)inostathead);
561 inostathead = NULL;
562 if (fsmodified && !preen)
563 printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
553 if (rerun)
564 if (rerun) {
565 if (wantrestart && (restarts++ < 10) &&
566 (preen || reply("RESTART")))
567 return (ERESTART);
554 printf("\n***** PLEASE RERUN FSCK *****\n");
568 printf("\n***** PLEASE RERUN FSCK *****\n");
569 }
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}
570 if (chkdoreload(mntp) != 0) {
571 if (!fsmodified)
572 return (0);
573 if (!preen)
574 printf("\n***** REBOOT NOW *****\n");
575 sync();
576 return (4);
577 }

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

664static void
665usage(void)
666{
667 (void) fprintf(stderr,
668"usage: %s [-BEFfnpry] [-b block] [-c level] [-m mode] filesystem ...\n",
669 getprogname());
670 exit(1);
671}
672
673void
674infohandler(int sig __unused)
675{
676 got_siginfo = 1;
677}
678
679void
680alarmhandler(int sig __unused)
681{
682 got_sigalarm = 1;
683}