summary refs log tree commit diff
diff options
context:
space:
mode:
authorJan (janneke) Nieuwenhuizen <janneke@gnu.org>2020-05-13 22:49:54 +0200
committerJan Nieuwenhuizen <janneke@gnu.org>2020-05-13 23:26:06 +0200
commitd155c9d93496ae620829fbc33b5694e74cda9683 (patch)
tree80d2642ca3f7c94acd8214f2ef8979437bedb5a3
parente792dd3244621579b25d146b6fe9cdbac60a222c (diff)
downloadguix-d155c9d93496ae620829fbc33b5694e74cda9683.tar.gz
syscalls: Add 'setxattr'.
* guix/build/syscalls.scm (setxattr): New procedure.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--guix/build/syscalls.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 4ee2b97e76..3bb4545c04 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -79,6 +79,7 @@
             fdatasync
             pivot-root
             scandir*
+            setxattr
 
             fcntl-flock
             lock-file
@@ -723,6 +724,23 @@ backend device."
              (list (strerror err))
              (list err))))))
 
+(define setxattr
+  (let ((proc (syscall->procedure int "setxattr"
+                                  `(* * * ,size_t ,int))))
+    (lambda* (file key value #:optional (flags 0))
+      "Set extended attribute KEY to VALUE on FILE."
+      (let*-values (((bv) (string->utf8 value))
+                    ((ret err)
+                     (proc (string->pointer/utf-8 file)
+                           (string->pointer key)
+                           (bytevector->pointer bv)
+                           (bytevector-length bv)
+                           flags)))
+        (unless (zero? ret)
+          (throw 'system-error "setxattr" "~S: ~A"
+                 (list file key value (strerror err))
+                 (list err)))))))
+
 
 ;;;
 ;;; Random.