mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 00:26:16 +03:00
libfaketime.c: get rid of stat64 things on aarch64-darwin
To give more context, stat64 is a child of large-file support (LFS) back in 1996, during the transition from 32-bit to 64-bit. People wanted 64-bit inodes in 32-bit systems, hence stat and stat64. Nowadays where everything is 64-bit, stat64 is mostly just an alias to stat, as stat is already native 64-bit. On modern implementations like musl, stat64 is even dropped entirely as a sane default. We observe the same in darwin's stat.h: #if !__DARWIN_ONLY_64_BIT_INO_T struct stat64 __DARWIN_STRUCT_STAT64; #endif /* !__DARWIN_ONLY_64_BIT_INO_T */ Because struct stat64 doesn't ever exist on aarch64-darwin, and we don't have to worry about people using stat64 calls, we can safely remove all stat64 bloat, according to __DARWIN_ONLY_64_BIT_INO_T. I nuked fake_stat64buf because only STAT64_HANDLER is using it, and only non-darwin stat64 things use that handler. I didn't do more because people might still use stat64 things on x86_64 (on glibc) and other older 32-bit platforms, and we still need to hook those. A loose follow up to PR #453. Fixes the remaining clang warnings on aarch64-darwin.
This commit is contained in:
@@ -208,10 +208,12 @@ static int (*real_xstat) (int, const char *, struct stat *);
|
||||
static int (*real_fxstat) (int, int, struct stat *);
|
||||
static int (*real_fxstatat) (int, int, const char *, struct stat *, int);
|
||||
static int (*real_lxstat) (int, const char *, struct stat *);
|
||||
#if !defined(__APPLE__) || !__DARWIN_ONLY_64_BIT_INO_T
|
||||
static int (*real_xstat64) (int, const char *, struct stat64 *);
|
||||
static int (*real_fxstat64) (int, int , struct stat64 *);
|
||||
static int (*real_fxstatat64) (int, int , const char *, struct stat64 *, int);
|
||||
static int (*real_lxstat64) (int, const char *, struct stat64 *);
|
||||
#endif
|
||||
#ifdef STATX_TYPE
|
||||
static int (*real_statx) (int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf);
|
||||
#endif
|
||||
@@ -983,6 +985,7 @@ static inline void fake_statbuf (struct stat *buf) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
static inline void fake_stat64buf (struct stat64 *buf) {
|
||||
#ifndef st_atime
|
||||
lock_for_stat();
|
||||
@@ -992,18 +995,13 @@ static inline void fake_stat64buf (struct stat64 *buf) {
|
||||
unlock_for_stat();
|
||||
#else
|
||||
lock_for_stat();
|
||||
#ifndef __APPLE__
|
||||
fake_clock_gettime(CLOCK_REALTIME, &buf->st_ctim);
|
||||
fake_clock_gettime(CLOCK_REALTIME, &buf->st_atim);
|
||||
fake_clock_gettime(CLOCK_REALTIME, &buf->st_mtim);
|
||||
#else
|
||||
fake_clock_gettime(CLOCK_REALTIME, &buf->st_ctimespec);
|
||||
fake_clock_gettime(CLOCK_REALTIME, &buf->st_atimespec);
|
||||
fake_clock_gettime(CLOCK_REALTIME, &buf->st_mtimespec);
|
||||
#endif
|
||||
unlock_for_stat();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* macOS dyld interposing uses the function's real name instead of real_name */
|
||||
#ifdef MACOS_DYLD_INTERPOSE
|
||||
@@ -1113,25 +1111,19 @@ int __lxstat (int ver, const char *path, struct stat *buf)
|
||||
{
|
||||
STAT_HANDLER(lxstat, buf, ver, path, buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
/* Contributed by Philipp Hachtmann in version 0.6 */
|
||||
int __xstat64 (int ver, const char *path, struct stat64 *buf)
|
||||
{
|
||||
STAT64_HANDLER(xstat64, buf, ver, path, buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
/* Contributed by Philipp Hachtmann in version 0.6 */
|
||||
int __fxstat64 (int ver, int fildes, struct stat64 *buf)
|
||||
{
|
||||
STAT64_HANDLER(fxstat64, buf, ver, fildes, buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
/* Added in v0.8 as suggested by Daniel Kahn Gillmor */
|
||||
#ifndef NO_ATFILE
|
||||
int __fxstatat64 (int ver, int fildes, const char *filename, struct stat64 *buf, int flag)
|
||||
@@ -1139,16 +1131,14 @@ int __fxstatat64 (int ver, int fildes, const char *filename, struct stat64 *buf,
|
||||
STAT64_HANDLER(fxstatat64, buf, ver, fildes, filename, buf, flag);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
/* Contributed by Philipp Hachtmann in version 0.6 */
|
||||
int __lxstat64 (int ver, const char *path, struct stat64 *buf)
|
||||
{
|
||||
STAT64_HANDLER(lxstat64, buf, ver, path, buf);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif /* ifndef __APPLE__ */
|
||||
#endif /* ifdef FAKE_STAT */
|
||||
|
||||
#ifdef STATX_TYPE
|
||||
static inline void fake_statx_timestamp(struct statx_timestamp* p)
|
||||
@@ -2689,10 +2679,12 @@ static void ftpl_really_init(void)
|
||||
real_fxstat = dlsym(RTLD_NEXT, "__fxstat");
|
||||
real_fxstatat = dlsym(RTLD_NEXT, "__fxstatat");
|
||||
real_lxstat = dlsym(RTLD_NEXT, "__lxstat");
|
||||
#if !defined(__APPLE__) || !__DARWIN_ONLY_64_BIT_INO_T
|
||||
real_xstat64 = dlsym(RTLD_NEXT,"__xstat64");
|
||||
real_fxstat64 = dlsym(RTLD_NEXT, "__fxstat64");
|
||||
real_fxstatat64 = dlsym(RTLD_NEXT, "__fxstatat64");
|
||||
real_lxstat64 = dlsym(RTLD_NEXT, "__lxstat64");
|
||||
#endif
|
||||
#ifdef STATX_TYPE
|
||||
real_statx = dlsym(RTLD_NEXT, "statx");
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user