summaryrefslogtreecommitdiff
path: root/src/cmd/setxattr.c
diff options
context:
space:
mode:
authordzwdz2024-08-18 23:06:26 +0200
committerdzwdz2024-08-18 23:06:26 +0200
commit8b4a2d50de67b746bcc472bd46c55d83eff668fc (patch)
tree21bcf9814b07bc54e7705f4e9ae93528d627e838 /src/cmd/setxattr.c
parent446acde84c7f244792bf412996678254ee296356 (diff)
kernel: basic _sys_setxattr implementationHEADmain
Diffstat (limited to 'src/cmd/setxattr.c')
-rw-r--r--src/cmd/setxattr.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cmd/setxattr.c b/src/cmd/setxattr.c
new file mode 100644
index 0000000..c2e422e
--- /dev/null
+++ b/src/cmd/setxattr.c
@@ -0,0 +1,23 @@
+#include <camellia.h>
+#include <camellia/syscalls.h>
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ if (argc != 4) {
+ fprintf(stderr, "usage: setxattr file key value\n");
+ return 1;
+ }
+ hid_t h = camellia_open(argv[1], OPEN_WRITE);
+ if (h < 0) err(1, "open");
+
+ ssize_t ret = _sys_setxattr(h, argv[2], argv[3], strlen(argv[3]), 0);
+ if (ret < 0) {
+ errno = -ret;
+ err(1, "setxattr");
+ }
+}