aboutsummaryrefslogtreecommitdiff
path: root/tools/diag
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2022-08-13 19:41:53 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2022-08-13 19:43:40 +0000
commite68866164212d62b8158e93f09bd29554428eef0 (patch)
treeddd9bf4f9f7d26f0783e6343335d9bb89b5b3887 /tools/diag
parent88951aaaee73b87121b0f121224fe188a5b5e6e3 (diff)
downloadsrc-e68866164212d62b8158e93f09bd29554428eef0.tar.gz
src-e68866164212d62b8158e93f09bd29554428eef0.zip
Move the ability to search for alternate UFS superblocks from fsck_ffs(8)
into ffs_sbsearch() to allow use by other parts of the system. Historically only fsck_ffs(8), the UFS filesystem checker, had code to track down and use alternate UFS superblocks. Since fsdb(8) used much of the fsck_ffs(8) implementation it had some ability to track down alternate superblocks. This change extracts the code to track down alternate superblocks from fsck_ffs(8) and puts it into a new function ffs_sbsearch() in sys/ufs/ffs/ffs_subr.c. Like ffs_sbget() and ffs_sbput() also found in ffs_subr.c, these functions can be used directly by the kernel subsystems. Additionally they are exported to the UFS library, libufs(8) so that they can be used by user-level programs. The new functions added to libufs(8) are sbfind(3) that is an alternative to sbread(3) and sbsearch(3) that is an alternative to sbget(3). See their manual pages for further details. The utilities that have been changed to search for superblocks are dumpfs(8), fsdb(8), ffsinfo(8), and fsck_ffs(8). Also, the prtblknos(8) tool found in tools/diag/prtblknos searches for superblocks. The UFS specific mount code uses the superblock search interface when mounting the root filesystem and when the administrator doing a mount(8) command specifies the force flag (-f). The standalone UFS boot code (found in stand/libsa/ufs.c) uses the superblock search code in the hope of being able to get the system up and running so that fsck_ffs(8) can be used to get the filesystem cleaned up. The following utilities have not been changed to search for superblocks: clri(8), tunefs(8), snapinfo(8), fstyp(8), quot(8), dump(8), fsirand(8), growfs(8), quotacheck(8), gjournal(8), and glabel(8). When these utilities fail, they do report the cause of the failure. The one exception is the tasting code used to try and figure what a given disk contains. The tasting code will remain silent so as not to put out a slew of messages as it trying to taste every new mass storage device that shows up. Reviewed by: kib Reviewed by: Warner Losh Tested by: Peter Holm Differential Revision: https://reviews.freebsd.org/D36053 Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'tools/diag')
-rw-r--r--tools/diag/prtblknos/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/diag/prtblknos/main.c b/tools/diag/prtblknos/main.c
index 25a717760922..65efa786b700 100644
--- a/tools/diag/prtblknos/main.c
+++ b/tools/diag/prtblknos/main.c
@@ -56,7 +56,6 @@ main(argc, argv)
char ibuf[64];
char *fsname, *filename;
ino_t inonum;
- int error;
filename = NULL;
if (argc == 2) {
@@ -83,7 +82,8 @@ main(argc, argv)
fsname = *++argv;
/* get the superblock. */
- if ((error = ufs_disk_fillout(&disk, fsname)) < 0)
+ if (ufs_disk_fillout_blank(&disk, fsname) == -1 ||
+ sbfind(&disk, 0) == -1)
err(1, "Cannot access file system superblock on %s", fsname);
fs = (struct fs *)&disk.d_sb;
@@ -99,7 +99,7 @@ main(argc, argv)
(void)printf("%s (inode #%jd): ", filename,
(intmax_t)inonum);
- if ((error = getinode(&disk, &dp, inonum)) < 0)
+ if (getinode(&disk, &dp, inonum) < 0)
warn("Read of inode %jd on %s failed: %s",
(intmax_t)inonum, fsname, disk.d_error);