unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Sent <richard@freakingpenguin.com>
To: 70542@debbugs.gnu.org
Cc: Richard Sent <richard@freakingpenguin.com>
Subject: [bug#70542] [PATCH v2 2/3] file-systems: Add host-to-ip nested function
Date: Thu, 25 Apr 2024 00:56:04 -0400	[thread overview]
Message-ID: <b550045a4446747cba63342d8e12a1c1a0bdccd8.1714020965.git.richard@freakingpenguin.com> (raw)
In-Reply-To: <784e7f59e64d7d8c29f7e0207f5d15727cdd8ba2.1714020965.git.richard@freakingpenguin.com>

* gnu/build/file-systems (mount-file-system): Split out getaddrinfo logic into a
dedicated function, (host-to-ip)

Change-Id: I522d70a10651ca79533a4fc60b96b884243a3526
---
 gnu/build/file-systems.scm | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 78d779f398..e47ac39ab0 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -1156,6 +1156,14 @@ (define* (mount-file-system fs #:key (root "/root")
                             (repair (file-system-repair fs)))
   "Mount the file system described by FS, a <file-system> object, under ROOT."
 
+  (define* (host-to-ip host #:optional service)
+    "Return the IP address for host, which may be an IP address or a hostname."
+    (let* ((aa (match (getaddrinfo host service) ((x . _) x)))
+           (sa (addrinfo:addr aa))
+           (inet-addr (inet-ntop (sockaddr:fam sa)
+                                 (sockaddr:addr sa))))
+      inet-addr))
+
   (define (mount-nfs source mount-point type flags options)
     (let* ((idx (string-rindex source #\:))
            (host-part (string-take source idx))
@@ -1163,11 +1171,7 @@ (define* (mount-file-system fs #:key (root "/root")
            (host (match (string-split host-part (string->char-set "[]"))
                  (("" h "") h)
                  ((h) h)))
-           (aa (match (getaddrinfo host "nfs") ((x . _) x)))
-           (sa (addrinfo:addr aa))
-           (inet-addr (inet-ntop (sockaddr:fam sa)
-                                 (sockaddr:addr sa))))
-
+           (inet-addr (host-to-ip host "nfs")))
       ;; Mounting an NFS file system requires passing the address
       ;; of the server in the addr= option
       (mount source mount-point type flags
@@ -1176,6 +1180,7 @@ (define* (mount-file-system fs #:key (root "/root")
                             (if options
                                 (string-append "," options)
                                 "")))))
+
   (let* ((type    (file-system-type fs))
          (source  (canonicalize-device-spec (file-system-device fs)))
          (target  (string-append root "/"
-- 
2.41.0





  reply	other threads:[~2024-04-25  4:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 20:44 [bug#70542] [PATCH 0/4] Improve Shepherd service support for networked file systems Richard Sent
2024-04-23 20:47 ` [bug#70542] [PATCH 1/4] file-systems: Add requirements field to file-systems Richard Sent
2024-04-24 17:31   ` Liliana Marie Prikler
2024-04-23 20:47 ` [bug#70542] [PATCH 2/4] services: base: Use requirements to delay some file-systems Richard Sent
2024-04-24 17:30   ` Liliana Marie Prikler
2024-04-23 20:47 ` [bug#70542] [PATCH 3/4] file-systems: Add support for mounting CIFS file systems Richard Sent
2024-04-24 17:29   ` Liliana Marie Prikler
2024-04-24 18:22     ` Richard Sent
2024-04-24 18:47       ` Liliana Marie Prikler
2024-04-24 19:19         ` Richard Sent
2024-04-23 20:47 ` [bug#70542] [PATCH 4/4] system: Do not check for CIFS file system availability Richard Sent
2024-04-24 17:26   ` Liliana Marie Prikler
2024-04-23 20:51 ` [bug#70542] Missing reference in cover letter Richard Sent
2024-04-25  4:56 ` [bug#70542] [PATCH v2 1/3] services: base: Add optional delayed mount of file-systems Richard Sent
2024-04-25  4:56   ` Richard Sent [this message]
2024-04-25  4:56   ` [bug#70542] [PATCH v2 3/3] file-systems: Add support for mounting CIFS file systems Richard Sent
2024-04-25  6:51 ` [bug#70542] [PATCH 0/4] Improve Shepherd service support for networked " Jonathan Brielmaier via Guix-patches via
2024-04-25 13:43   ` Richard Sent
2024-06-01 23:26 ` [bug#70542] [PATCH v3 0/3] " Richard Sent
2024-06-01 23:26   ` [bug#70542] [PATCH v3 1/3] services: base: Add optional delayed mount of file-systems Richard Sent
2024-06-01 23:26   ` [bug#70542] [PATCH v3 2/3] file-systems: Add host-to-ip nested function Richard Sent
2024-06-01 23:26   ` [bug#70542] [PATCH v3 3/3] file-systems: Add support for mounting CIFS file systems Richard Sent
2024-06-04 10:06   ` bug#70542: [PATCH v3 0/3] Improve Shepherd service support for networked " 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

  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=b550045a4446747cba63342d8e12a1c1a0bdccd8.1714020965.git.richard@freakingpenguin.com \
    --to=richard@freakingpenguin.com \
    --cc=70542@debbugs.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).