patches/uClibc/0.9.30.2/220-fstatat-fix-up-behavior-on-32-64-bit-hosts.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jan 03 23:40:22 2011 +0100 (2011-01-03)
changeset 2267 7af68e6083aa
permissions -rw-r--r--
libc-glibc: remove 2.3.6

This is an obsolete version which is no longer used by any sample (the only
user, the ia64 sample, has been removed).

It also makes the code path a bit complex, with twists just to accomodate
that version. Removing the version will make those twists go away, and
will ease commonalisation of glibc and eglibc in the future (hopefully!).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
yann@1819
     1
From d43f068e84513ed88392df4ca27d49ad01145fd2 Mon Sep 17 00:00:00 2001
yann@1819
     2
From: Mike Frysinger <vapier@gentoo.org>
yann@1819
     3
Date: Sun, 6 Sep 2009 12:12:12 -0400
yann@1819
     4
Subject: [PATCH 07/15] fstatat: fix up behavior on 32/64 bit hosts
yann@1819
     5
MIME-Version: 1.0
yann@1819
     6
Content-Type: text/plain; charset=UTF-8
yann@1819
     7
Content-Transfer-Encoding: 8bit
yann@1819
     8
yann@1819
     9
The fstatat() syscall is a little funky in that it sometimes changes name
yann@1819
    10
between 32 and 64 bit hosts, but it should always operate on a 64bit stat
yann@1819
    11
structure.  So for the fstatat() function, make sure we convert it from a
yann@1819
    12
64bit kstat to a 32bit stat.
yann@1819
    13
yann@1819
    14
Along these lines, we need to restore the __xstat32_conv() function.
yann@1819
    15
yann@1819
    16
Reported-by: Timo Teräs <timo.teras@iki.fi>
yann@1819
    17
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
yann@1819
    18
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
yann@1819
    19
---
yann@1819
    20
 libc/sysdeps/linux/common/fstatat.c   |    9 +++++++--
yann@1819
    21
 libc/sysdeps/linux/common/fstatat64.c |    5 +++++
yann@1819
    22
 libc/sysdeps/linux/common/xstatconv.c |   19 +++++++++++++++++++
yann@1819
    23
 libc/sysdeps/linux/common/xstatconv.h |    1 +
yann@1819
    24
 4 files changed, 32 insertions(+), 2 deletions(-)
yann@1819
    25
yann@1819
    26
diff --git a/libc/sysdeps/linux/common/fstatat.c b/libc/sysdeps/linux/common/fstatat.c
yann@1819
    27
index 149c189..33daa7c 100644
yann@1819
    28
--- a/libc/sysdeps/linux/common/fstatat.c
yann@1819
    29
+++ b/libc/sysdeps/linux/common/fstatat.c
yann@1819
    30
@@ -10,15 +10,20 @@
yann@1819
    31
 #include <sys/stat.h>
yann@1819
    32
 #include "xstatconv.h"
yann@1819
    33
 
yann@1819
    34
+/* 64bit ports tend to favor newfstatat() */
yann@1819
    35
+#ifdef __NR_newfstatat
yann@1819
    36
+# define __NR_fstatat64 __NR_newfstatat
yann@1819
    37
+#endif
yann@1819
    38
+
yann@1819
    39
 #ifdef __NR_fstatat64
yann@1819
    40
 int fstatat(int fd, const char *file, struct stat *buf, int flag)
yann@1819
    41
 {
yann@1819
    42
 	int ret;
yann@1819
    43
-	struct kernel_stat kbuf;
yann@1819
    44
+	struct kernel_stat64 kbuf;
yann@1819
    45
 
yann@1819
    46
 	ret = INLINE_SYSCALL(fstatat64, 4, fd, file, &kbuf, flag);
yann@1819
    47
 	if (ret == 0)
yann@1819
    48
-		__xstat_conv(&kbuf, buf);
yann@1819
    49
+		__xstat32_conv(&kbuf, buf);
yann@1819
    50
 
yann@1819
    51
 	return ret;
yann@1819
    52
 }
yann@1819
    53
diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c
yann@1819
    54
index 5ae1fad..95627af 100644
yann@1819
    55
--- a/libc/sysdeps/linux/common/fstatat64.c
yann@1819
    56
+++ b/libc/sysdeps/linux/common/fstatat64.c
yann@1819
    57
@@ -12,6 +12,11 @@
yann@1819
    58
 
yann@1819
    59
 #ifdef __UCLIBC_HAS_LFS__
yann@1819
    60
 
yann@1819
    61
+/* 64bit ports tend to favor newfstatat() */
yann@1819
    62
+#ifdef __NR_newfstatat
yann@1819
    63
+# define __NR_fstatat64 __NR_newfstatat
yann@1819
    64
+#endif
yann@1819
    65
+
yann@1819
    66
 #ifdef __NR_fstatat64
yann@1819
    67
 int fstatat64(int fd, const char *file, struct stat64 *buf, int flag)
yann@1819
    68
 {
yann@1819
    69
diff --git a/libc/sysdeps/linux/common/xstatconv.c b/libc/sysdeps/linux/common/xstatconv.c
yann@1819
    70
index e575b26..50455c6 100644
yann@1819
    71
--- a/libc/sysdeps/linux/common/xstatconv.c
yann@1819
    72
+++ b/libc/sysdeps/linux/common/xstatconv.c
yann@1819
    73
@@ -46,6 +46,25 @@ void attribute_hidden __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
yann@1819
    74
 	buf->st_ctim = kbuf->st_ctim;
yann@1819
    75
 }
yann@1819
    76
 
yann@1819
    77
+void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
yann@1819
    78
+{
yann@1819
    79
+	/* Convert to current kernel version of `struct stat64'. */
yann@1819
    80
+	memset(buf, 0x00, sizeof(*buf));
yann@1819
    81
+	buf->st_dev = kbuf->st_dev;
yann@1819
    82
+	buf->st_ino = kbuf->st_ino;
yann@1819
    83
+	buf->st_mode = kbuf->st_mode;
yann@1819
    84
+	buf->st_nlink = kbuf->st_nlink;
yann@1819
    85
+	buf->st_uid = kbuf->st_uid;
yann@1819
    86
+	buf->st_gid = kbuf->st_gid;
yann@1819
    87
+	buf->st_rdev = kbuf->st_rdev;
yann@1819
    88
+	buf->st_size = kbuf->st_size;
yann@1819
    89
+	buf->st_blksize = kbuf->st_blksize;
yann@1819
    90
+	buf->st_blocks = kbuf->st_blocks;
yann@1819
    91
+	buf->st_atim = kbuf->st_atim;
yann@1819
    92
+	buf->st_mtim = kbuf->st_mtim;
yann@1819
    93
+	buf->st_ctim = kbuf->st_ctim;
yann@1819
    94
+}
yann@1819
    95
+
yann@1819
    96
 #ifdef __UCLIBC_HAS_LFS__
yann@1819
    97
 
yann@1819
    98
 void attribute_hidden __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
yann@1819
    99
diff --git a/libc/sysdeps/linux/common/xstatconv.h b/libc/sysdeps/linux/common/xstatconv.h
yann@1819
   100
index 57c8bcb..7568da8 100644
yann@1819
   101
--- a/libc/sysdeps/linux/common/xstatconv.h
yann@1819
   102
+++ b/libc/sysdeps/linux/common/xstatconv.h
yann@1819
   103
@@ -26,6 +26,7 @@
yann@1819
   104
 #include <bits/kernel_stat.h>
yann@1819
   105
 
yann@1819
   106
 extern void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf) attribute_hidden;
yann@1819
   107
+extern void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf) attribute_hidden;
yann@1819
   108
 #if defined __UCLIBC_HAS_LFS__
yann@1819
   109
 extern void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf) attribute_hidden;
yann@1819
   110
 #endif
yann@1819
   111
-- 
yann@1819
   112
1.6.6.1
yann@1819
   113