mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Feature request: expose Linux-specific renameat2 function
@ 2023-02-20 23:28 vi0oss
  2023-02-21  4:09 ` Markus Wichmann
  0 siblings, 1 reply; 2+ messages in thread
From: vi0oss @ 2023-02-20 23:28 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: 0001-expose-renameat2-function-if-such-syscall-is-availab.patch --]
[-- Type: text/x-diff, Size: 1071 bytes --]

From 70d1747dd0fb31df780d2e0255a8e0417899b6ca Mon Sep 17 00:00:00 2001
From: Vitaly _Vi Shukela <vi0oss@gmail.com>
Date: Tue, 21 Feb 2023 00:23:45 +0100
Subject: [PATCH] expose renameat2 function if such syscall is available

Does not include RENAME_EXCHANGE, RENAME_NOREPLACE or
RENAME_WHITEOUT constants that are likely to be the
reason to use renameat2 instead of renameat, but this
should still simplify linking issues arising from the
use of renameat2 and enable simpler workarounds.
---
 src/unistd/renameat.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/unistd/renameat.c b/src/unistd/renameat.c
index c3b40a25..fe1adaf4 100644
--- a/src/unistd/renameat.c
+++ b/src/unistd/renameat.c
@@ -9,3 +9,10 @@ int renameat(int oldfd, const char *old, int newfd, const char *new)
 	return syscall(SYS_renameat2, oldfd, old, newfd, new, 0);
 #endif
 }
+
+#ifdef SYS_renameat2
+int renameat2(int oldfd, const char *old, int newfd, const char *new, unsigned int flags)
+{
+	return syscall(SYS_renameat2, oldfd, old, newfd, new, flags);
+}
+#endif
-- 
2.39.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] Feature request: expose Linux-specific renameat2 function
  2023-02-20 23:28 [musl] Feature request: expose Linux-specific renameat2 function vi0oss
@ 2023-02-21  4:09 ` Markus Wichmann
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Wichmann @ 2023-02-21  4:09 UTC (permalink / raw)
  To: musl

On Tue, Feb 21, 2023 at 12:28:41AM +0100, vi0oss wrote:
> Does not include RENAME_EXCHANGE, RENAME_NOREPLACE or
> RENAME_WHITEOUT constants that are likely to be the
> reason to use renameat2 instead of renameat, but this
> should still simplify linking issues arising from the
> use of renameat2 and enable simpler workarounds.

I'm wondering why this system call cannot be handled like every other
new system interface: By making the users copy the necessary definitions
into their projects and wrapping the syscall themselves while the libc
does not contain them.

I don't think the patch could be applied as-is. There is little obvious
reason (and no reason given) why this needs to be added to the
renameat.c file instead of its own file. Nor is it obvious why the
abovementioned constants cannot be added under _GNU_SOURCE. If they are
kernel interface, they cannot change anymore.

Ciao,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-21  4:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-20 23:28 [musl] Feature request: expose Linux-specific renameat2 function vi0oss
2023-02-21  4:09 ` Markus Wichmann

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).