From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#22050: [PATCH v4 1/2] linux-boot: Add make-static-device-nodes. Date: Fri, 15 Dec 2017 10:41:37 +0100 Message-ID: <87374cmipa.fsf@gnu.org> References: <20171213223240.605-1-dannym@scratchpost.org> <20171214195636.787-1-dannym@scratchpost.org> <20171214195636.787-2-dannym@scratchpost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePmVJ-0004xV-7m for bug-guix@gnu.org; Fri, 15 Dec 2017 04:42:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePmVG-0003tD-4P for bug-guix@gnu.org; Fri, 15 Dec 2017 04:42:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:54177) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePmVG-0003sk-0n for bug-guix@gnu.org; Fri, 15 Dec 2017 04:42:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ePmVF-0003G7-R3 for bug-guix@gnu.org; Fri, 15 Dec 2017 04:42:01 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <20171214195636.787-2-dannym@scratchpost.org> (Danny Milosavljevic's message of "Thu, 14 Dec 2017 20:56:35 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Danny Milosavljevic Cc: 22050@debbugs.gnu.org Hi Danny, Danny Milosavljevic skribis: > * gnu/build/linux-boot.scm (make-static-device-nodes): New variable. > : 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 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=E2=80=99d suggest =E2=80=98read-static-device-nodes=E2=80=99,= with a docstring: (define (read-static-device-nodes port) "Read from PORT a list of written in the format used by /lib/modules/*/*.devname files." =E2=80=A6) > + (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 =E2=80=9C(format=E2=80=9D with the =E2=80=98e=E2=80=99 of =E2=80=98le= t=E2=80=99. :-) > +(define create-device-node Please add a comment saying what it does. > + (match-lambda > + (($ 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=E2=80=99s important also to mention why those nodes need to be created by hand. Thank you! Ludo=E2=80=99.