From nobody Thu May 2 07:40:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513782070559607.2614465011602; Wed, 20 Dec 2017 07:01:10 -0800 (PST) Received: from localhost ([::1]:54748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRfrk-0001X5-Du for importer@patchew.org; Wed, 20 Dec 2017 10:01:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRSHz-0001ce-TM for qemu-devel@nongnu.org; Tue, 19 Dec 2017 19:31:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRSHw-0006Ir-2P for qemu-devel@nongnu.org; Tue, 19 Dec 2017 19:31:15 -0500 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:42158) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eRSHv-0006Hl-Ql for qemu-devel@nongnu.org; Tue, 19 Dec 2017 19:31:11 -0500 Received: by mail-pl0-x244.google.com with SMTP id bd8so7999766plb.9 for ; Tue, 19 Dec 2017 16:31:11 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id 73sm34510867pfr.145.2017.12.19.16.31.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Dec 2017 16:31:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=subject:date:message-id:cc:from:to; bh=guHqNQ272yhCf5SKGqWCxYn+GDWPAJFt5XX+/SBgz28=; b=IInV/ErDRmeRsn6ird5nV8524bF1K87R2Fp4s/izkBhakWafjBELV5mTJS6NXiZi64 VdA1ejq+TvkkdR0oMz2jXjT+h6Yrc2NkwHyVT/asZCswgNpdOW5y4AzLlz1s1wvVnndY s/yA41f6SJsULqY9hq7/1oQuM4+D7FuHHeY/i+VQXrZ0CjbW7CT6hFzTJMdkqvNToo31 Zy3sTuQAgimE0a+Fl+4/Cu4uCov78DnIN5Xih3r7mGfzjgBf1FyqmHjhonV9+5djtcFc L/OWpknxO2EIkTDhtCfKQpVazK9KUzhC+14IRCt3zN5abZr1NSLburGodpmdc/RQ/+Tu ignQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:cc:from:to; bh=guHqNQ272yhCf5SKGqWCxYn+GDWPAJFt5XX+/SBgz28=; b=CSzC5Li0fKQ2aEuNM9LyaTfELAhfdQ5qUOB0kcuIVfEgsQgzjn/psZlPavZfM25Dj4 Ix8Rkd/Mh95nhMeqjUvZkUHaL+uUqy9Me2nsbuyY06p3DHyqm9B8kEb8773OOqO+UhMx 1fAyEuQtGP4UIqBSB9Dab50wsAmLSRHQjXH+FucG2qkgaca4LqBBi5A3YLfzOOUEj7Lb C9mpgq2Y+skMdSiyjJnkoRJb2XGQ+qMHn0GAXfXFnSyYT58GDfxm7Bh2+7LYu40MbbvB F9u3JlpIDbs77aGgpy+oTWqOuJzFKiQ95j/XoLACE6wgEq6NTxjBGYnTx10ZZfXxKgQb xAVA== X-Gm-Message-State: AKGB3mKk6++LgirCMxua7r9AuhB6X39wbBZ3m4NoI5CZac78cB3fucix ANtHcD/orfb7h7EKEChujlimAw== X-Google-Smtp-Source: ACJfBouA4bJmaUoFbOWBNs3SguA3M92IkiA3yt79IMHhBL32KnvDRIUsZHN+dhcwxz0z0y3ONwvF9A== X-Received: by 10.159.214.135 with SMTP id n7mr4821908plp.75.1513729870102; Tue, 19 Dec 2017 16:31:10 -0800 (PST) Date: Tue, 19 Dec 2017 16:29:41 -0800 Message-Id: <20171220002941.14560-1-palmer@dabbelt.com> X-Mailer: git-send-email 2.13.6 From: Palmer Dabbelt To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 X-Mailman-Approved-At: Wed, 20 Dec 2017 09:59:03 -0500 Subject: [Qemu-devel] [PATCH] linux-user: Implement renameat2 when defined 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: Bastian Koppelmann , Palmer Dabbelt , Michael Clark , Sagar Karandikar Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Palmer Dabbelt The RISC-V Linux port was recently accept upstream and will be released as part of 4.15. While working on our glibc port I discovered that qemu's user-mode emulation doesn't support renameat2, which has replaced rename as part of the default system call list for new architectures. Since a bunch of commonly used functionality boils down to rename (and now renameat2), we ended up with many failures. This patch adds support for renameat2. As I'm not familiar with QEMU development, I haven't really testing anything more than a simple "./configure; make" on the upstream codebase, but I did test this against our (not yet upstream) QEMU port where it appears to work for me. I've just cobbled it together by copying the existing renameat implementation, but as there appears to be no glibc wrapper for renameat2 on either of the systems I've tried this on I just emited the system call directly. commit b0da6d44157aa6e652de7634343708251ba64146 Author: James Hogan Date: Fri Apr 29 22:29:26 2016 +0100 asm-generic: Drop renameat syscall from default list The newer renameat2 syscall provides all the functionality provided= by the renameat syscall and adds flags, so future architectures won't = need to include renameat. Therefore drop the renameat syscall from the generic syscall list u= nless __ARCH_WANT_RENAMEAT is defined by the architecture's unistd.h prio= r to including asm-generic/unistd.h, and adjust all architectures using = the generic syscall list to define it so that no in-tree architectures = are affected. Michael, Sagar, and Bastian are the RISC-V QEMU guys, I just use it. I've CC'd them all here to serve as sort of a surprise introduction for everyone -- they haven't seen the patch before, so blame me for the stupid parts :). CC: Michael Clark CC: Sagar Karandikar CC: Bastian Koppelmann Signed-off-by: Palmer Dabbelt --- linux-user/syscall.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 11c9116c4a1e..ece574f47aca 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8342,6 +8342,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long= arg1, } break; #endif +#if defined(TARGET_NR_renameat2) && defined(__NR_renameat2) + case TARGET_NR_renameat2: + { + void *p2; + p =3D lock_user_string(arg2); + p2 =3D lock_user_string(arg4); + if (!p || !p2) + ret =3D -TARGET_EFAULT; + else + ret =3D get_errno(syscall(__NR_renameat2, arg1, p, arg3, p= 2, arg5)); + unlock_user(p2, arg4, 0); + unlock_user(p, arg2, 0); + } + break; +#endif #ifdef TARGET_NR_mkdir case TARGET_NR_mkdir: if (!(p =3D lock_user_string(arg1))) --=20 2.13.6