From patchwork Fri Jan 18 21:31:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156063 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3736185jaa; Fri, 18 Jan 2019 13:44:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN5C2h9NjcxCCg1WVhdkxUeCvdNCPnSBo7Jr5FCRPmLH8svLJ3hhyABSNZLFwh6bfXMxgylo X-Received: by 2002:adf:8143:: with SMTP id 61mr17629045wrm.47.1547847866894; Fri, 18 Jan 2019 13:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547847866; cv=none; d=google.com; s=arc-20160816; b=01cFMAuIynzDWo+rU5B3xYas60+7xVjH6KdkcOd/Uk+rpGynAGhy8pTc5VijefFKzj 7ukihyDIl+ZqZkAj9Ecrdr0DV81fPIX1ocHNGDtNX4zPw3cM+T+zdW7LZXhBugGcD6km F7jvMK2it0kgXAtyXzvb9zotVBeuEgSYs9llZ14t+X3H5MyzwEBfBEJctuOt7rZfvapq 3v+VJbmh4lt/OixrIG30J2SNasVxHzHjn/+dVue2B7p1jhbW3gcKpJFo/leuZ0zi6Rr2 npdAjTScondBOJe7c9kUl+3RN4I4Iwl7tRIDJNO6BVC14C5rmHvf6q4b21gtjoVEyX+F i7SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=K+wNFSCsbxRWr3U8isWrQQJrl4aYn/PQ1fyYDV6k6YI=; b=YsHloNAgUqc7/peuQdqtCIJ+w1eliTPjblrs/PXENeQRG1dwHnfM+1oFBENu+vkKeB FYjD70Z2Xba0lvGC73jDzegEXmXo32EPQBzkMmabnhEncs+J3M8++/lUYG3yufJguDw4 UFVHSlFRvmTYDLnOT0UfPeWkWZbbljDzJXNiIgI2Mjo+igiuVAZMJ/FpIgbG/01CK/sN mwNgCzzFjoD1A+HtBuEF8C5WAfU27N1BQka2jLFSupHSoypXCM9OohhY3bw8ep3kkqTQ QYeTk7WpZpvbB7dd4oe7VYQabYjKgWmCxIx6FepKBUUMU1VxQQPD1q+0JkgYAyfB64ud +BVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="KkR/JdGz"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71si63445793wrl.91.2019.01.18.13.44.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Jan 2019 13:44:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="KkR/JdGz"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:47552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbw9-0006ni-O1 for patch@linaro.org; Fri, 18 Jan 2019 16:44:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbl4-0005eC-Qw for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkbl3-0005KB-5t for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:58 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:43471) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbl2-0005D1-Sg for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:57 -0500 Received: by mail-pf1-x443.google.com with SMTP id w73so7189495pfk.10 for ; Fri, 18 Jan 2019 13:32:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K+wNFSCsbxRWr3U8isWrQQJrl4aYn/PQ1fyYDV6k6YI=; b=KkR/JdGzjynWyJY8W9Rznbja9FLFX6lL5oE74S8c5vjGjg5XfGJvYp7BQtofm2DJl4 yuvdONErB6WIqHT0MFPAjXy7IcLokU3XMHlsW7HbYhsG6OUCF0j8XU5IZ/fUSDUsHEZ4 f73D+WCHXp1gb1ioTtdEAQVAiUVoExaej6sbM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K+wNFSCsbxRWr3U8isWrQQJrl4aYn/PQ1fyYDV6k6YI=; b=GHUUkEqZyUBw6thI5UKenc9acIEYC+HB0LYLluj5KUWeaccDWXlIO469dgEbuPzb8B ad2zIGEkrQT2Qp7DNJputzKXPeHvfdZwmtMn4uSndV9WPajWEe5+wdcKAuJoawXcRZtj Yx4WAiqT424qRPy60zgcsSFOenooSZbpg4F2QB7k3+hFVK6MS+9Q5P9LTrKmdGC0iJgF Bg2QnXQzavFhZca7x1TQhGCHAFvxUlIcqplKAcIVRCG7NSWUUCX5/0zF3Kp6PaU2vK5m YsedH9aFE9BBn0rMCNHpRroS6lgupropUB0HnyE1idkQP5Ai2dJxYiBz9vWNyhQ4iLQs laOQ== X-Gm-Message-State: AJcUukflW66eBaXWxDey9MeTjaTLuzIh9k5DBwCcYvhXRV893jF1hdQW yBcCZ1mfRHE3wferJUSa351bHPguPZQ= X-Received: by 2002:a63:4b60:: with SMTP id k32mr19228152pgl.186.1547847171528; Fri, 18 Jan 2019 13:32:51 -0800 (PST) Received: from cloudburst.twiddle.net ([2001:8000:10e0:a000:c673:a6b6:fdef:1933]) by smtp.gmail.com with ESMTPSA id v12sm5833667pgg.41.2019.01.18.13.32.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:32:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:31:09 +1100 Message-Id: <20190118213122.22865-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190118213122.22865-1-richard.henderson@linaro.org> References: <20190118213122.22865-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v6 36/49] linux-user: Split out utime, utimes, futimesat 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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 9 ++++ linux-user/strace.c | 41 --------------- linux-user/syscall-file.inc.c | 95 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 63 ----------------------- linux-user/strace.list | 9 ---- 5 files changed, 104 insertions(+), 113 deletions(-) -- 2.17.2 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 9d0dd7457b..2767e335d8 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -36,6 +36,9 @@ SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR); SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); SYSCALL_DEF(fchmod, ARG_DEC, ARG_MODEFLAG); SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); +#ifdef TARGET_NR_futimesat +SYSCALL_DEF(futimesat, ARG_ATDIRFD, ARG_STR, ARG_PTR); +#endif #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif @@ -172,6 +175,12 @@ SYSCALL_DEF(umount2, ARG_STR, ARG_UMOUNTFLAG); SYSCALL_DEF(unlink, ARG_STR); #endif SYSCALL_DEF(unlinkat, ARG_ATDIRFD, ARG_STR, ARG_UNLINKATFLAG); +#ifdef TARGET_NR_utime +SYSCALL_DEF(utime, ARG_STR, ARG_PTR); +#endif +#ifdef TARGET_NR_utimes +SYSCALL_DEF(utimes, ARG_STR, ARG_PTR); +#endif #ifdef TARGET_NR_vfork /* Emulate vfork() with fork(). */ SYSCALL_DEF_FULL(vfork, .impl = impl_fork); diff --git a/linux-user/strace.c b/linux-user/strace.c index 78781b8817..b54949df27 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1284,21 +1284,6 @@ print_fcntl(const struct syscallname *name, #endif -#ifdef TARGET_NR_futimesat -static void -print_futimesat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_timeval(arg2, 0); - print_timeval(arg2 + sizeof (struct target_timeval), 1); - print_syscall_epilogue(name); -} -#endif - #if defined(TARGET_NR_socket) static void print_socket(const struct syscallname *name, @@ -2003,32 +1988,6 @@ print_symlinkat(const struct syscallname *name, } #endif -#ifdef TARGET_NR_utime -static void -print_utime(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_pointer(arg1, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_utimes -static void -print_utimes(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_pointer(arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_utimensat static void print_utimensat(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 7ec1c26347..6a7ef80bfc 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -84,6 +84,38 @@ SYSCALL_IMPL(fchmodat) return do_fchmodat(arg1, arg2, arg3); } +#ifdef TARGET_NR_futimesat +SYSCALL_IMPL(futimesat) +{ + int dirfd = arg1; + abi_ulong target_path = arg2; + abi_ulong target_tv = arg3; + struct timeval *tvp, tv[2]; + char *p; + abi_long ret; + + if (target_tv) { + if (copy_from_user_timeval(&tv[0], target_tv) + || copy_from_user_timeval(&tv[1], + target_tv + + sizeof(struct target_timeval))) { + return -TARGET_EFAULT; + } + tvp = tv; + } else { + tvp = NULL; + } + + p = lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(futimesat(dirfd, path(p), tvp)); + unlock_user(p, target_path, 0); + return ret; +} +#endif + static abi_long do_linkat(int olddirfd, abi_ulong target_oldpath, int newdirfd, abi_ulong target_newpath, int flags) @@ -867,6 +899,69 @@ SYSCALL_IMPL(unlinkat) return do_unlinkat(arg1, arg2, arg3); } +#ifdef TARGET_NR_utime +SYSCALL_IMPL(utime) +{ + abi_ulong target_path = arg1; + abi_ulong target_times = arg2; + struct utimbuf tbuf, *host_tbuf; + struct target_utimbuf *target_tbuf; + char *p; + abi_long ret; + + if (target_times) { + if (!lock_user_struct(VERIFY_READ, target_tbuf, target_times, 1)) { + return -TARGET_EFAULT; + } + tbuf.actime = tswapal(target_tbuf->actime); + tbuf.modtime = tswapal(target_tbuf->modtime); + unlock_user_struct(target_tbuf, arg2, 0); + host_tbuf = &tbuf; + } else { + host_tbuf = NULL; + } + + p = lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(utime(p, host_tbuf)); + unlock_user(p, target_path, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_utimes +SYSCALL_IMPL(utimes) +{ + abi_ulong target_path = arg1; + abi_ulong target_tv = arg2; + struct timeval *tvp, tv[2]; + char *p; + abi_long ret; + + if (target_tv) { + if (copy_from_user_timeval(&tv[0], target_tv) + || copy_from_user_timeval(&tv[1], + target_tv + + sizeof(struct target_timeval))) { + return -TARGET_EFAULT; + } + tvp = tv; + } else { + tvp = NULL; + } + + p = lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(utimes(p, tvp)); + unlock_user(p, target_path, 0); + return ret; +} +#endif + SYSCALL_IMPL(write) { int fd = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f3ea9600c8..ca462fde61 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5327,69 +5327,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_utime - case TARGET_NR_utime: - { - struct utimbuf tbuf, *host_tbuf; - struct target_utimbuf *target_tbuf; - if (arg2) { - if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) - return -TARGET_EFAULT; - tbuf.actime = tswapal(target_tbuf->actime); - tbuf.modtime = tswapal(target_tbuf->modtime); - unlock_user_struct(target_tbuf, arg2, 0); - host_tbuf = &tbuf; - } else { - host_tbuf = NULL; - } - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(utime(p, host_tbuf)); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#ifdef TARGET_NR_utimes - case TARGET_NR_utimes: - { - struct timeval *tvp, tv[2]; - if (arg2) { - if (copy_from_user_timeval(&tv[0], arg2) - || copy_from_user_timeval(&tv[1], - arg2 + sizeof(struct target_timeval))) - return -TARGET_EFAULT; - tvp = tv; - } else { - tvp = NULL; - } - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(utimes(p, tvp)); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_futimesat) - case TARGET_NR_futimesat: - { - struct timeval *tvp, tv[2]; - if (arg3) { - if (copy_from_user_timeval(&tv[0], arg3) - || copy_from_user_timeval(&tv[1], - arg3 + sizeof(struct target_timeval))) - return -TARGET_EFAULT; - tvp = tv; - } else { - tvp = NULL; - } - if (!(p = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret = get_errno(futimesat(arg1, path(p), tvp)); - unlock_user(p, arg2, 0); - } - return ret; -#endif #ifdef TARGET_NR_access case TARGET_NR_access: if (!(p = lock_user_string(arg1))) { diff --git a/linux-user/strace.list b/linux-user/strace.list index b119b7a20c..c0c1b896f7 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -226,9 +226,6 @@ #ifdef TARGET_NR_futex { TARGET_NR_futex, "futex" , NULL, print_futex, NULL }, #endif -#ifdef TARGET_NR_futimesat -{ TARGET_NR_futimesat, "futimesat" , NULL, print_futimesat, NULL }, -#endif #ifdef TARGET_NR_getcpu { TARGET_NR_getcpu, "getcpu" , "%s(%p,%d)", NULL, NULL }, #endif @@ -1392,12 +1389,6 @@ #ifdef TARGET_NR_ustat { TARGET_NR_ustat, "ustat" , "%s(%#x,%p)", NULL, NULL }, #endif -#ifdef TARGET_NR_utime -{ TARGET_NR_utime, "utime" , NULL, print_utime, NULL }, -#endif -#ifdef TARGET_NR_utimes -{ TARGET_NR_utimes, "utimes" , NULL, print_utimes, NULL }, -#endif #ifdef TARGET_NR_utrap_install { TARGET_NR_utrap_install, "utrap_install" , NULL, NULL, NULL }, #endif