syscalls: Add 'setxattr'.
* guix/build/syscalls.scm (setxattr): New procedure. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
		
							parent
							
								
									e792dd3244
								
							
						
					
					
						commit
						d155c9d934
					
				
					 1 changed files with 18 additions and 0 deletions
				
			
		| 
						 | 
					@ -79,6 +79,7 @@
 | 
				
			||||||
            fdatasync
 | 
					            fdatasync
 | 
				
			||||||
            pivot-root
 | 
					            pivot-root
 | 
				
			||||||
            scandir*
 | 
					            scandir*
 | 
				
			||||||
 | 
					            setxattr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            fcntl-flock
 | 
					            fcntl-flock
 | 
				
			||||||
            lock-file
 | 
					            lock-file
 | 
				
			||||||
| 
						 | 
					@ -723,6 +724,23 @@ backend device."
 | 
				
			||||||
             (list (strerror err))
 | 
					             (list (strerror err))
 | 
				
			||||||
             (list 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.
 | 
					;;; Random.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue