Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
compat: fstatat is available everywhere
Baptiste Daroussin committed 3 months ago
commit fd612a1bd6823904e896ea91f1389f300f35a80d
parent 5e23dd0
3 files changed +2 -26
modified auto.def
@@ -180,7 +180,7 @@ cc-check-includes stdint.h inttypes.h
cc-check-functions arc4random arc4random_stir chflagsat \
	closefrom fopencookie funopen getprogname \
	strtofflags strtonum utimensat __res_setservers \
-
	faccessat fstatat openat readlinkat fflagstostr reallocarray strchrnul \
+
	fstatat openat readlinkat fflagstostr reallocarray strchrnul \
	copy_file_range

cc-with { -includes { libutil.h }} {
modified compat/bsd_compat.h
@@ -104,10 +104,6 @@ void closefrom(int lowfd);
#define	AT_SYMLINK_NOFOLLOW	0x200
#endif

-
#if !HAVE_FSTATAT
-
int fstatat(int fd, const char *path, struct stat *buf, int flag);
-
#endif
-

#if !HAVE_OPENAT
int openat(int fd, const char *path, int flags, ...);
#endif
modified compat/file_at.c
@@ -33,7 +33,7 @@
#include <stdarg.h>
#include <unistd.h>

-
#if !HAVE_UNLINKAT || !HAVE_FSTATAT
+
#if !HAVE_UNLINKAT

static pthread_mutex_t file_at_lock = PTHREAD_MUTEX_INITIALIZER;
static int file_at_dfd = -1;
@@ -109,26 +109,6 @@ readlinkat(int fd, const char *restrict path, char *restrict buf,
}
#endif

-
#if !HAVE_FSTATAT
-
int
-
fstatat(int fd, const char *path, struct stat *buf, int flag)
-
{
-
	int ret;
-

-
	if ((ret = file_chdir_lock(fd) != 0))
-
		return ret;
-

-
	if (flag & AT_SYMLINK_NOFOLLOW) {
-
		ret = lstat(path, buf);
-
	} else {
-
		ret = stat(path, buf);
-
	}
-

-
	file_chdir_unlock(fd);
-
	return ret;
-
}
-
#endif
-

#if !HAVE_OPENAT
int
openat(int fd, const char *path, int flags, ...)