[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/21] linux-user: fix utimensat
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PATCH 07/21] linux-user: fix utimensat |
Date: |
Fri, 12 Jun 2009 16:50:17 +0300 |
From: Riku Voipio <address@hidden>
The glibc function for utimensat glibc returns -EINVAL when the path is null
which is a different behaviour with the syscall.
path can be null because internally the glibc is using utimensat with
path null when implmenting futimens. If path is null, call futimes
instead.
don't try to copy timespec from user if is NULL.
Add configure check for older systems
Signed-off-by: Riku Voipio <address@hidden>
---
configure | 22 ++++++++++++++++++++++
linux-user/syscall.c | 38 ++++++++++++++++++++++++--------------
2 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/configure b/configure
index 11501c6..ecea67c 100755
--- a/configure
+++ b/configure
@@ -1281,6 +1281,25 @@ EOF
fi
fi
+# check if utimensat and futimens are supported
+utimens=no
+cat > $TMPC << EOF
+#define _ATFILE_SOURCE
+#define _GNU_SOURCE
+#include <stddef.h>
+#include <fcntl.h>
+
+int main(void)
+{
+ utimensat(AT_FDCWD, "foo", NULL, 0);
+ futimens(0, NULL);
+ return 0;
+}
+EOF
+if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+ utimens=yes
+fi
+
# Check if tools are available to build documentation.
if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o !
-x "`which pod2man 2>/dev/null`" \) ; then
build_docs="no"
@@ -1679,6 +1698,9 @@ fi
if test "$atfile" = "yes" ; then
echo "#define CONFIG_ATFILE 1" >> $config_h
fi
+if test "$utimens" = "yes" ; then
+ echo "#define CONFIG_UTIMENSAT 1" >> $config_h
+fi
if test "$inotify" = "yes" ; then
echo "#define CONFIG_INOTIFY 1" >> $config_h
fi
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 056581d..9e4e061 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -406,13 +406,6 @@ static int sys_unlinkat(int dirfd, const char *pathname,
int flags)
return (unlinkat(dirfd, pathname, flags));
}
#endif
-#ifdef TARGET_NR_utimensat
-static int sys_utimensat(int dirfd, const char *pathname,
- const struct timespec times[2], int flags)
-{
- return (utimensat(dirfd, pathname, times, flags));
-}
-#endif
#else /* !CONFIG_ATFILE */
/*
@@ -471,12 +464,24 @@ _syscall3(int,sys_symlinkat,const char *,oldpath,
#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat)
_syscall3(int,sys_unlinkat,int,dirfd,const char *,pathname,int,flags)
#endif
+
+#endif /* CONFIG_ATFILE */
+
+#ifdef CONFIG_UTIMENSAT
+static int sys_utimensat(int dirfd, const char *pathname,
+ const struct timespec times[2], int flags)
+{
+ if (pathname == NULL)
+ return futimens(dirfd, times);
+ else
+ return utimensat(dirfd, pathname, times, flags);
+}
+#else
#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)
_syscall4(int,sys_utimensat,int,dirfd,const char *,pathname,
const struct timespec *,tsp,int,flags)
#endif
-
-#endif /* CONFIG_ATFILE */
+#endif /* CONFIG_UTIMENSAT */
#ifdef CONFIG_INOTIFY
#include <sys/inotify.h>
@@ -6669,17 +6674,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)
case TARGET_NR_utimensat:
{
- struct timespec ts[2];
- target_to_host_timespec(ts, arg3);
- target_to_host_timespec(ts+1, arg3+sizeof(struct target_timespec));
+ struct timespec *tsp, ts[2];
+ if (!arg3) {
+ tsp = NULL;
+ } else {
+ target_to_host_timespec(ts, arg3);
+ target_to_host_timespec(ts+1, arg3+sizeof(struct
target_timespec));
+ tsp = ts;
+ }
if (!arg2)
- ret = get_errno(sys_utimensat(arg1, NULL, ts, arg4));
+ ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));
else {
if (!(p = lock_user_string(arg2))) {
ret = -TARGET_EFAULT;
goto fail;
}
- ret = get_errno(sys_utimensat(arg1, path(p), ts, arg4));
+ ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4));
unlock_user(p, arg2, 0);
}
}
--
1.6.2.1
- [Qemu-devel] [PATCH 18/21] RFC: fix fcntl support in linux-user - new try, (continued)
- [Qemu-devel] [PATCH 18/21] RFC: fix fcntl support in linux-user - new try, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 05/21] linux-user: strace now handles guest strings correctly [v2], riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 09/21] Return EOPNOTSUPP instead of ENOSYS for *xattr* syscalls, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 04/21] linux-user: added x86 and x86_64 support for ELF coredump, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 19/21] linux-user: initialize mmap_mutex properly, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 13/21] linux-user: support private futexes, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 14/21] add futex wake op, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 07/21] linux-user: fix utimensat,
riku . voipio <=
- [Qemu-devel] [PATCH 15/21] linux-user: update syscall list, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 02/21] Implement shm* syscalls and fix 64/32bit errors, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 10/21] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 12/21] linux-user: include linux/fs.h, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 20/21] linux-user/syscall.c: define _ATFILE_SOURCE, riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 16/21] linux-user: implement pipe2 [v3], riku . voipio, 2009/06/12
- [Qemu-devel] [PATCH 17/21] linux-user: add tee, splice and vmsplice, riku . voipio, 2009/06/12