Skip to content

Commit

Permalink
glibc: trying to fix a bug related to the system calls (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxython committed Oct 18, 2022
1 parent fd51300 commit b0abcc2
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 5 deletions.
28 changes: 23 additions & 5 deletions distro/glibc/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

pkgname=glibc
pkgver=2.36
pkgrel=0
pkgrel=1
_commit=be176490b818b65b5162c332eb6b581690b16e5c
pkgdesc="GNU C Library"
arch=(any)
Expand All @@ -24,7 +24,14 @@ source=(https://ftp.gnu.org/gnu/libc/glibc-$pkgver.tar.xz{,.sig}
'locale.gen.txt'
'sdt-config.h'
'sdt.h'
'grun')
'grun'
'statx.c.patch'
'xstat64.c.patch'
'lxstat64.c.patch'
'fxstatat64.c.patch'
'fxstat64.c.patch'
'fstatat64.c.patch'
'clock_gettime.c.patch')
sha256sums=('1c959fea240906226062cb4b1e7ebce71a9f0e3c0836c09e7e3423d434fcfe75'
'SKIP'
'9254552968fb94543cc394ab99c641f2d72198b5f448e1847f7d697e669fbefd'
Expand All @@ -39,7 +46,14 @@ sha256sums=('1c959fea240906226062cb4b1e7ebce71a9f0e3c0836c09e7e3423d434fcfe75'
'd42648cea552ba5353a32e264686e992263289d5cc86207314dffc54ab514981'
'cdc234959c6fdb43f000d3bb7d1080b0103f4080f5e67bcfe8ae1aaf477812f0'
'774061aff612a377714a509918a9e0e0aafce708b87d2d7e06b1bd1f6542fe70'
'016a827f4876283a1f169b2f8849b077450ba5903d8f4c7ff3c2737df4d8ffdc')
'016a827f4876283a1f169b2f8849b077450ba5903d8f4c7ff3c2737df4d8ffdc'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP')
validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # "Carlos O'Donell <[email protected]>"
BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar

Expand All @@ -52,8 +66,12 @@ prepare() {

[[ ! -d glibc ]] && ln -s glibc-$pkgver glibc

sed -i 's|/tmp|/data/data/com.termux/files/usr/tmp|g' $(grep -R /tmp/ glibc-$pkgver | grep -v /var/ | awk -F'[:=]' '{printf $1 "\n"}')
sed -i 's|/var/tmp|/data/data/com.termux/files/usr/tmp|g' $(grep -R /var/tmp glibc-$pkgver | awk -F'[:=]' '{printf $1 "\n"}')
sed -i 's|/tmp|/data/data/com.termux/files/usr/tmp|g' $(grep -R /tmp/ ${srcdir}/glibc-${pkgver} | grep -v /var/ | awk -F'[:=]' '{printf $1 "\n"}')
sed -i 's|/var/tmp|/data/data/com.termux/files/usr/tmp|g' $(grep -R /var/tmp ${srcdir}/glibc-${pkgver} | awk -F'[:=]' '{printf $1 "\n"}')

if [ -f ${srcdir}/glibc-${pkgver}/sysdeps/unix/sysv/linux/generic/chmod.c ]; then
mv ${srcdir}/glibc-${pkgver}/sysdeps/unix/sysv/linux/generic/chmod.c ${srcdir}/glibc-${pkgver}/sysdeps/unix/sysv/linux/chmod.c
fi
}

build() {
Expand Down
15 changes: 15 additions & 0 deletions distro/glibc/clock_gettime.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- src/glibc-2.36/sysdeps/unix/sysv/linux/clock_gettime.c 2022-07-30 01:03:09.000000000 +0300
+++ src/glibc-2.36/sysdeps/unix/sysv/linux/clock_gettime.c.patch 2022-10-18 22:31:17.784495202 +0300
@@ -65,12 +65,6 @@
}
#endif

- r = INTERNAL_SYSCALL_CALL (clock_gettime64, clock_id, tp);
- if (r == 0)
- return 0;
- if (r != -ENOSYS)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
-
#ifndef __ASSUME_TIME64_SYSCALLS
/* Fallback code that uses 32-bit support. */
struct timespec tp32;
52 changes: 52 additions & 0 deletions distro/glibc/fstatat64.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--- src/glibc-2.36/sysdeps/unix/sysv/linux/fstatat64.c 2022-07-30 01:03:09.000000000 +0300
+++ src/glibc-2.36/sysdeps/unix/sysv/linux/fstatat64.c.patch 2022-10-07 22:37:40.624262457 +0300
@@ -40,48 +40,7 @@
"__blkcnt_t and __blkcnt64_t must match");
#endif

-#if (__WORDSIZE == 32 \
- && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) \
- || defined STAT_HAS_TIME32 \
- || (!defined __NR_newfstatat && !defined __NR_fstatat64)
-# define FSTATAT_USE_STATX 1
-
-static inline int
-fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,
- int flag)
-{
- /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32. Also
- 64-bit time_t support is done through statx syscall. */
- struct statx tmp;
- int r = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
- STATX_BASIC_STATS, &tmp);
- if (r != 0)
- return r;
-
- *buf = (struct __stat64_t64) {
- .st_dev = __gnu_dev_makedev (tmp.stx_dev_major, tmp.stx_dev_minor),
- .st_rdev = __gnu_dev_makedev (tmp.stx_rdev_major, tmp.stx_rdev_minor),
- .st_ino = tmp.stx_ino,
- .st_mode = tmp.stx_mode,
- .st_nlink = tmp.stx_nlink,
- .st_uid = tmp.stx_uid,
- .st_gid = tmp.stx_gid,
- .st_atime = tmp.stx_atime.tv_sec,
- .st_atim.tv_nsec = tmp.stx_atime.tv_nsec,
- .st_mtime = tmp.stx_mtime.tv_sec,
- .st_mtim.tv_nsec = tmp.stx_mtime.tv_nsec,
- .st_ctime = tmp.stx_ctime.tv_sec,
- .st_ctim.tv_nsec = tmp.stx_ctime.tv_nsec,
- .st_size = tmp.stx_size,
- .st_blocks = tmp.stx_blocks,
- .st_blksize = tmp.stx_blksize,
- };
-
- return r;
-}
-#else
-# define FSTATAT_USE_STATX 0
-#endif
+#define FSTATAT_USE_STATX 0

/* Only statx supports 64-bit timestamps for 32-bit architectures with
__ASSUME_STATX, so there is no point in building the fallback. */
22 changes: 22 additions & 0 deletions distro/glibc/fxstat64.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- src/glibc-2.36/sysdeps/unix/sysv/linux/fxstat64.c 2022-07-30 01:03:09.000000000 +0300
+++ src/glibc-2.36/sysdeps/unix/sysv/linux/fxstat64.c.patch 2022-10-07 22:35:03.954262517 +0300
@@ -50,14 +50,6 @@
if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
return INLINE_SYSCALL_CALL (fstat, fd, buf);
return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
-# else
- /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32. */
- struct statx tmp;
- int r = INLINE_SYSCALL_CALL (statx, fd, "", AT_EMPTY_PATH,
- STATX_BASIC_STATS, &tmp);
- if (r == 0)
- __cp_stat64_statx (buf, &tmp);
- return r;
# endif
#else
/* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa, m68k,
@@ -79,3 +71,4 @@
#endif

#endif /* LIB_COMPAT */
+
20 changes: 20 additions & 0 deletions distro/glibc/fxstatat64.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- src/glibc-2.36/sysdeps/unix/sysv/linux/fxstatat64.c 2022-07-30 01:03:09.000000000 +0300
+++ src/glibc-2.36/sysdeps/unix/sysv/linux/fxstatat64.c.patch 2022-10-07 22:31:59.294262587 +0300
@@ -44,17 +44,6 @@
struct stat64 st64;
int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
return r ?: __xstat32_conv (vers, &st64, (struct stat *) st);
-# else
- /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32. */
- if (vers == _STAT_VER_KERNEL)
- {
- struct statx tmp;
- int r = INLINE_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
- STATX_BASIC_STATS, &tmp);
- if (r == 0)
- __cp_stat64_statx (st, &tmp);
- return r;
- }
# endif
#else
/* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa, m68k,
21 changes: 21 additions & 0 deletions distro/glibc/lxstat64.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- src/glibc-2.36/sysdeps/unix/sysv/linux/lxstat64.c 2022-07-30 01:03:09.000000000 +0300
+++ src/glibc-2.36/sysdeps/unix/sysv/linux/lxstat64.c.patch 2022-10-07 22:27:46.944262684 +0300
@@ -53,18 +53,6 @@
if (vers == _STAT_VER_KERNEL)
return INLINE_SYSCALL_CALL (newfstatat, AT_FDCWD, name, buf,
AT_SYMLINK_NOFOLLOW);
-# else
- /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32. */
- if (vers == _STAT_VER_KERNEL)
- {
- struct statx tmp;
- int r = INLINE_SYSCALL_CALL (statx, AT_FDCWD, name,
- AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
- STATX_BASIC_STATS, &tmp);
- if (r == 0)
- __cp_stat64_statx (buf, &tmp);
- return r;
- }
# endif
#else
# if STAT_IS_KERNEL_STAT
18 changes: 18 additions & 0 deletions distro/glibc/statx.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- src/glibc-2.36/sysdeps/unix/sysv/linux/statx.c 2022-02-03 08:27:54.000000000 +0300
+++ src/glibc-2.36/sysdeps/unix/sysv/linux/statx.c.patch 2022-10-07 10:17:06.418934334 +0300
@@ -25,14 +25,5 @@
statx (int fd, const char *path, int flags,
unsigned int mask, struct statx *buf)
{
- int ret = INLINE_SYSCALL_CALL (statx, fd, path, flags, mask, buf);
-#ifdef __ASSUME_STATX
- return ret;
-#else
- if (ret == 0 || errno != ENOSYS)
- /* Preserve non-error/non-ENOSYS return values. */
- return ret;
- else
- return statx_generic (fd, path, flags, mask, buf);
-#endif
+ return statx_generic (fd, path, flags, mask, buf);
}
20 changes: 20 additions & 0 deletions distro/glibc/xstat64.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- src/glibc-2.36/sysdeps/unix/sysv/linux/xstat64.c 2022-07-30 01:03:09.000000000 +0300
+++ src/glibc-2.36/sysdeps/unix/sysv/linux/xstat64.c.patch 2022-10-07 22:26:06.884262722 +0300
@@ -52,17 +52,6 @@
/* New kABIs which uses generic 64-bit Linux ABI, e.g. aarch64, riscv64. */
if (vers == _STAT_VER_KERNEL)
return INLINE_SYSCALL_CALL (newfstatat, AT_FDCWD, name, buf, 0);
-# else
- /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32. */
- if (vers == _STAT_VER_KERNEL)
- {
- struct statx tmp;
- int r = INLINE_SYSCALL_CALL (statx, AT_FDCWD, name, AT_NO_AUTOMOUNT,
- STATX_BASIC_STATS, &tmp);
- if (r == 0)
- __cp_stat64_statx (buf, &tmp);
- return r;
- }
# endif
#else
# if STAT_IS_KERNEL_STAT

0 comments on commit b0abcc2

Please sign in to comment.