aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/linux/generic/sys-xattr.cpp
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:00 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 17:28:32 -0500
commitbd5969fc876a10b18613302db7087ef3c40f18e1 (patch)
tree7c2b8619afe902abf99570df2873fbdf40a4d1a1 /lib/mlibc/options/linux/generic/sys-xattr.cpp
parenta95b38b1b92b172e6cc4e8e56a88a30cc65907b0 (diff)
lib: Add mlibc
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/options/linux/generic/sys-xattr.cpp')
-rw-r--r--lib/mlibc/options/linux/generic/sys-xattr.cpp122
1 files changed, 122 insertions, 0 deletions
diff --git a/lib/mlibc/options/linux/generic/sys-xattr.cpp b/lib/mlibc/options/linux/generic/sys-xattr.cpp
new file mode 100644
index 0000000..c8d598f
--- /dev/null
+++ b/lib/mlibc/options/linux/generic/sys-xattr.cpp
@@ -0,0 +1,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;
+}