From nobody Fri Nov 7 12:04:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547847961934399.57832427674384; Fri, 18 Jan 2019 13:46:01 -0800 (PST) Received: from localhost ([127.0.0.1]:47597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbxg-0007xv-IO for importer@patchew.org; Fri, 18 Jan 2019 16:46:00 -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) 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) 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-Google-Smtp-Source: ALg8bN7dV4X6MHVbsuZlGHhmqa94WDN6ZnVi/pX+FHzb/ypwVYKK1F+f4EuEUumTCbQeaRgs9xR7fw== X-Received: by 2002:a63:4b60:: with SMTP id k32mr19228152pgl.186.1547847171528; Fri, 18 Jan 2019 13:32:51 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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 =3D 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 =20 =20 -#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 =20 -#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); } =20 +#ifdef TARGET_NR_futimesat +SYSCALL_IMPL(futimesat) +{ + int dirfd =3D arg1; + abi_ulong target_path =3D arg2; + abi_ulong target_tv =3D 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 =3D tv; + } else { + tvp =3D NULL; + } + + p =3D lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret =3D 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); } =20 +#ifdef TARGET_NR_utime +SYSCALL_IMPL(utime) +{ + abi_ulong target_path =3D arg1; + abi_ulong target_times =3D 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 =3D tswapal(target_tbuf->actime); + tbuf.modtime =3D tswapal(target_tbuf->modtime); + unlock_user_struct(target_tbuf, arg2, 0); + host_tbuf =3D &tbuf; + } else { + host_tbuf =3D NULL; + } + + p =3D lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret =3D 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 =3D arg1; + abi_ulong target_tv =3D 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 =3D tv; + } else { + tvp =3D NULL; + } + + p =3D lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret =3D get_errno(utimes(p, tvp)); + unlock_user(p, target_path, 0); + return ret; +} +#endif + SYSCALL_IMPL(write) { int fd =3D 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; =20 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 =3D tswapal(target_tbuf->actime); - tbuf.modtime =3D tswapal(target_tbuf->modtime); - unlock_user_struct(target_tbuf, arg2, 0); - host_tbuf =3D &tbuf; - } else { - host_tbuf =3D NULL; - } - if (!(p =3D lock_user_string(arg1))) - return -TARGET_EFAULT; - ret =3D 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 =3D tv; - } else { - tvp =3D NULL; - } - if (!(p =3D lock_user_string(arg1))) - return -TARGET_EFAULT; - ret =3D 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 =3D tv; - } else { - tvp =3D NULL; - } - if (!(p =3D lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret =3D 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 =3D 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 --=20 2.17.2