diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-02-01 12:18:35 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-02-01 15:09:09 +0000 |
commit | 330fbea5b2d6bd7db84f7ea7afe87cf1bcd438e0 (patch) | |
tree | 5a1c1de5498303ace3de64f771ccba949f202df0 /daemon/xattr.c | |
parent | 90d6386c13edcb479113889bbd3cedf83c2e6277 (diff) | |
download | libguestfs-330fbea5b2d6bd7db84f7ea7afe87cf1bcd438e0.tar.gz libguestfs-330fbea5b2d6bd7db84f7ea7afe87cf1bcd438e0.tar.xz libguestfs-330fbea5b2d6bd7db84f7ea7afe87cf1bcd438e0.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;
}
[...]
Diffstat (limited to 'daemon/xattr.c')
-rw-r--r-- | daemon/xattr.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/daemon/xattr.c b/daemon/xattr.c index 24457488..92d0cf18 100644 --- a/daemon/xattr.c +++ b/daemon/xattr.c @@ -511,6 +511,11 @@ do_lgetxattr (const char *path, const char *name, size_t *size_r) } #else /* no xattr.h */ + +/* Note that the wrapper code (daemon/stubs.c) ensures that the + * functions below are never called because + * optgroup_linuxxattrs_available returns false. + */ int optgroup_linuxxattrs_available (void) { @@ -520,55 +525,55 @@ optgroup_linuxxattrs_available (void) guestfs_int_xattr_list * do_getxattrs (const char *path) { - NOT_AVAILABLE (NULL); + abort (); } guestfs_int_xattr_list * do_lgetxattrs (const char *path) { - NOT_AVAILABLE (NULL); + abort (); } int do_setxattr (const char *xattr, const char *val, int vallen, const char *path) { - NOT_AVAILABLE (-1); + abort (); } int do_lsetxattr (const char *xattr, const char *val, int vallen, const char *path) { - NOT_AVAILABLE (-1); + abort (); } int do_removexattr (const char *xattr, const char *path) { - NOT_AVAILABLE (-1); + abort (); } int do_lremovexattr (const char *xattr, const char *path) { - NOT_AVAILABLE (-1); + abort (); } guestfs_int_xattr_list * do_lxattrlist (const char *path, char *const *names) { - NOT_AVAILABLE (NULL); + abort (); } char * do_getxattr (const char *path, const char *name, size_t *size_r) { - NOT_AVAILABLE (NULL); + abort (); } char * do_lgetxattr (const char *path, const char *name, size_t *size_r) { - NOT_AVAILABLE (NULL); + abort (); } #endif /* no xattr.h */ |