From patchwork Thu Apr 25 04:56:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 63338 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 96C7F27BBE2; Thu, 25 Apr 2024 05:58:27 +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=unavailable 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 C880027BBE9 for ; Thu, 25 Apr 2024 05:58:25 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzrBK-0007ly-B8; Thu, 25 Apr 2024 00:58:02 -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 1rzrB6-0007j5-Va for guix-patches@gnu.org; Thu, 25 Apr 2024 00:57:50 -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 1rzrB6-0004cl-Mz for guix-patches@gnu.org; Thu, 25 Apr 2024 00:57:48 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzrBN-0008Sn-Sj for guix-patches@gnu.org; Thu, 25 Apr 2024 00:58:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70542] [PATCH v2 1/3] services: base: Add optional delayed mount of file-systems References: In-Reply-To: Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 25 Apr 2024 04:58:05 +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.171402108232510 (code B ref 70542); Thu, 25 Apr 2024 04:58:05 +0000 Received: (at 70542) by debbugs.gnu.org; 25 Apr 2024 04:58:02 +0000 Received: from localhost ([127.0.0.1]:60328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzrBE-0008RN-W1 for submit@debbugs.gnu.org; Thu, 25 Apr 2024 00:58:01 -0400 Received: from mail-108-mta59.mxroute.com ([136.175.108.59]:42921) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzrB8-0008Q2-CM for 70542@debbugs.gnu.org; Thu, 25 Apr 2024 00:57:54 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta59.mxroute.com (ZoneMTA) with ESMTPSA id 18f139da3e90008ca2.001 for <70542@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 25 Apr 2024 04:57:29 +0000 X-Zone-Loop: fa98ce4f2a9aeb040a47bb2faeba62812971e77ca3e6 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: 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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=vOPokPfPk8VpB87OVgfZvG+sPA5RYqb4xYKtITTM2GA=; b=iNeKeskk5xV5Va5EDP2FbPjXEM SD5JzTs6qn430GuNHiPxYykgYKTzLrTTh+TlL9ZnsHWEJqz6Jb51ZYWoZZkmwUVbVfofntDm1gqfk p5mVBidOl4yNv6NDiawUkkJeku9i5fSQ7ts9wDAZ0w+MHXj9rJcEVsUTecrys/lidlZkl631VIEa2 l7BV6z5uojXj3tR199y/AUM8Faouk3n9FErQ7PKm/Hqe0FOxKzYmG33Of1SuKkJl0IouaacvTTgmR M/TctQQI3AmW7aLcfZJd/mUX4/pGIRog7Wn2XJdhwATluNoxSV+vhSQbsrz+hsg8b3Y8/hO5FdTf6 hYMdtg9A==; From: Richard Sent Date: Thu, 25 Apr 2024 00:56:03 -0400 Message-ID: <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 Add a mechanism to only require mounting a subset of file-system entries during early Shepherd initialization. Any file-system with additional Shepherd service requirements (e.g. networking) is not required to provision 'file-systems. * gnu/services/base.scm (file-system-shepherd-service): Splice file-system-requirements into the Shepherd service requirement list. * gnu/services/base.scm (file-system-shepherd-services): Provision 'file-system only when file system services without additional Shepherd requirements are started. * gnu/system/file-systems.scm (file-system): Add requirements field to the file-system record. This field is used for adding additional Shepherd requirements to a file-system Shepherd service. * doc/guix.texi: Add documentation for file-system requirements. Change-Id: If0392db03d48e8820aa53df1df482c12ec72e1a5 --- doc/guix.texi | 13 +++++++++++++ gnu/services/base.scm | 14 ++++++++++++-- gnu/system/file-systems.scm | 3 +++ 3 files changed, 28 insertions(+), 2 deletions(-) base-commit: 91d9e145e15241c20729a4f1fa43f3d662f6b806 diff --git a/doc/guix.texi b/doc/guix.texi index 3ee9f54773..5c89e2110f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17750,6 +17750,19 @@ File Systems Another example is a file system that depends on a mapped device, for example for an encrypted partition (@pxref{Mapped Devices}). + +@item @code{requirements} (default: @code{'()}) +This is a list of symbols denoting Shepherd requirements that must be +met before mounting the file system. + +As an example, an NFS file system would typically have a requirement for +@code{networking}. + +Typically, file systems are mounted before most other Shepherd services +are started. However, file systems with a non-empty requirements field +are mounted after Shepherd services have begun. Any Shepherd service +that depends on a file system with a non-empty requirements field must +depend on it directly and not on the generic symbol @code{file-systems}. @end table @end deftp diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 3f912225a0..4fd946c4aa 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -403,6 +403,7 @@ (define (file-system-shepherd-service file-system) (create? (file-system-create-mount-point? file-system)) (mount? (file-system-mount? file-system)) (dependencies (file-system-dependencies file-system)) + (requirements (file-system-requirements file-system)) (packages (file-system-packages (list file-system)))) (and (or mount? create?) (with-imported-modules (source-module-closure @@ -411,7 +412,8 @@ (define (file-system-shepherd-service file-system) (provision (list (file-system->shepherd-service-name file-system))) (requirement `(root-file-system udev - ,@(map dependency->shepherd-service-name dependencies))) + ,@(map dependency->shepherd-service-name dependencies) + ,@requirements)) (documentation "Check, mount, and unmount the given file system.") (start #~(lambda args #$(if create? @@ -460,12 +462,20 @@ (define (file-system-shepherd-services file-systems) (or (file-system-mount? x) (file-system-create-mount-point? x))) file-systems))) + (define sink (shepherd-service (provision '(file-systems)) (requirement (cons* 'root-file-system 'user-file-systems (map file-system->shepherd-service-name - file-systems))) + ;; Do not require file systems with Shepherd + ;; requirements to provision + ;; 'file-systems. Many Shepherd services + ;; require 'file-systems, so we would likely + ;; deadlock. + (filter (lambda (file-system) + (null? (file-system-requirements file-system))) + file-systems)))) (documentation "Target for all the initially-mounted file systems") (start #~(const #t)) (stop #~(const #f)))) diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index af0567bd3e..76a51a2b69 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -57,6 +57,7 @@ (define-module (gnu system file-systems) file-system-repair file-system-create-mount-point? file-system-dependencies + file-system-requirements file-system-location file-system-type-predicate @@ -185,6 +186,8 @@ (define-record-type* file-system (default #f)) (dependencies file-system-dependencies ; list of (default '())) ; or + (requirements file-system-requirements ; list of symbols + (default '())) (location file-system-location (default (current-source-location)) (innate))) 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 "/" From patchwork Thu Apr 25 04:56:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 63339 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 C61EE27BBEC; Thu, 25 Apr 2024 05:59:19 +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=unavailable 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 AC4DB27BBE2 for ; Thu, 25 Apr 2024 05:59:18 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzrCM-0007z9-V1; Thu, 25 Apr 2024 00:59:07 -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 1rzrCL-0007ym-IK for guix-patches@gnu.org; Thu, 25 Apr 2024 00:59:05 -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 1rzrCK-0004zG-Af; Thu, 25 Apr 2024 00:59:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzrCY-0000FD-Ca; Thu, 25 Apr 2024 00:59:18 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70542] [PATCH v2 3/3] file-systems: Add support for mounting CIFS file systems Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 25 Apr 2024 04:59:17 +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 , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 70542-submit@debbugs.gnu.org id=B70542.1714021125565 (code B ref 70542); Thu, 25 Apr 2024 04:59:17 +0000 Received: (at 70542) by debbugs.gnu.org; 25 Apr 2024 04:58:45 +0000 Received: from localhost ([127.0.0.1]:60335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzrBu-00007v-Lo for submit@debbugs.gnu.org; Thu, 25 Apr 2024 00:58:44 -0400 Received: from mail-108-mta189.mxroute.com ([136.175.108.189]:44785) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzrBR-0008Ti-R3 for 70542@debbugs.gnu.org; Thu, 25 Apr 2024 00:58:14 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta189.mxroute.com (ZoneMTA) with ESMTPSA id 18f139de8c20008ca2.001 for <70542@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 25 Apr 2024 04:57:46 +0000 X-Zone-Loop: 579330028cbf4d74e0df57f44a47ece3e70142f0d0bb 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:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To: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=vs0ksIXRLil2Wu6ptR0iYB7JH/lgfD33tOt8ohbEIV4=; b=OabaQKX/ndCDK6nJMOnyWd/IMn olMe/05FmCwT5gmMkp+ca8j6TEB5V+FmETFxHm1Cz2Tb9wncHoFKbtHIu/+xlWY9a1DVbBbeAfK33 p0Qs2I5GK8xXuwve8yMKntazx6YMpaIQo19av6KOrVUwbX9h8O2scEOqe+vWVZvwADSD6b9RlWqqh p2ZOlQ5LorrTSXjzYYzn5k5fT4qGIklOJT+wHwVvHKJftvi4fK89GM6qiFYU6EkFGPpbgEv2B6bqC dmiPSmcldkImOBtBkPYfFUHAOS0haZPf6J98AJowY3q9DUazWBOal6Kth9ICLiA+xR10F72sacKnq zQ8j1IXQ==; From: Richard Sent Date: Thu, 25 Apr 2024 00:56:05 -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 (canonicalize-device-name): Do not attempt to resolve CIFS formatted device specifications. (mount-file-systems): Add mount-cifs nested function. * gnu/machine/ssh.scm (machine-check-file-system-availability): Skip checking for CIFS availability, similar to NFS. * guix/scripts/system.scm (check-file-system-availability): Likewise. Change-Id: I182e290eba64bbe5d1332815eb93bb68c01e0c3c --- gnu/build/file-systems.scm | 45 ++++++++++++++++++++++++++++++++++++-- gnu/machine/ssh.scm | 3 ++- guix/scripts/system.scm | 3 ++- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index e47ac39ab0..ae29b36c4e 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2020 Maxim Cournoyer ;;; Copyright © 2022 Oleg Pykhalov ;;; Copyright © 2024 Nicolas Graves +;;; Copyright © 2024 Richard Sent ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,6 +38,7 @@ (define-module (gnu build file-systems) #:use-module (rnrs bytevectors) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) + #:use-module (ice-9 regex) #:use-module (system foreign) #:autoload (system repl repl) (start-repl) #:use-module (srfi srfi-1) @@ -1047,8 +1049,11 @@ (define (canonicalize-device-spec spec) (match spec ((? string?) - (if (or (string-contains spec ":/") (string=? spec "none")) - spec ; do not resolve NFS / tmpfs devices + (if (or (string-contains spec ":/") ;nfs + (and (>= (string-length spec) 2) + (equal? (string-take spec 2) "//")) ;cifs + (string=? spec "none")) + spec ; do not resolve NFS / CIFS / tmpfs devices ;; Nothing to do, but wait until SPEC shows up. (resolve identity spec identity))) ((? file-system-label?) @@ -1181,6 +1186,40 @@ (define* (mount-file-system fs #:key (root "/root") (string-append "," options) ""))))) + (define (mount-cifs source mount-point type flags options) + ;; Source is of form "///" + (let* ((regex-match (string-match "//([^/]+)/(.+)" source)) + (server (match:substring regex-match 1)) + (share (match:substring regex-match 2)) + ;; Match ",guest,", ",guest$", "^guest,", or "^guest$," not + ;; e.g. user=foo,pass=notaguest + (guest? (string-match "(^|,)(guest)($|,)" options)) + ;; Perform DNS resolution now instead of attempting kernel dns + ;; resolver upcalling. /sbin/request-key does not exist and the + ;; kernel hardcodes the path. + ;; + ;; (getaddrinfo) doesn't support cifs service, so omit it. + (inet-addr (host-to-ip server))) + (mount source mount-point type flags + (string-append "ip=" + inet-addr + ;; As of Linux af1a3d2ba9 (v5.11) unc is ignored + ;; and source is parsed by the kernel + ;; directly. Pass it for compatibility. + ",unc=" + ;; Match format of mount.cifs's mount syscall. + "\\\\" server "\\" share + (if guest? + ",user=,pass=" + "") + (if options + ;; No need to delete "guest" from options. + ;; linux/fs/smb/client/fs_context.c explicitly + ;; ignores it. Also, avoiding excess commas + ;; when deleting is a pain. + (string-append "," options) + ""))))) + (let* ((type (file-system-type fs)) (source (canonicalize-device-spec (file-system-device fs))) (target (string-append root "/" @@ -1215,6 +1254,8 @@ (define* (mount-file-system fs #:key (root "/root") (cond ((string-prefix? "nfs" type) (mount-nfs source target type flags options)) + ((string-prefix? "cifs" type) + (mount-cifs source target type flags options)) ((memq 'shared (file-system-flags fs)) (mount source target type flags options) (mount "none" target #f MS_SHARED)) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index b47ce7c225..0be9ebbc0d 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -222,7 +222,8 @@ (define (machine-check-file-system-availability machine) (not (member (file-system-type fs) %pseudo-file-system-types)) ;; Don't try to validate network file systems. - (not (string-prefix? "nfs" (file-system-type fs))) + (not (or (string-prefix? "nfs" (file-system-type fs)) + (string-prefix? "cifs" (file-system-type fs)))) (not (memq 'bind-mount (file-system-flags fs))))) (operating-system-file-systems (machine-operating-system machine)))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 2260bcf985..99c58f3812 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -591,7 +591,8 @@ (define (check-file-system-availability file-systems) (not (member (file-system-type fs) %pseudo-file-system-types)) ;; Don't try to validate network file systems. - (not (string-prefix? "nfs" (file-system-type fs))) + (not (or (string-prefix? "nfs" (file-system-type fs)) + (string-prefix? "cifs" (file-system-type fs)))) (not (memq 'bind-mount (file-system-flags fs))))) file-systems))