aboutsummaryrefslogtreecommitdiffstats
path: root/tools/fakeroot/patches/300-glibc-2.33-compatibility.patch
blob: a460cace0c4bb82d3e6c9671eb16e88ef1950a7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
--- a/libfakeroot.c
+++ b/libfakeroot.c
@@ -90,6 +90,16 @@
 #define SEND_GET_XATTR64(a,b,c) send_get_xattr64(a,b)
 #endif
 
+#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
+
 /*
    These INT_* (which stands for internal) macros should always be used when
    the fakeroot library owns the storage of the stat variable.
@@ -1358,6 +1368,54 @@ int renameat(int olddir_fd, const char *
 #endif /* HAVE_FSTATAT */
 
 
+#if defined(__GLIBC__) && __GLIBC_PREREQ(2,33)
+/* Glibc 2.33 exports symbols for these functions in the shared lib */
+  int lstat(const char *file_name, struct stat *statbuf) {
+     return WRAP_LSTAT LSTAT_ARG(_STAT_VER, file_name, statbuf);
+  }
+  int stat(const char *file_name, struct stat *st) {
+     return WRAP_STAT STAT_ARG(_STAT_VER, file_name, st);
+  }
+  int fstat(int fd, struct stat *st) {
+     return WRAP_FSTAT FSTAT_ARG(_STAT_VER, fd, st);
+  }
+
+  #ifdef HAVE_FSTATAT
+    int fstatat(int dir_fd, const char *path, struct stat *st, int flags) {
+       return WRAP_FSTATAT FSTATAT_ARG(_STAT_VER, dir_fd, path, st, flags);
+    }
+  #endif
+
+  #ifdef STAT64_SUPPORT
+    int lstat64(const char *file_name, struct stat64 *st) {
+       return WRAP_LSTAT64 LSTAT64_ARG(_STAT_VER, file_name, st);
+    }
+    int stat64(const char *file_name, struct stat64 *st) {
+       return WRAP_STAT64 STAT64_ARG(_STAT_VER, file_name, st);
+    }
+    int fstat64(int fd, struct stat64 *st) {
+       return WRAP_FSTAT64 FSTAT64_ARG(_STAT_VER, fd, st);
+    }
+
+    #ifdef HAVE_FSTATAT
+      int fstatat64(int dir_fd, const char *path, struct stat64 *st, int flags) {
+	 return WRAP_FSTATAT64 FSTATAT64_ARG(_STAT_VER, dir_fd, path, st, flags);
+      }
+    #endif
+  #endif
+
+  int mknod(const char *pathname, mode_t mode, dev_t dev) {
+     return WRAP_MKNOD MKNOD_ARG(_STAT_VER, pathname, mode, &dev);
+  }
+
+  #if defined(HAVE_FSTATAT) && defined(HAVE_MKNODAT)
+    int mknodat(int dir_fd, const char *pathname, mode_t mode, dev_t dev) {
+       return WRAP_MKNODAT MKNODAT_ARG(_STAT_VER, dir_fd, pathname, mode, &dev);
+    }
+  #endif
+#endif /* GLIBC_PREREQ */
+
+
 #ifdef FAKEROOT_FAKENET
 pid_t fork(void)
 {
@@ -2024,11 +2082,7 @@ FTSENT *fts_read(FTS *ftsp) {
             || r->fts_info == FTS_NS || r->fts_info == FTS_NSOK))
     r->fts_statp = NULL;  /* Otherwise fts_statp may be a random pointer */
   if(r && r->fts_statp) {  /* Should we bother checking fts_info here? */
-# if defined(STAT64_SUPPORT) && !defined(__APPLE__)
-    SEND_GET_STAT64(r->fts_statp, _STAT_VER);
-# else
     SEND_GET_STAT(r->fts_statp, _STAT_VER);
-# endif
   }
 
   return r;
@@ -2047,11 +2101,7 @@ FTSENT *fts_children(FTS *ftsp, int opti
   first=next_fts_children(ftsp, options);
   for(r = first; r; r = r->fts_link) {
     if(r && r->fts_statp) {  /* Should we bother checking fts_info here? */
-# if defined(STAT64_SUPPORT) && !defined(__APPLE__)
-      SEND_GET_STAT64(r->fts_statp, _STAT_VER);
-# else
       SEND_GET_STAT(r->fts_statp, _STAT_VER);
-# endif
     }
   }
 
@@ -2483,7 +2533,7 @@ int statx (int dirfd, const char *path,
 
 #ifdef LIBFAKEROOT_DEBUGGING
   if (fakeroot_debug) {
-    fprintf(stderr, "statx fd %d\n", fd);
+    fprintf(stderr, "statx fd %d\n", dirfd);
   }
 #endif /* LIBFAKEROOT_DEBUGGING */
   r=INT_NEXT_FSTATAT(dirfd, path, &st, flags);
--- a/configure.ac
+++ b/configure.ac
@@ -184,13 +184,13 @@ AC_MSG_CHECKING([for type of arg of __xm
   ]], [[
        int __xmknod  ( int ver,
                        const char *pathname ,
-                       mode_t  mode ,  dev_t dev);
+                       mode_t  mode ,  dev_t *dev);
   ]])],[
-   AC_DEFINE(XMKNOD_FRTH_ARG,)
-   AC_MSG_RESULT([no extra *])
-  ],[
    AC_DEFINE(XMKNOD_FRTH_ARG,[*])
    AC_MSG_RESULT([needs *])
+  ],[
+   AC_DEFINE(XMKNOD_FRTH_ARG,)
+   AC_MSG_RESULT([no extra *])
 
   ])
 
@@ -211,13 +211,13 @@ AC_MSG_CHECKING([for type of arg of __xm
        int __xmknodat  ( int ver,
                          int dirfd,
                          const char *pathname ,
-                         mode_t  mode ,  dev_t dev);
+                         mode_t  mode ,  dev_t *dev);
   ]])],[
-   AC_DEFINE(XMKNODAT_FIFTH_ARG,)
-   AC_MSG_RESULT([no extra *])
-  ],[
    AC_DEFINE(XMKNODAT_FIFTH_ARG,[*])
    AC_MSG_RESULT([needs *])
+  ],[
+   AC_DEFINE(XMKNODAT_FIFTH_ARG,)
+   AC_MSG_RESULT([no extra *])
 
   ])