From nobody Sun May 5 11:29:55 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651087036; cv=none; d=zohomail.com; s=zohoarc; b=Xy5KpwcyuB7a9cac9Y+a6ThmhaOrMO1X0hkeIS9Ak7024TfSjUPlzaewsp/wrOpD9tbdJjV3yyTUTjKnkR+oGb9hanX438pwhx0C9374U3gMsK84jbEbYUJzqJ7R5ZQOTjjciksDngrJw+9Mpwpiq1tCUo/ZYKrhXOeIsltgt5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651087036; 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=eiUhLnvniCRFRmHg94IspHR8zuzxCuN7kmOFel0V+B0=; b=Oimiqt9dCKxupXqOjfh7Cj1M/9Q0UDAQ2YIAoOzvHgR6Fu8M5gbPpqDwH3jkN9KI2VksKo9jcyuqOuQcfMlqJVVI0uG5r6LXKV3Wi0F3x8Ss5JNwbz62gTTm2b0sG+ylfM78bXgZ2sMi98Q7mFrK9C9DJ/2n7iKoOgDanzDTGrw= 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+importer2=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 1651087036534357.3169992314761; Wed, 27 Apr 2022 12:17:16 -0700 (PDT) Received: from localhost ([::1]:55178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njnA3-00022V-2y for importer2@patchew.org; Wed, 27 Apr 2022 15:17:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njn4Y-00024S-SM; Wed, 27 Apr 2022 15:11:35 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:59663) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njn4X-0008PM-9q; Wed, 27 Apr 2022 15:11:34 -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=eiUhLnvniCRFRmHg94IspHR8zuzxCuN7kmOFel0V+B0=; b=b9Uwp qvOOnsFd45gWMaFR8gTAn3Zw2GJv7spVhxLnZY7tgANY7500oohlivF4W31TuydkLuy8Fn8nKEWqD Thg1C+rdnZRpTA/u9OmxR6TwWoTjsBybZgtbyj/ZtvIWfBGBK9Fr3sct/a3r81bAc6ssoiFI0NW4M zmbgj1FS/aUbgU5GetGDF4GVgwSIgwFO9LWzfBYau0CRP2FZpQvw3g/oyPz5ulUogFoYFFb4OP4oM +JwQ3/oK+/rkfRcVDnh9Hs4vNG8DymeQKN08QMoOLBmqu4K20rw9L8SXWb8esJf11WYp5JmDHeFTt I7lz1SZH+kLpj+62vBsG88FzUTJ4g==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 27 Apr 2022 20:54:04 +0200 Subject: [PATCH v4 1/6] 9pfs: fix qemu_mknodat(S_IFREG) on macOS To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=a5338eada3c5130046785014c185ec4fa0ddeaa7@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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651087038308100001 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 --- 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.32.0 (Apple Git-132) From nobody Sun May 5 11:29:55 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651086871; cv=none; d=zohomail.com; s=zohoarc; b=hxfjSz9ANxInX9nr5wwxzx7SigDCxyIk4DRfZgZBRIN7Sx7qDXmG8YSspxUSJcGfQwUdSHFxsF+lKP2S8k7cQmtno/+1UWHosmS6PGEPxxLocLhCJijzpgekyqn7bF6mD6IGjaTWYts3QJqggT2SI5oapBDZn91x8aDsfSWgGWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651086871; 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=556k4ngJS5CyCJoMXwyu7XACdGcph3syQGhlYecwWg4=; b=QwEuKl4hYmuF16e3J5e7aCjbmEeKdGFjy2qMeCl7+3ZtNtCvLJNlZSGKzSbXKIoATUDr/teQ0IjLyynpExl7lyQJbfnQq1xZ1nEU1ik46EwE4ynYTWv+e4M8UTVLFejULFq/ZruvhE6mdjySeE0J5iFBld/fDQcWNMlTsFAAETc= 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+importer2=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 1651086871590264.7679130239859; Wed, 27 Apr 2022 12:14:31 -0700 (PDT) Received: from localhost ([::1]:47758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njn7O-0005Mm-8y for importer2@patchew.org; Wed, 27 Apr 2022 15:14:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <489275615f29a2efc97cbd6130c98669ed28a24b@lizzy.crudebyte.com>) id 1njn4h-0002SZ-C8; Wed, 27 Apr 2022 15:11:43 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:32965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <489275615f29a2efc97cbd6130c98669ed28a24b@lizzy.crudebyte.com>) id 1njn4f-0008Pp-Oe; Wed, 27 Apr 2022 15:11:43 -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=556k4ngJS5CyCJoMXwyu7XACdGcph3syQGhlYecwWg4=; b=Qbli6 Zil54yE9yxi6m+Inhkv2M20omIgd+UaK/Esrcs2iQ63+dZ7WVitEG6yeNwILt++mFAoVT/k5XCRvh e4vGoa7PiUprkLBtl5864d2sqoxwKD8NsWZXtuER7B+InjOEck4jttNr/iFRMrBZkrgw/r/lxeBqn QRYlXo90apbkycoR/2NUFERoE8UT4bLPbXRvGpH+VrlmOxCIshZxF3vRoss1uKKvqAQ97BMEYO41G OkUYcg2xOJzor6U8FZw028Jpv/ooR1+qfTF3TOTXfQe+89wcAr4NIBBgOw6KPzG2lyIQEDzzODmuC vlBZbiyF+tE6SsUisrDn27Q87Ncvg==; Message-Id: <489275615f29a2efc97cbd6130c98669ed28a24b.1651085922.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 27 Apr 2022 20:54:17 +0200 Subject: [PATCH v4 2/6] 9pfs: fix qemu_mknodat(S_IFSOCK) on macOS To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=489275615f29a2efc97cbd6130c98669ed28a24b@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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651086873138100001 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 --- hw/9pfs/9p-util-darwin.c | 45 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index e24d09763a..7d00db47a9 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -74,6 +74,45 @@ 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 + }; + + /* + * sun_path is only 104 bytes, explicit filename length check required + */ + if (sizeof(addr.sun_path) - 1 < strlen(filename) + 2) { + errno =3D ENAMETOOLONG; + return -1; + } + fd =3D socket(PF_UNIX, SOCK_DGRAM, 0); + if (fd =3D=3D -1) { + return fd; + } + snprintf(addr.sun_path, sizeof(addr.sun_path), "./%s", filename); + 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_ANY); +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 +132,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.32.0 (Apple Git-132) From nobody Sun May 5 11:29:55 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651086879; cv=none; d=zohomail.com; s=zohoarc; b=nx64EbfcUiAdWxLN+W3Aa9vW6+Xd78ypaA0QlUKAQQybDAapPwQIOnlra29aplBcoZ5roX4hdB3bqkajMgcHHOMYjrVM8FZsov4g8fffDNF+haKeiQrgckVZ1tFrP8b/8SkDngpnjZOr3+4pUNKN/cwWC+NDCqg2rUFI68nNtp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651086879; 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=vq90Q4vtQmJgyHCseX/Xdws1yT3xxELHmtULnL9IalE=; b=BY3R/7vAUcN5CiLhYHBtEGiEFpI6gnHAqpaErEhyhiSUsb3ejClSlxLmWT2eVoRuXRz/cfaK/4iIxnbih6cCrb5DAGBoCvcygqrcQL6wSgkyQH3eZRC5mZXVRfi7SIDdZiHYvFZhjP8BZ8gBYvuXXyo2EFOb0fBUfjj5zOx6Qc4= 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+importer2=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 1651086879744169.69721352255635; Wed, 27 Apr 2022 12:14:39 -0700 (PDT) Received: from localhost ([::1]:47974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njn7W-0005Va-Mj for importer2@patchew.org; Wed, 27 Apr 2022 15:14:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <987d81b5f25f2850f0cc53e99d02e7c9a5ac2c3b@lizzy.crudebyte.com>) id 1njn4j-0002aB-K2; Wed, 27 Apr 2022 15:11:45 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:47533) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <987d81b5f25f2850f0cc53e99d02e7c9a5ac2c3b@lizzy.crudebyte.com>) id 1njn4h-0008Q1-RR; Wed, 27 Apr 2022 15:11:45 -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=vq90Q4vtQmJgyHCseX/Xdws1yT3xxELHmtULnL9IalE=; b=Q/uYv 2JzXge122aoSbR542qE+EyO7vwokeQllY2g+UH2I/L00lMosinjuV8J7t7ZxoOwDYkrVT+LPsQ6T5 YYaMAGenv6MtNYz0xhB3V42FKccUUtorOIp+KHLkDlBCwu5DcUvbK0h25iCPosHoJt/Dzoawui/lb UuT/SO6+qX08SS5Gm+gs0cMRj9p+QWqNqZE4aBM/+1qdSlxyHBgMRRk/ue4xySByI+btKXzbRZ3yH Q1tO1pRxyh2prDkD/+rct7XzYNHlIzaxlU8+MRytwUjXZn4aeBu5k2BxfP0suK1p7WLCQG/qt6Abd 0r/uGSifvENWE6DALOpsRYVFdFLIw==; Message-Id: <987d81b5f25f2850f0cc53e99d02e7c9a5ac2c3b.1651085922.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 27 Apr 2022 20:54:29 +0200 Subject: [PATCH v4 3/6] 9pfs: fix wrong encoding of rdev field in Rgetattr on macOS To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=987d81b5f25f2850f0cc53e99d02e7c9a5ac2c3b@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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651086881134100001 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 --- 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.32.0 (Apple Git-132) From nobody Sun May 5 11:29:55 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651087048; cv=none; d=zohomail.com; s=zohoarc; b=E/FDWiJgZTxRDfeJsyJ+3m1uk/bLJGpsVxWYh2tegtxDvAIPvckjLKWSJ2X7bM0areQuOPgPCUcC4TSVLm8vlO2qxRKXEuZeD0SCInQ+F2u4cmdwmA2BkJRrSe94uFx9hqlqYZQb5So0ZLwhugSgHHf6ldFYcb3rBISE2WGZpBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651087048; 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=h5gEMFKynyRupF+CalLbdJKoS+M1CM7mAUU/pFySbx4=; b=PwUSYjjCd/vbGPDHFkKz8Lhrcp5JmGPfzoo2zVCnwsZnkxvFZF7kqHlX9qU7T10MDx9+f9lNs0Mc8iOhMo3XWG84YC7kOfir69rMuL6UlSbv9ZU0lSVcdfsse2Z1TqjqzNn7Sy9IKff5G/VYVPIiV4sO1RO5eB8cTSUNQRb+r9g= 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+importer2=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 1651087048621540.1226716851464; Wed, 27 Apr 2022 12:17:28 -0700 (PDT) Received: from localhost ([::1]:56158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njnAF-0002lI-IH for importer2@patchew.org; Wed, 27 Apr 2022 15:17:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1173395e19ee888a7dbde19b5362e862753d3e8b@lizzy.crudebyte.com>) id 1njn4v-00039i-RD; Wed, 27 Apr 2022 15:11:58 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:51969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1173395e19ee888a7dbde19b5362e862753d3e8b@lizzy.crudebyte.com>) id 1njn4u-0008Ro-4C; Wed, 27 Apr 2022 15:11:57 -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=h5gEMFKynyRupF+CalLbdJKoS+M1CM7mAUU/pFySbx4=; b=bg8Io qNUJld8x165C5Ep50+ZnrSAdQHrRXh0SfU09Azh8us6FU/9k+NGr2WavDQkoMD2vunRIxOC+hKJfW JuaycgsLc0pyniUDWPjTNIKLyPh1JhBQZBAnRUc4CSygro5atmJB48OY7GIwQ4dKyheuRR+k+axij O67mIpB99yoLodJrwMDN3MEz40fu4tKneXvgFKfkd7zp4JmE8USOSMWfk555MxWZseQZSUOudj3Hb J9I1xUrDYMiUDwqsaHdlvANr8bq0ZdoOwGKXKBruP+5Do7Gw4AjAmfrKUbVbg25lnyEUciflJAisw YCl9OHd4Snck95XVlt8WoCfW/NESA==; Message-Id: <1173395e19ee888a7dbde19b5362e862753d3e8b.1651085922.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 27 Apr 2022 20:54:37 +0200 Subject: [PATCH v4 4/6] 9pfs: fix wrong errno being sent to Linux client on macOS host To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=1173395e19ee888a7dbde19b5362e862753d3e8b@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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651087050383100001 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 --- 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.32.0 (Apple Git-132) From nobody Sun May 5 11:29:55 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651086962; cv=none; d=zohomail.com; s=zohoarc; b=awUFvVBnyFQZDdM1MKJsielQ/5wzngy6vO84yGvjVjttOIXueuuM+drNPc4SFvbpYMw93yJ28m0awsO/OSJmT/dqH6Hrjl24CD+NrBGAp6iV68tTG1wNmP/vhbzvlRtYtvjI3bE6ZAtUQ1eTyxg5wcUQPRrygz34mwcIpZKDMlU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651086962; 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=zIrDZd4x8Db0Bp3YUnjhpQ8lXXOO3jEp+5fUqSQpDeA=; b=UDVStopT26eFfnQniEUhQ9OSFHChkha+D2KsbZZkC1eWrPzMwh0zKxfzyU7gAoqPO6kiku1FFtTN7I4Urs8sNLzziDujldafE3UWsfPWDs67m5algYc5N21K09mpHGk0LBs+o5YW/qxOoaUbBS+rlNXPHY7qGH3gQK3i/y93c28= 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+importer2=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 165108696294399.50260734465348; Wed, 27 Apr 2022 12:16:02 -0700 (PDT) Received: from localhost ([::1]:49936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njn8r-0006qW-QO for importer2@patchew.org; Wed, 27 Apr 2022 15:16:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9734fae9a02b748846af667c58a1ef005f4e6759@lizzy.crudebyte.com>) id 1njn52-0003Lk-Px; Wed, 27 Apr 2022 15:12:04 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:37583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9734fae9a02b748846af667c58a1ef005f4e6759@lizzy.crudebyte.com>) id 1njn4z-0008Ru-ND; Wed, 27 Apr 2022 15:12:03 -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=zIrDZd4x8Db0Bp3YUnjhpQ8lXXOO3jEp+5fUqSQpDeA=; b=IFWGp Eadpc3np8GKiXnbpfmEc9brZxZvbitH9MNMwY9NlK9wrTA+zNnb9MWivTc7/vzkAAFsr7DW/MwGKR uX5IKbngSlrbflv2cxnr8VQKB3kHyRiXPj0cVmGi64VDUlK6z4jkgD7OURz7ahoLoXV/3OYE1z2Oz LRAe3aUDE4ElaL8t5260g39Sm2Wooo45WlYMPHIxRJNyjLYng2p50gIqksAKDQDI1vbymoOe/pfdf aMTOE/kT9mOSdbX/eFI3nvAqJhscQBiAhiQF/eoelkQXRBHePqQoOC9AeCYYj8p4Dw3Vah+V0HMcH FOMyK+WIXQpPdYIaKeAQUW2lNMcow==; Message-Id: <9734fae9a02b748846af667c58a1ef005f4e6759.1651085922.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 27 Apr 2022 20:54:54 +0200 Subject: [PATCH v4 5/6] 9pfs: fix removing non-existent POSIX ACL xattr on macOS host To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=9734fae9a02b748846af667c58a1ef005f4e6759@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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651086963626100001 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 --- 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.32.0 (Apple Git-132) From nobody Sun May 5 11:29:55 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1651087190; cv=none; d=zohomail.com; s=zohoarc; b=aHWiVxEmRthyGIgcsNWGt9bmIiko6sfGBk1nPhU+M4nqoqtaGGDHQehJxueFW+tb6iMqZ48rIXdYC7VRRHEy55qxFs4VgPMzjY810B0wLWm1hXCG1SOxRVNsAO4SD4HuX3S1Shjy1L6QKxB8IBc6EQqCCo4egfe/AaZMTJmzUT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651087190; 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=9e+j84JOd+3vjiq5peNtNOibkFPVEgahs9aMHNwCat8=; b=Zt0H3Yo4G3MxILucSFO+ItQTcTSXVflVTSLe5YDWmH9QivfulXuF5Hh6+ZQqpM+m8SO3PNhHOBMu8MugYUgu4AjQbRE9aywlKAYGCdXwYTAPsCXESONGEmvYQRTAkwfrLSuKyK4XlH/m0643Zg7iyLtwOAF8Fnlpi4RlYDxkYBM= 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+importer2=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 1651087190300128.32728992854925; Wed, 27 Apr 2022 12:19:50 -0700 (PDT) Received: from localhost ([::1]:33634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njnCX-0006cI-BB for importer2@patchew.org; Wed, 27 Apr 2022 15:19:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <233e6406128f5b90278e3d717e93b70c8e987217@lizzy.crudebyte.com>) id 1njn58-0003OV-Aj; Wed, 27 Apr 2022 15:12:11 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:38587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <233e6406128f5b90278e3d717e93b70c8e987217@lizzy.crudebyte.com>) id 1njn56-0000CD-7y; Wed, 27 Apr 2022 15:12:09 -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=9e+j84JOd+3vjiq5peNtNOibkFPVEgahs9aMHNwCat8=; b=Sfw9H 54oDyJaLukftwGXr7g2DPsOk5fBdybShf48MAkgzcSuYIfk9f7dOIWV6hmU9yx1/JhhdU+imPQjCU ESaaeThkAlRpMRdplfEYAMjksPmvqDWr7BftxghsmTrEkZMlsy1VTnVDCcOx46mc4vqhQwt1UMyBt 36Lsky4+e03jMZKT3y2e0qJmwxRiSdh/oGFlkALCX5WF1g6eChvsMjfjLZM1K6hooOQXz0obKN0gC QPIL8I3QBzDOn6emsnlPyrKT/bGaR5qRLNZkY1mJBP8GeSbDAyT4WNZJ6CXe7BcPnaPnD1ETiFzMq VQh3Vtajx6Ezt3vByKJ+wo+Iw72WQ==; Message-Id: <233e6406128f5b90278e3d717e93b70c8e987217.1651085922.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 27 Apr 2022 20:56:38 +0200 Subject: [PATCH v4 6/6] 9pfs: fix qemu_mknodat() to always return -1 on error on macOS host To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=233e6406128f5b90278e3d717e93b70c8e987217@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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1651087191933100001 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 --- 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 7d00db47a9..649a3ec61c 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -127,7 +127,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.32.0 (Apple Git-132)