Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap fstatat and fstatat64 (glibc 2.33) #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ AC_CHECK_FUNCS(m4_normalize([
freopen64
fstat
fstat64
fstatat
fstatat64
fts_children
fts_open
fts_read
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ libfakechroot_la_SOURCES = \
fopen64.c \
freopen.c \
freopen64.c \
fstatat.c \
fstatat64.c \
fts.c \
fts64.c \
ftw.c \
Expand Down
42 changes: 42 additions & 0 deletions src/fstatat.c
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions src/fstatat64.c
Original file line number Diff line number Diff line change
@@ -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