66 lines
2.3 KiB
Diff
66 lines
2.3 KiB
Diff
From 74d5818d42a1e09e6f6f1dccda8254fb8b2c6d57 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Tue, 2 Aug 2022 12:38:57 +0100
|
|
Subject: [PATCH 3/3] info: Improve error message when the export may be
|
|
unknown to the server
|
|
|
|
For example:
|
|
|
|
$ nbdkit -r file dir=/var/tmp/disks --run 'nbdinfo $uri'
|
|
nbdkit: file[1]: error: open: : No such file or directory
|
|
nbdkit: file[1]: error: open: : No such file or directory
|
|
nbdinfo: nbd_opt_go: server replied with error to opt_go request: No such file or directory for export:
|
|
|
|
What happened here is we requested the default export (because the
|
|
nbdkit-provided $uri points to that). nbdkit-file-plugin doesn't
|
|
provide a default export so that's an error.
|
|
|
|
However the error message is weird and unactionable. We print the
|
|
default export name, but as that is an empty string we end up printing
|
|
"for export: ". And we don't tell the user what they can do to
|
|
recover from this.
|
|
|
|
After this commit the message has been improved:
|
|
|
|
$ nbdkit -r file dir=/var/tmp/disks --run 'nbdinfo $uri '
|
|
nbdkit: file[1]: error: open: : No such file or directory
|
|
nbdkit: file[1]: error: open: : No such file or directory
|
|
nbdinfo: nbd_opt_go: server replied with error to opt_go request: No such file or directory for the default export
|
|
nbdinfo: suggestion: to list all exports on the server, use --list
|
|
|
|
We now print "default export" if we spot that the default export was
|
|
requested, and we print an actionable suggestion.
|
|
---
|
|
info/show.c | 12 +++++++++++-
|
|
1 file changed, 11 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/info/show.c b/info/show.c
|
|
index 140220d8c6..df647f3d56 100644
|
|
--- a/info/show.c
|
|
+++ b/info/show.c
|
|
@@ -71,10 +71,20 @@ show_one_export (struct nbd_handle *nbd, const char *desc,
|
|
fprintf (stderr, "%s: %s", progname, nbd_get_error ());
|
|
|
|
char *e = nbd_get_export_name (nbd);
|
|
- if (e) fprintf (stderr, " for export: %s", e);
|
|
+ if (e) {
|
|
+ if (e[0] == '\0')
|
|
+ fprintf (stderr, " for the default export");
|
|
+ else
|
|
+ fprintf (stderr, " for export: %s", e);
|
|
+ }
|
|
free (e);
|
|
fprintf (stderr, "\n");
|
|
|
|
+ if (!list_all)
|
|
+ fprintf (stderr, "%s: suggestion: "
|
|
+ "to list all exports on the server, use --list\n",
|
|
+ progname);
|
|
+
|
|
return false;
|
|
}
|
|
size = nbd_get_size (nbd);
|
|
--
|
|
2.37.0.rc2
|
|
|