git: 6d645da0d49d - main - stand: Search less agressively for UFS super block

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 18 Aug 2022 12:41:56 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d645da0d49decc0352f27b8b5ff1983c611659d

commit 6d645da0d49decc0352f27b8b5ff1983c611659d
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-08-18 12:40:24 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-08-18 12:41:11 +0000

    stand: Search less agressively for UFS super block
    
    The boot loader should look in the standard places for the UFS
    superblock, but not go too far into the speculative realm. Supress
    errors about hash being invalid, which will allow us to boot, even when
    the superblock looks good, but fails the hash test. This defers any
    policy decisions about booting and/or recovery to userland. This also
    has the side effect of eliminating some rather spammy messages when UFS
    searches devices with filesystems that are not UFS...
    
    Sponsored by:           Netflix
    Reviewed by:            mckusick
    Differential Revision:  https://reviews.freebsd.org/D36253
---
 stand/libsa/ufs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/stand/libsa/ufs.c b/stand/libsa/ufs.c
index 65cda349879a..769fe9120ee6 100644
--- a/stand/libsa/ufs.c
+++ b/stand/libsa/ufs.c
@@ -151,6 +151,9 @@ static int	search_directory(char *, struct open_file *, ino_t *);
 static int	ufs_use_sa_read(void *, off_t, void **, int);
 
 /* from ffs_subr.c */
+int	ffs_sbget(void *devfd, struct fs **fsp, off_t sblock, int flags,
+	    char *filltype,
+	    int (*readfunc)(void *devfd, off_t loc, void **bufp, int size));
 int	ffs_sbsearch(void *, struct fs **, int, char *,
 	    int (*)(void *, off_t, void **, int));
 
@@ -529,8 +532,8 @@ ufs_open(const char *upath, struct open_file *f)
 	if (mnt == NULL) {
 		/* read super block */
 		twiddle(1);
-		if ((rc = ffs_sbsearch(f, &fs, 0, "stand", ufs_use_sa_read))
-		    != 0) {
+		if ((rc = ffs_sbget(f, &fs, UFS_STDSB, UFS_NOHASHFAIL, "stand",
+		    ufs_use_sa_read)) != 0) {
 			goto out;
 		}
 	} else {