1
0
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:
Samuel Thibault
2022-09-17 19:47:57 +00:00
parent 6841aed6c4
commit 7ae60af75b
29 changed files with 123 additions and 226 deletions

View File

@@ -18,6 +18,9 @@
#include <errno.h>
#include <sys/stat.h>
#include <stddef.h>
#include <fcntl.h>
#include <fstatat_common.h>
#include "statconv.c"
@@ -25,6 +28,7 @@ int
__lstat (const char *file, struct stat *buf)
{
struct stat64 buf64;
return __lstat64 (file, &buf64) ?: stat64_conv (buf, &buf64);
return __fstatat64_common (AT_FDCWD, file, &buf64, 0, O_NOLINK) ?:
stat64_conv (buf, &buf64);
}
weak_alias (__lstat, lstat)