From patchwork Thu Dec 26 19:28:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Noah Evans X-Patchwork-Id: 35861 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 0455227BBEB; Fri, 27 Dec 2024 13:48:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,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 5424127BBE2 for ; Fri, 27 Dec 2024 13:48:39 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tRAhK-00071l-W3; Fri, 27 Dec 2024 08:48:15 -0500 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 1tR3ao-0001sF-KB for guix-patches@gnu.org; Fri, 27 Dec 2024 01:13:02 -0500 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 1tR3ao-0007xE-Bz for guix-patches@gnu.org; Fri, 27 Dec 2024 01:13:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:From:MIME-Version:To:Subject; bh=v3ETJi45b6f7Qk88yK2m5z5Vwo9fJH4+3kMls+ScJGo=; b=QWR0fbE6eHVh8EFYXRleBvF8LzAhWmeXXcfxOH39jck+Mza1i+H9SFEnaj6xWVq5d7Rdoy7TNzWxlZNx71PLPU5g9fBN+BCZ+Fg436Dj9fB8+K/LXvXb7LXnY8imoxFxnPznIoAtGH57z5vbqqMSRQiU2P15PqgZEqD2Fz/0dJqGRU+rKPdy/Y8vldfKVUs5QvKANZdx6Rc8NOe3DeKx/4Rf2G2pWJuOJiHmoRy5riWlB9TgNJLkjTbpjut9iNlU0N2/Heo5k7Bm594KU+p7v86MOuIn+N+GxF3XCd424+ChS5Ey/6+lBMppJ8kjubCmQjF7KQ+Nua0B9PHLN88lOA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tR3ao-0004xj-5A for guix-patches@gnu.org; Fri, 27 Dec 2024 01:13:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75133] [PATCH] syscalls: Add implementation of statfs for guile-static. Resent-From: Noah Evans Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 27 Dec 2024 06:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75133 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75133@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.173527993418986 (code B ref -1); Fri, 27 Dec 2024 06:13:01 +0000 Received: (at submit) by debbugs.gnu.org; 27 Dec 2024 06:12:14 +0000 Received: from localhost ([127.0.0.1]:44429 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tR3a1-0004w6-PZ for submit@debbugs.gnu.org; Fri, 27 Dec 2024 01:12:14 -0500 Received: from lists.gnu.org ([209.51.188.17]:40132) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tQtXP-0005rd-Oo for submit@debbugs.gnu.org; Thu, 26 Dec 2024 14:28:52 -0500 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 1tQtXO-0004MS-NH for guix-patches@gnu.org; Thu, 26 Dec 2024 14:28:50 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQtXM-00080D-RO for guix-patches@gnu.org; Thu, 26 Dec 2024 14:28:50 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-38633b5dbcfso6482793f8f.2 for ; Thu, 26 Dec 2024 11:28:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735241326; x=1735846126; darn=gnu.org; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=v3ETJi45b6f7Qk88yK2m5z5Vwo9fJH4+3kMls+ScJGo=; b=mH/Gtq62RLkDM64pY2/x/VwiWu6JrLoGd/qooEW+jMrdH5ieJXpW042fdh6VY1j0x6 /6yjHL0XpiwPJzmhJNdSq16LW3aKuNvJJJ55WYTa9uIapY1RzZEnElBI4IMdZ0XRlQEd mX+/TM9PKwHQAR4mqfzU/r+vQoZGiqxhaVeyeNXPujBkmYQPtkETIHZuRW00Mn06iFpm G9wj+ShJQbHiKHFZIUd68y51VcB3u9Xi9N7a8J5/+uFKAMZAyzQgIyEBj5aeGAk3b4DE WuE/TvlA+buk2I6uD4CqJDA3V5AVBYD1BtM7aLe8CmCXbA60/Ah3hevZ5Pb2psBbnl5W KkZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735241326; x=1735846126; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=v3ETJi45b6f7Qk88yK2m5z5Vwo9fJH4+3kMls+ScJGo=; b=c3HuEXJR6kw0iPWvvjWlVBUaD68fkwllWT7p0Q1TTQwhNS+9PK9HKhcXwCLmoFvBJu CCxzgiNjDS3q6ZYBSJXQ2ivhtmuRM9HCmrmBnx3QCGnnIdLX/aMTBcYvsRq2msZWiouD V8xgG2m0p8KKWhe5NC8hQpf/PhwBTDPy/lT46dbLg+oHwcPvhkESnBUsilzM/atcqFSI uw2nrcWuMciaOdFdsQ/UAe4vzMG9AgpZDazAvKRZ7fqQTfKbcAswMG59INmxcoZ/ZR3w cfinsv1OwRGzK2MiFKqU0lLIfNbdAfPpDLYSZiRgFM8q+nRODkeimMWWWHGUPtGWw5DX G/hg== X-Gm-Message-State: AOJu0YxKWR6JrAzNgh+DuC9Ifd+4J/SlEtYhKIluo1Gts4kIzq+8xblL zJbio0Bn/sfKjh8nYPFv4d5EPtmvilx6i6GXAmN9sPsMPdX75cQFl6QfYpEsp1O/YvPsWIntvjt ub86uFhZouufcdX5TkM7XyrNtGmdQwpYU3eY= X-Gm-Gg: ASbGncsI1klyTAbzHCohjGD7yie+ySaSpSaPdW1KyIiUYS+DrlHseWftslgb1d5ZCRS duyN9R9fBgO4Xs0VfRWlgUsk106AduBIJPlv7k2msiQNh5mEYg+g= X-Google-Smtp-Source: AGHT+IF4GwXpc0qu6Z/K5+l62rwNFESfCFSrqfB95cfE6p2Z9r6HPLGPFgwLDmvTsjZccv1IMqusgFqj6iT1GkUDtSM= X-Received: by 2002:a05:6000:713:b0:386:3903:86eb with SMTP id ffacd0b85a97d-38a221f1fd1mr19609750f8f.23.1735241326126; Thu, 26 Dec 2024 11:28:46 -0800 (PST) MIME-Version: 1.0 From: Noah Evans Date: Thu, 26 Dec 2024 14:28:35 -0500 Message-ID: Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=noahevans256@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 27 Dec 2024 01:12:12 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Fri, 27 Dec 2024 08:48:13 -0500 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 * guix/build/syscalls.scm (statfs): Add implementation for calling from guile-static. * gnu/packages/patches/guile-3.0-linux-syscalls.patch, gnu/packages/patches/guile-linux-syscalls.patch (statfs-raw): C Function to support above. This is needed when bind mounting filesystems from the initrd guile, or else you get an error like this: https://lists.gnu.org/archive/html/help-guix/2021-07/msg00050.html Change-Id: Ibc8f1f27648add90639bd391aff8d61c6a23b884 --- .../patches/guile-3.0-linux-syscalls.patch | 34 ++++++++++++++++++- .../patches/guile-linux-syscalls.patch | 34 ++++++++++++++++++- guix/build/syscalls.scm | 30 ++++++++++------ 3 files changed, 85 insertions(+), 13 deletions(-) (define (free-disk-space file) "Return the free disk space, in bytes, on the file system that hosts FILE." base-commit: f03a0e2d19f95eb0961472842540970c2f7605f1 diff --git a/gnu/packages/patches/guile-3.0-linux-syscalls.patch b/gnu/packages/patches/guile-3.0-linux-syscalls.patch index 0d27f77ee2..1332d31241 100644 --- a/gnu/packages/patches/guile-3.0-linux-syscalls.patch +++ b/gnu/packages/patches/guile-3.0-linux-syscalls.patch @@ -6,7 +6,7 @@ a statically-linked Guile in an initrd that doesn't have libc.so around. diff --git a/libguile/posix.c b/libguile/posix.c --- a/libguile/posix.c +++ b/libguile/posix.c -@@ -2375,6 +2375,336 @@ scm_init_popen (void) +@@ -2375,6 +2375,368 @@ scm_init_popen (void) } #endif /* HAVE_START_CHILD */ @@ -339,6 +339,38 @@ diff --git a/libguile/posix.c b/libguile/posix.c +} +#undef FUNC_NAME +#endif ++ ++#include ++ ++SCM_DEFINE (scm_statfs_raw, "statfs-raw", 1, 0, 0, ++ (SCM filesystem), ++ "Return a bytevector describing @var{filesystem}") ++#define FUNC_NAME s_scm_statfs_raw ++{ ++ int err; ++ char *c_filesystem; ++ SCM bv; ++ ++ c_filesystem = scm_to_locale_string (filesystem); ++ ++ bv = scm_c_make_bytevector (sizeof (struct statfs)); ++ struct statfs *bv_pointer = scm_to_pointer (scm_bytevector_to_pointer (bv, scm_from_int (0))); ++ ++ err = statfs (c_filesystem, bv_pointer); ++ if (err != 0) ++ err = errno; ++ ++ free (c_filesystem); ++ ++ if (err != 0) ++ { ++ errno = err; ++ SCM_SYSERROR; ++ } ++ ++ return bv; ++} ++#undef FUNC_NAME + void scm_init_posix () diff --git a/gnu/packages/patches/guile-linux-syscalls.patch b/gnu/packages/patches/guile-linux-syscalls.patch index 12cddff47b..04645caeb8 100644 --- a/gnu/packages/patches/guile-linux-syscalls.patch +++ b/gnu/packages/patches/guile-linux-syscalls.patch @@ -7,7 +7,7 @@ diff --git a/libguile/posix.c b/libguile/posix.c index b0fcad5fd..1343186e3 100644 --- a/libguile/posix.c +++ b/libguile/posix.c -@@ -2341,6 +2341,335 @@ scm_init_popen (void) +@@ -2341,6 +2341,367 @@ scm_init_popen (void) } #endif /* HAVE_START_CHILD */ @@ -339,6 +339,38 @@ index b0fcad5fd..1343186e3 100644 +} +#undef FUNC_NAME +#endif ++ ++#include ++ ++SCM_DEFINE (scm_statfs_raw, "statfs-raw", 1, 0, 0, ++ (SCM filesystem), ++ "Return a bytevector describing @var{filesystem}") ++#define FUNC_NAME s_scm_statfs_raw ++{ ++ int err; ++ char *c_filesystem; ++ SCM bv; ++ ++ c_filesystem = scm_to_locale_string (filesystem); ++ ++ bv = scm_c_make_bytevector (sizeof (struct statfs)); ++ struct statfs *bv_pointer = scm_to_pointer (scm_bytevector_to_pointer (bv, scm_from_int (0))); ++ ++ err = statfs (c_filesystem, bv_pointer); ++ if (err != 0) ++ err = errno; ++ ++ free (c_filesystem); ++ ++ if (err != 0) ++ { ++ errno = err; ++ SCM_SYSERROR; ++ } ++ ++ return bv; ++} ++#undef FUNC_NAME + void scm_init_posix () diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 2c20edf058..e2af4efd12 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2021 Chris Marusich ;;; Copyright © 2021 Tobias Geerinckx-Rice ;;; Copyright © 2022 Oleg Pykhalov +;;; Copyright © 2024 Noah Evans ;;; ;;; This file is part of GNU Guix. ;;; @@ -930,18 +931,25 @@ (define-c-struct %statfs ; (spare (array fsword 4))) (define statfs - (let ((proc (syscall->procedure int (if musl-libc? "statfs" "statfs64") '(* *)))) - (lambda (file) - "Return a data structure describing the file system + (if (module-defined? the-scm-module 'statfs-raw) + (lambda (file) + "Return a data structure describing the file system mounted at FILE." - (let*-values (((stat) (make-bytevector sizeof-statfs)) - ((ret err) (proc (string->pointer file) - (bytevector->pointer stat)))) - (if (zero? ret) - (read-statfs stat) - (throw 'system-error "statfs" "~A: ~A" - (list file (strerror err)) - (list err))))))) + (read-statfs ((module-ref the-scm-module 'statfs-raw) file))) + (let ((proc (syscall->procedure int + (if musl-libc? "statfs" "statfs64") + '(* *)))) + (lambda (file) + "Return a data structure describing the file system +mounted at FILE." + (let*-values (((stat) (make-bytevector sizeof-statfs)) + ((ret err) (proc (string->pointer file) + (bytevector->pointer stat)))) + (if (zero? ret) + (read-statfs stat) + (throw 'system-error "statfs" "~A: ~A" + (list file (strerror err)) + (list err))))))))