patches/uClibc/0.9.30.2/220-fstatat-fix-up-behavior-on-32-64-bit-hosts.patch
changeset 1819 66fcfb3d6745
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/uClibc/0.9.30.2/220-fstatat-fix-up-behavior-on-32-64-bit-hosts.patch	Sun Feb 28 11:50:15 2010 +0100
     1.3 @@ -0,0 +1,113 @@
     1.4 +From d43f068e84513ed88392df4ca27d49ad01145fd2 Mon Sep 17 00:00:00 2001
     1.5 +From: Mike Frysinger <vapier@gentoo.org>
     1.6 +Date: Sun, 6 Sep 2009 12:12:12 -0400
     1.7 +Subject: [PATCH 07/15] fstatat: fix up behavior on 32/64 bit hosts
     1.8 +MIME-Version: 1.0
     1.9 +Content-Type: text/plain; charset=UTF-8
    1.10 +Content-Transfer-Encoding: 8bit
    1.11 +
    1.12 +The fstatat() syscall is a little funky in that it sometimes changes name
    1.13 +between 32 and 64 bit hosts, but it should always operate on a 64bit stat
    1.14 +structure.  So for the fstatat() function, make sure we convert it from a
    1.15 +64bit kstat to a 32bit stat.
    1.16 +
    1.17 +Along these lines, we need to restore the __xstat32_conv() function.
    1.18 +
    1.19 +Reported-by: Timo Teräs <timo.teras@iki.fi>
    1.20 +Signed-off-by: Mike Frysinger <vapier@gentoo.org>
    1.21 +Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
    1.22 +---
    1.23 + libc/sysdeps/linux/common/fstatat.c   |    9 +++++++--
    1.24 + libc/sysdeps/linux/common/fstatat64.c |    5 +++++
    1.25 + libc/sysdeps/linux/common/xstatconv.c |   19 +++++++++++++++++++
    1.26 + libc/sysdeps/linux/common/xstatconv.h |    1 +
    1.27 + 4 files changed, 32 insertions(+), 2 deletions(-)
    1.28 +
    1.29 +diff --git a/libc/sysdeps/linux/common/fstatat.c b/libc/sysdeps/linux/common/fstatat.c
    1.30 +index 149c189..33daa7c 100644
    1.31 +--- a/libc/sysdeps/linux/common/fstatat.c
    1.32 ++++ b/libc/sysdeps/linux/common/fstatat.c
    1.33 +@@ -10,15 +10,20 @@
    1.34 + #include <sys/stat.h>
    1.35 + #include "xstatconv.h"
    1.36 + 
    1.37 ++/* 64bit ports tend to favor newfstatat() */
    1.38 ++#ifdef __NR_newfstatat
    1.39 ++# define __NR_fstatat64 __NR_newfstatat
    1.40 ++#endif
    1.41 ++
    1.42 + #ifdef __NR_fstatat64
    1.43 + int fstatat(int fd, const char *file, struct stat *buf, int flag)
    1.44 + {
    1.45 + 	int ret;
    1.46 +-	struct kernel_stat kbuf;
    1.47 ++	struct kernel_stat64 kbuf;
    1.48 + 
    1.49 + 	ret = INLINE_SYSCALL(fstatat64, 4, fd, file, &kbuf, flag);
    1.50 + 	if (ret == 0)
    1.51 +-		__xstat_conv(&kbuf, buf);
    1.52 ++		__xstat32_conv(&kbuf, buf);
    1.53 + 
    1.54 + 	return ret;
    1.55 + }
    1.56 +diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c
    1.57 +index 5ae1fad..95627af 100644
    1.58 +--- a/libc/sysdeps/linux/common/fstatat64.c
    1.59 ++++ b/libc/sysdeps/linux/common/fstatat64.c
    1.60 +@@ -12,6 +12,11 @@
    1.61 + 
    1.62 + #ifdef __UCLIBC_HAS_LFS__
    1.63 + 
    1.64 ++/* 64bit ports tend to favor newfstatat() */
    1.65 ++#ifdef __NR_newfstatat
    1.66 ++# define __NR_fstatat64 __NR_newfstatat
    1.67 ++#endif
    1.68 ++
    1.69 + #ifdef __NR_fstatat64
    1.70 + int fstatat64(int fd, const char *file, struct stat64 *buf, int flag)
    1.71 + {
    1.72 +diff --git a/libc/sysdeps/linux/common/xstatconv.c b/libc/sysdeps/linux/common/xstatconv.c
    1.73 +index e575b26..50455c6 100644
    1.74 +--- a/libc/sysdeps/linux/common/xstatconv.c
    1.75 ++++ b/libc/sysdeps/linux/common/xstatconv.c
    1.76 +@@ -46,6 +46,25 @@ void attribute_hidden __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
    1.77 + 	buf->st_ctim = kbuf->st_ctim;
    1.78 + }
    1.79 + 
    1.80 ++void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
    1.81 ++{
    1.82 ++	/* Convert to current kernel version of `struct stat64'. */
    1.83 ++	memset(buf, 0x00, sizeof(*buf));
    1.84 ++	buf->st_dev = kbuf->st_dev;
    1.85 ++	buf->st_ino = kbuf->st_ino;
    1.86 ++	buf->st_mode = kbuf->st_mode;
    1.87 ++	buf->st_nlink = kbuf->st_nlink;
    1.88 ++	buf->st_uid = kbuf->st_uid;
    1.89 ++	buf->st_gid = kbuf->st_gid;
    1.90 ++	buf->st_rdev = kbuf->st_rdev;
    1.91 ++	buf->st_size = kbuf->st_size;
    1.92 ++	buf->st_blksize = kbuf->st_blksize;
    1.93 ++	buf->st_blocks = kbuf->st_blocks;
    1.94 ++	buf->st_atim = kbuf->st_atim;
    1.95 ++	buf->st_mtim = kbuf->st_mtim;
    1.96 ++	buf->st_ctim = kbuf->st_ctim;
    1.97 ++}
    1.98 ++
    1.99 + #ifdef __UCLIBC_HAS_LFS__
   1.100 + 
   1.101 + void attribute_hidden __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
   1.102 +diff --git a/libc/sysdeps/linux/common/xstatconv.h b/libc/sysdeps/linux/common/xstatconv.h
   1.103 +index 57c8bcb..7568da8 100644
   1.104 +--- a/libc/sysdeps/linux/common/xstatconv.h
   1.105 ++++ b/libc/sysdeps/linux/common/xstatconv.h
   1.106 +@@ -26,6 +26,7 @@
   1.107 + #include <bits/kernel_stat.h>
   1.108 + 
   1.109 + extern void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf) attribute_hidden;
   1.110 ++extern void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf) attribute_hidden;
   1.111 + #if defined __UCLIBC_HAS_LFS__
   1.112 + extern void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf) attribute_hidden;
   1.113 + #endif
   1.114 +-- 
   1.115 +1.6.6.1
   1.116 +