aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2018-02-08 23:14:24 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2018-02-08 23:14:24 +0000
commit31461aa2f18c3e2921b211a3988ef28ba2d2f0a2 (patch)
tree697b3af23a94b85487e5e5a4436b5523eab9371b /sbin
parent068beacf21ea3ca33dd07741bb23939e24d84bef (diff)
downloadsrc-31461aa2f18c3e2921b211a3988ef28ba2d2f0a2.tar.gz
src-31461aa2f18c3e2921b211a3988ef28ba2d2f0a2.zip
Include files missed in 329051.
Notes
Notes: svn path=/head/; revision=329052
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck_ffs/fsck.h1
-rw-r--r--sbin/fsck_ffs/globs.c1
-rw-r--r--sbin/fsck_ffs/main.c42
3 files changed, 43 insertions, 1 deletions
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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#define IN_RTLD /* So we pickup the P_OSREL defines */
#include <sys/param.h>
#include <sys/file.h>
#include <sys/mount.h>
@@ -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.