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 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 |
68int restarts; 69 |
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; |
87 while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:npRrSyZ")) != -1) { |
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; |
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 } |
194 while (argc > 0) { 195 if (checkfilesys(*argv) == ERESTART) 196 continue; 197 argc--; 198 argv++; 199 } |
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(); |
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"); |
564 if (rerun) { 565 if (wantrestart && (restarts++ < 10) && 566 (preen || reply("RESTART"))) 567 return (ERESTART); |
568 printf("\n***** PLEASE RERUN FSCK *****\n"); |
569 } |
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} |