Branch data Line data Source code
1 : : #include "xattr.h"
2 : :
3 : : #include <errno.h>
4 : : #include <unistd.h>
5 : : #include <string.h>
6 : : #include <features.h>
7 : : #include <sys/xattr.h>
8 : :
9 : : #ifndef ENOATTR
10 : : # define ENOATTR ENODATA /* No such attribute */
11 : : #endif
12 : :
13 : : int
14 : 0 : xattr_get(int fd, const char *name, void *value, size_t size)
15 : : {
16 [ # # ]: 0 : if (fgetxattr(fd, name, value, size) == -1) {
17 [ # # ]: 0 : if ((errno == ENOATTR) || (errno == ENOTSUP)) {
18 : 0 : memset(value, 0, size);
19 : 0 : return 0;
20 : : }
21 : 0 : return -errno;
22 : : }
23 : :
24 : : return 0;
25 : : }
26 : :
27 : : int
28 : 0 : xattr_set(int fd, const char *name, const void *value, size_t size)
29 : : {
30 [ # # ]: 0 : if (fsetxattr(fd, name, value, size, 0) == -1)
31 : 0 : return -errno;
32 : : return 0;
33 : : }
|