diff options
author | Christopher Baines <mail@cbaines.net> | 2020-11-29 14:19:55 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-11-29 17:34:18 +0000 |
commit | ff01206345e2306cc633db48e0b29eab9077091a (patch) | |
tree | 25c7ee17005dadc9bf4fae3f0873e03a4704f782 /guix/cpio.scm | |
parent | ed2545f0fa0e2ad99d5a0c45f532c539b299b9fb (diff) | |
parent | 7c2e67400ffaef8eb6f30ef7126c976ee3d7e36c (diff) | |
download | guix-patches-ff01206345e2306cc633db48e0b29eab9077091a.tar guix-patches-ff01206345e2306cc633db48e0b29eab9077091a.tar.gz |
Merge remote-tracking branch 'origin/master' into core-updates
Diffstat (limited to 'guix/cpio.scm')
-rw-r--r-- | guix/cpio.scm | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/guix/cpio.scm b/guix/cpio.scm index e4692e2e9c..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 @@ -132,9 +133,10 @@ (%make-cpio-header MAGIC inode mode uid gid nlink mtime - (if (= C_ISDIR (logand mode C_FMT)) - 0 - size) + (if (or (= C_ISLNK (logand mode C_FMT)) + (= C_ISREG (logand mode C_FMT))) + size + 0) major minor rmajor rminor (+ name-size 1) ;include trailing zero 0))) ;checksum @@ -146,6 +148,8 @@ denotes, similar to 'stat:type'." (cond ((= C_ISREG fmt) 'regular) ((= C_ISDIR fmt) 'directory) ((= C_ISLNK fmt) 'symlink) + ((= C_ISBLK fmt) 'block-special) + ((= C_ISCHR fmt) 'char-special) (else (error "unsupported file type" mode))))) @@ -187,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!!!") @@ -233,6 +256,10 @@ produces with the '-H newc' option." (put-string port target))) ((directory) #t) + ((block-special) + #t) + ((char-special) + #t) (else (error "file type not supported"))) |