unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#44507] [PATCH 0/3] Create "dev.cpio" for Heads.
@ 2020-11-07 20:47 Danny Milosavljevic
  2020-11-07 21:27 ` [bug#44507] [PATCH 1/3] linux-initrd: Handle 'block-special and 'char-special cpio headers as well Danny Milosavljevic
  2020-11-22 10:07 ` bug#44507: [PATCH 0/3] Create "dev.cpio" for Heads Danny Milosavljevic
  0 siblings, 2 replies; 5+ messages in thread
From: Danny Milosavljevic @ 2020-11-07 20:47 UTC (permalink / raw)
  To: 44507; +Cc: Danny Milosavljevic

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(-)





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#44507] [PATCH 1/3] linux-initrd: Handle 'block-special and 'char-special cpio headers as well.
  2020-11-07 20:47 [bug#44507] [PATCH 0/3] Create "dev.cpio" for Heads Danny Milosavljevic
@ 2020-11-07 21:27 ` Danny Milosavljevic
  2020-11-07 21:27   ` [bug#44507] [PATCH 2/3] linux-initrd: Add special-file->cpio-header* Danny Milosavljevic
  2020-11-07 21:27   ` [bug#44507] [PATCH 3/3] gnu: Add heads-dev-cpio Danny Milosavljevic
  2020-11-22 10:07 ` bug#44507: [PATCH 0/3] Create "dev.cpio" for Heads Danny Milosavljevic
  1 sibling, 2 replies; 5+ messages in thread
From: Danny Milosavljevic @ 2020-11-07 21:27 UTC (permalink / raw)
  To: 44507; +Cc: Danny Milosavljevic

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




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#44507] [PATCH 2/3] linux-initrd: Add special-file->cpio-header*
  2020-11-07 21:27 ` [bug#44507] [PATCH 1/3] linux-initrd: Handle 'block-special and 'char-special cpio headers as well Danny Milosavljevic
@ 2020-11-07 21:27   ` Danny Milosavljevic
  2020-11-07 21:27   ` [bug#44507] [PATCH 3/3] gnu: Add heads-dev-cpio Danny Milosavljevic
  1 sibling, 0 replies; 5+ messages in thread
From: Danny Milosavljevic @ 2020-11-07 21:27 UTC (permalink / raw)
  To: 44507; +Cc: Danny Milosavljevic

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




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#44507] [PATCH 3/3] gnu: Add heads-dev-cpio.
  2020-11-07 21:27 ` [bug#44507] [PATCH 1/3] linux-initrd: Handle 'block-special and 'char-special cpio headers as well Danny Milosavljevic
  2020-11-07 21:27   ` [bug#44507] [PATCH 2/3] linux-initrd: Add special-file->cpio-header* Danny Milosavljevic
@ 2020-11-07 21:27   ` Danny Milosavljevic
  1 sibling, 0 replies; 5+ messages in thread
From: Danny Milosavljevic @ 2020-11-07 21:27 UTC (permalink / raw)
  To: 44507; +Cc: Danny Milosavljevic

* 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)))




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#44507: [PATCH 0/3] Create "dev.cpio" for Heads.
  2020-11-07 20:47 [bug#44507] [PATCH 0/3] Create "dev.cpio" for Heads Danny Milosavljevic
  2020-11-07 21:27 ` [bug#44507] [PATCH 1/3] linux-initrd: Handle 'block-special and 'char-special cpio headers as well Danny Milosavljevic
@ 2020-11-22 10:07 ` Danny Milosavljevic
  1 sibling, 0 replies; 5+ messages in thread
From: Danny Milosavljevic @ 2020-11-22 10:07 UTC (permalink / raw)
  To: 44507-done

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

Pushed dev.cpio generator to guix master as these commits:

* b1dfc64552265d66e60d11c2a1b6f4da549cd495
* 8e7c98963f7e51b2ee9fd140f1aa59cf0f762a60
* d82f227291699e4bea655fbac23620576702667b

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-22 10:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-07 20:47 [bug#44507] [PATCH 0/3] Create "dev.cpio" for Heads Danny Milosavljevic
2020-11-07 21:27 ` [bug#44507] [PATCH 1/3] linux-initrd: Handle 'block-special and 'char-special cpio headers as well Danny Milosavljevic
2020-11-07 21:27   ` [bug#44507] [PATCH 2/3] linux-initrd: Add special-file->cpio-header* Danny Milosavljevic
2020-11-07 21:27   ` [bug#44507] [PATCH 3/3] gnu: Add heads-dev-cpio Danny Milosavljevic
2020-11-22 10:07 ` bug#44507: [PATCH 0/3] Create "dev.cpio" for Heads Danny Milosavljevic

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).