|
|
Message-ID: <1a044c57cee.1313a8e6930948.7595669041576353325@soss.website>
Date: Thu, 27 Aug 2026 14:49:48 -0500
From: Skye Soss <skye@...s.website>
To: "musl" <musl@...ts.openwall.com>
Subject: [PATCH v2] add linux-specific close_range syscall wrapper
This patch adds the close_range syscall wrapper.
The syscall was added in Linux 5.9.
The Linux syscall accepts the flags parameter as unsigned, but glibc's wrapper
uses a signed integer. The cast ensures that sign extension does not occur.
Because function availability is often checked via HAVE_ macros, this needs
to be exposed as a wrapper function; forcing users to use syscall() is not
good enough for configure-time detection (as done by GLib).
---
include/unistd.h | 3 +++
src/linux/close_range.c | 8 ++++++++
2 files changed, 11 insertions(+)
create mode 100644 src/linux/close_range.c
diff --git a/include/unistd.h b/include/unistd.h
index 42b0e82b..0b0e52a6 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -185,6 +185,8 @@ extern int optreset;
#endif
#ifdef _GNU_SOURCE
+#define CLOSE_RANGE_UNSHARE 0x01
+#define CLOSE_RANGE_CLOEXEC 0x02
extern char **environ;
int setresuid(uid_t, uid_t, uid_t);
int setresgid(gid_t, gid_t, gid_t);
@@ -196,6 +198,7 @@ int euidaccess(const char *, int);
int eaccess(const char *, int);
ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
pid_t gettid(void);
+int close_range(unsigned, unsigned, int);
#endif
#if defined(_LARGEFILE64_SOURCE)
diff --git a/src/linux/close_range.c b/src/linux/close_range.c
new file mode 100644
index 00000000..ab44411a
--- /dev/null
+++ b/src/linux/close_range.c
@@ -0,0 +1,8 @@
+#define _GNU_SOURCE
+#include <unistd.h>
+#include "syscall.h"
+
+int close_range(unsigned first, unsigned last, int flags)
+{
+ return syscall(SYS_close_range, first, last, (unsigned)flags);
+}
--
2.55.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.