From nobody Sat May 11 15:32:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651411169; cv=none; d=zohomail.com; s=zohoarc; b=XdgotM0MXa8VSNSBdrxNEMEwxwU4TFmYp6vIdJnbYZUuQuZiu2+TTYU6X42cRh+F4JxB6QTjXc15PpuZ0YOHM5zXTUa/tC1l1/hECDqcxr4zVuwHq1Cu+XJDK6xirtdLqzCDFLRNII9BeP3m6+VSQINvoO46wtvDzlHAoo4jybQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651411169; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=hytBxthYet9DFawcgXKMYZNCCM1++ItNvinKuyVuDJ0=; b=M1JgRw3o7+FtegnExN+QnGRJgDoHzIa2WcPqib5+BQLOQ/kUVPNm9J5CE1QzKcS7VALN89yWnuqanoOA4MsGubX0s77HR8Lb241RQBC1iQk9xn/Vhbt/59eQjBFiSo9Cqb5lUKDScKNbuPZjpiKQb4yHQS2x++NYv+n8Fh3zmCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651411168847230.83885538340178; Sun, 1 May 2022 06:19:28 -0700 (PDT) Received: from localhost ([::1]:47430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl9Tz-0003I9-8h for importer@patchew.org; Sun, 01 May 2022 09:19:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <0009df31cb51cb2be681f4eebd58a9776d75a580@lizzy.crudebyte.com>) id 1nl9SH-00010w-S6 for qemu-devel@nongnu.org; Sun, 01 May 2022 09:17:42 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:33441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <0009df31cb51cb2be681f4eebd58a9776d75a580@lizzy.crudebyte.com>) id 1nl9SA-0005Gp-3i for qemu-devel@nongnu.org; Sun, 01 May 2022 09:17:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=hytBxthYet9DFawcgXKMYZNCCM1++ItNvinKuyVuDJ0=; b=KaoDY sWnTwx0JATiXmUpmP/zRmYkuuMuJudZfVcGqI35zcznYUjpb0MODaZ8mhQWaPG0yK3Xf96yNc8BxB zav/m1WRY/jRnwUcrnDWXoWq5Zmp6QGt0H0+kSCBCX7/C8fv2JdipYu0nxFTA+9jlSBh7t6Pgc/Ri sZGREum4CdBctG+UMahYTSsg5CZ3nVFczjYS6KMrcTM1vCvcD8KFTsxxej0SnlUZaAUWHVLjasHR3 BzpulJf0UFZ5nQE7PleraaSyzNrjKSb2wgkUYc/ChxCXYLCYR4D23kx71K2dsNiEIQH+g2615yXyf nImhVHcKDjpiivmusAHFt8IWNr9Hw==; Message-Id: <0009df31cb51cb2be681f4eebd58a9776d75a580.1651410615.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 01 May 2022 15:10:16 +0200 Subject: [PULL v2 1/7] 9pfs: fix inode sequencing in 'synth' driver To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Cc: Greg Kurz , Akihiko Odaki , Will Cohen 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=91.194.90.13; envelope-from=0009df31cb51cb2be681f4eebd58a9776d75a580@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651411171705100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The 'synth' driver's root node and the 'synth' driver's first subdirectory node falsely share the same inode number (zero), which makes it impossible for 9p clients (i.e. 9p test cases) to distinguish root node and first subdirectory from each other by comparing their QIDs (which are derived by 9p server from driver's inode numbers). Fix this issue by using prefix-increment instead of postfix-increment operator while generating new inode numbers for subdirectories and files. Link: https://lore.kernel.org/qemu-devel/3859307.hTDP4D0zbi@silver/ Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: --- hw/9pfs/9p-synth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index d99d263985..1c5813e4dd 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -92,7 +92,7 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode, } } /* Add the name */ - node =3D v9fs_add_dir_node(parent, mode, name, NULL, synth_node_count+= +); + node =3D v9fs_add_dir_node(parent, mode, name, NULL, ++synth_node_coun= t); v9fs_add_dir_node(node, parent->attr->mode, "..", parent->attr, parent->attr->inode); v9fs_add_dir_node(node, node->attr->mode, ".", @@ -130,7 +130,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int= mode, mode =3D ((mode & 0777) | S_IFREG); node =3D g_new0(V9fsSynthNode, 1); node->attr =3D &node->actual_attr; - node->attr->inode =3D synth_node_count++; + node->attr->inode =3D ++synth_node_count; node->attr->nlink =3D 1; node->attr->read =3D read; node->attr->write =3D write; --=20 2.30.2 From nobody Sat May 11 15:32:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651411195; cv=none; d=zohomail.com; s=zohoarc; b=Ciwj6lsZewSkvDiZ6ph26aM4kNn+HHtVZcQy72S7l8msPD1KEZAJsG5bG1hVyVZeXHRULht2c2y5hJOaDiFcOcqInjphGdc6H3fkjGOxJvFdrdrP2NXl8ewLIXwS7PooQbCdGII08WmgFyDvjqaWmLMNrlZAXihaZfThbR9dNDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651411195; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=C5l63rnifQ9IJrl0xxrAJKuGJe/pQG2u2yCendSHmc8=; b=IcDRWwzk0xq52+uUdjLU8FQhj/aY8DCdZUONmeFebqm77yQLBRhBL678I/Gf3cFmhI8acQm29SzuK/63ZjrtINY+HAH2O+SpVUg+NMkpQzEsAqrOeGmTmLaXAFt4XHEZHYus4om2VuIHTOUrHsDHjeYJyV6DHD3chs0BgmBVmHo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651411195104840.817697168525; Sun, 1 May 2022 06:19:55 -0700 (PDT) Received: from localhost ([::1]:48568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl9UO-00043r-Vq for importer@patchew.org; Sun, 01 May 2022 09:19:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <096af171274cc76c51bf11366ae257391ddfed2a@lizzy.crudebyte.com>) id 1nl9SH-00010y-SF for qemu-devel@nongnu.org; Sun, 01 May 2022 09:17:42 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:33343) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <096af171274cc76c51bf11366ae257391ddfed2a@lizzy.crudebyte.com>) id 1nl9SF-0005H9-Gt for qemu-devel@nongnu.org; Sun, 01 May 2022 09:17:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=C5l63rnifQ9IJrl0xxrAJKuGJe/pQG2u2yCendSHmc8=; b=eNHPd eJQf8RcaHc7jW3zlGvklXx22ezLtKTIEhz1qgfmkxy53J0wx1PSH9DdVzkMh2YrqAKso6yKNEQMST LXcHPcqDyXOKR6eGy+5b805BnRXJKoHIbQzKjRqOGmEjxhaCh5x/T901r7pz+0bSflKKMxgfu+7hd VwofMIYzaQvF7tV3B+uXxmivVdD2dqLg3ooQ1EZ2KGswUmnf8snTCi6jdkcYABvJY0nbrtbgxMRuR vbJCpVZnSTeEdlzxKXrg7CJl99ntJqsTtY3Sy8CcpejsY93gf28TBXgJYeiyICxPZN5Egq9Ey0BHM EKBZLkzFkGlAB6Cui6qoEmfclOsig==; Message-Id: <096af171274cc76c51bf11366ae257391ddfed2a.1651410615.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 01 May 2022 15:10:16 +0200 Subject: [PULL v2 2/7] 9pfs: fix qemu_mknodat(S_IFREG) on macOS To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Cc: Greg Kurz , Akihiko Odaki , Will Cohen 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=91.194.90.13; envelope-from=096af171274cc76c51bf11366ae257391ddfed2a@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651411197211100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" mknod() on macOS does not support creating regular files, so divert to openat_file() if S_IFREG is passed with mode argument. Furthermore, 'man 2 mknodat' on Linux says: "Zero file type is equivalent to type S_IFREG". Link: https://lore.kernel.org/qemu-devel/17933734.zYzKuhC07K@silver/ Signed-off-by: Christian Schoenebeck Reviewed-by: Will Cohen Reviewed-by: Greg Kurz Reviewed-by: Akihiko Odaki Message-Id: <3102ca936f88bc1f79d2a325e5bc68f48f54e6e3.1651228000.git.qemu_o= ss@crudebyte.com> --- hw/9pfs/9p-util-darwin.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index bec0253474..e24d09763a 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -77,6 +77,15 @@ int fsetxattrat_nofollow(int dirfd, const char *filename= , const char *name, int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) { int preserved_errno, err; + + if (S_ISREG(mode) || !(mode & S_IFMT)) { + int fd =3D openat_file(dirfd, filename, O_CREAT, mode); + if (fd =3D=3D -1) { + return fd; + } + close(fd); + return 0; + } if (!pthread_fchdir_np) { error_report_once("pthread_fchdir_np() not available on this versi= on of macOS"); return -ENOTSUP; --=20 2.30.2 From nobody Sat May 11 15:32:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651411182; cv=none; d=zohomail.com; s=zohoarc; b=Xy/YBBSbHCOMjNWIunbEvBZOs7AmVxnZad+3Nij8jS1fV3u23gy+HEq+Jp2x+ORpqzDYW+HBXyjs1L8kiROdkhhp7ulet/dpg+nwfZVZVgePHQAaWl2arttt7oOZM9/dvdQ4gw0XtvRbM+TEL3arj4ONaOafOJS+WzOT6M0MZEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651411182; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ZcMsvSugTf271vnxH3C0WYRJBWSsglfIsUHDSa91fd8=; b=OCQ4MVAO6Kq8pZ1pMoJeyYW9ld5YKX6XU2wjcIpMiK5rQIYHdWUS6NEQVrY7WfEWall5gMTJTsHztnDRwUZjHLSM/X6TxydmPed3spTF0Cntp1h2aSpZmRtP23hfhsND/4ZxqgBnSzbW1zFi07SKAkwfzmXg9QtYLzMUM02+TIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651411182816917.3683881969729; Sun, 1 May 2022 06:19:42 -0700 (PDT) Received: from localhost ([::1]:48090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl9UD-0003jS-LL for importer@patchew.org; Sun, 01 May 2022 09:19:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <055ab89327bab83f1bd07e9de07f7628643d3d8d@lizzy.crudebyte.com>) id 1nl9SO-00015f-0S for qemu-devel@nongnu.org; Sun, 01 May 2022 09:17:48 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:50205) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <055ab89327bab83f1bd07e9de07f7628643d3d8d@lizzy.crudebyte.com>) id 1nl9SK-0005HD-Kg for qemu-devel@nongnu.org; Sun, 01 May 2022 09:17:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=ZcMsvSugTf271vnxH3C0WYRJBWSsglfIsUHDSa91fd8=; b=niDpF kxO8v42+cSpk5poZU8HdCkt8GHmOGq7UpiIy+J2OIaZtFd6jlVaXzo95Q5/Td5kYWl0l66IGovGb7 +abvmxA8tcgnjOQmpbOIWSJsAxoOpcjlY0ucrxkxxmuihMCYZ33qokTBWbPKUOcIlb8Fbp15PbDK8 Ug2uFC58VjLumKbXaMb1fT9IidmvtaZw3t2sh1oYsKgWvhu+E40E8b6jHlWdVkR1Gaq67LoSbVMXR 2Kn2a2d8f06fjrAo4JDdCo47DEEvfrRq87+KBweysPgv7Cp17xKCAZisSO5WuzpbL4gyaxRronEzr cqEC+IkC+b4ufO3fMHOxCBwAklPAw==; Message-Id: <055ab89327bab83f1bd07e9de07f7628643d3d8d.1651410615.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 01 May 2022 15:10:16 +0200 Subject: [PULL v2 3/7] 9pfs: fix qemu_mknodat(S_IFSOCK) on macOS To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Cc: Greg Kurz , Akihiko Odaki , Will Cohen 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=91.194.90.13; envelope-from=055ab89327bab83f1bd07e9de07f7628643d3d8d@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651411183519100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" mknod() on macOS does not support creating sockets, so divert to call sequence socket(), bind() and fchmodat() respectively if S_IFSOCK was passed with mode argument. Link: https://lore.kernel.org/qemu-devel/17933734.zYzKuhC07K@silver/ Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Reviewed-by: Akihiko Odaki Message-Id: <2e7b5ecd7a6d83a538db4e8a22d8fb03e9e0f06e.1651228001.git.qemu_o= ss@crudebyte.com> [C.S. - Use AT_SYMLINK_NOFOLLOW instead of AT_SYMLINK_NOFOLLOW_ANY. ] Link: https://lore.kernel.org/qemu-devel/3704033.BMyLRrx2Jx@silver/ --- hw/9pfs/9p-util-darwin.c | 42 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index e24d09763a..bd2dd81548 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -74,6 +74,42 @@ int fsetxattrat_nofollow(int dirfd, const char *filename= , const char *name, */ #if defined CONFIG_PTHREAD_FCHDIR_NP =20 +static int create_socket_file_at_cwd(const char *filename, mode_t mode) { + int fd, err; + struct sockaddr_un addr =3D { + .sun_family =3D AF_UNIX + }; + + err =3D snprintf(addr.sun_path, sizeof(addr.sun_path), "./%s", filenam= e); + if (err < 0 || err >=3D sizeof(addr.sun_path)) { + errno =3D ENAMETOOLONG; + return -1; + } + fd =3D socket(PF_UNIX, SOCK_DGRAM, 0); + if (fd =3D=3D -1) { + return fd; + } + err =3D bind(fd, (struct sockaddr *) &addr, sizeof(addr)); + if (err =3D=3D -1) { + goto out; + } + /* + * FIXME: Should rather be using descriptor-based fchmod() on the + * socket file descriptor above (preferably before bind() call), + * instead of path-based fchmodat(), to prevent concurrent transient + * state issues between creating the named FIFO file at bind() and + * delayed adjustment of permissions at fchmodat(). However currently + * macOS (12.x) does not support such operations on socket file + * descriptors yet. + * + * Filed report with Apple: FB9997731 + */ + err =3D fchmodat(AT_FDCWD, filename, mode, AT_SYMLINK_NOFOLLOW); +out: + close_preserve_errno(fd); + return err; +} + int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) { int preserved_errno, err; @@ -93,7 +129,11 @@ int qemu_mknodat(int dirfd, const char *filename, mode_= t mode, dev_t dev) if (pthread_fchdir_np(dirfd) < 0) { return -1; } - err =3D mknod(filename, mode, dev); + if (S_ISSOCK(mode)) { + err =3D create_socket_file_at_cwd(filename, mode); + } else { + err =3D mknod(filename, mode, dev); + } preserved_errno =3D errno; /* Stop using the thread-local cwd */ pthread_fchdir_np(-1); --=20 2.30.2 From nobody Sat May 11 15:32:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651411411; cv=none; d=zohomail.com; s=zohoarc; b=ivZo9GBeLOXOLxqB7mor0ZbJmkrd1O2X7da16jXl24LxO/5IAP3Umr7Y+RA1+8pW6EL72exXixse7mqo0jieSv4+jjzdI57EubjPRR7doiID2jALXg4HFNp6GFWTPDUQqMQ+roeAS+bc4YW1nWoRkIeGVmXxE3cdlbh62Pdi2ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651411411; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=CjJA8/0P+2ostIOlk621je1IpvbiNDPC5b5zlHj9Qg4=; b=dIr03vt7eYMxPvuJ6kSmy+h6sxJiuVy81PoYX1CR0VQW602QT6T0bdI2YpxkbaEsFe4Oaf6nr9MrM8UuXGAcAez5ecXWDPf0dnueKZ8K+vdWnRU0NawreddpjNnhb+vH2MXdEKwIddGX/igZBof0wmNdkV/Fh/HGW7RdqMBTlsc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651411411532927.9815207932153; Sun, 1 May 2022 06:23:31 -0700 (PDT) Received: from localhost ([::1]:55094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl9Xu-0000Ec-Ff for importer@patchew.org; Sun, 01 May 2022 09:23:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nl9ST-0001AK-GK for qemu-devel@nongnu.org; Sun, 01 May 2022 09:17:56 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:44299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nl9SR-0005HK-QO for qemu-devel@nongnu.org; Sun, 01 May 2022 09:17:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=CjJA8/0P+2ostIOlk621je1IpvbiNDPC5b5zlHj9Qg4=; b=Uxnb/ fIJQ88VPupazljaEmGzEOxmHSoCdBk8+FDhGoE1Y4kOyzkSOOHGTVcSWmyG4OV8FXyuFn1xTprXxJ 9RT8QuFbfpDibpCNR/1IQe50mvLdSX+M4zZV9w2bNY6tXqnb3Q67EC5TUpu0Sc+MjfbHaOw7EjmQ0 hAe5/su9E7jxWB7ECjS3QdCs7jGJTglc6b95U4XvPprLAryHWUrHuwoxuxmDr11hBP3d4BvwCYqmG XMwOFOUdaTIy6Omf9q5fSwciujpzCvcZR2F+nK6GZRraIsPL7slPn9JF2Hkfu5BrVU04vUO8KigjQ i43DeqpjOH1O0eYVG3nWSkyIdZmUA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 01 May 2022 15:10:16 +0200 Subject: [PULL v2 4/7] 9pfs: fix wrong encoding of rdev field in Rgetattr on macOS To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Cc: Greg Kurz , Akihiko Odaki , Will Cohen 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=91.194.90.13; envelope-from=e5c88e2264ebd0bfe35b347b8cdca1e3af784d84@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651411412313100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The 'rdev' field in 9p reponse 'Rgetattr' is of type dev_t, which is actually a system dependant type and therefore both the size and encoding of dev_t differ between macOS and Linux. So far we have sent 'rdev' to guest in host's dev_t format as-is, which caused devices to appear with wrong device numbers on guests running on macOS hosts, eventually leading to various misbehaviours on guest in conjunction with device files. This patch fixes this issue by converting the device number from host's dev_t format to Linux dev_t format. As 9p request 'Tgettattr' is exclusive to protocol version 9p2000.L, it should be fair to assume that 'rdev' field is assumed to be in Linux dev_t format by client as well. Signed-off-by: Christian Schoenebeck Link: https://lore.kernel.org/qemu-devel/20220421093056.5ab1e7ed@bahia/ Reviewed-by: Greg Kurz Reviewed-by: Akihiko Odaki Message-Id: --- hw/9pfs/9p-util.h | 39 +++++++++++++++++++++++++++++++++++++++ hw/9pfs/9p.c | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 97e681e167..2cc9a5dbfb 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,6 +19,45 @@ #define O_PATH_9P_UTIL 0 #endif =20 +#if !defined(CONFIG_LINUX) + +/* + * Generates a Linux device number (a.k.a. dev_t) for given device major + * and minor numbers. + * + * To be more precise: it generates a device number in glibc's format + * (MMMM_Mmmm_mmmM_MMmm, 64 bits) actually, which is compatible with + * Linux's format (mmmM_MMmm, 32 bits), as described in . + */ +static inline uint64_t makedev_dotl(uint32_t dev_major, uint32_t dev_minor) +{ + uint64_t dev; + + // from glibc sysmacros.h: + dev =3D (((uint64_t) (dev_major & 0x00000fffu)) << 8); + dev |=3D (((uint64_t) (dev_major & 0xfffff000u)) << 32); + dev |=3D (((uint64_t) (dev_minor & 0x000000ffu)) << 0); + dev |=3D (((uint64_t) (dev_minor & 0xffffff00u)) << 12); + return dev; +} + +#endif + +/* + * Converts given device number from host's device number format to Linux + * device number format. As both the size of type dev_t and encoding of + * dev_t is system dependant, we have to convert them for Linux guests if + * host is not running Linux. + */ +static inline uint64_t host_dev_to_dotl_dev(dev_t dev) +{ +#ifdef CONFIG_LINUX + return dev; +#else + return makedev_dotl(major(dev), minor(dev)); +#endif +} + #ifdef CONFIG_DARWIN #define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) #define qemu_lgetxattr(...) getxattr(__VA_ARGS__, 0, XATTR_NOFOLLOW) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 225f31fc31..4a296a0b94 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1327,7 +1327,7 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const st= ruct stat *stbuf, v9lstat->st_nlink =3D stbuf->st_nlink; v9lstat->st_uid =3D stbuf->st_uid; v9lstat->st_gid =3D stbuf->st_gid; - v9lstat->st_rdev =3D stbuf->st_rdev; + v9lstat->st_rdev =3D host_dev_to_dotl_dev(stbuf->st_rdev); v9lstat->st_size =3D stbuf->st_size; v9lstat->st_blksize =3D stat_to_iounit(pdu, stbuf); v9lstat->st_blocks =3D stbuf->st_blocks; --=20 2.30.2 From nobody Sat May 11 15:32:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651411492; cv=none; d=zohomail.com; s=zohoarc; b=QQUHVAkwEtMF63bw0ekBwv4sge5cb4yrLqlRCUhMep9kItEXY5hvp/pmbYgYe7PhD14Obywnx/S95r4X9eAW1EKmvmBQ9UVN8C93CVsB8CNAudcuYgPfmFfrXw67yA7KgHETIYVnt1Jo0bwZi24Jzni2qoAOeGnHHadkpunkHcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651411492; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=UHp1FZ3jSPBJ1DJ+nvKwoCAHVka/edXXXWSQF8lJAW0=; b=ePZtp3kseg3PB9X4IV7DfnwQucqZTV5adGcMYN7gklhBcGtNiaTz0oAcLURl3MQOAqqFYw6kTIFtASWcKPAwRbEoK/uK6AG4bYmoQoT4m32nXyyGKEbMX/WGM7kHqmVZGWHwdjg1H75LqkNli2F8cY/zCakNuuHJekG8uMz+Ubs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651411492196683.2135762490168; Sun, 1 May 2022 06:24:52 -0700 (PDT) Received: from localhost ([::1]:32958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl9ZC-0004NX-MP for importer@patchew.org; Sun, 01 May 2022 09:24:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <951fe2f89f46f5d51eead066556edc7369e23915@lizzy.crudebyte.com>) id 1nl9Sb-0001Do-J9 for qemu-devel@nongnu.org; Sun, 01 May 2022 09:18:01 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:49419) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <951fe2f89f46f5d51eead066556edc7369e23915@lizzy.crudebyte.com>) id 1nl9SY-0005HV-Az for qemu-devel@nongnu.org; Sun, 01 May 2022 09:17:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=UHp1FZ3jSPBJ1DJ+nvKwoCAHVka/edXXXWSQF8lJAW0=; b=ODFdM pcmeoyyyf87c7yU2Qcc5czpA/Vwl0hG6MhBM7wt1J3NQcvxjzLmV3u/MXjMjcc9VXRsj4S7hADjmV 4INzloTdfLwB7s4oBGTH7b5KRU+YmNJTe0t9qMCh90BT/vcAbU/d4pco3KNFL1KG8JCi7O82594zb 71tN0KytoyU/6WsWsaawL8OEwmaT/r1apPVCsz5SQCXLIdLCWWNF4pCH1dMhMHtUSayXEg6/G3kRv MetYrVpdzFR9uS1Q4OWpvyMdGWTtljutxGobzCtTedpzTm6CL1s2etuio3RhV4m+g6G5GxAAKWPnn dC/4FmzzEzCNvI8zxJvxymggMsfbQ==; Message-Id: <951fe2f89f46f5d51eead066556edc7369e23915.1651410615.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 01 May 2022 15:10:16 +0200 Subject: [PULL v2 5/7] 9pfs: fix wrong errno being sent to Linux client on macOS host To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Cc: Greg Kurz , Akihiko Odaki , Will Cohen 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=91.194.90.13; envelope-from=951fe2f89f46f5d51eead066556edc7369e23915@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651411492730100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Linux and macOS only share some errno definitions with equal macro name and value. In fact most mappings for errno are completely different on the two systems. This patch converts some important errno values from macOS host to corresponding Linux errno values before eventually sending such error codes along with 'Rlerror' replies (if 9p2000.L is used that is). Not having translated errnos before violated the 9p2000.L protocol spec, which says: " size[4] Rlerror tag[2] ecode[4] ... ecode is a numerical Linux errno. " https://github.com/chaos/diod/wiki/protocol#lerror----return-error-code This patch fixes a bunch of misbehaviours when running a Linux client on macOS host. For instance this patch fixes: mount -t 9p -o posixacl ... on Linux guest if security_mode=3Dmapped was used for 9p server, which refused to mount successfully, because macOS returned ENOATTR=3D=3D93 when client tried to retrieve POSIX ACL xattrs, because errno 93 is defined as EPROTONOSUPPORT=3D=3D93 on Linux, so Linux client believed that xattrs were not supported by filesystem on host in general. Signed-off-by: Christian Schoenebeck Link: https://lore.kernel.org/qemu-devel/20220421124835.3e664669@bahia/ Reviewed-by: Greg Kurz Reviewed-by: Akihiko Odaki Message-Id: --- hw/9pfs/9p-util.h | 30 ++++++++++++++++++++++++++++++ hw/9pfs/9p.c | 2 ++ 2 files changed, 32 insertions(+) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 2cc9a5dbfb..c3526144c9 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -58,6 +58,36 @@ static inline uint64_t host_dev_to_dotl_dev(dev_t dev) #endif } =20 +/* Translates errno from host -> Linux if needed */ +static inline int errno_to_dotl(int err) { +#if defined(CONFIG_LINUX) + /* nothing to translate (Linux -> Linux) */ +#elif defined(CONFIG_DARWIN) + /* + * translation mandatory for macOS hosts + * + * FIXME: Only most important errnos translated here yet, this should = be + * extended to as many errnos being translated as possible in future. + */ + if (err =3D=3D ENAMETOOLONG) { + err =3D 36; /* =3D=3DENAMETOOLONG on Linux */ + } else if (err =3D=3D ENOTEMPTY) { + err =3D 39; /* =3D=3DENOTEMPTY on Linux */ + } else if (err =3D=3D ELOOP) { + err =3D 40; /* =3D=3DELOOP on Linux */ + } else if (err =3D=3D ENOATTR) { + err =3D 61; /* =3D=3DENODATA on Linux */ + } else if (err =3D=3D ENOTSUP) { + err =3D 95; /* =3D=3DEOPNOTSUPP on Linux */ + } else if (err =3D=3D EOPNOTSUPP) { + err =3D 95; /* =3D=3DEOPNOTSUPP on Linux */ + } +#else +#error Missing errno translation to Linux for this host system +#endif + return err; +} + #ifdef CONFIG_DARWIN #define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) #define qemu_lgetxattr(...) getxattr(__VA_ARGS__, 0, XATTR_NOFOLLOW) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 4a296a0b94..0cd0c14c2a 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1054,6 +1054,8 @@ static void coroutine_fn pdu_complete(V9fsPDU *pdu, s= size_t len) } len +=3D ret; id =3D P9_RERROR; + } else { + err =3D errno_to_dotl(err); } =20 ret =3D pdu_marshal(pdu, len, "d", err); --=20 2.30.2 From nobody Sat May 11 15:32:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651411418; cv=none; d=zohomail.com; s=zohoarc; b=SFIDJvy82VVPtMBSGubW40GCJn36YBgfB1dSDUyorrReorJuBPSQHJNo57aqKtkh3AGEFCn4qEztcYks31AZCIa2QaJHqansQnmi1/3ng9K2ePwp1cMgj9AmemmXJSG4CPEsFVGKpnYJXBQ6IWQfcF2Kq/JMyjaB4kInR/LWTv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651411418; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=JGBaf1+WaNX2Qb3Axq1QwKtUaKy2Gz5UqWp+NQDJ6JU=; b=f5L7/HO4NeucNHlDkkxpqkT7hjgC81hVF1Ub0RHQYBQyO+Yyi8S1BatFA8Bgi92WGXWucnV7ZInHx1Q6l+u+2OtNOLwNBRHtzQK8SNmhu22btNtRiGL+gZOjyMTokCFhk84j1nKxt7CI0xzFz1GMCt8jMYu0gEICRdLflNgetiA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651411418024520.0387830476736; Sun, 1 May 2022 06:23:38 -0700 (PDT) Received: from localhost ([::1]:55586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl9Y0-0000ak-Pa for importer@patchew.org; Sun, 01 May 2022 09:23:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9ea3164611a63e898a979f2da24caa1abd29d906@lizzy.crudebyte.com>) id 1nl9Si-0001Hm-Me for qemu-devel@nongnu.org; Sun, 01 May 2022 09:18:16 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:37401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9ea3164611a63e898a979f2da24caa1abd29d906@lizzy.crudebyte.com>) id 1nl9Sg-0005II-0d for qemu-devel@nongnu.org; Sun, 01 May 2022 09:18:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=JGBaf1+WaNX2Qb3Axq1QwKtUaKy2Gz5UqWp+NQDJ6JU=; b=JYN38 GFeBZ4x9iNZVIOaloysalteKiSmz2tF7xwDiFgKgsGwYm/iYKz/MRpnjKVqk88h3J2upv4G3vZ6jb 8vzQZTbgb7/defzvcJ9BZaulCb6RfEgoWKp64CktZKY/e8iKNBfhlaoRbkTwhN6xrpfaaNkm0J1l4 nyPVKKhZlIVC8g4kdnp+PeHofv3ryDW7KEAGUTVbyyITg7tglT/z6ZV4ErRkN5HK1NRLJ2cX+1ajn ZxjtcTpS9Hh4jFMfF8Aqi4Pxf50OgyZ6yo2aTXZqzohSxYu5/evof8m5ZZAnQxi2iTMkHmSAv24hu +hACdK322wibzJYY/BXgBVabRQ2gQ==; Message-Id: <9ea3164611a63e898a979f2da24caa1abd29d906.1651410615.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 01 May 2022 15:10:16 +0200 Subject: [PULL v2 6/7] 9pfs: fix removing non-existent POSIX ACL xattr on macOS host To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Cc: Greg Kurz , Akihiko Odaki , Will Cohen 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=91.194.90.13; envelope-from=9ea3164611a63e898a979f2da24caa1abd29d906@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651411420154100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When mapped POSIX ACL is used, we are ignoring errors when trying to remove a POSIX ACL xattr that does not exist. On Linux hosts we would get ENODATA in such cases, on macOS hosts however we get ENOATTR instead. As we can be sure that ENOATTR is defined as being identical on Linux hosts (at least by qemu/xattr.h), it is safe to fix this issue by simply comparing against ENOATTR instead of ENODATA. This patch fixes e.g. a command on Linux guest like: cp --preserve=3Dmode old new Signed-off-by: Christian Schoenebeck Link: https://lore.kernel.org/qemu-devel/2866993.yOYK24bMf6@silver/ Reviewed-by: Greg Kurz Reviewed-by: Akihiko Odaki Message-Id: <34f81e9bffd7a3e65fb7aab5b56c107bd0aac960.1651228001.git.qemu_o= ss@crudebyte.com> --- hw/9pfs/9p-posix-acl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-posix-acl.c b/hw/9pfs/9p-posix-acl.c index eadae270dd..4b2cb3c66c 100644 --- a/hw/9pfs/9p-posix-acl.c +++ b/hw/9pfs/9p-posix-acl.c @@ -65,7 +65,11 @@ static int mp_pacl_removexattr(FsContext *ctx, int ret; =20 ret =3D local_removexattr_nofollow(ctx, path, MAP_ACL_ACCESS); - if (ret =3D=3D -1 && errno =3D=3D ENODATA) { + /* + * macOS returns ENOATTR (!=3DENODATA on macOS), whereas Linux returns + * ENODATA (=3D=3DENOATTR on Linux), so checking for ENOATTR is fine + */ + if (ret =3D=3D -1 && errno =3D=3D ENOATTR) { /* * We don't get ENODATA error when trying to remove a * posix acl that is not present. So don't throw the error @@ -115,7 +119,11 @@ static int mp_dacl_removexattr(FsContext *ctx, int ret; =20 ret =3D local_removexattr_nofollow(ctx, path, MAP_ACL_DEFAULT); - if (ret =3D=3D -1 && errno =3D=3D ENODATA) { + /* + * macOS returns ENOATTR (!=3DENODATA on macOS), whereas Linux returns + * ENODATA (=3D=3DENOATTR on Linux), so checking for ENOATTR is fine + */ + if (ret =3D=3D -1 && errno =3D=3D ENOATTR) { /* * We don't get ENODATA error when trying to remove a * posix acl that is not present. So don't throw the error --=20 2.30.2 From nobody Sat May 11 15:32:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651411504; cv=none; d=zohomail.com; s=zohoarc; b=JN/Q5WjLZpDWQ8LMg12JEZvP/kKTyjHNt5GC5Or+hNLnWqoz4d2sUdVRSXuhpBmQSw/u1n9VN3Hu9xbH1dLCXlpfCQf0gyg2/7ZoFs0SjH/uyp0XKRf6AV53mrDElFqpvoQc1iDm4mYaGFR+rjt0G4HVBh4XmonTPTPqURL0cLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651411504; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=+inl/5cpOXs40ozy4YakG2iXX+wQU4SPqqeXKR162vs=; b=l1eHyR9knCZE48olso2Ps3Z8lW4XYGDaxJCcv/rAMconNw967zAFc0lVOvO9lhKyXyedVzPNcyqcn/HSTXq7s09dDzA3eBQtqVguH8CjMyso83aMW48BIxeTG6qHN1rBkOsd5JiJBm+emkBdHa0/09OyW1jU4XND48tHeV5mAfc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165141150454191.31532394306112; Sun, 1 May 2022 06:25:04 -0700 (PDT) Received: from localhost ([::1]:33692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl9ZP-0004rB-4q for importer@patchew.org; Sun, 01 May 2022 09:25:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <063c75db2e03938b2fadb052c4661adae36e352c@lizzy.crudebyte.com>) id 1nl9TF-00029q-8m for qemu-devel@nongnu.org; Sun, 01 May 2022 09:18:41 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:59437) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <063c75db2e03938b2fadb052c4661adae36e352c@lizzy.crudebyte.com>) id 1nl9TD-0005Na-Qi for qemu-devel@nongnu.org; Sun, 01 May 2022 09:18:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=+inl/5cpOXs40ozy4YakG2iXX+wQU4SPqqeXKR162vs=; b=NCZ4X WeyV3RU+xdT9wrUT+Hodqkg/1SOoMxp5/1U9oZbTy8jiBcMn9X/PBvhXdRVWhEKlidkbg4rG6u8yP 0qMczixQFKzrNG3G2ZcQLNiW/LDbTp7VNYa3CLyro0us2PTfPjJBgfVA0+7SJRW/XYGpNey96OwDj p0aILc4VQxZE9iX4ipXRvO1LpyT4EH+5JIsxvVnb26giCmTosCGqAuqaJjAmGvOXcvymb3+Cdkb7w JTU1quGEJIV9Fj+L0raPk4knAlcjnfPPeDMIKHcBVA4X+AcQtVZ9U6TPEwtOYozRbQ8xQ4FxjRw9s HKy5Mk+QBmgiyTM/o3pmPzXJe8Eiw==; Message-Id: <063c75db2e03938b2fadb052c4661adae36e352c.1651410615.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 01 May 2022 15:10:16 +0200 Subject: [PULL v2 7/7] 9pfs: fix qemu_mknodat() to always return -1 on error on macOS host To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Cc: Greg Kurz , Akihiko Odaki , Will Cohen 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=91.194.90.13; envelope-from=063c75db2e03938b2fadb052c4661adae36e352c@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651411506633100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qemu_mknodat() is expected to behave according to its POSIX API, and therefore should always return exactly -1 on any error, and errno should be set for the actual error code. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Reviewed-by: Akihiko Odaki Message-Id: --- hw/9pfs/9p-util-darwin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index bd2dd81548..95146e7354 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -124,7 +124,8 @@ int qemu_mknodat(int dirfd, const char *filename, mode_= t mode, dev_t dev) } if (!pthread_fchdir_np) { error_report_once("pthread_fchdir_np() not available on this versi= on of macOS"); - return -ENOTSUP; + errno =3D ENOTSUP; + return -1; } if (pthread_fchdir_np(dirfd) < 0) { return -1; --=20 2.30.2