diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-09-17 19:47:57 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-09-17 19:58:30 +0000 |
commit | 7ae60af75b78f408420512c58fd5a08ca7a88bad (patch) | |
tree | 51ef7f542c448a0717e69029f1b9dd164933c7bd /sysdeps/mach/hurd/rename.c | |
parent | 6841aed6c4abde1aa7015348496c86cadc227a1f (diff) | |
download | glibc-7ae60af75b78f408420512c58fd5a08ca7a88bad.tar.gz glibc-7ae60af75b78f408420512c58fd5a08ca7a88bad.tar.xz glibc-7ae60af75b78f408420512c58fd5a08ca7a88bad.zip |
hurd: Factorize at/non-at functions
Non-at functions can be implemented by just calling the corresponding at function with AT_FDCWD and zero at_flags. In the linkat case, the at behavior is different (O_NOLINK), so this introduces __linkat_common to pass O_NOLINK as appropriate. lstat functions can also be implemented with fstatat by adding __fstatat64_common which takes a flags parameter in addition to the at_flags parameter, In the end this factorizes chmod, chown, link, lstat64, mkdir, readlink, rename, stat64, symlink, unlink, utimes. This also makes __lstat, __lxstat64, __stat and __xstat64 directly use __fstatat64_common instead of __lstat64 or __stat64.
Diffstat (limited to 'sysdeps/mach/hurd/rename.c')
-rw-r--r-- | sysdeps/mach/hurd/rename.c | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/sysdeps/mach/hurd/rename.c b/sysdeps/mach/hurd/rename.c index 75b4e75e93..cf2fa19913 100644 --- a/sysdeps/mach/hurd/rename.c +++ b/sysdeps/mach/hurd/rename.c @@ -22,24 +22,5 @@ int rename (const char *old, const char *new) { - error_t err; - file_t olddir, newdir; - const char *oldname, *newname; - - olddir = __directory_name_split (old, (char **) &oldname); - if (olddir == MACH_PORT_NULL) - return -1; - newdir = __directory_name_split (new, (char **) &newname); - if (newdir == MACH_PORT_NULL) - { - __mach_port_deallocate (__mach_task_self (), olddir); - return -1; - } - - err = __dir_rename (olddir, oldname, newdir, newname, 0); - __mach_port_deallocate (__mach_task_self (), olddir); - __mach_port_deallocate (__mach_task_self (), newdir); - if (err) - return __hurd_fail (err); - return 0; + return __renameat2 (AT_FDCWD, old, AT_FDCWD, new, 0); } |