git: 588f03ec9b9e - main - bectl: Improve error message when ZFS root is not found.

From: Andrew Gallatin <gallatin_at_FreeBSD.org>
Date: Fri, 31 Mar 2023 14:37:31 UTC
The branch main has been updated by gallatin:

URL: https://cgit.FreeBSD.org/src/commit/?id=588f03ec9b9ebd3c17b3e978140ff3f3e4bcad73

commit 588f03ec9b9ebd3c17b3e978140ff3f3e4bcad73
Author:     Andrew Gallatin <gallatin@FreeBSD.org>
AuthorDate: 2023-03-30 21:57:26 +0000
Commit:     Andrew Gallatin <gallatin@FreeBSD.org>
CommitDate: 2023-03-31 14:27:38 +0000

    bectl: Improve error message when ZFS root is not found.
    
    When recovering a system that is unbootable due to some
    problem with the active BE, it is likely you'll be booted
    from a rescue image running UFS.  In this case, bectl
    needs help finding the zpool root that you want to operate
    on.  In this case, improve the error message to suggest
    specifying a root, rather than just emitting a generic
    error message that might imply, to the naive user, that
    there is a ZFS compatibility issue between the rescue
    image and the on-disk ZFS pool.
    
    Reviewed by: imp, kevans
    Sponsored by: Netflix
    Differential Revision:  https://reviews.freebsd.org/D39346
---
 sbin/bectl/bectl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c
index 2b7af4e55419..814b98ba8a8a 100644
--- a/sbin/bectl/bectl.c
+++ b/sbin/bectl/bectl.c
@@ -584,9 +584,13 @@ main(int argc, char *argv[])
 	}
 
 	if ((be = libbe_init(root)) == NULL) {
-		if (!cmd->silent)
+		if (!cmd->silent) {
 			fprintf(stderr, "libbe_init(\"%s\") failed.\n",
 			    root != NULL ? root : "");
+			if (root == NULL)
+				fprintf(stderr,
+				    "Try specifying ZFS root using -r.\n");
+		}
 		return (-1);
 	}