remove unuse files

This commit is contained in:
cherry530 2022-01-27 18:56:33 +08:00
parent 606d79eb8f
commit 2d6233d6ee
10 changed files with 590 additions and 508 deletions

View File

@ -1,468 +0,0 @@
From 46f5da05629638d9ea67782d4afc0b0f5154e7b9 Mon Sep 17 00:00:00 2001
From: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Date: Wed, 16 Aug 2017 19:20:03 +0300
Subject: [PATCH] Add support of LFS-compatible fts functions
Since glibc 2.23, fts has LFS support.
---
configure.ac | 15 ++++--
src/Makefile.am | 1 +
src/fts.c | 147 +++++++++++++++++++++++++++++++++-----------------------
src/fts64.c | 33 +++++++++++++
4 files changed, 132 insertions(+), 64 deletions(-)
create mode 100644 src/fts64.c
diff --git a/configure.ac b/configure.ac
index 30557a4..e87ce94 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,6 +190,7 @@ AC_CHECK_FUNCS(m4_normalize([
fts_children
fts_open
fts_read
+ fts64_open
ftw
ftw64
futimesat
@@ -315,11 +316,19 @@ m4_foreach_w([function], [getpeername getsockname],
ACX_CHECK_FUNC_ARGTYPES([fts_open],
[], [sys/types.h sys/stat.h fts.h],
- [[FTS *], [char * const *_], [int], [int (*_)(const FTSENT **, const FTSENT **)]],
- [[FTS *]],
+ [[FTSOBJ *], [char * const *_], [int], [int (*_)(const FTSENTRY **, const FTSENTRY **)]],
+ [[FTSOBJ *]],
[[char * const *_]],
[[int _]],
- [[int (*_)(const FTSENT * const *, const FTSENT * const *)], [int (*_)(const FTSENT **, const FTSENT **)]])
+ [[int (*_)(const FTSENTRY * const *, const FTSENTRY * const *)], [int (*_)(const FTSENTRY **, const FTSENTRY **)]])
+
+ACX_CHECK_FUNC_ARGTYPES([fts64_open],
+ [], [sys/types.h sys/stat.h fts.h],
+ [[FTSOBJ *], [char * const *_], [int], [int (*_)(const FTSENTRY **, const FTSENTRY **)]],
+ [[FTSOBJ *]],
+ [[char * const *_]],
+ [[int _]],
+ [[int (*_)(const FTSENTRY * const *, const FTSENTRY * const *)], [int (*_)(const FTSENTRY **, const FTSENTRY **)]])
ACX_CHECK_FUNC_ARGTYPES([readlink],
[
diff --git a/src/Makefile.am b/src/Makefile.am
index 01fc652..8af41eb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,6 +62,7 @@ libfakechroot_la_SOURCES = \
freopen.c \
freopen64.c \
fts.c \
+ fts64.c \
ftw.c \
ftw64.c \
futimesat.c \
diff --git a/src/fts.c b/src/fts.c
index 61ac032..e69e1b7 100644
--- a/src/fts.c
+++ b/src/fts.c
@@ -32,10 +32,13 @@
#include <config.h>
+#if !defined FTS64_C__ || (defined FTS64_C__ && HAVE_FTS64_OPEN)
+
#define _ATFILE_SOURCE
#define _BSD_SOURCE
#define _XOPEN_SOURCE 500
#define _DEFAULT_SOURCE
+#define _LARGEFILE64_SOURCE
#include <sys/param.h>
#include <sys/stat.h>
@@ -80,16 +83,34 @@
# endif
#endif
-static FTSENT *fts_alloc(FTS *, char *, size_t);
-static FTSENT *fts_build(FTS *, int);
-static void fts_lfree(FTSENT *);
-static void fts_load(FTS *, FTSENT *);
+/* Support for the LFS API version. */
+#ifndef FTS_OPEN
+/* functions */
+# define FTS_OPEN fts_open
+# define FTS_CLOSE fts_close
+# define FTS_READ fts_read
+# define FTS_SET fts_set
+# define FTS_CHILDREN fts_children
+/* types */
+# define FTSOBJ FTS
+# define _FTSENT _ftsent
+# define FTSENTRY FTSENT
+# define INO_T ino_t
+# define STAT stat
+# define FSTAT fstat
+# define LSTAT lstat
+#endif
+
+static FTSENTRY *fts_alloc(FTSOBJ *, char *, size_t);
+static FTSENTRY *fts_build(FTSOBJ *, int);
+static void fts_lfree(FTSENTRY *);
+static void fts_load(FTSOBJ *, FTSENTRY *);
static size_t fts_maxarglen(char * const *);
-static void fts_padjust(FTS *, FTSENT *);
-static int fts_palloc(FTS *, size_t);
-static FTSENT *fts_sort(FTS *, FTSENT *, int);
-static u_short fts_stat(FTS *, FTSENT *, int);
-static int fts_safe_changedir(FTS *, FTSENT *, int, char *);
+static void fts_padjust(FTSOBJ *, FTSENTRY *);
+static int fts_palloc(FTSOBJ *, size_t);
+static FTSENTRY *fts_sort(FTSOBJ *, FTSENTRY *, int);
+static u_short fts_stat(FTSOBJ *, FTSENTRY *, int);
+static int fts_safe_changedir(FTSOBJ *, FTSENTRY *, int, char *);
#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
@@ -104,14 +125,14 @@ static int fts_safe_changedir(FTS *, FTSENT *, int, char *);
#define BNAMES 2 /* fts_children, names only */
#define BREAD 3 /* fts_read */
-FTS *
-fts_open(char * const *argv, int options,
+FTSOBJ *
+FTS_OPEN(char * const *argv, int options,
FTS_OPEN_TYPE_ARG3(compar))
{
- FTS *sp;
- FTSENT *p, *root;
+ FTSOBJ *sp;
+ FTSENTRY *p, *root;
int nitems;
- FTSENT *parent, *tmp = NULL;
+ FTSENTRY *parent, *tmp = NULL;
size_t len;
debug("fts_open({\"%s\", ...}, %d, &compar)", **argv, options);
@@ -123,7 +144,7 @@ fts_open(char * const *argv, int options,
}
/* Allocate/initialize the stream */
- if ((sp = calloc(1, sizeof(FTS))) == NULL)
+ if ((sp = calloc(1, sizeof(FTSOBJ))) == NULL)
return (NULL);
sp->fts_compar = (void *)compar;
sp->fts_options = options;
@@ -216,7 +237,7 @@ mem1: free(sp);
}
static void
-fts_load(FTS *sp, FTSENT *p)
+fts_load(FTSOBJ *sp, FTSENTRY *p)
{
size_t len;
char *cp;
@@ -240,9 +261,9 @@ fts_load(FTS *sp, FTSENT *p)
}
int
-fts_close(FTS *sp)
+FTS_CLOSE(FTSOBJ *sp)
{
- FTSENT *freep, *p;
+ FTSENTRY *freep, *p;
int rfd, error = 0;
debug("fts_close(&sp)");
@@ -292,10 +313,10 @@ fts_close(FTS *sp)
(p->fts_path[p->fts_pathlen - 1] == '/' \
? p->fts_pathlen - 1 : p->fts_pathlen)
-FTSENT *
-fts_read(FTS *sp)
+FTSENTRY *
+FTS_READ(FTSOBJ *sp)
{
- FTSENT *p, *tmp;
+ FTSENTRY *p, *tmp;
int instr;
char *t;
int saved_errno;
@@ -490,7 +511,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
*/
/* ARGSUSED */
int
-fts_set(FTS *sp, FTSENT *p, int instr)
+FTS_SET(FTSOBJ *sp, FTSENTRY *p, int instr)
{
debug("fts_set(&sp, &p, %d)", instr);
if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
@@ -502,10 +523,10 @@ fts_set(FTS *sp, FTSENT *p, int instr)
return (0);
}
-FTSENT *
-fts_children(FTS *sp, int instr)
+FTSENTRY *
+FTS_CHILDREN(FTSOBJ *sp, int instr)
{
- FTSENT *p;
+ FTSENTRY *p;
int fd;
debug("fts_children(&sp, %d)", instr);
@@ -586,12 +607,12 @@ fts_children(FTS *sp, int instr)
* directories and for any files after the subdirectories in the directory have
* been found, cutting the stat calls by about 2/3.
*/
-static FTSENT *
-fts_build(FTS *sp, int type)
+static FTSENTRY *
+fts_build(FTSOBJ *sp, int type)
{
struct dirent *dp;
- FTSENT *p, *head;
- FTSENT *cur, *tail;
+ FTSENTRY *p, *head;
+ FTSENTRY *cur, *tail;
DIR *dirp;
void *oldaddr;
size_t len, maxlen;
@@ -834,12 +855,12 @@ mem1: saved_errno = errno;
}
static u_short
-fts_stat(FTS *sp, FTSENT *p, int follow)
+fts_stat(FTSOBJ *sp, FTSENTRY *p, int follow)
{
- FTSENT *t;
+ FTSENTRY *t;
dev_t dev;
- ino_t ino;
- struct stat *sbp, sb;
+ INO_T ino;
+ struct STAT *sbp, sb;
int saved_errno;
/* If user needs stat info, stat buffer already allocated. */
@@ -851,18 +872,18 @@ fts_stat(FTS *sp, FTSENT *p, int follow)
* fail, set the errno from the stat call.
*/
if (ISSET(FTS_LOGICAL) || follow) {
- if (stat(p->fts_accpath, sbp)) {
+ if (STAT(p->fts_accpath, sbp)) {
saved_errno = errno;
- if (!lstat(p->fts_accpath, sbp)) {
+ if (!LSTAT(p->fts_accpath, sbp)) {
errno = 0;
return (FTS_SLNONE);
}
p->fts_errno = saved_errno;
goto err;
}
- } else if (lstat(p->fts_accpath, sbp)) {
+ } else if (LSTAT(p->fts_accpath, sbp)) {
p->fts_errno = errno;
-err: memset(sbp, 0, sizeof(struct stat));
+err: memset(sbp, 0, sizeof(struct STAT));
return (FTS_NS);
}
@@ -902,10 +923,10 @@ err: memset(sbp, 0, sizeof(struct stat));
return (FTS_DEFAULT);
}
-static FTSENT *
-fts_sort(FTS *sp, FTSENT *head, int nitems)
+static FTSENTRY *
+fts_sort(FTSOBJ *sp, FTSENTRY *head, int nitems)
{
- FTSENT **ap, *p;
+ FTSENTRY **ap, *p;
/*
* Construct an array of pointers to the structures and call qsort(3).
@@ -915,11 +936,11 @@ fts_sort(FTS *sp, FTSENT *head, int nitems)
* 40 so don't realloc one entry at a time.
*/
if (nitems > sp->fts_nitems) {
- struct _ftsent **a;
+ struct _FTSENT **a;
sp->fts_nitems = nitems + 40;
if ((a = realloc(sp->fts_array,
- sp->fts_nitems * sizeof(FTSENT *))) == NULL) {
+ sp->fts_nitems * sizeof(FTSENTRY *))) == NULL) {
if (sp->fts_array)
free(sp->fts_array);
sp->fts_array = NULL;
@@ -930,33 +951,33 @@ fts_sort(FTS *sp, FTSENT *head, int nitems)
}
for (ap = sp->fts_array, p = head; p; p = p->fts_link)
*ap++ = p;
- qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), (void *)sp->fts_compar);
+ qsort((void *)sp->fts_array, nitems, sizeof(FTSENTRY *), (void *)sp->fts_compar);
for (head = *(ap = sp->fts_array); --nitems; ++ap)
ap[0]->fts_link = ap[1];
ap[0]->fts_link = NULL;
return (head);
}
-static FTSENT *
-fts_alloc(FTS *sp, char *name, size_t namelen)
+static FTSENTRY *
+fts_alloc(FTSOBJ *sp, char *name, size_t namelen)
{
- FTSENT *p;
+ FTSENTRY *p;
size_t len;
#ifdef HAVE_STRUCT__FTSENT_FTS_NAME_TYPE_CHAR_P
struct ftsent_withstat {
- FTSENT ent;
+ FTSENTRY ent;
struct stat statbuf;
};
/*
* The file name is a variable length array and no stat structure is
- * necessary if the user has set the nostat bit. Allocate the FTSENT
+ * necessary if the user has set the nostat bit. Allocate the FTSENTRY
* structure, the file name and the stat structure in one chunk, but
* be careful that the stat structure is reasonably aligned.
*/
if (ISSET(FTS_NOSTAT))
- len = sizeof(FTSENT) + namelen + 1;
+ len = sizeof(FTSENTRY) + namelen + 1;
else
len = sizeof(struct ftsent_withstat) + namelen + 1;
@@ -985,15 +1006,15 @@ fts_alloc(FTS *sp, char *name, size_t namelen)
#else
/*
* The file name is a variable length array and no stat structure is
- * necessary if the user has set the nostat bit. Allocate the FTSENT
+ * necessary if the user has set the nostat bit. Allocate the FTSENTRY
* structure, the file name and the stat structure in one chunk, but
* be careful that the stat structure is reasonably aligned. Since the
* fts_name field is declared to be of size 1, the fts_name pointer is
* namelen + 2 before the first possible address of the stat structure.
*/
- len = sizeof(FTSENT) + namelen;
+ len = sizeof(FTSENTRY) + namelen;
if (!ISSET(FTS_NOSTAT))
- len += sizeof(struct stat) + ALIGNBYTES;
+ len += sizeof(struct STAT) + ALIGNBYTES;
if ((p = malloc(len)) == NULL)
return (NULL);
@@ -1002,7 +1023,7 @@ fts_alloc(FTS *sp, char *name, size_t namelen)
p->fts_namelen = namelen;
p->fts_instr = FTS_NOINSTR;
if (!ISSET(FTS_NOSTAT))
- p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
+ p->fts_statp = (struct STAT *)ALIGN(p->fts_name + namelen + 2);
memcpy(p->fts_name, name, namelen);
#endif
@@ -1010,9 +1031,9 @@ fts_alloc(FTS *sp, char *name, size_t namelen)
}
static void
-fts_lfree(FTSENT *head)
+fts_lfree(FTSENTRY *head)
{
- FTSENT *p;
+ FTSENTRY *p;
/* Free a linked list of structures. */
while ((p = head)) {
@@ -1028,7 +1049,7 @@ fts_lfree(FTSENT *head)
* plus 256 bytes so don't realloc the path 2 bytes at a time.
*/
static int
-fts_palloc(FTS *sp, size_t more)
+fts_palloc(FTSOBJ *sp, size_t more)
{
char *p;
@@ -1060,9 +1081,9 @@ fts_palloc(FTS *sp, size_t more)
* already returned.
*/
static void
-fts_padjust(FTS *sp, FTSENT *head)
+fts_padjust(FTSOBJ *sp, FTSENTRY *head)
{
- FTSENT *p;
+ FTSENTRY *p;
char *addr = sp->fts_path;
#define ADJUST(p) { \
@@ -1100,17 +1121,17 @@ fts_maxarglen(char * const *argv)
* Assumes p->fts_dev and p->fts_ino are filled in.
*/
static int
-fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
+fts_safe_changedir(FTSOBJ *sp, FTSENTRY *p, int fd, char *path)
{
int ret, oerrno, newfd;
- struct stat sb;
+ struct STAT sb;
newfd = fd;
if (ISSET(FTS_NOCHDIR))
return (0);
if (fd < 0 && (newfd = open(path, O_RDONLY, 0)) < 0)
return (-1);
- if (fstat(newfd, &sb)) {
+ if (FSTAT(newfd, &sb)) {
ret = -1;
goto bail;
}
@@ -1127,3 +1148,7 @@ bail:
errno = oerrno;
return (ret);
}
+
+#else
+typedef int empty_translation_unit;
+#endif
diff --git a/src/fts64.c b/src/fts64.c
new file mode 100644
index 0000000..ba98805
--- /dev/null
+++ b/src/fts64.c
@@ -0,0 +1,33 @@
+/* File tree traversal functions LFS version.
+ Copyright (C) 2015-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C 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.
+
+ The GNU C 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 the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define FTS64_C__
+#define FTS_OPEN fts64_open
+#define FTS_CLOSE fts64_close
+#define FTS_READ fts64_read
+#define FTS_SET fts64_set
+#define FTS_CHILDREN fts64_children
+#define FTSOBJ FTS64
+#define FTSENTRY FTSENT64
+#define _FTSENT _ftsent64
+#define INO_T ino64_t
+#define STAT stat64
+#define FSTAT fstat64
+#define LSTAT lstat64
+
+#include "fts.c"
--
2.14.1

View File

@ -1,33 +0,0 @@
From 9d56c292b454eff51bf9bbd60f25497bae43d65e Mon Sep 17 00:00:00 2001
From: caodongxia <315816521@qq.com>
Date: Wed, 30 Jun 2021 09:41:47 +0800
Subject: [PATCH] patch
Referencehttps://bugs.archlinux.org/task/69572
---
src/libfakechroot.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/libfakechroot.h b/src/libfakechroot.h
index f395ac4..b546c20 100644
--- a/src/libfakechroot.h
+++ b/src/libfakechroot.h
@@ -32,6 +32,15 @@
#define debug fakechroot_debug
+#ifndef _STAT_VER
+# if defined (__aarch64__)
+# define _STAT_VER 0
+# elif defined (__x86_64__)
+# define _STAT_VER 1
+# else
+# define _STAT_VER 3
+# endif
+#endif
#ifdef HAVE___ATTRIBUTE__VISIBILITY
# define LOCAL __attribute__((visibility("hidden")))
--
2.27.0

View File

@ -0,0 +1,23 @@
From 534e6d555736b97211523970d378dfb0db2608e9 Mon Sep 17 00:00:00 2001
From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Date: Mon, 22 Feb 2021 21:44:07 -0800
Subject: [PATCH] tmpnam.c: fix heap overflow
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
src/tmpnam.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tmpnam.c b/src/tmpnam.c
index ce60817..917ee6b 100644
--- a/src/tmpnam.c
+++ b/src/tmpnam.c
@@ -42,7 +42,7 @@ wrapper(tmpnam, char *, (char * s))
expand_chroot_path(ptr);
- ptr2 = malloc(strlen(ptr));
+ ptr2 = malloc(strlen(ptr) + 1);
if (ptr2 == NULL) return NULL;
strcpy(ptr2, ptr);

View File

@ -0,0 +1,213 @@
From 693a3597ea7fccfb62f357503ff177bd3e3d5a89 Mon Sep 17 00:00:00 2001
From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Date: Mon, 22 Feb 2021 21:47:09 -0800
Subject: [PATCH] fix glibc 2.33+ compatibility
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
configure.ac | 20 ++++++++++++++++++++
src/ftw.c | 2 +-
src/ftw64.c | 14 +++++++++++---
src/libfakechroot.h | 15 +++++++++++++++
src/lstat.c | 2 +-
src/lstat.h | 2 +-
src/lstat64.c | 2 +-
src/mknod.c | 2 +-
src/mknodat.c | 2 +-
src/stat.c | 2 +-
src/stat64.c | 2 +-
11 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
index f8cdb32..9cc2e77 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,26 @@ ACX_CHECK_C_ATTRIBUTE_VISIBILITY
# Checks for libraries.
AC_CHECK_LIB([dl], [dlsym])
+AH_TEMPLATE([NEW_GLIBC], [glibc >= 2.33])
+AC_MSG_CHECKING([for glibc 2.33+])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #include <sys/stat.h>
+ ]], [[
+#ifdef __GLIBC__
+#if !__GLIBC_PREREQ(2,33)
+#error glibc<2.33
+#endif
+#else
+#error not glibc
+#endif
+ ]])],[
+ AC_DEFINE(NEW_GLIBC,1)
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_DEFINE(NEW_GLIBC,0)
+ AC_MSG_RESULT([no])
+ ])
+
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
diff --git a/src/ftw.c b/src/ftw.c
index 92fc126..a9abc85 100644
--- a/src/ftw.c
+++ b/src/ftw.c
@@ -185,7 +185,7 @@ int rpl_lstat (const char *, struct stat *);
# define NFTW_NEW_NAME __new_nftw
# define INO_T ino_t
# define STAT stat
-# ifdef _LIBC
+# if defined(_LIBC) && !NEW_GLIBC
# define LXSTAT __lxstat
# define XSTAT __xstat
# define FXSTATAT __fxstatat
diff --git a/src/ftw64.c b/src/ftw64.c
index 7cc8cdf..cee1f2b 100644
--- a/src/ftw64.c
+++ b/src/ftw64.c
@@ -18,6 +18,8 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include "config.h"
+
#define __FTW64_C
#define FTW_NAME ftw64
#define NFTW_NAME nftw64
@@ -25,9 +27,15 @@
#define NFTW_NEW_NAME __new_nftw64
#define INO_T ino64_t
#define STAT stat64
-#define LXSTAT __lxstat64
-#define XSTAT __xstat64
-#define FXSTATAT __fxstatat64
+#if NEW_GLIBC
+# define LXSTAT(V,f,sb) lstat64 (f,sb)
+# define XSTAT(V,f,sb) stat64 (f,sb)
+# define FXSTATAT(V,d,f,sb,m) fstatat64 (d, f, sb, m)
+#else
+# define LXSTAT __lxstat64
+# define XSTAT __xstat64
+# define FXSTATAT __fxstatat64
+#endif
#define FTW_FUNC_T __ftw64_func_t
#define NFTW_FUNC_T __nftw64_func_t
diff --git a/src/libfakechroot.h b/src/libfakechroot.h
index 4cf199f..64ff15f 100644
--- a/src/libfakechroot.h
+++ b/src/libfakechroot.h
@@ -200,6 +200,21 @@
# endif
#endif
+#ifndef _STAT_VER
+ #if defined (__aarch64__)
+ #define _STAT_VER 0
+ #elif defined (__powerpc__) && __WORDSIZE == 64
+ #define _STAT_VER 1
+ #elif defined (__riscv) && __riscv_xlen==64
+ #define _STAT_VER 0
+ #elif defined (__s390x__)
+ #define _STAT_VER 1
+ #elif defined (__x86_64__)
+ #define _STAT_VER 1
+ #else
+ #define _STAT_VER 3
+ #endif
+#endif
typedef void (*fakechroot_wrapperfn_t)(void);
diff --git a/src/lstat.c b/src/lstat.c
index 54e3263..fa38323 100644
--- a/src/lstat.c
+++ b/src/lstat.c
@@ -20,7 +20,7 @@
#include <config.h>
-#ifndef HAVE___LXSTAT
+#if !defined(HAVE___LXSTAT) || NEW_GLIBC
#include <sys/stat.h>
#include <unistd.h>
diff --git a/src/lstat.h b/src/lstat.h
index ee48303..c46a2b9 100644
--- a/src/lstat.h
+++ b/src/lstat.h
@@ -24,7 +24,7 @@
#include <config.h>
#include "libfakechroot.h"
-#ifndef HAVE___LXSTAT
+#if !defined(HAVE___LXSTAT) || NEW_GLIBC
wrapper_proto(lstat, int, (const char *, struct stat *));
diff --git a/src/lstat64.c b/src/lstat64.c
index b6212fc..a332d7c 100644
--- a/src/lstat64.c
+++ b/src/lstat64.c
@@ -20,7 +20,7 @@
#include <config.h>
-#if defined(HAVE_LSTAT64) && !defined(HAVE___LXSTAT64)
+#if defined(HAVE_LSTAT64) && (!defined(HAVE___LXSTAT64) || NEW_GLIBC)
#define _LARGEFILE64_SOURCE
#define _BSD_SOURCE
diff --git a/src/mknod.c b/src/mknod.c
index 2771037..aeb750b 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -20,7 +20,7 @@
#include <config.h>
-#ifndef HAVE___XMKNOD
+#if !defined(HAVE___XMKNOD) || NEW_GLIBC
#include <sys/stat.h>
#include "libfakechroot.h"
diff --git a/src/mknodat.c b/src/mknodat.c
index 732a22b..3239b35 100644
--- a/src/mknodat.c
+++ b/src/mknodat.c
@@ -20,7 +20,7 @@
#include <config.h>
-#if defined(HAVE_MKNODAT) && !defined(HAVE___XMKNODAT)
+#if defined(HAVE_MKNODAT) && (!defined(HAVE___XMKNODAT) || NEW_GLIBC)
#define _ATFILE_SOURCE
#include <sys/stat.h>
diff --git a/src/stat.c b/src/stat.c
index 7b37793..5ef57ba 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -20,7 +20,7 @@
#include <config.h>
-#ifndef HAVE___XSTAT
+#if !defined(HAVE___XSTAT) || NEW_GLIBC
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
diff --git a/src/stat64.c b/src/stat64.c
index a360f66..993ce80 100644
--- a/src/stat64.c
+++ b/src/stat64.c
@@ -20,7 +20,7 @@
#include <config.h>
-#if defined(HAVE_STAT64) && !defined(HAVE___XSTAT64)
+#if defined(HAVE_STAT64) && (!defined(HAVE___XSTAT64) || NEW_GLIBC)
#define _BSD_SOURCE
#define _LARGEFILE64_SOURCE

View File

@ -0,0 +1,93 @@
From 75d7e6fa191c11a791faff06a0de86eaa7801d05 Mon Sep 17 00:00:00 2001
From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Date: Mon, 22 Feb 2021 21:46:36 -0800
Subject: [PATCH] declare missing bufs, remove ver from lstat
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
src/lstat.c | 8 +++++---
src/lstat.h | 2 +-
src/mknod.c | 2 ++
src/stat.c | 2 ++
src/stat64.c | 2 ++
5 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/lstat.c b/src/lstat.c
index 3f6d819..54e3263 100644
--- a/src/lstat.c
+++ b/src/lstat.c
@@ -28,9 +28,11 @@
#include "lstat.h"
-wrapper(lstat, int, (int ver, const char * filename, struct stat * buf))
+wrapper(lstat, int, (const char * filename, struct stat * buf))
{
- debug("lstat(%d, \"%s\", &buf)", ver, filename);
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("lstat(\"%s\", &buf)", filename);
if (!fakechroot_localdir(filename)) {
if (filename != NULL) {
@@ -40,7 +42,7 @@ wrapper(lstat, int, (int ver, const char * filename, struct stat * buf))
}
}
- return lstat_rel(ver, filename, buf);
+ return lstat_rel(filename, buf);
}
diff --git a/src/lstat.h b/src/lstat.h
index 751c1ea..ee48303 100644
--- a/src/lstat.h
+++ b/src/lstat.h
@@ -26,7 +26,7 @@
#ifndef HAVE___LXSTAT
-wrapper_proto(lstat, int, (int, const char *, struct stat *));
+wrapper_proto(lstat, int, (const char *, struct stat *));
int lstat_rel(const char *, struct stat *);
diff --git a/src/mknod.c b/src/mknod.c
index 52fd33b..2771037 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -28,6 +28,8 @@
wrapper(mknod, int, (const char * pathname, mode_t mode, dev_t dev))
{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
debug("mknod(\"%s\", 0%o, %ld)", pathname, mode, dev);
expand_chroot_path(pathname);
return nextcall(mknod)(pathname, mode, dev);
diff --git a/src/stat.c b/src/stat.c
index 7845662..7b37793 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -33,6 +33,8 @@
wrapper(stat, int, (const char * file_name, struct stat * buf))
{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
debug("stat(\"%s\", &buf)", file_name);
expand_chroot_path(file_name);
return nextcall(stat)(file_name, buf);
diff --git a/src/stat64.c b/src/stat64.c
index aac9c75..a360f66 100644
--- a/src/stat64.c
+++ b/src/stat64.c
@@ -34,6 +34,8 @@
wrapper(stat64, int, (const char * file_name, struct stat64 * buf))
{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
debug("stat64(\"%s\", &buf)", file_name);
expand_chroot_path(file_name);
return nextcall(stat64)(file_name, buf);

137
86.patch Normal file
View File

@ -0,0 +1,137 @@
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

View File

@ -0,0 +1,102 @@
From b42d1fb9538f680af2f31e864c555414ccba842a Mon Sep 17 00:00:00 2001
From: Piotr Roszatycki <piotr.roszatycki@gmail.com>
Date: Mon, 10 Feb 2020 13:59:10 -0800
Subject: [PATCH] New `statx` function
---
NEWS.md | 1 +
configure.ac | 1 +
src/Makefile.am | 1 +
src/statx.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 47 insertions(+)
create mode 100644 src/statx.c
diff --git a/NEWS.md b/NEWS.md
index 9de12fe..f1210bf 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,10 @@
# NEWS
+XX Xxx XXXX
+
+* UNRELEASED
+* New `statx(2)` function was added: glibc supports it since 2.28.
+
## Version 2.20.1
22 Mar 2019
diff --git a/configure.ac b/configure.ac
index a654edd..f8cdb32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -277,6 +277,7 @@ AC_CHECK_FUNCS(m4_normalize([
statfs64
statvfs
statvfs64
+ statx
stpcpy
strchrnul
strlcpy
diff --git a/src/Makefile.am b/src/Makefile.am
index d729b0e..6066345 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -152,6 +152,7 @@ libfakechroot_la_SOURCES = \
statfs64.c \
statvfs.c \
statvfs64.c \
+ statx.c \
stpcpy.c \
strchrnul.c \
strchrnul.h \
diff --git a/src/statx.c b/src/statx.c
new file mode 100644
index 0000000..524f73e
--- /dev/null
+++ b/src/statx.c
@@ -0,0 +1,44 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010-2020 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_STATX
+
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "libfakechroot.h"
+
+
+wrapper(statx, int, (int dirfd, const char * pathname, int flags, unsigned int mask, struct statx * statxbuf))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("statx(%d, \"%s\", %d, %u, &statxbuf)", dirfd, pathname, flags, mask);
+ expand_chroot_path_at(dirfd, pathname);
+ return nextcall(statx)(dirfd, pathname, flags, mask, statxbuf);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif

Binary file not shown.

BIN
fakechroot-2.20.1.tar.gz Normal file

Binary file not shown.

View File

@ -1,18 +1,30 @@
Name: fakechroot
Version: 2.19
Release: 9
Version: 2.20.1
Release: 1
Summary: Gives a fake chroot environment
License: LGPLv2+
URL: https://github.com/dex4er/fakechroot
Source0: https://github.com/dex4er/fakechroot/archive/%{version}/fakechroot-%{version}.tar.gz
Patch0000: 0001-Add-support-of-LFS-compatible-fts-functions.patch
Patch0001: 0002-fix-glic-2.33-_STAT_VER-not-defined.patch
#Patch1 URL: https://github.com/dex4er/fakechroot/commit/b42d1fb9538f680af2f31e864c555414ccba842a.patch
#Patch2 URL: https://github.com/dex4er/fakechroot/pull/85/commits/534e6d555736b97211523970d378dfb0db2608e9.patch
#Patch3 URL: https://github.com/dex4er/fakechroot/pull/85/commits/75d7e6fa191c11a791faff06a0de86eaa7801d05.patch
#Patch4 URL: https://github.com/dex4er/fakechroot/pull/85/commits/693a3597ea7fccfb62f357503ff177bd3e3d5a89.patch
#Patch5 URL: https://github.com/dex4er/fakechroot/pull/86.patch
Patch1: b42d1fb9538f680af2f31e864c555414ccba842a.patch
Patch2: 534e6d555736b97211523970d378dfb0db2608e9.patch
Patch3: 75d7e6fa191c11a791faff06a0de86eaa7801d05.patch
Patch4: 693a3597ea7fccfb62f357503ff177bd3e3d5a89.patch
Patch5: 86.patch
Requires: binutils binutils-devel
Provides: fakechroot-libs = %{version}-%{release}
Obsoletes: fakechroot-libs < %{version}-%{release}
BuildRequires: autoconf automake libtool perl-podlators perl-generators
BuildRequires: /usr/bin/pod2man
BuildRequires: gdbm-libs
Requires: /usr/bin/objdump
%description
fakechroot creates a fake environment in which user could run a command and
@ -30,15 +42,15 @@ chmod -x scripts/{relocatesymlinks,restoremode,savemode}.sh
%build
autoreconf -vfi
%configure --disable-static --disable-silent-rules
%configure --disable-static --disable-silent-rules --with-libpath="%{_libdir}/fakechroot:/usr/lib/fakechroot"
%make_build
%install
%make_install
%delete_la
find %{buildroot}%{_libdir} -name '*.la' -delete -print
%check
#make check
%make_build check
%files
%doc scripts/{relocatesymlinks,restoremode,savemode}.sh
@ -53,6 +65,9 @@ autoreconf -vfi
%{_mandir}/man1/fakechroot.1*
%changelog
* Tue Jan 18 2022 SimpleUpdate Robot <tc@openeuler.org> - 2.20.1-1
- Upgrade to version 2.20.1
* Wed Jun 30 2021 caodongxia<caodongxia@huawei.com> - 2.19-9
- Fix '_STAT_VER' undeclared