summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-07-19 16:28:19 +0000
committerLennart Poettering <lennart@poettering.net>2004-07-19 16:28:19 +0000
commitc9c32fafa054ac5817262eb2a17cab3d6c64973a (patch)
tree585ba0acdd82f21275521a42dbb1c4eb8a2de023
parenta952692561d8b1c59d4a384812b52d7225953bb3 (diff)
add support for xattr omit
git-svn-id: file:///home/lennart/svn/public/syrep/trunk@59 07ea20a6-d2c5-0310-9e02-9ef735347d72
-rw-r--r--configure.ac14
-rw-r--r--src/update.c42
2 files changed, 56 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index d389f31..cb69d1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,9 @@ AC_CHECK_HEADER([sys/sendfile.h], sendfile=yes, sendfile=no)
if test "x$sendfile" = xyes ; then
AC_CHECK_LIB([c], [sendfile], sendfile=yes, sendfile=no)
+fi
+
+if test "x$sendfile" = xyes ; then
AC_DEFINE([USE_SENDFILE], [1], [Use sendfile()])
fi
@@ -79,6 +82,17 @@ else
AC_DEFINE([ARCH_IS_BIG_ENDIAN], [0], [Big Endian machine])
fi
+# Check for XATTR
+AC_CHECK_HEADER([attr/xattr.h], xattr=yes, xattr=no)
+
+if test "x$xattr" = xyes ; then
+ AC_CHECK_LIB([attr], [getxattr], xattr=yes, xattr=no)
+fi
+
+if test "x$xattr" = xyes ; then
+ AC_DEFINE([USE_XATTR], [1], [Use extended attributes])
+fi
+
# 64 Bit LFS support
AC_SYS_LARGEFILE
diff --git a/src/update.c b/src/update.c
index 4fe6758..5cc176e 100644
--- a/src/update.c
+++ b/src/update.c
@@ -29,12 +29,21 @@
#include <assert.h>
#include <time.h>
+#ifdef USE_XATTR
+#include <sys/types.h>
+#include <attr/xattr.h>
+#endif
+
#include "update.h"
#include "dbstruct.h"
#include "util.h"
#include "dbutil.h"
#include "md5util.h"
+#ifdef USE_XATTR
+#define XATTR_NAME "user.syrep"
+#endif
+
static int dbput(DB* db, const void *k, int klen, const void*d, int dlen, int f) {
DBT key, data;
int ret;
@@ -143,6 +152,28 @@ static int handle_file(struct syrep_db_context *c, uint32_t version, const char
return write_entry(c, &name, md, &meta);
}
+#ifdef USE_XATTR
+
+static int xattr_omit(const char *p) {
+ char t[256];
+ ssize_t l;
+
+ if ((l = getxattr(p, XATTR_NAME, t, sizeof(t)-1)) < 0)
+ return 0;
+
+ t[l] = 0;
+ if (strcmp(t, "omit") == 0)
+ return 1;
+
+ if (t[0] == 0)
+ return 0;
+
+ fprintf(stderr, "Invalid extended attribute '%s:%s' for file '%s'\n", XATTR_NAME, t, p);
+ return -1;
+}
+
+#endif
+
static int iterate_dir(struct syrep_db_context *c, struct syrep_md_cache *cache, uint32_t version, const char *root) {
int r = -1;
DIR *dir;
@@ -178,6 +209,17 @@ static int iterate_dir(struct syrep_db_context *c, struct syrep_md_cache *cache,
continue;
}
+#ifdef USE_XATTR
+ {
+ int omit;
+ if ((omit = xattr_omit(p)) < 0)
+ goto finish;
+
+ if (omit == 1)
+ continue;
+ }
+#endif
+
if (S_ISDIR(st.st_mode)) {
if (iterate_dir(c, cache, version, p) < 0)
goto finish;