summaryrefslogtreecommitdiffstats
path: root/daemon/realpath.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-02-01 12:18:35 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-02-02 10:23:03 +0000
commit59bb4bf3b4fbe2dd284b8be06b4738974238fac9 (patch)
tree7313b5d264ef50e66d44c8efc5f01d147a4d50bd /daemon/realpath.c
parent81b9aed9c312aaf844fc14321b6c504d106542c5 (diff)
downloadlibguestfs-59bb4bf3b4fbe2dd284b8be06b4738974238fac9.tar.gz
libguestfs-59bb4bf3b4fbe2dd284b8be06b4738974238fac9.tar.xz
libguestfs-59bb4bf3b4fbe2dd284b8be06b4738974238fac9.zip
Clarify the error message when unavailable functions are called (RHBZ#679737).
Callers are supposed to use the availability API to check for functions that may not be available in particular builds of libguestfs. If they don't do this, currently they tend to get obscure error messages, eg: libguestfs: error: zerofree: /dev/vda1: zerofree: No such file or directory This commit changes the error message to explain what callers ought to be doing instead: libguestfs: error: zerofree: feature 'zerofree' is not available in this build of libguestfs. Read 'AVAILABILITY' in the guestfs(3) man page for how to check for the availability of features. This patch makes the stubs check for availability. The stub code changes to: static void zerofree_stub (XDR *xdr_in) { [...] /* The caller should have checked before calling this. */ if (! optgroup_zerofree_available ()) { reply_with_error ("feature '%s' is not available in this\n" "build of libguestfs. Read 'AVAILABILITY' in the guestfs(3) man page for\n" "how to check for the availability of features.", "zerofree"); goto done; } [...] (cherry picked from commit 330fbea5b2d6bd7db84f7ea7afe87cf1bcd438e0)
Diffstat (limited to 'daemon/realpath.c')
-rw-r--r--daemon/realpath.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/daemon/realpath.c b/daemon/realpath.c
index 8ec96743..126ef193 100644
--- a/daemon/realpath.c
+++ b/daemon/realpath.c
@@ -36,20 +36,17 @@
#define NAME_MAX FILENAME_MAX
#endif
+#ifdef HAVE_REALPATH
+
int
optgroup_realpath_available (void)
{
-#ifdef HAVE_REALPATH
return 1;
-#else
- return 0;
-#endif
}
char *
do_realpath (const char *path)
{
-#ifdef HAVE_REALPATH
char *ret;
CHROOT_IN;
@@ -61,11 +58,24 @@ do_realpath (const char *path)
}
return ret; /* caller frees */
-#else
- NOT_AVAILABLE (NULL);
-#endif
}
+#else /* !HAVE_REALPATH */
+
+int
+optgroup_realpath_available (void)
+{
+ return 0;
+}
+
+char *
+do_realpath (const char *path)
+{
+ abort ();
+}
+
+#endif /* !HAVE_REALPATH */
+
static int find_path_element (int fd_cwd, char *name, size_t *name_len_ret);
char *