Commit Graph

113 Commits

Author SHA1 Message Date
Ludovic Courtès 7e9d9f28e9
syscalls: Add 'mounts' and the <mount> record type.
* guix/build/syscalls.scm (<mount>): New record type.
(option-string->mount-flags, mount-flags)
(octal-decode, mounts): New procedures.
(mount-points): Rewrite in terms of 'mount'.
* tests/syscalls.scm ("mounts"): New test.
2021-02-25 11:29:35 +01:00
Ludovic Courtès 46bb1a41ae
syscalls: Define MS_RELATIME.
* guix/build/syscalls.scm (MS_RELATIME): New variable.
2021-02-25 11:29:35 +01:00
Jan (janneke) Nieuwenhuizen ab9e30039d
syscalls: set-thread-name, thread-name: Fix thinko.
* guix/build/syscalls.scm (set-thread-name, thread-name): Oops, fix thinko.
2020-06-08 16:49:03 +02:00
Jan (janneke) Nieuwenhuizen 1428926f1f
syscalls: set-thread-name, thread-name: Stub for the Hurd.
Avoid crash

    Backtrace:
    guix/build/syscalls.scm:405:8: In procedure prctl: Function not implemented

because of missing prctl on the Hurd.

* guix/build/syscalls.scm (set-thread-name, thread-name): Rename to ...
(set-thread-name!/linux,thread-name/linux): ...this.
(set-thread-name, thread-name): Swtich between linux implementation and or
stub.
2020-06-08 13:51:17 +02:00
Ludovic Courtès 17a102332a
syscalls: 'terminal-dimension' ignores EPERM.
Fixes <https://bugs.gnu.org/41581>.
Reported by Tobias Geerinckx-Rice <me@tobias.gr>.

* guix/build/syscalls.scm (terminal-dimension): Add EPERM to the list of
errno code for FALL-BACK.
2020-05-29 18:31:38 +02:00
Jesse Dowell b56cbe8974
syscalls: Properly match %HOST-TYPE.
Fixes <https://bugs.gnu.org/41546>.

Regression introduced in 0d371c633f.

* guix/build/syscalls.scm (write-socket-address!)
(read-socket-address): Use 'string-contains' instead of
'string-suffix?'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-05-29 18:31:38 +02:00
Jan (janneke) Nieuwenhuizen 0d371c633f
syscalls: Adjust 'sockaddr-in', 'sockaddr-in6' structs for the Hurd.
* guix/build/syscalls.scm (sockaddr-in,sockaddr-in6): Rename to ...
(sockaddr-in/linux, sockaddr-in6/linux): ... this.  Rename introduced bindings
as well.
(write-socket-address!/linux,read-socket-address/linux): Rename from
(write-socket-address!, read-socket-address): ... new switches between those
and ...
(write-socket-address!/hurd, read-socket-address/hurd): ... these new function.
2020-05-15 10:08:56 +02:00
Jan (janneke) Nieuwenhuizen df05842332
syscalls: Add 'getxattr'.
* guix/build/syscalls.scm (getxattr): New procedure.
* tests/syscalls.scm ("getxattr, setxattr"): Test it, together with setxattr.
2020-05-14 00:48:12 +02:00
Jan (janneke) Nieuwenhuizen d155c9d934
syscalls: Add 'setxattr'.
* guix/build/syscalls.scm (setxattr): New procedure.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2020-05-13 23:26:06 +02:00
Jan (janneke) Nieuwenhuizen 598be42dfa
syscalls: Add ioctl flags for the Hurd.
Use

    #include <stdio.h>
    #include <net/if.h>
    #include <hurd/ioctl.h>

    int
    main ()
    {
      printf ("SIOCSIFFLAGS #x%x\n", SIOCSIFFLAGS);
      printf ("SIOCGIFADDR #x%x\n", SIOCGIFADDR);
      printf ("SIOCSIFADDR #x%x\n", SIOCSIFADDR);
      printf ("SIOCGIFNETMASK #x%x\n", SIOCGIFNETMASK);
      printf ("SIOCSIFNETMASK #x%x\n", SIOCSIFNETMASK);
    #if 0
      printf ("SIOCADDRT #x%x\n", SIOCADDRT);
      printf ("SIOCDELRT #x%x\n", SIOCDELRT);
    #endif
    }

to fill in some blanks.  Adding and removing route apparently not supported.

* guix/build/syscalls.scm (SIOCSIFFLAGS SIOCGIFADDR, SIOCSIFADDR,
SIOCGIFNETMASK, SIOCSIFNETMASK):
2020-05-07 07:11:03 +02:00
Ludovic Courtès 86f5decd20
syscalls: 'define-c-struct' supports cross-compilation.
Reported by Jan (janneke) Nieuwenhuizen <janneke@gnu.org>.

Before that, we'd always use the 'sizeof' and 'alignof' value obtained
from the host at macro-expansion time.

* guix/build/syscalls.scm (sizeof*, alignof*): When the target word size
differs from the host word size, emit a call to 'sizeof'/'alignof'.
2020-05-05 23:45:56 +02:00
Julien Lepiller fd546bbbee
syscalls: Fix Linux detection in 'readdir*'.
* guix/build/syscalls.scm (readdir*): Fix Linux detection for
`arm-unknown-linux-gnueabihf'.
2020-04-20 16:30:14 +02:00
Ludovic Courtès 82d8959e5d
syscalls: 'readdir*' chooses between the Linux and Hurd code at run time.
Partly fixes <https://bugs.gnu.org/40574>.
Reported by Jan Nieuwenhuizen <janneke@gnu.org>.

Previously, we'd choose at expansion time whether to use the Hurd or the
Linux variant, taking the cross-compilation target into account.  This
would lead to the wrong decision when (guix build syscalls) is evaluated
while we're cross-compiling to GNU/Hurd.

This is a followup to 1ab9e48339.

* guix/build/syscalls.scm (define-generic-identifier)
(read-dirent-header, %struct-dirent-header, sizeof-dirent-header):
Remove.
(readdir*): Rename to...
(readdir-procedure): ... this, and add parameters.
(readdir*): Define as a call to 'readdir-procedure' as a function of
%HOST-TYPE.
2020-04-16 18:33:21 +02:00
Ludovic Courtès 9a067fe7ee
syscalls: 'with-file-lock' re-grabs lock when reentering its dynamic extent.
* guix/build/syscalls.scm (call-with-file-lock)
(call-with-file-lock/no-wait): Initialize PORT in the 'dynamic-wind'
"in" handler.  This allows us to re-enter a captured continuation and
have the lock grabbed anew.
2020-03-22 12:42:51 +01:00
Ludovic Courtès b782688d71
syscalls: Pass the right 'throw' arguments in 'call-with-file-lock/no-wait'.
Reported by Matt Wette <matt.wette@gmail.com>
in <https://bugs.gnu.org/39194>.

* guix/build/syscalls.scm (call-with-file-lock/no-wait): When
re-throwing, pass KEY in addition to ARGS.
2020-01-19 23:11:37 +01:00
Guillaume Le Vaillant 0dc5c85638
file-systems: Add support for 'strict-atime' and 'lazy-time' flags.
* guix/build/syscalls.scm (MS_LAZYTIME): New variable.
* gnu/build/file-systems.scm (mount-flags->bit-mask): Add match rules for
  'strict-atime' and 'lazy-time'.
* doc/guix.texi (File Systems): Add 'strict-atime' and 'lazy-time' to the list
  of supported flags.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2019-12-07 01:00:24 +01:00
Ludovic Courtès 3f8e890d91
ui: 'with-profile-lock' keeps going upon ENOLCK.
* guix/build/syscalls.scm (call-with-file-lock/no-wait): Really pass
ARGS to HANDLER.  Return #f when HANDLER is called.
* guix/ui.scm (profile-lock-handler): Emit a mere warning upon ENOLCK.
2019-11-29 15:54:20 +01:00
Julien Lepiller f49e913188
guix: Add file-locking with no wait.
* guix/build/syscalls.scm (with-file-lock/no-wait): New procedure.
(lock-file): Take a #:wait? key.
2019-11-08 21:52:30 +01:00
Ludovic Courtès 5e5f716794
syscalls: Add 'add-to-entropy-count'.
* guix/build/syscalls.scm (RNDADDTOENTCNT): New variable.
(add-to-entropy-count): New procedure.
* tests/syscalls.scm ("add-to-entropy-count"): New test.
2019-10-05 22:05:02 +02:00
Ludovic Courtès 96783ed627
syscalls: 'define-as-needed' does not re-export local variables.
Fixes <https://bugs.gnu.org/36723>.
Reported by Timothy Sample <samplet@ngyro.com>.

* guix/build/syscalls.scm (define-as-needed): Rewrite to use lower-level
module primitives; define VARIABLE only if it's not already defined to
avoid "re-exporting local variable" error.
2019-07-19 00:52:36 +02:00
Ludovic Courtès 456c7ade09
syscalls: Use 'define-as-needed' for 'AT_' constants introduced in Guile 2.2.5.
* guix/build/syscalls.scm (AT_FDCWD, AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR)
(AT_SYMLINK_FOLLOW, AT_NO_AUTOMOUNT, AT_EMPTY_PATH): Define using
'define-as-needed'.
2019-07-15 10:00:12 +02:00
Ludovic Courtès 4593f5a654
syscalls: Add 'terminal-rows'.
* guix/build/syscalls.scm (terminal-dimension): New procedure.
(terminal-columns): Rewrite in terms of 'terminal-dimension'.
(terminal-rows): New procedure.
* tests/syscalls.scm ("terminal-rows"): New test.
2019-06-27 11:14:40 +02:00
Ludovic Courtès 5f0cf1df71
syscalls: 'with-lock-file' catches ENOSYS.
* guix/build/syscalls.scm (call-with-file-lock): Catch ENOSYS raised by
'lock-file'.
2019-06-05 23:10:36 +02:00
Ludovic Courtès 89ceb86ad4
syscalls: 'with-file-lock' expands to a call to 'call-with-file-lock'.
* guix/build/syscalls.scm (call-with-file-lock): New procedure.
(with-file-lock): Expand to a call to 'call-with-file-lock'.
2019-06-05 23:10:36 +02:00
Ludovic Courtès b7178c22bf
syscalls: Add 'with-file-lock' macro.
* guix/scripts/offload.scm (lock-file, unlock-file, with-file-lock):
Move to...
* guix/build/syscalls.scm: ... here.
2019-06-05 23:10:36 +02:00
Marius Bakke 5f5499d684
syscalls: Add 'arp-network-interface?'.
* guix/build/syscalls.scm (IFF_NOARP): New variable.
(arp-network-interface?): New public procedure.
2019-05-09 20:00:21 +02:00
Tobias Geerinckx-Rice 88401314f9
guix: Fix typo in docstring.
* guix/build/syscalls.scm (device-in-use?)<docstring>: Fix typo.
2019-04-30 13:56:35 +02:00
rendaw 9d3053819d
file-systems: Support the 'no-atime' flag.
* guix/build/syscalls.scm (MS_NOATIME): New variable.
* gnu/build/file-systems.scm (mount-flags->bit-mask): Support it.
* doc/guix.texi (File Systems): Document it and add cross-references to
the relevant documentation.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2019-04-29 12:19:03 +02:00
Ludovic Courtès 077589459c
syscalls: 'device-in-use?' returns #f upon EINVAL.
This mirrors the behavior of the 'fdisk_device_is_used' function of
util-linux.

* guix/build/syscalls.scm (device-in-use?): Return #f upon EINVAL.
2019-01-17 14:04:28 +01:00
Ludovic Courtès a1f5dfc202
syscalls: 'device-in-use?' does not create a port.
* guix/build/syscalls.scm (device-in-use?): Use 'open-fdes' rather than
'open-file'.
2019-01-17 14:04:27 +01:00
Mathieu Othacehe b08bea0497
build: syscalls: Add device-in-use?.
This new procedure uses BLKRRPART to determine whether or not a device is
busy. It is useful when a device does not appear as mounted but is maybe used
by the kernel. This is the case with overlayfs lowerdir backend device for
example.

* guix/build/syscalls.scm (device-in-use?): New exported procedure.
2019-01-17 14:04:22 +01:00
Ludovic Courtès a65177a657
maint: Remove 'cond-expand' forms for Guile 2.0.
Note: Leave 'cond-expand' forms used in the build-side modules that can
run on %BOOTSTRAP-GUILE, which is currently Guile 2.0.

* guix/build/compile.scm: Move 'use-modules' clause from 'cond-expand'
to 'define-module' form.
(%default-optimizations): Remove 'cond-expand'.
* guix/build/download.scm (tls-wrap): Remove 'cond-expand'.
* guix/build/syscalls.scm: Remove 'cond-expand' form around
'%set-automatic-finalization-enabled?!' and
'without-automatic-finalization'.
* guix/inferior.scm (port->inferior): Remove 'cond-expand'.
* guix/scripts/pack.scm (wrapped-package)[build]: Remove 'cond-expand'.
* guix/status.scm (build-event-output-port): Remove 'cond-expand'.
* guix/store.scm (open-inet-socket): Remove 'cond-expand'.
* guix/ui.scm (install-locale): Remove 'cond-expand'.
* tests/status.scm ("current-build-output-port, UTF-8 + garbage"):
Remove 'cond-expand'.
* tests/store.scm ("current-build-output-port, UTF-8 + garbage"):
Remove 'cond-expand'.
2019-01-09 14:47:53 +01:00
Ludovic Courtès f8121329b1
syscalls: Report lack of a libc symbol as ENOSYS.
* guix/build/syscalls.scm (syscall->procedure): Throw to 'system-error
with ENOSYS when NAME cannot be found.
2018-09-10 17:47:52 +02:00
Ludovic Courtès 25c7ff6a3e
syscalls: Define AT_SYMLINK_NOFOLLOW et al.
* guix/build/syscalls.scm (AT_FDCWD, AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR)
(AT_SYMLINK_FOLLOW, AT_NO_AUTOMOUNT, AT_EMPTY_PATH): New variables.
* tests/syscalls.scm ("utime with AT_SYMLINK_NOFOLLOW"): New test.
2018-07-03 17:50:04 +02:00
Ludovic Courtès 1d84d7bf60
build: Require Guile >= 2.0.13.
* README, configure.ac, doc/guix.texi (Requirements): Increase minimum
Guile version from 2.0.9 to 2.0.13.
* config-daemon.ac: Remove use of 'GUIX_CHECK_UNBUFFERED_CBIP'.
* m4/guix.m4 (GUIX_CHECK_UNBUFFERED_CBIP): Remove.
* guix/build/download.scm (current-http-proxy): Remove.
* guix/build/syscalls.scm (%libc-errno-pointer, errno): Remove.
(syscall->procedure): Use #:return-errno unconditionally.
* guix/hash.scm (open-sha256-input-port)[unbuffered]: Remove outdated
comment.
* guix/http-client.scm (when-guile<=2.0.5-or-otherwise-broken): Remove.
<top level>: Remove 'when-guile<=2.0.5-or-otherwise-broken' block.
* guix/scripts/substitute.scm (fetch): Remove 'guile-version>?'
conditional.
* tests/hash.scm (supports-unbuffered-cbip?): Remove.
<top level>: Remove 'test-skip' call.
2018-02-26 18:19:34 +01:00
Ludovic Courtès 45c32bd7e5
syscalls: Define 'input-flags' for 'tcgetattr' and friends.
* guix/build/syscalls.scm (input-flags): New macro.
2017-12-06 08:51:08 +01:00
Eric Bavier 7f0bb6540a
syscalls: clone: Define syscall-id for aarch64.
* guix/build/syscalls.scm (clone): Define syscall-id for aarch64 machines.
2017-10-09 18:55:18 -05:00
Leo Famulari 6c1a317e29
Merge branch 'master' into core-updates 2017-07-23 03:42:12 -04:00
Ludovic Courtès ef03d8dc37
syscalls: Delay resolution of "scm_set_automatic_finalization_enabled".
* guix/build/syscalls.scm (%set-automatic-finalization-enabled?!) [guile-2.2]:
Wrap in 'delay'.
2017-07-18 15:31:12 +02:00
Danny Milosavljevic 0bc6fe323d
syscalls: Add network-interface-running?
* guix/build/syscalls.scm (network-interface-running?): New variable.
Export it.
* tests/syscalls.scm: Add test.

Co-authored-by: John Darrington <jmd@gnu.org>
2017-07-12 16:15:30 +02:00
Ludovic Courtès 1ab9e48339
syscalls: Adjust 'dirent64' struct for GNU/Hurd.
Reported by rennes@openmailbox.org.

* guix/build/syscalls.scm (file-type->symbol): New procedure.
(%struct-dirent-header): Rename to...
(%struct-dirent-header/linux): ... this.  Rename introduced bindings as
well.
(%struct-dirent-header/hurd): New C struct.
(define-generic-identifier): New macro.
(read-dirent-header, %struct-dirent-header, sizeof-dirent-header):
Define in terms of 'define-generic-identifier'.
2017-07-10 00:07:36 +02:00
Ludovic Courtès 3bacc655c5
syscalls: 'opendir*' error message shows the file name.
* guix/build/syscalls.scm (opendir*): Add NAME to the 'system-error'
message.
2017-06-18 00:14:07 +02:00
Ludovic Courtès fa73c19373
syscalls: Add 'scandir*'.
* guix/build/syscalls.scm (%struct-dirent-header): New C struct.
(string->pointer/utf-8, pointer->string/utf-8): New procedures.
(opendir*, closedir*, readdir*, scandir*): New procedures.
* tests/syscalls.scm ("scandir*, ENOENT")
("scandir*, ASCII file names", "scandir*, UTF-8 file names")
("scandir*, properties): New tests.
2017-06-16 17:08:22 +02:00
Ludovic Courtès 65f224dc8d
syscalls: Provide 'free-disk-space'.
* guix/build/syscalls.scm (free-disk-space): New procedure.
* guix/scripts/gc.scm (guix-gc)[ensure-free-space]: Use it instead of
'statfs'.
2017-06-02 18:47:07 +02:00
Ludovic Courtès aa401f9ba6
syscalls: Add 'thread-name' and 'set-thread-name'.
* guix/build/syscalls.scm (PR_SET_NAME, PR_GET_NAME)
(%max-thread-name-length): New variables.
(%prctl, set-thread-name, thread-name): New procedures.
* tests/syscalls.scm ("set-thread-name"): New test.
2017-05-28 23:13:39 +02:00
Mathieu Othacehe 23e525e109
syscalls: Add load-linux-module.
* guix/build/syscalls.scm (load-linux-module): New procedure. Reimplemented
from guile-linux-syscalls.patch.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2017-04-11 11:13:26 +02:00
Mathieu Othacehe c5cd4fad09
syscalls: Use define-as-needed for network-interface syscalls.
* guix/build/syscalls.scm (network-interface-flags): Use define-as-needed macro
and remove from export list.
(set-network-interface-flags): Ditto.
(set-network-interface-address): Ditto.
(IFF_UP, IFF_BROADCAST and IFF_LOOPBACK): Ditto.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2017-04-11 11:13:25 +02:00
Mathieu Othacehe 7df4d3465d
syscalls: Use define-as-needed for mount and umount.
* guix/build/syscalls.scm (mount): Use define-as-needed macro
and remove from export list.
(umount): Ditto.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2017-04-11 11:13:25 +02:00
Mathieu Othacehe 8336df0668
syscalls: Add reboot.
* guix/build/syscalls.scm (define-as-needed): New macro.
(reboot): New procedure. Reimplemented from guile-linux-syscalls.patch.
(RB_AUTOBOOT, ..., RB_KEXEC): New flags copied from static Guile patch.

Co-Authored-By: Ludovic Courtès <ludo@gnu.org>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2017-04-11 11:13:25 +02:00
Mathieu Othacehe f91fcd9c42
syscalls: Allow mount and umount use from static Guile.
* guix/build/syscalls.scm (mount): Use Guile core mount if called from
  static Guile, otherwise use FFI based mount implementation.
  (umount): Ditto.
  This allows to use (guix build syscalls) from a module independently
  of calling context.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2017-04-07 23:30:39 +02:00