From patchwork Tue Apr 23 20:47:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 63322 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 751E327BBE9; Tue, 23 Apr 2024 21:49:15 +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 9FE8227BBE2 for ; Tue, 23 Apr 2024 21:49:12 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzN4h-00032g-5v; Tue, 23 Apr 2024 16:49:11 -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 1rzN4O-0002zb-1g for guix-patches@gnu.org; Tue, 23 Apr 2024 16:48:52 -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 1rzN4N-0003Od-9N for guix-patches@gnu.org; Tue, 23 Apr 2024 16:48:51 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzN4d-0003Xq-Gz for guix-patches@gnu.org; Tue, 23 Apr 2024 16:49:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70542] [PATCH 1/4] file-systems: Add requirements field to file-systems Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 23 Apr 2024 20:49:07 +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.171390529913081 (code B ref 70542); Tue, 23 Apr 2024 20:49:07 +0000 Received: (at 70542) by debbugs.gnu.org; 23 Apr 2024 20:48:19 +0000 Received: from localhost ([127.0.0.1]:54255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzN3j-0003NV-Ku for submit@debbugs.gnu.org; Tue, 23 Apr 2024 16:48:18 -0400 Received: from mail-108-mta19.mxroute.com ([136.175.108.19]:46821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzN3d-0003M9-3a for 70542@debbugs.gnu.org; Tue, 23 Apr 2024 16:48:09 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta19.mxroute.com (ZoneMTA) with ESMTPSA id 18f0cb6e2b40003bea.001 for <70542@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 23 Apr 2024 20:47:43 +0000 X-Zone-Loop: 0216e505b7a0a8264361f18032a25031e2a3b3c2cb82 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=v3IW4uFe6Ct60NonFKfWMHf3ECzON50UkPPy5OhczLo=; b=iC/D/0ppWINBDLjJjss8erhdpz 34hfaO4vv5+P5m1U237xZOZmKXfRXvB0uzJ8EecLSJGFW7akMBlBigC3OAYDB89BemIzSLwycvOVD OZzK6OdI85gXP0eBsd0+Fc3W30p+F5lYZ8r2QoaHa2IpxlKPm/iih94cFqIr9oX6HoxWKutE/vLzM PxOe3fdRMyYlJ/oF9Xz+msVZsDuldHpuO5elTCWDT9lsXXyuuMmecTGgOgaoLvJ5P66caQVYf1JkH HxpnEFeh4857UfW657x0ws1M3Hlyp6Bo8hIo3w+BuIqxfVSmcZ4dJe+ay9Vf62BlCj72A87bxBsGX l3lJoeOg==; From: Richard Sent Date: Tue, 23 Apr 2024 16:47:19 -0400 Message-ID: In-Reply-To: References: 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/system/file-systems.scm (file-system): Add requirements field to the file-system record. This field will be 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/system/file-systems.scm | 3 +++ 2 files changed, 16 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 65af136e61..80b24e2de9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17751,6 +17751,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/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 Tue Apr 23 20:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 63323 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 8D41427BBEA; Tue, 23 Apr 2024 21:49:33 +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 E364527BBE2 for ; Tue, 23 Apr 2024 21:49:32 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzN4o-00035p-58; Tue, 23 Apr 2024 16:49:18 -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 1rzN4S-000329-Qx for guix-patches@gnu.org; Tue, 23 Apr 2024 16:48:57 -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 1rzN4S-0003Sf-I5 for guix-patches@gnu.org; Tue, 23 Apr 2024 16:48:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzN4i-0003Yz-M1 for guix-patches@gnu.org; Tue, 23 Apr 2024 16:49:12 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70542] [PATCH 2/4] services: base: Use requirements to delay some file-systems Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 23 Apr 2024 20:49:11 +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.171390534613608 (code B ref 70542); Tue, 23 Apr 2024 20:49:11 +0000 Received: (at 70542) by debbugs.gnu.org; 23 Apr 2024 20:49:06 +0000 Received: from localhost ([127.0.0.1]:54263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzN4Y-0003Wr-9a for submit@debbugs.gnu.org; Tue, 23 Apr 2024 16:49:05 -0400 Received: from mail-108-mta34.mxroute.com ([136.175.108.34]:38921) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzN3d-0003MA-4e for 70542@debbugs.gnu.org; Tue, 23 Apr 2024 16:48:12 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta34.mxroute.com (ZoneMTA) with ESMTPSA id 18f0cb6f2a20003bea.001 for <70542@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 23 Apr 2024 20:47:47 +0000 X-Zone-Loop: fb768efe4dcacf4848e89ee4ceeb28903401ea06368c 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=JFnq50DttwZ+qap2nmDE1ZtMkgIdnaAfw2lUNyI0zJs=; b=HqeOuTJXpxzEfIHBnvfI3r28PU uVnrJ/voJ3+DzGk1L5VQLpqLi2VOUsu8qdlbQfbDjFVQsy6UeoiN2o4O+kysHmgEV3L+45fgsWl4/ wWD/CF7jyDEabHbaxym95s5pf2K9ZGy+PztoSzZBILCYqbJiIy8ph1f2ViPlNmIjfzd6Owuag0nZq x9hzs5U6R/kticDvl4jaUJGpixw53GhbnIcmGZl2OnrueA0ePWnebftt4Ugl7I52yys+6IgcCGjS/ mMEVpwHeChTx8hUHNCYlAUuZMuEEsA7bmGdAk9SOg42LjkufNnIjOaHo9nXgfX76HxS2NnBhujorQ 7r73/tCw==; From: Richard Sent Date: Tue, 23 Apr 2024 16:47:20 -0400 Message-ID: <91efec381997bd89208d9f4a47141ae6481fb963.1713904784.git.richard@freakingpenguin.com> In-Reply-To: References: 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 a subset of file-system entries during early Shepherd initialization. Any file-system with additional Shepherd service requirements (e.g. networking) will be brought up after 'file-systems is provisioned. * 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 when file-systems that satisfy initial-file-system? are started. Change-Id: I7b1336ee970f4320f7431bef187e66f34f0d718c --- gnu/services/base.scm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 3f912225a0..af92b700b4 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,22 @@ (define (file-system-shepherd-services file-systems) (or (file-system-mount? x) (file-system-create-mount-point? x))) file-systems))) + + (define (initial-file-system? file-system) + "Return #t if the file system should be mounted initially or #f." + ;; File systems with additional Shepherd requirements (e.g. networking) + ;; should not be considered initial. Those requirements likely rely on + ;; 'file-systems being provisioned. + (null? (file-system-requirements file-system))) + (define sink (shepherd-service (provision '(file-systems)) (requirement (cons* 'root-file-system 'user-file-systems (map file-system->shepherd-service-name - file-systems))) + ;; Only file systems considered initial should + ;; be required to provision 'file-systems. + (filter initial-file-system? file-systems)))) (documentation "Target for all the initially-mounted file systems") (start #~(const #t)) (stop #~(const #f)))) From patchwork Tue Apr 23 20:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 63325 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 31A9227BBE2; Tue, 23 Apr 2024 21:50:34 +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 1830D27BBE9 for ; Tue, 23 Apr 2024 21:50:30 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzN5i-0003Wb-Up; Tue, 23 Apr 2024 16:50:16 -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 1rzN5Z-0003SO-1I for guix-patches@gnu.org; Tue, 23 Apr 2024 16:50: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 1rzN5Y-0003hp-4c for guix-patches@gnu.org; Tue, 23 Apr 2024 16:50:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzN5o-0003kl-JS for guix-patches@gnu.org; Tue, 23 Apr 2024 16:50:20 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70542] [PATCH 3/4] file-systems: Add support for mounting CIFS file systems Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 23 Apr 2024 20:50:20 +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.171390535313685 (code B ref 70542); Tue, 23 Apr 2024 20:50:20 +0000 Received: (at 70542) by debbugs.gnu.org; 23 Apr 2024 20:49:13 +0000 Received: from localhost ([127.0.0.1]:54265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzN4b-0003XQ-Qk for submit@debbugs.gnu.org; Tue, 23 Apr 2024 16:49:11 -0400 Received: from mail-108-mta217.mxroute.com ([136.175.108.217]:38211) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzN3h-0003N5-VT for 70542@debbugs.gnu.org; Tue, 23 Apr 2024 16:48:17 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta217.mxroute.com (ZoneMTA) with ESMTPSA id 18f0cb701b30003bea.001 for <70542@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 23 Apr 2024 20:47:51 +0000 X-Zone-Loop: 20718e557b230361005c5e9978407a7cec17626c1460 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=hF0faV2T67I+4RAauNmiSl9RRGb3R2Gw5DORSuQpHLg=; b=iKHYhzqAu+M0UDae3lX/b0oxU6 xU7k54SXSiGWt0zaAh5sh7IV87wEpsx8k0o9Z4Ty3jDjmWq5Au8ODHpLTg5hl3boco8dLYQauNmLZ KhfhDA8wDAhAXFI2yc0bTg8qHlBi2IQkqbkZvv2WhOL6D8IXaj+xSPNuHEKv9WPUs2LwuDmy+JQMm CrFRD4tkTCScAyimVdOGAD6Iub0I6f/OFCZWIulBYk1hwqeMeUe+m3t7Cgz5Q42OwPgaFXEp7Wgga L3bCAHzGDOtOCMr2jdOgcgrxnVOncgXHQYpII2UUVb7YKx9xlNyT+6tssFzhkdYfYlESVAM26VFEI /7yn1DZQ==; From: Richard Sent Date: Tue, 23 Apr 2024 16:47:21 -0400 Message-ID: In-Reply-To: References: 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. * gnu/build/file-systems (mount-file-system): Add (mount-cifs) and (host-to-ip). Logic for ip/host to ip resolution was duplicated with mount-nfs, so isolate into a dedicated function. Change-Id: I522d70a10651ca79533a4fc60b96b884243a3526 --- gnu/build/file-systems.scm | 60 +++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index 78d779f398..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?) @@ -1156,6 +1161,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 +1176,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 +1185,41 @@ (define* (mount-file-system fs #:key (root "/root") (if options (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 "/" @@ -1210,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)) From patchwork Tue Apr 23 20:47:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 63324 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 50CF327BBEB; Tue, 23 Apr 2024 21:50:30 +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 3EF0E27BBE2 for ; Tue, 23 Apr 2024 21:50:25 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzN5o-0003ZO-Jc; Tue, 23 Apr 2024 16:50:23 -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 1rzN5d-0003UK-CH for guix-patches@gnu.org; Tue, 23 Apr 2024 16:50:09 -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 1rzN5c-0003nd-5d; Tue, 23 Apr 2024 16:50:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzN5s-0003lM-1A; Tue, 23 Apr 2024 16:50:24 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70542] [PATCH 4/4] system: Do not check for CIFS file system availability 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: Tue, 23 Apr 2024 20:50:23 +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.171390535913755 (code B ref 70542); Tue, 23 Apr 2024 20:50:23 +0000 Received: (at 70542) by debbugs.gnu.org; 23 Apr 2024 20:49:19 +0000 Received: from localhost ([127.0.0.1]:54269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzN4h-0003Yf-KX for submit@debbugs.gnu.org; Tue, 23 Apr 2024 16:49:16 -0400 Received: from mail-108-mta205.mxroute.com ([136.175.108.205]:39331) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzN3n-0003OB-2E for 70542@debbugs.gnu.org; Tue, 23 Apr 2024 16:48:19 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta205.mxroute.com (ZoneMTA) with ESMTPSA id 18f0cb70c560003bea.001 for <70542@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 23 Apr 2024 20:47:53 +0000 X-Zone-Loop: 64cc3a143911022501d988fb8399ffcea087e1bc289a 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=LBLAiBjTSPvGnakzep01c6deoJNF1KR5XHn9hW3qe9U=; b=CojS/kxOhcEudZ36nlsKHLxOsB 4L+xTsBG+AkBYrVSvvd0ihDLK3EU68JdaHac1hJ1uXa7kxcTg318BHn4aeDKNkkCVSWeQ9ZF+C6gk HZGGfD2M3WE2K2aaDmRWwtxU5ek79DpGcMbzWZzehGlr5JWV3rVHIM91xP50eGIfI0+IkjxXmFCgP YqHV4lMJVSZQdJ+36PovfYEn53GXqfEQtm9QXZawp+9CYKRq+GCz+yiEJC7pjq1ia9uOV2qEHuabf 9XI7MT8TCUAiOYZQhikC9t4X6VpKsUKVt/QK0QwKtBnSB2gM6cfzf5T4sOJdjO23j5T8PT6RnasLM mdZnTkhw==; From: Richard Sent Date: Tue, 23 Apr 2024 16:47:22 -0400 Message-ID: <26b45dc93012f6a25a8eefed69e1c470fc8e4ad8.1713904784.git.richard@freakingpenguin.com> In-Reply-To: References: 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/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: Ib6452d1b0d3c15028c79b05422ffa317de0a419a --- gnu/machine/ssh.scm | 3 ++- guix/scripts/system.scm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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))