diff --git a/man2/renameat.2 b/man2/renameat.2 index 432ddfd..e2f80d8 100644 --- a/man2/renameat.2 +++ b/man2/renameat.2 @@ -24,7 +24,7 @@ .\" .TH RENAMEAT 2 2012-05-04 "Linux" "Linux Programmer's Manual" .SH NAME -renameat \- rename a file relative to directory file descriptors +renameat, renameat2 \- rename a file relative to directory file descriptors .SH SYNOPSIS .nf .B #include /* Definition of AT_* constants */ @@ -32,6 +32,9 @@ renameat \- rename a file relative to directory file descriptors .sp .BI "int renameat(int " olddirfd ", const char *" oldpath , .BI " int " newdirfd ", const char *" newpath ); + +.BI "int renameat2(int " olddirfd ", const char *" oldpath , +.BI " int " newdirfd ", const char *" newpath ", unsigned int " flags ); .fi .sp .in -4n @@ -55,7 +58,9 @@ _ATFILE_SOURCE .SH DESCRIPTION The .BR renameat () -system call operates in exactly the same way as +and +.BR renameat2 () +system calls operate in exactly the same way as .BR rename (2), except for the differences described in this manual page. @@ -94,10 +99,37 @@ is as for except that a relative pathname is interpreted relative to the directory referred to by the file descriptor .IR newdirfd . + +.BR renameat2 () +has an additional +.I flags +argument. +.BR renameat2 () +call with a zero +.I flags +argument is equivalent to +.BR renameat (). + +The +.I flags +argument is a bitfield consisting of zero or more of the following +constants defined in +.IR : +.TP +.B RENAME_NOREPLACE +Don't overwrite the target of the rename. Return an error +if the target would be overwritten. +.TP +.B RENAME_EXCHANGE +Atomically exchange the source and destination. Both must exist +but may be of a different type (e.g. one a non-empty directory +and the other a symbolic link). .SH RETURN VALUE On success, .BR renameat () -returns 0. +and +.BR renameat2 () +return 0. On error, \-1 is returned and .I errno is set to indicate the error. @@ -105,9 +137,13 @@ is set to indicate the error. The same errors that occur for .BR rename (2) can also occur for -.BR renameat (). +.BR renameat () +and +.BR renameat2 (). The following additional errors can occur for -.BR renameat (): +.BR renameat () +and +.BR renameat2 (): .TP .B EBADF .I olddirfd @@ -124,12 +160,37 @@ or similar for .I newpath and .I newdirfd +.RE +.PP +The following additional errors are defined for +.BR renameat2 (): +.TP +.B EOPNOTSUPP +The filesystem does not support a flag in +.I flags +.TP +.B EINVAL +Invalid combination of +.I flags +.TP +.B EEXIST +.I flags +contain +.B RENAME_NOREPLACE +and the target of the rename exists +.TP +.B ENOENT +.I flags +contain +.B RENAME_EXCHANGE +and the target of the rename does not exist .SH VERSIONS .BR renameat () was added to Linux in kernel 2.6.16; library support was added to glibc in version 2.4. .SH CONFORMING TO -POSIX.1-2008. +.BR renameat () +is specified in POSIX.1-2008. .SH NOTES See .BR openat (2)