summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS7
-rw-r--r--src/metaentry.c15
-rw-r--r--src/metastore.c29
-rw-r--r--src/metastore.h8
4 files changed, 57 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 65bce94..f8a38a8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+Latest stuff
+------------------------------------------------------------------------
+
+ * Support building with no extended attributes support when NO_XATTR
+ macro is predefined to non-0 value (e.g. put -DNO_XATTR in CFLAGS).
+
+
v1.1.2 (2018-01-06)
------------------------------------------------------------------------
diff --git a/src/metaentry.c b/src/metaentry.c
index 65992f5..6c5bc84 100644
--- a/src/metaentry.c
+++ b/src/metaentry.c
@@ -25,7 +25,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <sys/xattr.h>
+
+#if !defined(NO_XATTR) || !NO_XATTR
+# include <sys/xattr.h>
+#endif /* !NO_XATTR */
+
#include <limits.h>
#include <dirent.h>
#include <sys/mman.h>
@@ -48,6 +52,7 @@
# define PATH_MAX 4096
#endif
+#if !defined(NO_XATTR) || !NO_XATTR
/* Free's a metaentry and all its parameters */
static void
mentry_free(struct metaentry *m)
@@ -72,6 +77,7 @@ mentry_free(struct metaentry *m)
free(m);
}
+#endif /* !NO_XATTR */
/* Allocates an empty metahash table */
static struct metahash *
@@ -189,12 +195,16 @@ mentries_print(const struct metahash *mhash)
struct metaentry *
mentry_create(const char *path)
{
+#if !defined(NO_XATTR) || !NO_XATTR
ssize_t lsize, vsize;
char *list, *attr;
+#endif /* !NO_XATTR */
struct stat sbuf;
struct passwd *pbuf;
struct group *gbuf;
+#if !defined(NO_XATTR) || !NO_XATTR
int i;
+#endif /* !NO_XATTR */
struct metaentry *mentry;
if (lstat(path, &sbuf)) {
@@ -230,6 +240,7 @@ mentry_create(const char *path)
if (S_ISLNK(mentry->mode))
return mentry;
+#if !defined(NO_XATTR) || !NO_XATTR
lsize = listxattr(path, NULL, 0);
if (lsize < 0) {
/* Perhaps the FS doesn't support xattrs? */
@@ -299,6 +310,8 @@ mentry_create(const char *path)
}
free(list);
+#endif /* !NO_XATTR */
+
return mentry;
}
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 <sys/stat.h>
#include <getopt.h>
#include <utime.h>
-#include <sys/xattr.h>
+
+#if !defined(NO_XATTR) || !NO_XATTR
+# include <sys/xattr.h>
+#endif /* !NO_XATTR */
+
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -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);
}
diff --git a/src/metastore.h b/src/metastore.h
index e5584ab..bedad6c 100644
--- a/src/metastore.h
+++ b/src/metastore.h
@@ -42,4 +42,12 @@
#define ACTIONS_READING 0x07
#define ACTIONS_WRITING 0x70
+/* Possible build defines */
+#ifndef NO_XATTR
+# define NO_XATTR 0
+#endif /* NO_XATTR */
+
+/* Messages */
+#define NO_XATTR_MSG "no XATTR support"
+
#endif /* METASTORE_H */