aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-12-16 00:13:45 +0000
committerUlrich Drepper <drepper@redhat.com>2005-12-16 00:13:45 +0000
commitfc30e8dafa2326ef5f5c05f032606635c329cc12 (patch)
treede36ee56586392e1d85fe068056c509a9f6b05b6 /sysdeps
parent29402b1285b2f8b8d65c1e478b59e658faaa2583 (diff)
downloadglibc-fc30e8dafa2326ef5f5c05f032606635c329cc12.tar
glibc-fc30e8dafa2326ef5f5c05f032606635c329cc12.tar.gz
glibc-fc30e8dafa2326ef5f5c05f032606635c329cc12.tar.bz2
glibc-fc30e8dafa2326ef5f5c05f032606635c329cc12.zip
Move errno setting code in separate function __atfct_seterrno_2.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/sysv/linux/renameat.c87
1 files changed, 48 insertions, 39 deletions
diff --git a/sysdeps/unix/sysv/linux/renameat.c b/sysdeps/unix/sysv/linux/renameat.c
index 9d94d5f86c..849c67b5d6 100644
--- a/sysdeps/unix/sysv/linux/renameat.c
+++ b/sysdeps/unix/sysv/linux/renameat.c
@@ -23,6 +23,52 @@
#include <sysdep.h>
+void
+attribute_hidden
+__atfct_seterrno_2 (int errval, int fd1, const char *buf1, int fd2,
+ const char *buf2)
+{
+ if (errval == ENOTDIR && (buf1 != NULL || buf2 != NULL))
+ {
+ /* This can mean either the file descriptor is invalid or
+ /proc is not mounted. */
+ struct stat64 st;
+
+ if (buf1 != NULL)
+ {
+ if (__fxstat64 (_STAT_VER, fd1, &st) != 0)
+ /* errno is already set correctly. */
+ return;
+
+ /* If /proc is not mounted there is nothing we can do. */
+ if (S_ISDIR (st.st_mode)
+ && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0
+ || !S_ISDIR (st.st_mode)))
+ {
+ errval = ENOSYS;
+ goto out;
+ }
+ }
+
+ if (buf2 != NULL)
+ {
+ if (__fxstat64 (_STAT_VER, fd2, &st) != 0)
+ /* errno is already set correctly. */
+ return;
+
+ /* If /proc is not mounted there is nothing we can do. */
+ if (S_ISDIR (st.st_mode)
+ && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0
+ || !S_ISDIR (st.st_mode)))
+ errval = ENOSYS;
+ }
+ }
+
+ out:
+ __set_errno (errval);
+}
+
+
/* Rename the file OLD relative to OLDFD to NEW relative to NEWFD. */
int
renameat (oldfd, old, newfd, new)
@@ -76,45 +122,8 @@ renameat (oldfd, old, newfd, new)
if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0))
{
- int errval = INTERNAL_SYSCALL_ERRNO (result, err);
- if (errval == ENOTDIR && (bufnew != NULL || bufold != NULL))
- {
- /* This can mean either the file descriptor is invalid or
- /proc is not mounted. */
- struct stat64 st;
-
- if (bufnew != NULL)
- {
- if (__fxstat64 (_STAT_VER, newfd, &st) != 0)
- /* errno is already set correctly. */
- return -1;
-
- /* If /proc is not mounted there is nothing we can do. */
- if (S_ISDIR (st.st_mode)
- && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0
- || !S_ISDIR (st.st_mode)))
- {
- errval = ENOSYS;
- goto out;
- }
- }
-
- if (bufold != NULL)
- {
- if (__fxstat64 (_STAT_VER, oldfd, &st) != 0)
- /* errno is already set correctly. */
- return -1;
-
- /* If /proc is not mounted there is nothing we can do. */
- if (S_ISDIR (st.st_mode)
- && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0
- || !S_ISDIR (st.st_mode)))
- errval = ENOSYS;
- }
- }
-
- out:
- __set_errno (errval);
+ __atfct_seterrno_2 (INTERNAL_SYSCALL_ERRNO (result, err), newfd, bufnew,
+ oldfd, bufold);
result = -1;
}