[Libguestfs] [PATCH] inspection: Set last errno to ENOTSUP when inspection APIs are not available.

Richard W.M. Jones rjones at redhat.com
Mon Mar 19 16:46:47 UTC 2012


From: "Richard W.M. Jones" <rjones at redhat.com>

Previously there was no programmatic way to tell if inspection APIs
were unavailable because they are not compiled in (because hivex isn't
around).  This contrasts with daemon APIs where the availability is
covered by the guestfs_available API.

Change the inspection APIs so that when they are not available, the
last errno is set to ENOTSUP.  (Note that ENOTSUP must be defined on
all POSIX platforms).

This allows programs to detect if they are using a version of
libguestfs that was compiled without support for inspection, without
having to parse error messages.
---
 src/inspect.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/inspect.c b/src/inspect.c
index 60c7dd4..117f57a 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -542,7 +542,7 @@ guestfs__inspect_get_hostname (guestfs_h *g, const char *root)
 /* XXX These functions should be in an optgroup. */
 
 #define NOT_IMPL(r)                                                     \
-  error (g, _("inspection API not available since this version of libguestfs was compiled without the hivex library")); \
+  guestfs_error_errno (g, ENOTSUP, _("inspection API not available since this version of libguestfs was compiled without the hivex library")); \
   return r
 
 char **
-- 
1.7.9.1




More information about the Libguestfs mailing list