freebsd-dev/sys/geom/label
Kirk McKusick b21582ee03 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
2022-07-30 22:51:38 -07:00
..
g_label_disk_ident.c geom: clean up empty lines in .c and .h files 2020-09-01 22:14:09 +00:00
g_label_ext2fs.c g_label: Handle small sector sizes when tasting 2021-09-07 11:19:29 -04:00
g_label_flashmap.c geom_label: Make glabel labels more trivial by separating the tasting 2020-07-26 00:44:59 +00:00
g_label_gpt.c geom_label: Make glabel labels more trivial by separating the tasting 2020-07-26 00:44:59 +00:00
g_label_iso9660.c g_label: Handle small sector sizes when tasting 2021-09-07 11:19:29 -04:00
g_label_msdosfs.c geom label msdosfs: sanity check BPB before using it for io request 2022-01-08 05:41:44 +02:00
g_label_msdosfs.h
g_label_ntfs.c geom_label: Add more validation for NTFS volume tasting 2021-10-04 18:15:06 -04:00
g_label_reiserfs.c g_label: Handle small sector sizes when tasting 2021-09-07 11:19:29 -04:00
g_label_ufs.c Add a flags parameter to the ffs_sbget() function that reads UFS superblocks. 2022-07-30 22:51:38 -07:00
g_label.c glabel: Set G_CF_DIRECT_SEND/RECEIVE for taste consumer. 2022-01-28 14:22:41 -05:00
g_label.h geom_label: Make glabel labels more trivial by separating the tasting 2020-07-26 00:44:59 +00:00