From patchwork Mon Jul 18 10:47:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9234389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 47132607FF for ; Mon, 18 Jul 2016 10:48:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36E3926AE3 for ; Mon, 18 Jul 2016 10:48:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B52D26B41; Mon, 18 Jul 2016 10:48:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9AA9D26AE3 for ; Mon, 18 Jul 2016 10:48:30 +0000 (UTC) Received: from localhost ([::1]:45796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP669-0006K8-PB for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Jul 2016 06:48:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP65m-0006Fv-NO for qemu-devel@nongnu.org; Mon, 18 Jul 2016 06:48:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP65l-0005qe-MN for qemu-devel@nongnu.org; Mon, 18 Jul 2016 06:48:06 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:58337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP65l-0005po-Ee for qemu-devel@nongnu.org; Mon, 18 Jul 2016 06:48:05 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bP65c-0002OB-Gd; Mon, 18 Jul 2016 11:47:56 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 18 Jul 2016 11:47:55 +0100 Message-Id: <1468838875-5297-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] linux-user: Use direct syscall for utimensat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The linux utimensat syscall differs in semantics from the libc function because the syscall combines the features of utimensat() and futimens(). Rather than trying to split these apart in order to call the two libc functions which then call the same underlying syscall, just always directly make the host syscall. This fixes bugs in some of the corner cases which should return errors from the syscall but which we were incorrectly directing to futimens(). This doesn't reduce the set of hosts that our syscall implementation will work on, because if the direct syscall fails ENOSYS then the libc functions would also fail ENOSYS. (The system call has been in the kernel since 2.6.22 anyway.) Signed-off-by: Peter Maydell --- This patch supersedes http://patchwork.ozlabs.org/patch/648919/ ("linux-user: fix "really futimens" condition in sys_utimensat()") linux-user/syscall.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0e87157..fe72abe 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -363,16 +363,7 @@ static int sys_getcwd1(char *buf, size_t size) } #ifdef TARGET_NR_utimensat -#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); -} -#elif defined(__NR_utimensat) +#if defined(__NR_utimensat) #define __NR_sys_utimensat __NR_utimensat _syscall4(int,sys_utimensat,int,dirfd,const char *,pathname, const struct timespec *,tsp,int,flags)