summary refs log tree commit diff
path: root/guix/cpio.scm
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@scratchpost.org>2020-11-07 22:27:32 +0100
committerDanny Milosavljevic <dannym@scratchpost.org>2020-11-22 11:03:31 +0100
commit8e7c98963f7e51b2ee9fd140f1aa59cf0f762a60 (patch)
tree95c1b41bd94afae72f51558eb86e8730b093a384 /guix/cpio.scm
parentb1dfc64552265d66e60d11c2a1b6f4da549cd495 (diff)
downloadguix-8e7c98963f7e51b2ee9fd140f1aa59cf0f762a60.tar.gz
linux-initrd: Add special-file->cpio-header*.
* guix/cpio.scm (special-file->cpio-header*): New public procedure.
Diffstat (limited to 'guix/cpio.scm')
-rw-r--r--guix/cpio.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/guix/cpio.scm b/guix/cpio.scm
index 5d38573971..c9932f5bf9 100644
--- a/guix/cpio.scm
+++ b/guix/cpio.scm
@@ -27,6 +27,7 @@
             make-cpio-header
             file->cpio-header
             file->cpio-header*
+            special-file->cpio-header*
             write-cpio-header
             read-cpio-header
 
@@ -190,6 +191,25 @@ produced in a deterministic fashion."
                       #:size (stat:size st)
                       #:name-size (string-length file-name))))
 
+(define* (special-file->cpio-header* file
+                                     device-type
+                                     device-major
+                                     device-minor
+                                     permission-bits
+                                     #:optional (file-name file))
+  "Create a character or block device header.
+
+DEVICE-TYPE is either 'char-special or 'block-special.
+
+The number of hard links is assumed to be 1."
+  (make-cpio-header #:mode (logior (match device-type
+                                    ('block-special C_ISBLK)
+                                    ('char-special C_ISCHR))
+                                    permission-bits)
+                    #:nlink 1
+                    #:rdev (device-number device-major device-minor)
+                    #:name-size (string-length file-name)))
+
 (define %trailer
   "TRAILER!!!")