mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
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.
This commit is contained in:
@@ -21,21 +21,13 @@
|
||||
#include <fcntl.h>
|
||||
#include <hurd.h>
|
||||
|
||||
#include <fstatat_common.h>
|
||||
|
||||
/* Get information about the file descriptor FD in BUF. */
|
||||
int
|
||||
__lstat64 (const char *file, struct stat64 *buf)
|
||||
{
|
||||
error_t err;
|
||||
file_t port;
|
||||
|
||||
port = __file_name_lookup (file, O_NOLINK, 0);
|
||||
if (port == MACH_PORT_NULL)
|
||||
return -1;
|
||||
err = __io_stat (port, buf);
|
||||
__mach_port_deallocate (__mach_task_self (), port);
|
||||
if (err)
|
||||
return __hurd_fail (err);
|
||||
return 0;
|
||||
return __fstatat64_common (AT_FDCWD, file, buf, 0, O_NOLINK);
|
||||
}
|
||||
hidden_def (__lstat64)
|
||||
weak_alias (__lstat64, lstat64)
|
||||
|
Reference in New Issue
Block a user