diff options
Diffstat (limited to 'src/update.c')
-rw-r--r-- | src/update.c | 42 |
1 files changed, 42 insertions, 0 deletions
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; |