From: ludo@gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 22050@debbugs.gnu.org
Subject: bug#22050: [PATCH v4 1/2] linux-boot: Add make-static-device-nodes.
Date: Fri, 15 Dec 2017 10:41:37 +0100 [thread overview]
Message-ID: <87374cmipa.fsf@gnu.org> (raw)
In-Reply-To: <20171214195636.787-2-dannym@scratchpost.org> (Danny Milosavljevic's message of "Thu, 14 Dec 2017 20:56:35 +0100")
Hi Danny,
Danny Milosavljevic <dannym@scratchpost.org> skribis:
> * gnu/build/linux-boot.scm (make-static-device-nodes): New variable.
> <device-node>: New variable.
> parse-static-nodes-from-devname-file: New variable.
> not-slash: New variable.
> report-system-error: New variable.
> catch-system-error: New variable.
> create-device-node: New variable.
Nitpick: please adjust the syntax.
> +(define-record-type <device-node>
> + (device-node name type major minor module)
Please add a one-line comment above like:
;; Representation of a /dev node.
> +(define (parse-static-nodes-from-devname-file devname-name)
> + (call-with-input-file devname-name
> + (lambda (input-file)
It would be more idiomatic to take an input port, rather than a file
name. Also I’d suggest ‘read-static-device-nodes’, with a docstring:
(define (read-static-device-nodes port)
"Read from PORT a list of <device-node> written in the format used
by /lib/modules/*/*.devname files."
…)
> + (let loop ((line (read-line input-file)))
> + (if (eof-object? line)
> + '()
> + (match (string-split line #\space)
> + (("#" _ ...)
> + (loop (read-line input-file)))
To make sure all comments are handled, change this clause to:
(((? (cut string-prefix? "#" <>)) _ ...)
(loop (read-line input-line)))
> +(define (report-system-error name . args)
> + (let ((errno (system-error-errno args)))
> + (format (current-error-port) "could not create '~a': ~a~%" name
> + (strerror errno))))
Align “(format” with the ‘e’ of ‘let’. :-)
> +(define create-device-node
Please add a comment saying what it does.
> + (match-lambda
> + (($ <device-node> name type major minor module)
> + (let ((name-parts (string-tokenize name not-slash)))
> + (let loop ((prefix "/dev")
> + (name-parts name-parts))
> + (match name-parts
> + ((leaf)
> + (let ((prefix (string-append prefix "/" leaf)))
> + (catch-system-error prefix
> + (mknod prefix type #o600 (device-number major minor)))))
> + ((prefix-addition tails ...)
> + (let ((prefix (string-append prefix "/" prefix-addition)))
> + (unless (file-exists? prefix)
> + (mkdir prefix #o755))
> + (loop prefix tails)))))))))
This looks good, but would it be enough to do:
(mkdir-p (dirname (string-append "/dev/" name)))
?
> +(define* (make-static-device-nodes linux-module-directory)
Docstring please. :-) IMO it’s important also to mention why those
nodes need to be created by hand.
Thank you!
Ludo’.
next prev parent reply other threads:[~2017-12-15 9:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 11:36 bug#22050: fuse.ko not automatically loaded on GuixSD Ludovic Courtès
2017-12-13 22:04 ` bug#22050: [PATCH 0/2] Create static device nodes before starting udev Danny Milosavljevic
2017-12-13 22:05 ` bug#22050: [PATCH 1/2] linux-boot: Add make-static-device-nodes Danny Milosavljevic
2017-12-13 22:05 ` bug#22050: [PATCH 2/2] services: base: Use make-static-device-nodes Danny Milosavljevic
2017-12-13 22:17 ` bug#22050: [PATCH v2 0/2] Create static device nodes before starting udev Danny Milosavljevic
2017-12-13 22:17 ` bug#22050: [PATCH v2 1/2] linux-boot: Add make-static-device-nodes Danny Milosavljevic
2017-12-13 22:17 ` bug#22050: [PATCH v2 2/2] services: base: Use make-static-device-nodes Danny Milosavljevic
2017-12-13 22:32 ` bug#22050: [PATCH v3 0/2] Create static device nodes before starting udev Danny Milosavljevic
2017-12-13 22:32 ` bug#22050: [PATCH v3 1/2] linux-boot: Add make-static-device-nodes Danny Milosavljevic
2017-12-14 8:52 ` Ludovic Courtès
2017-12-14 10:32 ` Danny Milosavljevic
2017-12-14 13:14 ` Ludovic Courtès
2017-12-14 18:21 ` Danny Milosavljevic
2017-12-13 22:32 ` bug#22050: [PATCH v3 2/2] services: base: Use make-static-device-nodes Danny Milosavljevic
2017-12-14 19:56 ` bug#22050: [PATCH v4 0/2] Create static device nodes before starting udev Danny Milosavljevic
2017-12-14 19:56 ` bug#22050: [PATCH v4 1/2] linux-boot: Add make-static-device-nodes Danny Milosavljevic
2017-12-15 9:41 ` Ludovic Courtès [this message]
2017-12-15 17:27 ` Danny Milosavljevic
2017-12-15 22:37 ` Ludovic Courtès
2017-12-14 19:56 ` bug#22050: [PATCH v4 2/2] services: base: Use make-static-device-nodes Danny Milosavljevic
2017-12-14 21:25 ` bug#22050: [PATCH v5 0/2] Create static device nodes before starting udev Danny Milosavljevic
2017-12-14 21:25 ` bug#22050: [PATCH v5 1/2] linux-boot: Add make-static-device-nodes Danny Milosavljevic
2017-12-14 21:25 ` bug#22050: [PATCH v5 2/2] services: base: Use make-static-device-nodes Danny Milosavljevic
2017-12-15 9:44 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87374cmipa.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=22050@debbugs.gnu.org \
--cc=dannym@scratchpost.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.