From nobody Sat Nov 15 20:33:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1595939743; cv=none; d=zohomail.com; s=zohoarc; b=DNJi9t8ID4t+KuVCfnXOHwHpAHe72BJWhoAgRlBQa4F7cQQNoHopB4LScelc/tK+dlS1qDHZxd6eo2BPpwtNfBppS/2zBGS34YsHsx7WIBTwZBHY0ClGcJ5GnmyZFrMdo0PStL6QZnc7ShKe0p/l+NT8HdExamh/mTuSrYbDM5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595939743; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h/h3EITiT1mBPFja0A0iPJSWZxt86i/BLs0Re2N2jrc=; b=Buhz2/Mr2qGxWpNu0btFF/mkglN0aP09DyGyqpEzhCjjvjC4zNsFuUyBPpCGVmIoy3QGOKswd6oFXxe8Y83ANnthgdQ6O973oUelIiYegS2sZe6wLMkvW9hkXz0a9sndcVPnGUVASKXpILuOKCUXV1rH3IcSEfl+eDdKdiIcjv0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1595939743177810.2212823076369; Tue, 28 Jul 2020 05:35:43 -0700 (PDT) Received: from localhost ([::1]:47830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k0OpZ-00062m-Rv for importer@patchew.org; Tue, 28 Jul 2020 08:35:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0Ooc-0004gn-Sp for qemu-devel@nongnu.org; Tue, 28 Jul 2020 08:34:42 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:54541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0Ooa-0001sm-7H for qemu-devel@nongnu.org; Tue, 28 Jul 2020 08:34:42 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M8QFi-1k4mWj1x8y-004UeB; Tue, 28 Jul 2020 14:34:37 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 3/3] linux-user: Use getcwd syscall directly Date: Tue, 28 Jul 2020 14:34:32 +0200 Message-Id: <20200728123432.501354-4-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200728123432.501354-1-laurent@vivier.eu> References: <20200728123432.501354-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:/m6m+2UHQjNwnywy/aks4shhDodjDeEv9vteG/MbstapZS/HIu7 blVEWtpyRiB1kdUsP26SAM+6V1YTZfnSdIKtwSiAPNx9+SyVn76cqwfnvQsTh6JC2jBDuvY jkJxzxBwUAFKU1ZvwSKfiH0YjW0GeemzSoufCN4Cx+6EgU8wMeHn4mXJ0b+Jir7Cm68/vCG FWh0gOXHVO7FbN6o47vNA== X-UI-Out-Filterresults: notjunk:1;V03:K0:wUMztYL5bCM=:3VjB2dsjuQubdg87GLs29Y xpfXruzuEiwxie7RF9pCRp+6Et4un740ca6dT2jDkg1uc31b15rBtTidzdW0a/UZcS1KVAd9H b4U/JEdWqBmR8gTbXonijEdErXYn8vWE1Xo63Kuqe5U2XwuFt43QJlsKZ5XdHzvSc8y5E8+Y5 9flaeksbgrKDqOdEd3tTRAof2eMMrVk1tjB6osgyDZo77WKhnjD9u0eiAowE5yicTbbrmIY8f qfVSrWEdZ9YRLCU7hRXUmtaX3V3O/erN2eNN3Tfp8DhMY0swmMBnS1JUDaHMXjqiSbkccrZDC kx5skjOzPqVBeBZNAmDodO1EPEJPiWprdNbeUe8wr2ut8pOnoi8tDmjnMe+CC9tOB2V13ghJv uJcnN4+INKZ3935h3Nlr5OHhn0j/s07sxE4yEnix9MtSu7JTUcEfDtST9UpKDEFYWFJ18H1dD 6u4CuPxrEnOFfmwbRpw4jBt5ummsqAqbmrNP3VgM9WDjErFlE/tZIR2TkF2IYojvu1YVmulLL 5AlY++QDxB8gvgo0vhuFcSj9u04F6tzOd6kdQGOTfF3IP7kuGQFbMtdym/jP83c5f+zCk29uS lpSbmFx9xTah91RIM9bgm8VXovSBKgz903KrDwbS+mObHTTZbp6Y/IDUtVH/LdPuDu+6h29yE ulJepmCZ8pX+T/hp4Pp7wkHP6HvvSx6nRd36y4nyyDqNcYcvFABMpqV0ipiXk8uwiRKSCrb7x zSqHyvpQ6CpIDEGq1QHmptPEabBgzMLWjU86d8zc/M7q5XhuyPwZx4sG9eyipVwqIt/7Z7661 189qycuYmsQeaL2cn9xDq4ej6V75WotUSZGNEEZw4B0y5yaaS9X/QUvBvA2AHEtZdOLBQVm Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/28 08:34:38 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andreas Schwab , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Andreas Schwab The glibc getcwd function returns different errors than the getcwd syscall, which triggers an assertion failure in the glibc getcwd function when running under the emulation. When the syscall returns ENAMETOOLONG, the glibc wrapper uses a fallback implementation that potentially handles an unlimited path length, and returns with ERANGE if the provided buffer is too small. The qemu emulation cannot distinguish the two cases, and thus always returns ERANGE. This is unexpected by the glibc wrapper. Signed-off-by: Andreas Schwab Reviewed-by: Laurent Vivier Message-Id: [lv: updated description] Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c1ebf7b8f384..945fc252791c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -388,14 +388,7 @@ static bitmask_transtbl fcntl_flags_tbl[] =3D { { 0, 0, 0, 0 } }; =20 -static int sys_getcwd1(char *buf, size_t size) -{ - if (getcwd(buf, size) =3D=3D NULL) { - /* getcwd() sets errno */ - return (-1); - } - return strlen(buf)+1; -} +_syscall2(int, sys_getcwd1, char *, buf, size_t, size) =20 #ifdef TARGET_NR_utimensat #if defined(__NR_utimensat) --=20 2.26.2