if (!(ref_name = virSecurityGetRefCountAttrName(name)))
goto cleanup;
- if (virFileGetXAttr(path, ref_name, &value) < 0) {
+ if (virFileGetXAttrQuiet(path, ref_name, &value) < 0) {
if (errno == ENOSYS || errno == ENODATA || errno == ENOTSUP) {
ret = 0;
} else {
if (!(ref_name = virSecurityGetRefCountAttrName(name)))
goto cleanup;
- if (virFileGetXAttr(path, ref_name, &value) < 0) {
+ if (virFileGetXAttrQuiet(path, ref_name, &value) < 0) {
if (errno == ENOSYS || errno == ENOTSUP) {
ret = 0;
goto cleanup;
#if HAVE_LIBATTR
/**
- * virFileGetXAttr;
+ * virFileGetXAttrQuiet;
* @path: a filename
* @name: name of xattr
* @value: read value
* -1 otherwise (with errno set).
*/
int
-virFileGetXAttr(const char *path,
- const char *name,
- char **value)
+virFileGetXAttrQuiet(const char *path,
+ const char *name,
+ char **value)
{
char *buf = NULL;
int ret = -1;
#else /* !HAVE_LIBATTR */
int
-virFileGetXAttr(const char *path ATTRIBUTE_UNUSED,
- const char *name ATTRIBUTE_UNUSED,
- char **value ATTRIBUTE_UNUSED)
+virFileGetXAttrQuiet(const char *path ATTRIBUTE_UNUSED,
+ const char *name ATTRIBUTE_UNUSED,
+ char **value ATTRIBUTE_UNUSED)
{
errno = ENOSYS;
return -1;
}
#endif /* HAVE_LIBATTR */
+
+/**
+ * virFileGetXAttr;
+ * @path: a filename
+ * @name: name of xattr
+ * @value: read value
+ *
+ * Reads xattr with @name for given @path and stores it into
+ * @value. Caller is responsible for freeing @value.
+ *
+ * Returns: 0 on success,
+ * -1 otherwise (with errno set AND error reported).
+ */
+int
+virFileGetXAttr(const char *path,
+ const char *name,
+ char **value)
+{
+ int ret;
+
+ if ((ret = virFileGetXAttrQuiet(path, name, value)) < 0) {
+ virReportSystemError(errno,
+ _("Unable to get XATTR %s on %s"),
+ name, path);
+ }
+
+ return ret;
+}