From c9c32fafa054ac5817262eb2a17cab3d6c64973a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 19 Jul 2004 16:28:19 +0000 Subject: add support for xattr omit git-svn-id: file:///home/lennart/svn/public/syrep/trunk@59 07ea20a6-d2c5-0310-9e02-9ef735347d72 --- configure.ac | 14 ++++++++++++++ src/update.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) 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 #include +#ifdef USE_XATTR +#include +#include +#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; -- cgit