diff options
-rw-r--r-- | sbin/fsck_ffs/Makefile | 4 | ||||
-rw-r--r-- | sbin/fsck_ffs/fsck.h | 5 | ||||
-rw-r--r-- | sbin/fsck_ffs/fsutil.c | 10 | ||||
-rw-r--r-- | sbin/fsck_ffs/inode.c | 4 | ||||
-rw-r--r-- | sbin/fsck_ffs/main.c | 25 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass5.c | 1 | ||||
-rw-r--r-- | sbin/fsck_ffs/setup.c | 6 |
7 files changed, 41 insertions, 14 deletions
diff --git a/sbin/fsck_ffs/Makefile b/sbin/fsck_ffs/Makefile index 5b7474f..ee164dd 100644 --- a/sbin/fsck_ffs/Makefile +++ b/sbin/fsck_ffs/Makefile @@ -7,7 +7,9 @@ LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_4.2bsd MAN= fsck_ffs.8 MLINKS= fsck_ffs.8 fsck_ufs.8 fsck_ffs.8 fsck_4.2bsd.8 SRCS= dir.c ea.c fsutil.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c \ - pass4.c pass5.c setup.c utilities.c ffs_subr.c ffs_tables.c + pass4.c pass5.c setup.c utilities.c ffs_subr.c ffs_tables.c gjournal.c +DPADD= ${LIBUFS} +LDADD= -lufs WARNS?= 2 CFLAGS+= -I${.CURDIR} diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index 32f9cfa..f9b38e0 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -328,9 +328,9 @@ ino_t allocdir(ino_t parent, ino_t request, int mode); ino_t allocino(ino_t request, int type); void blkerror(ino_t ino, const char *type, ufs2_daddr_t blk); char *blockcheck(char *name); -int bread(int fd, char *buf, ufs2_daddr_t blk, long size); +int blread(int fd, char *buf, ufs2_daddr_t blk, long size); void bufinit(void); -void bwrite(int fd, char *buf, ufs2_daddr_t blk, long size); +void blwrite(int fd, char *buf, ufs2_daddr_t blk, long size); void cacheino(union dinode *dp, ino_t inumber); void catch(int); void catchquit(int); @@ -388,3 +388,4 @@ void rwerror(const char *mesg, ufs2_daddr_t blk); void sblock_init(void); void setinodebuf(ino_t); int setup(char *dev); +void gjournal_check(const char *filesys); diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c index 6bb590e..65f996c 100644 --- a/sbin/fsck_ffs/fsutil.c +++ b/sbin/fsck_ffs/fsutil.c @@ -221,7 +221,7 @@ getblk(struct bufarea *bp, ufs2_daddr_t blk, long size) if (bp->b_bno != dblk) { flush(fswritefd, bp); diskreads++; - bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size); + bp->b_errs = blread(fsreadfd, bp->b_un.b_buf, dblk, size); bp->b_bno = dblk; bp->b_size = size; } @@ -244,11 +244,11 @@ flush(int fd, struct bufarea *bp) (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ", (long long)bp->b_bno); bp->b_errs = 0; - bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size); + blwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size); if (bp != &sblk) return; for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) { - bwrite(fswritefd, (char *)sblock.fs_csp + i, + blwrite(fswritefd, (char *)sblock.fs_csp + i, fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag), sblock.fs_cssize - i < sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize); @@ -345,7 +345,7 @@ ckfini(int markclean) } int -bread(int fd, char *buf, ufs2_daddr_t blk, long size) +blread(int fd, char *buf, ufs2_daddr_t blk, long size) { char *cp; int i, errs; @@ -387,7 +387,7 @@ bread(int fd, char *buf, ufs2_daddr_t blk, long size) } void -bwrite(int fd, char *buf, ufs2_daddr_t blk, long size) +blwrite(int fd, char *buf, ufs2_daddr_t blk, long size) { int i; char *cp; diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index e470f99..b41d843 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -329,10 +329,10 @@ getnextinode(ino_t inumber) lastinum += fullcnt; } /* - * If bread returns an error, it will already have zeroed + * If blread returns an error, it will already have zeroed * out the buffer, so we do not need to do so here. */ - (void)bread(fsreadfd, inodebuf, dblk, size); + (void)blread(fsreadfd, inodebuf, dblk, size); nextinop = inodebuf; } dp = (union dinode *)nextinop; diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index a717969..2529c87 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -237,6 +237,29 @@ checkfilesys(char *filesys) exit(7); /* Filesystem clean, report it now */ exit(0); } + if (preen && skipclean) { + /* + * If file system is gjournaled, check it here. + */ + if ((fsreadfd = open(filesys, O_RDONLY)) < 0 || readsb(0) == 0) + exit(3); /* Cannot read superblock */ + close(fsreadfd); + if ((sblock.fs_flags & FS_GJOURNAL) != 0) { + //printf("GJournaled file system detected on %s.\n", + // filesys); + if (sblock.fs_clean == 1) { + pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n"); + exit(0); + } + if ((sblock.fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) == 0) { + gjournal_check(filesys); + exit(0); + } else { + pfatal("UNEXPECTED INCONSISTENCY, %s\n", + "CANNOT RUN FAST FSCK\n"); + } + } + } /* * If we are to do a background check: * Get the mount point information of the file system @@ -437,7 +460,7 @@ checkfilesys(char *filesys) * Write out the duplicate super blocks */ for (cylno = 0; cylno < sblock.fs_ncg; cylno++) - bwrite(fswritefd, (char *)&sblock, + blwrite(fswritefd, (char *)&sblock, fsbtodb(&sblock, cgsblock(&sblock, cylno)), SBLOCKSIZE); } diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index 693831f..3275894 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -164,6 +164,7 @@ pass5(void) pfatal("CG %d: BAD MAGIC NUMBER\n", c); newcg->cg_time = cg->cg_time; newcg->cg_old_time = cg->cg_old_time; + newcg->cg_unrefs = cg->cg_unrefs; newcg->cg_cgx = c; dbase = cgbase(fs, c); dmax = dbase + fs->fs_fpg; diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index f6b736d..bdf88b4 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -249,7 +249,7 @@ setup(char *dev) for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) { size = sblock.fs_cssize - i < sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize; - if (bread(fsreadfd, (char *)sblock.fs_csp + i, + if (blread(fsreadfd, (char *)sblock.fs_csp + i, fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag), size) != 0 && !asked) { pfatal("BAD SUMMARY INFORMATION"); @@ -322,7 +322,7 @@ readsb(int listerr) if (bflag) { super = bflag; - if ((bread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE))) + if ((blread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE))) return (0); if (sblock.fs_magic == FS_BAD_MAGIC) { fprintf(stderr, BAD_MAGIC_MSG); @@ -337,7 +337,7 @@ readsb(int listerr) } else { for (i = 0; sblock_try[i] != -1; i++) { super = sblock_try[i] / dev_bsize; - if ((bread(fsreadfd, (char *)&sblock, super, + if ((blread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE))) return (0); if (sblock.fs_magic == FS_BAD_MAGIC) { |