From 39c5a5e929efc7c3b89a4e316dfd02b1734848d6 Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Mon, 19 Feb 2018 00:34:14 +0100 Subject: Support building with no extended attributes support. Support building with no extended attributes support when NO_XATTR macro is predefined to non-0 value (e.g. put -DNO_XATTR in CFLAGS). --- src/metastore.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/metastore.c') diff --git a/src/metastore.c b/src/metastore.c index ada41c4..9f01a8c 100644 --- a/src/metastore.c +++ b/src/metastore.c @@ -25,7 +25,11 @@ #include #include #include -#include + +#if !defined(NO_XATTR) || !NO_XATTR +# include +#endif /* !NO_XATTR */ + #include #include #include @@ -122,6 +126,11 @@ compare_print(struct metaentry *real, struct metaentry *stored, int cmp) if (cmp & DIFF_XATTR) msg(MSG_QUIET, "xattr "); msg(MSG_QUIET, "\n"); + + if (NO_XATTR && cmp & DIFF_XATTR) { + msg(MSG_WARNING, "%s:\txattr difference may be bogus: %s\n", + real->path, NO_XATTR_MSG); + } } /* @@ -235,9 +244,16 @@ compare_fix(struct metaentry *real, struct metaentry *stored, int cmp) msg(MSG_NORMAL, "%s:\tremoving xattr %s\n", real->path, real->xattr_names[i]); + if (NO_XATTR) { + msg(MSG_WARNING, "%s:\tremoving xattr %s failed: %s\n", + real->path, real->xattr_names[i], NO_XATTR_MSG); + } +#if !defined(NO_XATTR) || !NO_XATTR + else if (lremovexattr(real->path, real->xattr_names[i])) msg(MSG_DEBUG, "\tlremovexattr failed: %s\n", strerror(errno)); +#endif /* !NO_XATTR */ } for (i = 0; i < stored->xattrs; i++) { @@ -247,12 +263,19 @@ compare_fix(struct metaentry *real, struct metaentry *stored, int cmp) msg(MSG_NORMAL, "%s:\tadding xattr %s\n", stored->path, stored->xattr_names[i]); + if (NO_XATTR) { + msg(MSG_WARNING, "%s:\tadding xattr %s failed: %s\n", + stored->path, stored->xattr_names[i], NO_XATTR_MSG); + } +#if !defined(NO_XATTR) || !NO_XATTR + else if (lsetxattr(stored->path, stored->xattr_names[i], stored->xattr_values[i], stored->xattr_lvalues[i], XATTR_CREATE) ) msg(MSG_DEBUG, "\tlsetxattr failed: %s\n", strerror(errno)); +#endif /* !NO_XATTR */ } } } @@ -401,6 +424,10 @@ version(void) { printf("metastore %s\n", METASTORE_VER); + if (NO_XATTR) { + printf("Built with %s.\n", NO_XATTR_MSG); + } + exit(EXIT_SUCCESS); } -- cgit v1.2.1