aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/linux/generic/sys-xattr.cpp
blob: c8d598f39519543d5ad5ca894df0cfbce09e6bd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <errno.h>
#include <sys/xattr.h>

#include <mlibc/linux-sysdeps.hpp>
#include <bits/ensure.h>

int setxattr(const char *path, const char *name, const void *val, size_t size,
		int flags) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_setxattr, -1);

	if (int e = sysdep(path, name, val, size, flags); e) {
		errno = e;
		return -1;
	}
	return 0;
}

int lsetxattr(const char *path, const char *name, const void *val, size_t size,
		int flags) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_lsetxattr, -1);

	if (int e = sysdep(path, name, val, size, flags); e) {
		errno = e;
		return -1;
	}
	return 0;
}

int fsetxattr(int fd, const char *name, const void *val, size_t size,
		int flags) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_fsetxattr, -1);

	if (int e = sysdep(fd, name, val, size, flags); e) {
		errno = e;
		return -1;
	}
	return 0;
}

ssize_t getxattr(const char *path, const char *name, void *val, size_t size) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_getxattr, -1);

	ssize_t nread;
	if (int e = sysdep(path, name, val, size, &nread); e) {
		errno = e;
		return -1;
	}

	return nread;
}

ssize_t lgetxattr(const char *path, const char *name, void *val, size_t size) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_lgetxattr, -1);

	ssize_t nread;
	if (int e = sysdep(path, name, val, size, &nread); e) {
		errno = e;
		return -1;
	}

	return nread;
}

ssize_t fgetxattr(int fd, const char *name, void *val, size_t size) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_fgetxattr, -1);

	ssize_t nread;
	if (int e = sysdep(fd, name, val, size, &nread); e) {
		errno = e;
		return -1;
	}

	return nread;
}

int removexattr(const char *path, const char *name) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_removexattr, -1);
	return sysdep(path, name);
}

int lremovexattr(const char *path, const char *name) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_lremovexattr, -1);
	return sysdep(path, name);
}

int fremovexattr(int fd, const char *name) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_fremovexattr, -1);
	return sysdep(fd, name);
}

ssize_t listxattr(const char *path, char *list, size_t size) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_listxattr, -1);

	ssize_t nread;
	if (int e = sysdep(path, list, size, &nread); e) {
		errno = e;
		return -1;
	}
	return nread;
}

ssize_t llistxattr(const char *path, char *list, size_t size) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_llistxattr, -1);

	ssize_t nread;
	if (int e = sysdep(path, list, size, &nread); e) {
		errno = e;
		return -1;
	}
	return nread;
}

ssize_t flistxattr(int fd, char *list, size_t size) {
	auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_flistxattr, -1);

	ssize_t nread;
	if (int e = sysdep(fd, list, size, &nread); e) {
		errno = e;
		return -1;
	}
	return nread;
}