From patchwork Thu Apr 25 04:56:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 63340 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B4C8927BBE2; Thu, 25 Apr 2024 05:59:20 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 45A5727BBEA for ; Thu, 25 Apr 2024 05:59:19 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzrCG-0007yP-Fw; Thu, 25 Apr 2024 00:59:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzrCC-0007y3-QF for guix-patches@gnu.org; Thu, 25 Apr 2024 00:58:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzrCA-0004uP-WB for guix-patches@gnu.org; Thu, 25 Apr 2024 00:58:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzrCR-0000Do-Dn for guix-patches@gnu.org; Thu, 25 Apr 2024 00:59:11 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70542] [PATCH v2 2/3] file-systems: Add host-to-ip nested function Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 25 Apr 2024 04:59:10 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70542 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70542@debbugs.gnu.org Cc: Richard Sent Received: via spool by 70542-submit@debbugs.gnu.org id=B70542.1714021120506 (code B ref 70542); Thu, 25 Apr 2024 04:59:10 +0000 Received: (at 70542) by debbugs.gnu.org; 25 Apr 2024 04:58:40 +0000 Received: from localhost ([127.0.0.1]:60333 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzrBo-00006D-V8 for submit@debbugs.gnu.org; Thu, 25 Apr 2024 00:58:38 -0400 Received: from mail-108-mta14.mxroute.com ([136.175.108.14]:36599) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzrBH-0008Rq-SL for 70542@debbugs.gnu.org; Thu, 25 Apr 2024 00:58:02 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta14.mxroute.com (ZoneMTA) with ESMTPSA id 18f139dc8f00008ca2.001 for <70542@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 25 Apr 2024 04:57:38 +0000 X-Zone-Loop: 082bd6afa2b500dc65feda76776b6484c3bb71293a4b X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yasHRBpWaIqbi/HgdOUj3gkXs98JDrHEX8axByTcj9g=; b=Zc9q9gTJVpcneADfENiWf4LmOb gukNlHmvcKTCeYaLVbR0yYNh+l/MvyNC72ZsRZ5hkP+SNI1vWzf8NxakQboG5pPwgXHzOVrSVrs4a yZ27+wrfGONDJL5k9ix3VQTSVM47tfF6/uVQRg1vSPVFus047l12g2VMj1W9M0Uf3XWRP92pIN1/c e7Ohw9NhSI2hFrxAyYV6wk/2XEPhpVvX2Cu+XLemq/PoKrTVxe8feKIvwlv7LBmH6Mominei9dRTJ YYyb9wk5pGJVo+pfV8pTAIOebhaFx+oOOOnfqofQMkRJkeAAO3/0hYwAM1y5S0XYiDLMrhcjgk57F v2IJX1BA==; From: Richard Sent Date: Thu, 25 Apr 2024 00:56:04 -0400 Message-ID: In-Reply-To: <784e7f59e64d7d8c29f7e0207f5d15727cdd8ba2.1714020965.git.richard@freakingpenguin.com> References: <784e7f59e64d7d8c29f7e0207f5d15727cdd8ba2.1714020965.git.richard@freakingpenguin.com> MIME-Version: 1.0 X-Authenticated-Id: richard@freakingpenguin.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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 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 "/"