fakechroot/86.patch

138 lines
4.2 KiB
Diff

From afd606ed43ca97a58db68e5add6e9a90f0a74c9b Mon Sep 17 00:00:00 2001
From: neok-m4700 <neok-m4700@users.noreply.github.com>
Date: Wed, 24 Feb 2021 17:36:57 +0100
Subject: [PATCH] wrap fstatat and fstatat64
---
configure.ac | 2 ++
src/Makefile.am | 2 ++
src/fstatat.c | 42 ++++++++++++++++++++++++++++++++++++++++++
src/fstatat64.c | 43 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 89 insertions(+)
create mode 100644 src/fstatat.c
create mode 100644 src/fstatat64.c
diff --git a/configure.ac b/configure.ac
index f8cdb32..032dd3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -198,6 +198,8 @@ AC_CHECK_FUNCS(m4_normalize([
freopen64
fstat
fstat64
+ fstatat
+ fstatat64
fts_children
fts_open
fts_read
diff --git a/src/Makefile.am b/src/Makefile.am
index 6066345..eb311c0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -61,6 +61,8 @@ libfakechroot_la_SOURCES = \
fopen64.c \
freopen.c \
freopen64.c \
+ fstatat.c \
+ fstatat64.c \
fts.c \
fts64.c \
ftw.c \
diff --git a/src/fstatat.c b/src/fstatat.c
new file mode 100644
index 0000000..ca7578b
--- /dev/null
+++ b/src/fstatat.c
@@ -0,0 +1,42 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE_FSTATAT
+
+#define _ATFILE_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#include <sys/stat.h>
+#include <limits.h>
+#include "libfakechroot.h"
+
+wrapper(fstatat, int, (int dirfd, const char *pathname, struct stat *buf, int flags))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("fstatat(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
+ expand_chroot_path_at(dirfd, pathname);
+ return nextcall(fstatat)(dirfd, pathname, buf, flags);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif
diff --git a/src/fstatat64.c b/src/fstatat64.c
new file mode 100644
index 0000000..1863372
--- /dev/null
+++ b/src/fstatat64.c
@@ -0,0 +1,43 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE_FSTATAT64
+
+#define _ATFILE_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#define _LARGEFILE64_SOURCE
+#include <sys/stat.h>
+#include <limits.h>
+#include "libfakechroot.h"
+
+wrapper(fstatat64, int, (int dirfd, const char *pathname, struct stat64 *buf, int flags))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("fstatat64(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
+ expand_chroot_path_at(dirfd, pathname);
+ return nextcall(fstatat64)(dirfd, pathname, buf, flags);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif