#define RENAME_NOREPLACE 1 int rename(int sourcedirfd, const char *sourcepath, size_t sourcelen, int targetirfd, const char *targetpath, size_t targetlen, int flags);
This syscalls renames a file in an atomic operation, it is only available in
between files in the same mountpoint. If targetpath
exists, it will be
replaced, RENAME_NOREPLACE
may be passed in flags
for making the
call fail in said case instead of replacing silently.
The syscall return the new fd on success and -1
on failure. The errno
codes set on failure are:
EFAULT
: One of the passed values is outside addressable memory.
ENAMETOOLONG
: The passed path is too long.
EIO
: The operation could not be done out of an internal error.