From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ME8qK-0008Pw-3j for qemu-devel@nongnu.org; Tue, 09 Jun 2009 17:26:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ME8qF-0008NZ-Da for qemu-devel@nongnu.org; Tue, 09 Jun 2009 17:26:51 -0400 Received: from [199.232.76.173] (port=52278 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ME8qE-0008NJ-LL for qemu-devel@nongnu.org; Tue, 09 Jun 2009 17:26:46 -0400 Received: from mx2.redhat.com ([66.187.237.31]:39323) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ME8qE-0003UQ-4a for qemu-devel@nongnu.org; Tue, 09 Jun 2009 17:26:46 -0400 From: Eduardo Habkost Date: Tue, 9 Jun 2009 18:26:32 -0300 Message-Id: <1244582792-30589-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1244582792-30589-1-git-send-email-ehabkost@redhat.com> References: <1244582792-30589-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] check for utimensat() availability on configure List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori , Glauber Costa Cc: qemu-devel@nongnu.org Some glibc versions don't have utimensat() available, but have other xxxat() functions. Make a separated check for utimensat() to make sure we can compile linux-user against some older glibc versions. Signed-off-by: Eduardo Habkost --- configure | 24 ++++++++++++++++++++++++ linux-user/syscall.c | 25 +++++++++++++++++-------- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 89e7f53..a5ea78f 100755 --- a/configure +++ b/configure @@ -1254,6 +1254,27 @@ EOF fi fi +# Check for utimensat() separatedly, because some glibc versions +# have unlinkat() but not utimensat() available +utimensat=no +if [ "$linux_user" = "yes" -a "$atfile" = "yes" ] ; then + cat > $TMPC << EOF +#define _ATFILE_SOURCE +#include +#include + +int +main(void) +{ + struct timespec times[2]; + return (utimensat(AT_FDCWD, "nonexistent_file", times, 0)); +} +EOF + if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then + utimensat=yes + fi +fi + # Check for inotify functions when we are building linux-user # emulator. This is done because older glibc versions don't # have syscall stubs for these implemented. In that case we @@ -1673,6 +1694,9 @@ fi if test "$atfile" = "yes" ; then echo "#define CONFIG_ATFILE 1" >> $config_h fi +if test "$utimensat" = "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 d851edc..42e2b77 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -413,13 +413,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 */ /* @@ -478,12 +471,28 @@ _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 + +#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_UTIMENSAT */ #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 -- 1.6.3.rc4.29.g8146