From 2b9ad7bcf32e6170f173154c11f8f55166b11f7f Mon Sep 17 00:00:00 2001 From: mckusick Date: Thu, 8 Feb 2018 23:14:24 +0000 Subject: [PATCH] Include files missed in 329051. --- sbin/fsck_ffs/fsck.h | 1 + sbin/fsck_ffs/globs.c | 1 + sbin/fsck_ffs/main.c | 42 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index 56f01501022a..5cf2e73155b2 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -315,6 +315,7 @@ extern int Zflag; /* zero empty data blocks */ extern int inoopt; /* trim out unused inodes */ extern char ckclean; /* only do work if not cleanly unmounted */ extern int cvtlevel; /* convert to newer file system format */ +extern int ckhashadd; /* check hashes to be added */ extern int bkgrdcheck; /* determine if background check is possible */ extern int bkgrdsumadj; /* whether the kernel have ability to adjust superblock summary */ extern char usedsoftdep; /* just fix soft dependency inconsistencies */ diff --git a/sbin/fsck_ffs/globs.c b/sbin/fsck_ffs/globs.c index 6ce7dfd032c4..e04a5194b976 100644 --- a/sbin/fsck_ffs/globs.c +++ b/sbin/fsck_ffs/globs.c @@ -87,6 +87,7 @@ int Zflag; /* zero empty data blocks */ int inoopt; /* trim out unused inodes */ char ckclean; /* only do work if not cleanly unmounted */ int cvtlevel; /* convert to newer file system format */ +int ckhashadd; /* check hashes to be added */ int bkgrdcheck; /* determine if background check is possible */ int bkgrdsumadj; /* whether the kernel have ability to adjust superblock summary */ char usedsoftdep; /* just fix soft dependency inconsistencies */ diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 5a8365ef2ce7..c160295d2702 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -43,6 +43,7 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95"; #include __FBSDID("$FreeBSD$"); +#define IN_RTLD /* So we pickup the P_OSREL defines */ #include #include #include @@ -440,7 +441,46 @@ checkfilesys(char *filesys) flush(fswritefd, &sblk); fsmodified = ofsmodified; } - + /* + * If the filesystem was run on an old kernel that did not + * support check hashes, clear the check-hash flags so that + * we do not try to verify them. + */ + if ((sblock.fs_flags & FS_METACKHASH) == 0) + sblock.fs_metackhash = 0; + /* + * If we are running on a kernel that can provide check hashes + * that are not yet enabled for the filesystem and we are + * running manually without the -y flag, offer to add any + * supported check hashes that are not already enabled. + */ + ckhashadd = 0; + if (preen == 0 && yflag == 0 && sblock.fs_magic != FS_UFS1_MAGIC && + fswritefd != -1 && getosreldate() >= P_OSREL_CK_CYLGRP) { + if ((sblock.fs_metackhash & CK_CYLGRP) == 0 && + reply("ADD CYLINDER GROUP CHECK-HASH PROTECTION") != 0) + ckhashadd |= CK_CYLGRP; +#ifdef notyet + if ((sblock.fs_metackhash & CK_SUPERBLOCK) == 0 && + getosreldate() >= P_OSREL_CK_SUPERBLOCK && + reply("ADD SUPERBLOCK CHECK-HASH PROTECTION") != 0) + ckhashadd |= CK_SUPERBLOCK; + if ((sblock.fs_metackhash & CK_INODE) == 0 && + getosreldate() >= P_OSREL_CK_INODE && + reply("ADD INODE CHECK-HASH PROTECTION") != 0) + ckhashadd |= CK_INODE; + if ((sblock.fs_metackhash & CK_INDIR) == 0 && + getosreldate() >= P_OSREL_CK_INDIR && + reply("ADD INDIRECT BLOCK CHECK-HASH PROTECTION") != 0) + ckhashadd |= CK_INDIR; + if ((sblock.fs_metackhash & CK_DIR) == 0 && + getosreldate() >= P_OSREL_CK_DIR && + reply("ADD DIRECTORY CHECK-HASH PROTECTION") != 0) + ckhashadd |= CK_DIR; +#endif /* notyet */ + if (ckhashadd != 0) + sblock.fs_flags |= FS_METACKHASH; + } /* * Cleared if any questions answered no. Used to decide if * the superblock should be marked clean.