diff options
author | Noah Evans <noahevans256@gmail.com> | 2024-12-26 14:28:35 -0500 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2025-01-09 00:23:43 +0100 |
commit | 981af9992881b7395692bd6233722464d173a51f (patch) | |
tree | 8963402d3047ac88e5118b2a980728d27cfb7852 /gnu/packages/patches | |
parent | c8797e81fbf1d7ac810b8b3cadef3637746c210e (diff) |
syscalls: Add implementation of statfs for guile-static.
This is needed when bind mounting file systems from the initrd guile, or
else you get an error like this:
https://lists.gnu.org/archive/html/help-guix/2021-07/msg00050.html
* 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.
Change-Id: Ibc8f1f27648add90639bd391aff8d61c6a23b884
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/packages/patches')
-rw-r--r-- | gnu/packages/patches/guile-3.0-linux-syscalls.patch | 34 | ||||
-rw-r--r-- | gnu/packages/patches/guile-linux-syscalls.patch | 34 |
2 files changed, 66 insertions, 2 deletions
diff --git a/gnu/packages/patches/guile-3.0-linux-syscalls.patch b/gnu/packages/patches/guile-3.0-linux-syscalls.patch index 0d27f77ee2..13921b8b70 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 */ @@ -340,6 +340,38 @@ diff --git a/libguile/posix.c b/libguile/posix.c +#undef FUNC_NAME +#endif + ++#include <sys/statfs.h> ++ ++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..1ebbc72c52 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 */ @@ -340,6 +340,38 @@ index b0fcad5fd..1343186e3 100644 +#undef FUNC_NAME +#endif + ++#include <sys/statfs.h> ++ ++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 () { |