From: "Ludovic Courtès" <ludo@gnu.org>
To: "Jan \(janneke\) Nieuwenhuizen" <janneke@gnu.org>
Cc: 41855@debbugs.gnu.org
Subject: bug#41855: [PATCH 1/2] hurd-boot: Create individual translators instead of running MAKEDEV.
Date: Mon, 15 Jun 2020 21:54:52 +0200 [thread overview]
Message-ID: <87imfsyuib.fsf@gnu.org> (raw)
In-Reply-To: <20200614165649.3496-1-janneke@gnu.org> (Jan Nieuwenhuizen's message of "Sun, 14 Jun 2020 18:56:48 +0200")
Hi!
"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:
> * gnu/build/hurd-boot.scm (make-hurd-device-nodes): Do not create
> dev/{null,zero,full,random,urandom} mount points.
> (setup-translator, xattr-translator,
> showtrans-translator?, translated?, set-hurd-device-translators): New
> procedures.
> (boot-hurd-system): Use them instead of running MAKEDEV.
This is mostly about moving the logic from the MAKEDEV script to this
file, right? Sounds nice.
> +(define (xattr-translator? file-name)
> + "Return true if FILE-NAME has an extended @code{gnu.translator} attribute
> +set."
> + (false-if-exception
> + (not (string-null? (getxattr file-name "gnu.translator")))))
I’d call it ‘passive-translator-xattr?’.
In general, I’d avoid ‘false-if-exception’ as much as possible because
it can hide real issues. So here, you could catch 'system-error and
check for ENODATA. If you need it in several places, you can define a
‘false-if-ENODATA’ macro
> +(define (showtrans-translator? file-name)
> + "Return true if @file{showtrans} finds a translator installed on FILE-NAME."
Should be ‘passive-translator-installed?’ no? (IIRC ‘showtrans’ only
shows passive translator settings by default.)
> + (with-output-to-port (%make-void-port "w")
> + (lambda _
> + (with-error-to-port (%make-void-port "w")
> + (lambda _
> + (zero? (system* "showtrans" "--silent" file-name)))))))
> +
> +(define (translated? file-name)
> + "Return true if a translator is installed on FILE-NAME."
> + (if (string-contains %host-type "linux-gnu")
> + (xattr-translator? file-name)
> + (showtrans-translator? file-name)))
It’s counter-intuitive that hurd-boot.scm is used from GNU/Linux.
Should we move the shared bits in (gnu build hurd) or similar?
> +(define* (setup-translator file-name command #:optional (mode #o600))
> + "Setup translator COMMAND on FILE-NAME."
‘set-translator’? :-)
> + (false-if-exception (mkdir-p (scope "dev/vcs/1")))
> + (false-if-exception (mkdir-p (scope "dev/vcs/2")))
> + (false-if-exception (mkdir-p (scope "dev/vcs/3")))
> + (false-if-exception (rename-file "/dev/console" "/dev/console-"))
> + (for-each scope-setup-translator devices)
> +
> + (false-if-exception (symlink "/dev/random" "/dev/urandom"))
> + (false-if-exception (mkdir-p "/dev/fd"))
> + (false-if-exception (symlink "/dev/fd/0" "/dev/stdin"))
> + (false-if-exception (symlink "/dev/fd/1" "/dev/stdout"))
> + (false-if-exception (symlink "/dev/fd/2" "/dev/stderr")))
‘false-if-EEXIST’?
Thanks!
Ludo’.
prev parent reply other threads:[~2020-06-15 19:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-14 16:54 bug#41855: [PATCH 0/2] hurd-boot: Cleanups: Remove MAKEDEV, then use setxattr (on the Hurd) Jan (janneke) Nieuwenhuizen
2020-06-14 16:56 ` bug#41855: [PATCH 1/2] hurd-boot: Create individual translators instead of running MAKEDEV Jan (janneke) Nieuwenhuizen
2020-06-14 16:56 ` bug#41855: [PATCH 2/2] hurd-boot: Use 'setxattr' instead of invoking settrans Jan (janneke) Nieuwenhuizen
2020-06-15 20:00 ` Ludovic Courtès
2020-06-15 19:54 ` Ludovic Courtès [this message]
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87imfsyuib.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=41855@debbugs.gnu.org \
--cc=janneke@gnu.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 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).