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: head/sbin/fsck_ffs/main.c 163845 2006-10-31 22:06:56Z pjd $"); |
43 44#include <sys/param.h> 45#include <sys/stat.h> 46#include <sys/file.h> 47#include <sys/time.h> 48#include <sys/mount.h> 49#include <sys/resource.h> 50#include <sys/sysctl.h> --- 181 unchanged lines hidden (view full) --- 232 size = MIBSIZE; 233 if (sysctlnametomib("vfs.ffs.adjrefcnt", adjrefcnt, &size) < 0) 234 exit(6); /* Lacks kernel support */ 235 if ((mntp == NULL && sblock.fs_clean == 1) || 236 (mntp != NULL && (sblock.fs_flags & FS_UNCLEAN) == 0)) 237 exit(7); /* Filesystem clean, report it now */ 238 exit(0); 239 } |
240 if (preen && skipclean) { 241 /* 242 * If file system is gjournaled, check it here. 243 */ 244 if ((fsreadfd = open(filesys, O_RDONLY)) < 0 || readsb(0) == 0) 245 exit(3); /* Cannot read superblock */ 246 close(fsreadfd); 247 if ((sblock.fs_flags & FS_GJOURNAL) != 0) { 248 //printf("GJournaled file system detected on %s.\n", 249 // filesys); 250 if (sblock.fs_clean == 1) { 251 pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n"); 252 exit(0); 253 } 254 if ((sblock.fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) == 0) { 255 gjournal_check(filesys); 256 exit(0); 257 } else { 258 pfatal("UNEXPECTED INCONSISTENCY, %s\n", 259 "CANNOT RUN FAST FSCK\n"); 260 } 261 } 262 } |
263 /* 264 * If we are to do a background check: 265 * Get the mount point information of the file system 266 * create snapshot file 267 * return created snapshot file 268 * if not found, clear bkgrdflag and proceed with normal fsck 269 */ 270 if (bkgrdflag) { --- 184 unchanged lines hidden (view full) --- 455 sblock.fs_time = time(NULL); 456 sbdirty(); 457 } 458 if (cvtlevel && sblk.b_dirty) { 459 /* 460 * Write out the duplicate super blocks 461 */ 462 for (cylno = 0; cylno < sblock.fs_ncg; cylno++) |
463 blwrite(fswritefd, (char *)&sblock, |
464 fsbtodb(&sblock, cgsblock(&sblock, cylno)), 465 SBLOCKSIZE); 466 } 467 if (rerun) 468 resolved = 0; 469 470 /* 471 * Check to see if the file system is mounted read-write. --- 90 unchanged lines hidden --- |