mirror of
git://git.musl-libc.org/musl
synced 2024-11-27 03:53:58 +08:00
add renameat2 linux syscall wrapper
This syscall is available since Linux 3.15 and also implemented in glibc from version 2.28. It is commonly used in filesystem or security contexts. Constants RENAME_NOREPLACE, RENAME_EXCHANGE, RENAME_WHITEOUT are guarded by _GNU_SOURCE as with glibc.
This commit is contained in:
parent
0079972992
commit
05ce67fea9
@ -158,6 +158,13 @@ char *ctermid(char *);
|
||||
#define L_ctermid 20
|
||||
#endif
|
||||
|
||||
#if defined(_GNU_SOURCE)
|
||||
#define RENAME_NOREPLACE (1 << 0)
|
||||
#define RENAME_EXCHANGE (1 << 1)
|
||||
#define RENAME_WHITEOUT (1 << 2)
|
||||
|
||||
int renameat2(int, const char *, int, const char *, unsigned);
|
||||
#endif
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|
||||
|| defined(_BSD_SOURCE)
|
||||
|
11
src/linux/renameat2.c
Normal file
11
src/linux/renameat2.c
Normal file
@ -0,0 +1,11 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include "syscall.h"
|
||||
|
||||
int renameat2(int oldfd, const char *old, int newfd, const char *new, unsigned flags)
|
||||
{
|
||||
#ifdef SYS_renameat
|
||||
if (!flags) return syscall(SYS_renameat, oldfd, old, newfd, new);
|
||||
#endif
|
||||
return syscall(SYS_renameat2, oldfd, old, newfd, new, flags);
|
||||
}
|
Loading…
Reference in New Issue
Block a user