GNU bug report logs - #44507
[PATCH 0/3] Create "dev.cpio" for Heads.

Previous Next

Package: guix-patches;

Reported by: Danny Milosavljevic <dannym <at> scratchpost.org>

Date: Sat, 7 Nov 2020 20:48:02 UTC

Severity: normal

Tags: patch

Done: Danny Milosavljevic <dannym <at> scratchpost.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 44507 in the body.
You can then email your comments to 44507 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#44507; Package guix-patches. (Sat, 07 Nov 2020 20:48:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Danny Milosavljevic <dannym <at> scratchpost.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 07 Nov 2020 20:48:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: guix-patches <at> gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 0/3] Create "dev.cpio" for Heads.
Date: Sat,  7 Nov 2020 21:47:18 +0100
This patch series dynamically creates "dev.cpio" for Heads instead of
carrying it as a binary blob.

Danny Milosavljevic (3):
  linux-initrd: Handle 'block-special and 'char-special cpio headers as
    well.
  linux-initrd: Add special-file->cpio-header*
  gnu: Add heads-dev-cpio.

 gnu/packages/heads.scm | 34 ++++++++++++++++++++++++++++++++++
 guix/cpio.scm          | 33 ++++++++++++++++++++++++++++++---
 2 files changed, 64 insertions(+), 3 deletions(-)





Information forwarded to guix-patches <at> gnu.org:
bug#44507; Package guix-patches. (Sat, 07 Nov 2020 21:28:01 GMT) Full text and rfc822 format available.

Message #8 received at 44507 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 44507 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 1/3] linux-initrd: Handle 'block-special and 'char-special
 cpio headers as well.
Date: Sat,  7 Nov 2020 22:27:31 +0100
* guix/cpio.scm (make-cpio-header): Handle size correctly for all file types.
(mode->type): Add 'block-special, 'char-special.
---
 guix/cpio.scm | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/guix/cpio.scm b/guix/cpio.scm
index e4692e2e9c..5d38573971 100644
--- a/guix/cpio.scm
+++ b/guix/cpio.scm
@@ -132,9 +132,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 +147,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)))))
 
@@ -233,6 +236,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")))
 




Information forwarded to guix-patches <at> gnu.org:
bug#44507; Package guix-patches. (Sat, 07 Nov 2020 21:28:02 GMT) Full text and rfc822 format available.

Message #11 received at 44507 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 44507 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 2/3] linux-initrd: Add special-file->cpio-header*
Date: Sat,  7 Nov 2020 22:27:32 +0100
* guix/cpio.scm (special-file->cpio-header*): New public procedure.
---
 guix/cpio.scm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

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!!!")
 




Information forwarded to guix-patches <at> gnu.org:
bug#44507; Package guix-patches. (Sat, 07 Nov 2020 21:28:02 GMT) Full text and rfc822 format available.

Message #14 received at 44507 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 44507 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 3/3] gnu: Add heads-dev-cpio.
Date: Sat,  7 Nov 2020 22:27:33 +0100
* gnu/packages/heads.scm (heads-dev-cpio): New variable.
---
 gnu/packages/heads.scm | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/gnu/packages/heads.scm b/gnu/packages/heads.scm
index b28433431c..d7e90471a2 100644
--- a/gnu/packages/heads.scm
+++ b/gnu/packages/heads.scm
@@ -19,6 +19,7 @@
 (define-module (gnu packages heads)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix git-download)
@@ -161,3 +162,36 @@ done
     (synopsis "Musl-cross gcc 5 toolchain")
     (description "Musl-cross toolchain: binutils, gcc 5 and musl.")
     (license license:isc))))
+
+;; This package provides a "dev.cpio" file usable as a base for booting Heads.
+(define-public heads-dev-cpio
+  (package
+    (name "heads-dev-cpio")
+    (version "0.1")
+    (source #f)
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils)
+                  (guix cpio))
+       #:builder (begin
+                   (use-modules (guix build utils)
+                                (guix cpio)
+                                (srfi srfi-26))
+                   (mkdir-p "dev") ; input directory.
+                   (let* ((out (assoc-ref %outputs "out"))
+                          (libexec (string-append out "/libexec")))
+                     (mkdir-p libexec)
+                     (call-with-output-file (string-append libexec "/dev.cpio")
+                      (lambda (port)
+                        (write-cpio-archive '("dev" "dev/console") port
+                         #:file->header
+                         (lambda (name)
+                           (if (string=? "dev/console" name)
+                               (special-file->cpio-header* name 'char-special 5 1 #o600)
+                               (file->cpio-header* name))))))
+                     #t))))
+    (synopsis "\"dev.cpio\" for Heads")
+    (description "This package provides a \"dev.cpio\" file usable as a base for
+heads' initrd.")
+    (home-page "http://osresearch.net/")
+    (license license:bsd-2)))




Reply sent to Danny Milosavljevic <dannym <at> scratchpost.org>:
You have taken responsibility. (Sun, 22 Nov 2020 10:08:02 GMT) Full text and rfc822 format available.

Notification sent to Danny Milosavljevic <dannym <at> scratchpost.org>:
bug acknowledged by developer. (Sun, 22 Nov 2020 10:08:02 GMT) Full text and rfc822 format available.

Message #19 received at 44507-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 44507-done <at> debbugs.gnu.org
Subject: Re: [PATCH 0/3] Create "dev.cpio" for Heads.
Date: Sun, 22 Nov 2020 11:07:47 +0100
[Message part 1 (text/plain, inline)]
Pushed dev.cpio generator to guix master as these commits:

* b1dfc64552265d66e60d11c2a1b6f4da549cd495
* 8e7c98963f7e51b2ee9fd140f1aa59cf0f762a60
* d82f227291699e4bea655fbac23620576702667b
[Message part 2 (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 20 Dec 2020 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 184 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.