diff options
author | Przemyslaw Pawelczyk <przemoc@gmail.com> | 2018-02-19 00:34:14 +0100 |
---|---|---|
committer | Przemyslaw Pawelczyk <przemoc@gmail.com> | 2018-02-19 00:34:14 +0100 |
commit | 39c5a5e929efc7c3b89a4e316dfd02b1734848d6 (patch) | |
tree | e0094043968d09e981678702555c9da70f37c290 /src/metaentry.c | |
parent | 04df7fcc6d0f75bdf14fd87bcac9d609188e8675 (diff) |
Support building with no extended attributes support.
Support building with no extended attributes support when NO_XATTR
macro is predefined to non-0 value (e.g. put -DNO_XATTR in CFLAGS).
Diffstat (limited to 'src/metaentry.c')
-rw-r--r-- | src/metaentry.c | 15 |
1 files changed, 14 insertions, 1 deletions
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; } |