aboutsummaryrefslogtreecommitdiff
path: root/lib/libufs/type.c
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2022-07-31 05:44:01 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2022-07-31 05:51:38 +0000
commitb21582ee03ec1394e08173e276df311979856e54 (patch)
tree8943e21f5b9c1d044aa3f72ff4a2310594d3e8ea /lib/libufs/type.c
parentdc9e68ad0187bdfe4781256a6c4751e074e1e2a2 (diff)
downloadsrc-b21582ee03ec1394e08173e276df311979856e54.tar.gz
src-b21582ee03ec1394e08173e276df311979856e54.zip
Add a flags parameter to the ffs_sbget() function that reads UFS superblocks.
Rather than trying to shoehorn flags into the requested superblock address, create a separate flags parameter to the ffs_sbget() function in sys/ufs/ffs/ffs_subr.c. The ffs_sbget() function is used both in the kernel and in user-level utilities through export to the sbget() function in the libufs(3) library (see sbget(3) for details). The kernel uses ffs_sbget() when mounting UFS filesystems, in the glabel(8) and gjournal(8) GEOM utilities, and in the standalone library used when booting the system from a UFS root filesystem. The ffs_sbget() function reads the superblock located at the byte offset specified by its sblockloc parameter. The value UFS_STDSB may be specified for sblockloc to request that the standard location for the superblock be read. The two existing options are now flags: UFS_NOHASHFAIL will note if the check hash is wrong but will still return the superblock. This is used by the bootstrap code to give the system a chance to come up so that fsck can be run to correct the problem. UFS_NOMSG indicates that superblock inconsistency error messages should not be printed. It is used by programs like fsck that want to print their own error message and programs like glabel(8) that just want to know if a UFS filesystem exists on a partition. One additional flag is added: UFS_NOCSUM causes only the superblock itself to be returned, but does not read in any auxiliary data structures like the cylinder group summary information. It is used by clients like glabel(8) that just want to check for possible filesystem types. Using UFS_NOCSUM skips the superblock checks for csum data which allows superblocks that have corrupted csum data to be read and used. The validate_sblock() function checks that the superblock has not been corrupted in a way that can crash or hang the system. Unless the UFS_NOMSG flag is specified, it will print out any errors that it finds. Prior to this commit, validate_sblock() returned as soon as it found an inconsistency so would print at most one message. It now does all its checks so when UFS_NOMSG has not been specified will print out everything that it finds inconsistent. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'lib/libufs/type.c')
-rw-r--r--lib/libufs/type.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libufs/type.c b/lib/libufs/type.c
index ac5b8d17e84c..80b26cdb9c84 100644
--- a/lib/libufs/type.c
+++ b/lib/libufs/type.c
@@ -168,7 +168,8 @@ again: if ((ret = stat(name, &st)) < 0) {
disk->d_ufs = 0;
disk->d_error = NULL;
disk->d_si = NULL;
- disk->d_sblockloc = STDSB;
+ disk->d_sblockloc = UFS_STDSB;
+ disk->d_lookupflags = 0;
if (oname != name) {
name = strdup(name);