Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 774666
Collapse All | Expand All

(-)a/configure.ac (+1 lines)
Lines 277-282 AC_CHECK_FUNCS(m4_normalize([ Link Here
277
    statfs64
277
    statfs64
278
    statvfs
278
    statvfs
279
    statvfs64
279
    statvfs64
280
    statx
280
    stpcpy
281
    stpcpy
281
    strchrnul
282
    strchrnul
282
    strlcpy
283
    strlcpy
(-)a/src/Makefile.am (+1 lines)
Lines 152-157 libfakechroot_la_SOURCES = \ Link Here
152
    statfs64.c \
152
    statfs64.c \
153
    statvfs.c \
153
    statvfs.c \
154
    statvfs64.c \
154
    statvfs64.c \
155
    statx.c \
155
    stpcpy.c \
156
    stpcpy.c \
156
    strchrnul.c \
157
    strchrnul.c \
157
    strchrnul.h \
158
    strchrnul.h \
(-)a/src/statx.c (-1 / +44 lines)
Line 0 Link Here
0
--
1
/*
2
    libfakechroot -- fake chroot environment
3
    Copyright (c) 2010-2020 Piotr Roszatycki <dexter@debian.org>
4
5
    This library is free software; you can redistribute it and/or
6
    modify it under the terms of the GNU Lesser General Public
7
    License as published by the Free Software Foundation; either
8
    version 2.1 of the License, or (at your option) any later version.
9
10
    This library is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
    Lesser General Public License for more details.
14
15
    You should have received a copy of the GNU Lesser General Public
16
    License along with this library; if not, write to the Free Software
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
18
*/
19
20
21
#include <config.h>
22
23
#ifdef HAVE_STATX
24
25
#define _GNU_SOURCE
26
#include <sys/types.h>
27
#include <sys/stat.h>
28
#include <unistd.h>
29
30
#include "libfakechroot.h"
31
32
33
wrapper(statx, int, (int dirfd, const char * pathname, int flags, unsigned int mask, struct statx * statxbuf))
34
{
35
    char fakechroot_abspath[FAKECHROOT_PATH_MAX];
36
    char fakechroot_buf[FAKECHROOT_PATH_MAX];
37
    debug("statx(%d, \"%s\", %d, %u, &statxbuf)", dirfd, pathname, flags, mask);
38
    expand_chroot_path_at(dirfd, pathname);
39
    return nextcall(statx)(dirfd, pathname, flags, mask, statxbuf);
40
}
41
42
#else
43
typedef int empty_translation_unit;
44
#endif
1
src/tmpnam.c | 2 +-
45
src/tmpnam.c | 2 +-
2
1 file changed, 1 insertion(+), 1 deletion(-)
46
1 file changed, 1 insertion(+), 1 deletion(-)
(-)a/src/tmpnam.c (-2 / +1 lines)
Lines 42-48 wrapper(tmpnam, char *, (char * s)) Link Here
42
42
43
    expand_chroot_path(ptr);
43
    expand_chroot_path(ptr);
44
44
45
    ptr2 = malloc(strlen(ptr));
45
    ptr2 = malloc(strlen(ptr) + 1);
46
    if (ptr2 == NULL) return NULL;
46
    if (ptr2 == NULL) return NULL;
47
47
48
    strcpy(ptr2, ptr);
48
    strcpy(ptr2, ptr);
49
--
50
src/lstat.c  | 8 +++++---
49
src/lstat.c  | 8 +++++---
51
src/lstat.h  | 2 +-
50
src/lstat.h  | 2 +-
52
src/mknod.c  | 2 ++
51
src/mknod.c  | 2 ++
53
src/stat.c   | 2 ++
52
src/stat.c   | 2 ++
54
src/stat64.c | 2 ++
53
src/stat64.c | 2 ++
55
5 files changed, 12 insertions(+), 4 deletions(-)
54
5 files changed, 12 insertions(+), 4 deletions(-)
(-)a/src/lstat.c (-3 / +5 lines)
Lines 28-36 Link Here
28
#include "lstat.h"
28
#include "lstat.h"
29
29
30
30
31
wrapper(lstat, int, (int ver, const char * filename, struct stat * buf))
31
wrapper(lstat, int, (const char * filename, struct stat * buf))
32
{
32
{
33
    debug("lstat(%d, \"%s\", &buf)", ver, filename);
33
    char fakechroot_abspath[FAKECHROOT_PATH_MAX];
34
    char fakechroot_buf[FAKECHROOT_PATH_MAX];
35
    debug("lstat(\"%s\", &buf)", filename);
34
36
35
    if (!fakechroot_localdir(filename)) {
37
    if (!fakechroot_localdir(filename)) {
36
        if (filename != NULL) {
38
        if (filename != NULL) {
Lines 40-46 wrapper(lstat, int, (int ver, const char * filename, struct stat * buf)) Link Here
40
        }
42
        }
41
    }
43
    }
42
44
43
    return lstat_rel(ver, filename, buf);
45
    return lstat_rel(filename, buf);
44
}
46
}
45
47
46
48
(-)a/src/lstat.h (-1 / +1 lines)
Lines 26-32 Link Here
26
26
27
#ifndef HAVE___LXSTAT
27
#ifndef HAVE___LXSTAT
28
28
29
wrapper_proto(lstat, int, (int, const char *, struct stat *));
29
wrapper_proto(lstat, int, (const char *, struct stat *));
30
30
31
int lstat_rel(const char *, struct stat *);
31
int lstat_rel(const char *, struct stat *);
32
32
(-)a/src/mknod.c (+2 lines)
Lines 28-33 Link Here
28
28
29
wrapper(mknod, int, (const char * pathname, mode_t mode, dev_t dev))
29
wrapper(mknod, int, (const char * pathname, mode_t mode, dev_t dev))
30
{
30
{
31
    char fakechroot_abspath[FAKECHROOT_PATH_MAX];
32
    char fakechroot_buf[FAKECHROOT_PATH_MAX];
31
    debug("mknod(\"%s\", 0%o, %ld)", pathname, mode, dev);
33
    debug("mknod(\"%s\", 0%o, %ld)", pathname, mode, dev);
32
    expand_chroot_path(pathname);
34
    expand_chroot_path(pathname);
33
    return nextcall(mknod)(pathname, mode, dev);
35
    return nextcall(mknod)(pathname, mode, dev);
(-)a/src/stat.c (+2 lines)
Lines 33-38 Link Here
33
33
34
wrapper(stat, int, (const char * file_name, struct stat * buf))
34
wrapper(stat, int, (const char * file_name, struct stat * buf))
35
{
35
{
36
    char fakechroot_abspath[FAKECHROOT_PATH_MAX];
37
    char fakechroot_buf[FAKECHROOT_PATH_MAX];
36
    debug("stat(\"%s\", &buf)", file_name);
38
    debug("stat(\"%s\", &buf)", file_name);
37
    expand_chroot_path(file_name);
39
    expand_chroot_path(file_name);
38
    return nextcall(stat)(file_name, buf);
40
    return nextcall(stat)(file_name, buf);
(-)a/src/stat64.c (-1 / +2 lines)
Lines 34-39 Link Here
34
34
35
wrapper(stat64, int, (const char * file_name, struct stat64 * buf))
35
wrapper(stat64, int, (const char * file_name, struct stat64 * buf))
36
{
36
{
37
    char fakechroot_abspath[FAKECHROOT_PATH_MAX];
38
    char fakechroot_buf[FAKECHROOT_PATH_MAX];
37
    debug("stat64(\"%s\", &buf)", file_name);
39
    debug("stat64(\"%s\", &buf)", file_name);
38
    expand_chroot_path(file_name);
40
    expand_chroot_path(file_name);
39
    return nextcall(stat64)(file_name, buf);
41
    return nextcall(stat64)(file_name, buf);
40
--
41
configure.ac        | 20 ++++++++++++++++++++
42
configure.ac        | 20 ++++++++++++++++++++
42
src/ftw.c           |  2 +-
43
src/ftw.c           |  2 +-
43
src/ftw64.c         | 14 +++++++++++---
44
src/ftw64.c         | 14 +++++++++++---
44
src/libfakechroot.h | 15 +++++++++++++++
45
src/libfakechroot.h | 15 +++++++++++++++
45
src/lstat.c         |  2 +-
46
src/lstat.c         |  2 +-
46
src/lstat.h         |  2 +-
47
src/lstat.h         |  2 +-
47
src/lstat64.c       |  2 +-
48
src/lstat64.c       |  2 +-
48
src/mknod.c         |  2 +-
49
src/mknod.c         |  2 +-
49
src/mknodat.c       |  2 +-
50
src/mknodat.c       |  2 +-
50
src/stat.c          |  2 +-
51
src/stat.c          |  2 +-
51
src/stat64.c        |  2 +-
52
src/stat64.c        |  2 +-
52
11 files changed, 54 insertions(+), 11 deletions(-)
53
11 files changed, 54 insertions(+), 11 deletions(-)
(-)a/configure.ac (+20 lines)
Lines 75-80 ACX_CHECK_C_ATTRIBUTE_VISIBILITY Link Here
75
# Checks for libraries.
75
# Checks for libraries.
76
AC_CHECK_LIB([dl], [dlsym])
76
AC_CHECK_LIB([dl], [dlsym])
77
77
78
AH_TEMPLATE([NEW_GLIBC], [glibc >= 2.33])
79
AC_MSG_CHECKING([for glibc 2.33+])
80
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
81
       #include <sys/stat.h>
82
  ]], [[
83
#ifdef __GLIBC__
84
#if !__GLIBC_PREREQ(2,33)
85
#error glibc<2.33
86
#endif
87
#else
88
#error not glibc
89
#endif
90
  ]])],[
91
   AC_DEFINE(NEW_GLIBC,1)
92
   AC_MSG_RESULT([yes])
93
  ],[
94
   AC_DEFINE(NEW_GLIBC,0)
95
   AC_MSG_RESULT([no])
96
  ])
97
78
# Checks for header files.
98
# Checks for header files.
79
AC_HEADER_DIRENT
99
AC_HEADER_DIRENT
80
AC_HEADER_STDC
100
AC_HEADER_STDC
(-)a/src/ftw.c (-1 / +1 lines)
Lines 185-191 int rpl_lstat (const char *, struct stat *); Link Here
185
# define NFTW_NEW_NAME __new_nftw
185
# define NFTW_NEW_NAME __new_nftw
186
# define INO_T ino_t
186
# define INO_T ino_t
187
# define STAT stat
187
# define STAT stat
188
# ifdef _LIBC
188
# if defined(_LIBC) && !NEW_GLIBC
189
#  define LXSTAT __lxstat
189
#  define LXSTAT __lxstat
190
#  define XSTAT __xstat
190
#  define XSTAT __xstat
191
#  define FXSTATAT __fxstatat
191
#  define FXSTATAT __fxstatat
(-)a/src/ftw64.c (-3 / +11 lines)
Lines 18-23 Link Here
18
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19
   02111-1307 USA.  */
19
   02111-1307 USA.  */
20
20
21
#include "config.h"
22
21
#define __FTW64_C
23
#define __FTW64_C
22
#define FTW_NAME ftw64
24
#define FTW_NAME ftw64
23
#define NFTW_NAME nftw64
25
#define NFTW_NAME nftw64
Lines 25-33 Link Here
25
#define NFTW_NEW_NAME __new_nftw64
27
#define NFTW_NEW_NAME __new_nftw64
26
#define INO_T ino64_t
28
#define INO_T ino64_t
27
#define STAT stat64
29
#define STAT stat64
28
#define LXSTAT __lxstat64
30
#if NEW_GLIBC
29
#define XSTAT __xstat64
31
#  define LXSTAT(V,f,sb) lstat64 (f,sb)
30
#define FXSTATAT __fxstatat64
32
#  define XSTAT(V,f,sb) stat64 (f,sb)
33
#  define FXSTATAT(V,d,f,sb,m) fstatat64 (d, f, sb, m)
34
#else
35
#  define LXSTAT __lxstat64
36
#  define XSTAT __xstat64
37
#  define FXSTATAT __fxstatat64
38
#endif
31
#define FTW_FUNC_T __ftw64_func_t
39
#define FTW_FUNC_T __ftw64_func_t
32
#define NFTW_FUNC_T __nftw64_func_t
40
#define NFTW_FUNC_T __nftw64_func_t
33
41
(-)a/src/libfakechroot.h (+15 lines)
Lines 200-205 Link Here
200
# endif
200
# endif
201
#endif
201
#endif
202
202
203
#ifndef _STAT_VER
204
 #if defined (__aarch64__)
205
  #define _STAT_VER 0
206
 #elif defined (__powerpc__) && __WORDSIZE == 64
207
  #define _STAT_VER 1
208
 #elif defined (__riscv) && __riscv_xlen==64
209
  #define _STAT_VER 0
210
 #elif defined (__s390x__)
211
  #define _STAT_VER 1
212
 #elif defined (__x86_64__)
213
  #define _STAT_VER 1
214
 #else
215
  #define _STAT_VER 3
216
 #endif
217
#endif
203
218
204
typedef void (*fakechroot_wrapperfn_t)(void);
219
typedef void (*fakechroot_wrapperfn_t)(void);
205
220
(-)a/src/lstat.c (-1 / +1 lines)
Lines 20-26 Link Here
20
20
21
#include <config.h>
21
#include <config.h>
22
22
23
#ifndef HAVE___LXSTAT
23
#if !defined(HAVE___LXSTAT) || NEW_GLIBC
24
24
25
#include <sys/stat.h>
25
#include <sys/stat.h>
26
#include <unistd.h>
26
#include <unistd.h>
(-)a/src/lstat.h (-1 / +1 lines)
Lines 24-30 Link Here
24
#include <config.h>
24
#include <config.h>
25
#include "libfakechroot.h"
25
#include "libfakechroot.h"
26
26
27
#ifndef HAVE___LXSTAT
27
#if !defined(HAVE___LXSTAT) || NEW_GLIBC
28
28
29
wrapper_proto(lstat, int, (const char *, struct stat *));
29
wrapper_proto(lstat, int, (const char *, struct stat *));
30
30
(-)a/src/lstat64.c (-1 / +1 lines)
Lines 20-26 Link Here
20
20
21
#include <config.h>
21
#include <config.h>
22
22
23
#if defined(HAVE_LSTAT64) && !defined(HAVE___LXSTAT64)
23
#if defined(HAVE_LSTAT64) && (!defined(HAVE___LXSTAT64) || NEW_GLIBC)
24
24
25
#define _LARGEFILE64_SOURCE
25
#define _LARGEFILE64_SOURCE
26
#define _BSD_SOURCE
26
#define _BSD_SOURCE
(-)a/src/mknod.c (-1 / +1 lines)
Lines 20-26 Link Here
20
20
21
#include <config.h>
21
#include <config.h>
22
22
23
#ifndef HAVE___XMKNOD
23
#if !defined(HAVE___XMKNOD) || NEW_GLIBC
24
24
25
#include <sys/stat.h>
25
#include <sys/stat.h>
26
#include "libfakechroot.h"
26
#include "libfakechroot.h"
(-)a/src/mknodat.c (-1 / +1 lines)
Lines 20-26 Link Here
20
20
21
#include <config.h>
21
#include <config.h>
22
22
23
#if defined(HAVE_MKNODAT) && !defined(HAVE___XMKNODAT)
23
#if defined(HAVE_MKNODAT) && (!defined(HAVE___XMKNODAT) || NEW_GLIBC)
24
24
25
#define _ATFILE_SOURCE
25
#define _ATFILE_SOURCE
26
#include <sys/stat.h>
26
#include <sys/stat.h>
(-)a/src/stat.c (-1 / +1 lines)
Lines 20-26 Link Here
20
20
21
#include <config.h>
21
#include <config.h>
22
22
23
#ifndef HAVE___XSTAT
23
#if !defined(HAVE___XSTAT) || NEW_GLIBC
24
24
25
#define _BSD_SOURCE
25
#define _BSD_SOURCE
26
#define _DEFAULT_SOURCE
26
#define _DEFAULT_SOURCE
(-)a/src/stat64.c (-2 / +1 lines)
Lines 20-26 Link Here
20
20
21
#include <config.h>
21
#include <config.h>
22
22
23
#if defined(HAVE_STAT64) && !defined(HAVE___XSTAT64)
23
#if defined(HAVE_STAT64) && (!defined(HAVE___XSTAT64) || NEW_GLIBC)
24
24
25
#define _BSD_SOURCE
25
#define _BSD_SOURCE
26
#define _LARGEFILE64_SOURCE
26
#define _LARGEFILE64_SOURCE
27
--
28
configure.ac    |  2 ++
27
configure.ac    |  2 ++
29
src/Makefile.am |  2 ++
28
src/Makefile.am |  2 ++
30
src/fstatat.c   | 42 ++++++++++++++++++++++++++++++++++++++++++
29
src/fstatat.c   | 42 ++++++++++++++++++++++++++++++++++++++++++
31
src/fstatat64.c | 43 +++++++++++++++++++++++++++++++++++++++++++
30
src/fstatat64.c | 43 +++++++++++++++++++++++++++++++++++++++++++
32
4 files changed, 89 insertions(+)
31
4 files changed, 89 insertions(+)
33
create mode 100644 src/fstatat.c
32
create mode 100644 src/fstatat.c
34
create mode 100644 src/fstatat64.c
33
create mode 100644 src/fstatat64.c
(-)a/configure.ac (+2 lines)
Lines 218-223 AC_CHECK_FUNCS(m4_normalize([ Link Here
218
    freopen64
218
    freopen64
219
    fstat
219
    fstat
220
    fstat64
220
    fstat64
221
    fstatat
222
    fstatat64
221
    fts_children
223
    fts_children
222
    fts_open
224
    fts_open
223
    fts_read
225
    fts_read
(-)a/src/Makefile.am (+2 lines)
Lines 61-66 libfakechroot_la_SOURCES = \ Link Here
61
    fopen64.c \
61
    fopen64.c \
62
    freopen.c \
62
    freopen.c \
63
    freopen64.c \
63
    freopen64.c \
64
    fstatat.c \
65
    fstatat64.c \
64
    fts.c \
66
    fts.c \
65
    fts64.c \
67
    fts64.c \
66
    ftw.c \
68
    ftw.c \
(-)a/src/fstatat.c (+42 lines)
Line 0 Link Here
1
/*
2
    libfakechroot -- fake chroot environment
3
    Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@debian.org>
4
5
    This library is free software; you can redistribute it and/or
6
    modify it under the terms of the GNU Lesser General Public
7
    License as published by the Free Software Foundation; either
8
    version 2.1 of the License, or (at your option) any later version.
9
10
    This library is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
    Lesser General Public License for more details.
14
15
    You should have received a copy of the GNU Lesser General Public
16
    License along with this library; if not, write to the Free Software
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
18
*/
19
20
21
#include <config.h>
22
23
#ifdef HAVE_FSTATAT
24
25
#define _ATFILE_SOURCE
26
#define _POSIX_C_SOURCE 200809L
27
#include <sys/stat.h>
28
#include <limits.h>
29
#include "libfakechroot.h"
30
31
wrapper(fstatat, int, (int dirfd, const char *pathname, struct stat *buf, int flags))
32
{
33
    char fakechroot_abspath[FAKECHROOT_PATH_MAX];
34
    char fakechroot_buf[FAKECHROOT_PATH_MAX];
35
    debug("fstatat(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
36
    expand_chroot_path_at(dirfd, pathname);
37
    return nextcall(fstatat)(dirfd, pathname, buf, flags);
38
}
39
40
#else
41
typedef int empty_translation_unit;
42
#endif
(-)a/src/fstatat64.c (+43 lines)
Line 0 Link Here
1
/*
2
    libfakechroot -- fake chroot environment
3
    Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@debian.org>
4
5
    This library is free software; you can redistribute it and/or
6
    modify it under the terms of the GNU Lesser General Public
7
    License as published by the Free Software Foundation; either
8
    version 2.1 of the License, or (at your option) any later version.
9
10
    This library is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
    Lesser General Public License for more details.
14
15
    You should have received a copy of the GNU Lesser General Public
16
    License along with this library; if not, write to the Free Software
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
18
*/
19
20
21
#include <config.h>
22
23
#ifdef HAVE_FSTATAT64
24
25
#define _ATFILE_SOURCE
26
#define _POSIX_C_SOURCE 200809L
27
#define _LARGEFILE64_SOURCE
28
#include <sys/stat.h>
29
#include <limits.h>
30
#include "libfakechroot.h"
31
32
wrapper(fstatat64, int, (int dirfd, const char *pathname, struct stat64 *buf, int flags))
33
{
34
    char fakechroot_abspath[FAKECHROOT_PATH_MAX];
35
    char fakechroot_buf[FAKECHROOT_PATH_MAX];
36
    debug("fstatat64(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
37
    expand_chroot_path_at(dirfd, pathname);
38
    return nextcall(fstatat64)(dirfd, pathname, buf, flags);
39
}
40
41
#else
42
typedef int empty_translation_unit;
43
#endif

Return to bug 774666