, but that will not wo...">

There is no call function "renameat2" on Ubuntu 16.04

The man page for renameat2()says that I need to enable it <stdio.h>, but that will not work.

When i do

cd /usr/include
grep -r renameat2

I see that __SYSCALL is defined, but there is no glibc function. Flags for the system call are available at <linux/fs.h>, but this is not included.

+4
source share
1 answer

Ok, I found the answer here, a common glibc problem not adding system calls, and the man page is missing

Note. There is no glibc shell for this system call; see NOTES.

which is displayed on other pages. So I'm confused.

, https://lwn.net/Articles/655028/

#include <sys/syscall.h>
#include <linux/fs.h>

int src_fd = open("old_dir", O_PATH);
itn dest_fd = open("new_dir", O_PATH);
const char* src_path = "old_name.txt";
const char* dest_path = "new_name.txt";

unsigned int flags = RENAME_NOREPLACE;
int rc = syscall(SYS_renameat2, src_fd src_path, dest_fd, dest_path, flags);
+5

Source: https://habr.com/ru/post/1666803/


All Articles