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 --- src/update.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/update.c') 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