From nobody Wed May 8 14:42:28 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=1651231146; cv=none; d=zohomail.com; s=zohoarc; b=PX8KTrWq6I3IwkJWVjKnn6KPGOh/VYPqZGJkWn0Wic0ip0VM35YTJMIczL8eOtU16xRWIoA6SFgR1/OWd1lSUv18RputiWahvaDdFUnCHfnRy/+M4XGr+BlUn+OWGv2JrbALHy/09cyfEHA+7fbm4Z16wM5dj3mW5pxzdUzx1cU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651231146; 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=YYzODqQ7cEbFbrg273mSz++Y7K2kYKiiFRIf0BeR6V0hWotFH5Dl7deCXzQi0NA6MEqXJLYwNvHI8A+/faxUXoFqCIQZP544Wc+N9sxTwYmX9d/ifnv1lXPOgkU83hL3EOrqii1n3J9DJlEc6beAEQMWAiYJ4i6nB8S9KNUW1ME= 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 165123114609351.983969958080934; Fri, 29 Apr 2022 04:19:06 -0700 (PDT) Received: from localhost ([::1]:60620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkOeP-0001ZS-2i for importer@patchew.org; Fri, 29 Apr 2022 07:19:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3102ca936f88bc1f79d2a325e5bc68f48f54e6e3@lizzy.crudebyte.com>) id 1nkO5v-0006C1-GZ; Fri, 29 Apr 2022 06:43:27 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:40369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3102ca936f88bc1f79d2a325e5bc68f48f54e6e3@lizzy.crudebyte.com>) id 1nkO5t-00085s-Og; Fri, 29 Apr 2022 06:43:27 -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=AkU9U /90Wojgjt5O9PU0B/rpRAizmh2VyD1L57Lg1+Qfk7Mt0oOKwMGzK2WzLe1rbE4X5MCNNn/yMVIF0V QXApDg5pSyO8DvW1g0+bf41NQmHpmrLfiLOrPv36kuRNp4c35HpblB9M7nMtz1qNe72VZJUckki7t u80x1VltdmMKJRCCwkFvZ2Yaxx2D8gry8b4JkY1bza73mryrBjyZWLO/yK1E5WfWCHrYzL3UJLO4Z 9SLc40jV4XD85UKbTiqeiR2nph6oCnjXEYeXz5JEuShyvaek6sC3FKBSKcTPjPdE3tvh060fcBNXO 9NF4xk08dTgigE3TW/MMhdncRuvLg==; Message-Id: <3102ca936f88bc1f79d2a325e5bc68f48f54e6e3.1651228000.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 29 Apr 2022 12:25:05 +0200 Subject: [PATCH v5 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=3102ca936f88bc1f79d2a325e5bc68f48f54e6e3@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: 1651231147669100003 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 Wed May 8 14:42:28 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=1651231028; cv=none; d=zohomail.com; s=zohoarc; b=EkuRlykoqEmIb9Gcm90yOkOZPKxmJGlsr6hnf+9x1snGLud9p2cudytk3wHRYsS71QZUf5DZE33gqw9JHdynjVlUqE5MKqa2X5u2poMyliGckNEWe/meMyT1i6RWaXRnfxXoTRTLvTVgcecwG3/MREli9GWvWM2qgmuEVYAVmoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651231028; 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=Qtl7gjR1rluebtvN9uzweNSJYOjoQEx8+nOtMgAJ/RA=; b=AzElFIwvQjFHkHjzWOWEsp0VuQ7FoKuCqiR+oDFMr6VmXddN5fSp76/qHm+jMXhs/kbrSuNWZFULLH5EF1SeSPmvI5rPq9/JHUeSJswh7nQCLi29lwBQBgXAvwX8L6FKlxAMub3kZ0bnSa8NANiEtsqeDDNWo6InNgkUCXeWO0U= 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 1651231028178956.8644076096763; Fri, 29 Apr 2022 04:17:08 -0700 (PDT) Received: from localhost ([::1]:55732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkOcV-0006Yv-3X for importer@patchew.org; Fri, 29 Apr 2022 07:17:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <2e7b5ecd7a6d83a538db4e8a22d8fb03e9e0f06e@lizzy.crudebyte.com>) id 1nkO61-0006Uq-NW; Fri, 29 Apr 2022 06:43:33 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:47875) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <2e7b5ecd7a6d83a538db4e8a22d8fb03e9e0f06e@lizzy.crudebyte.com>) id 1nkO5z-000864-SA; Fri, 29 Apr 2022 06:43:33 -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=Qtl7gjR1rluebtvN9uzweNSJYOjoQEx8+nOtMgAJ/RA=; b=cQMVL cF0/00Fvaoy61Kow1ohu1/DVO1CuBZXPgD8McsbI3pVVemeSqon8Ojz+w4vQka4onBJsVU/V97dmy xPyze4RxBWEeAVrUl6+y1KnCLES69KYoOWIorKCUx76ZdUt+McJwb7FsSoAurgYhAVYs2uqV21w27 tSGfa9qXOvHkeGF0bVi0v1w+FoAScCm0ABEaoakVyBbYcsFP8kifGKJMSFQIJeFftW4bP4nVHvwTc oMJO49EMGqoN3Zz4KiM3yS5sFUQgX67zVOgwyJg44UqZwOnHBY9syenO84nWuSRJKpYjUhBdgvmJW SyyOEU38oJADPMIBA4+k+ibEGTE/w==; Message-Id: <2e7b5ecd7a6d83a538db4e8a22d8fb03e9e0f06e.1651228001.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 29 Apr 2022 12:25:11 +0200 Subject: [PATCH v5 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=2e7b5ecd7a6d83a538db4e8a22d8fb03e9e0f06e@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: 1651231028949100001 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: Akihiko Odaki Reviewed-by: Greg Kurz --- 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..619c403ba7 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_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 +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.32.0 (Apple Git-132) From nobody Wed May 8 14:42:28 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=1651231270; cv=none; d=zohomail.com; s=zohoarc; b=IZZOckeq/5kgXipOIO5gQ8w8wK6fehP+JIKG2JE2VKGuu5WCgl+/89nItgLtv397ZYEQfmyUrKNTdvTJ0i0CI0lhxVAePcNw4CqqT0D+hye7SjCCC0yOls8KvSy3gVKIThB8MWzmmaJiYbuAXliSCDK2Ja3fsPXnk5KKkfXppk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651231270; 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=Z1Vsky0g3IQckEnJCNy1NFQmZpp1M5NZsmxO1UnZNAZFIc91qDYrE5muRt4EMQIn53xEK4KQPOM6xtL5IKzg4Uo5g0LlG7lAyIhlPLJs5jJM5WicChfObVjkCrkXwzp1XUyviTozHoZW4BzLvmX/X06V72nkt0lKiu3/DiizIck= 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 1651231270416763.0640748874614; Fri, 29 Apr 2022 04:21:10 -0700 (PDT) Received: from localhost ([::1]:35776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkOgP-0003vt-EP for importer@patchew.org; Fri, 29 Apr 2022 07:21:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkO69-0006pm-Ih; Fri, 29 Apr 2022 06:43:41 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:36753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkO67-00086H-EA; Fri, 29 Apr 2022 06:43: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=vq90Q4vtQmJgyHCseX/Xdws1yT3xxELHmtULnL9IalE=; b=RjIF9 pHcm0MM/p/b6Jk/tddyYwuDf+Rmqdxa+A0KndS1eLBG3IgMSBMS4oGqZoHhIIa1NtbmE1HWirPdoq qo2cwDg+UNFbyjWuevuCjWUzMCjF6wFABvYFr9bpj53zBc4o59dG4L0cIwyKPjM56EDnv8zPvFOKV d8ru+1XfMQ6F4tFMXYoyyuvG44g9ZsE83+milbEza1NE61iPX2Hx8fJhfs2w/5K1t9RIio/YxWsY3 RjE/i6jTy2D2G5ajXaKyaKL1AAr7vKSyNxIcQ43pO5pOM2TY+TmhfRm1JCWkyhn+C1lomW6cJNQ3n /cOvrbZpGvTR2m0Q5cOcE48ZwmdoA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 29 Apr 2022 12:25:15 +0200 Subject: [PATCH v5 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=b3a430c2c382ba69a7405e04c0b090ab0d86f17e@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: 1651231272227100001 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 Wed May 8 14:42:28 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=1651231115; cv=none; d=zohomail.com; s=zohoarc; b=XvMoefah3NSmQdt53i5toLNaYWIct4TpfU4ca6pETgxJfrNnxqKJ80i1jetIDyeTCBT2yFM6comWSPK9GCxJovuy2DN4qnugIpWqrgKLuj/GHJ/MMMkEvdLyPHXFh5qoWkjZyvxdo4GeD21y3XDfCe0FuZrBnArZPAbNzYoSx5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651231115; 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=mRo+P3i95xH10rFpZmcYuUzUWWpBbrZZ8ovfqiehL6fCWREwm+uiFGKG2JdwFU1g721cvZTWGKVi3ckTur3WVJaXluy/nrwkJblEiqCh0edOCZmctWJ6sdLr3/T0XC0UFI8iqcKCNG6+U34R0CpaTFutqJJW+w9QHSDk/WVydx8= 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 1651231115539167.79147719888851; Fri, 29 Apr 2022 04:18:35 -0700 (PDT) Received: from localhost ([::1]:59102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkOdt-0000Uw-Cg for importer@patchew.org; Fri, 29 Apr 2022 07:18:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkO6D-00071T-VJ; Fri, 29 Apr 2022 06:43:46 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:60357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkO6C-000876-DA; Fri, 29 Apr 2022 06:43: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=h5gEMFKynyRupF+CalLbdJKoS+M1CM7mAUU/pFySbx4=; b=MEL0j lgM07e3DRm5qSz0EiUGapzxiAuLyVe0NaVWA5nxJGF8jpvTsGyMBo4/hxU9pc/zICzo239b6kiBDZ U6+lJwYZIaBoLKroefMob6ddXAdY+ruE9jwqWNl06D8xu7J+ZIusVKQ5ASDHeYogA2uSJUvfvuGtD NkiwsXWRpkCXX8wB7BHPfmyBEpOREdQZwSPuKqMPQ9afrA49ogj8Gl1T1dNIGggnFQ82uq+LCjwhj lfHJQTP92XVKYCZmxOYsnCY4c/O8p+1hIRUj7ENX0cvTsCItkxZ5b9NRkR1Fuveb/NP0CIvLMxxX3 TR0bc9W0TRXiaP8mS/JoTq3DvHmgA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 29 Apr 2022 12:25:18 +0200 Subject: [PATCH v5 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=b322ab298a62069e527d2b032028bdc9115afacd@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: 1651231117693100001 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 Wed May 8 14:42:28 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=1651231136; cv=none; d=zohomail.com; s=zohoarc; b=LMQpNZ9ys3TUwWNDPhEar+YeXG8WnKDPEDqc0Ksk/Y/+6fVMKuK2Yxc4NDGZXOCp/Fiwssr3l8CsS2MAdJM9kovFLPR3BzVNYmgbPzDOXei2hnIcNaNLHYJN460NVw14oSDVyA7GYpwt/py52RMGGtNOWC3+eYAKmTRvVBKfXbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651231136; 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=e2ox5VS2LR9oyNR4CtKGkRf+AzFv8Mt7WD+oDQggk7PySchLuHycCM6U/H5sbFVbk0g2N/gS4d14rrIBjgxpS+vblTKjcpEGPO0rh+Zmtk6ACIywaiYOalblVmj4YMC/U22lKPhyKwGdMTSgyjdz3YJYXf1FrQ6cQe2TxYbFY2k= 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 1651231136349746.5723584000691; Fri, 29 Apr 2022 04:18:56 -0700 (PDT) Received: from localhost ([::1]:59714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkOeE-0000vn-Og for importer@patchew.org; Fri, 29 Apr 2022 07:18:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <34f81e9bffd7a3e65fb7aab5b56c107bd0aac960@lizzy.crudebyte.com>) id 1nkO6K-0007BZ-8U; Fri, 29 Apr 2022 06:43:52 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:55657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <34f81e9bffd7a3e65fb7aab5b56c107bd0aac960@lizzy.crudebyte.com>) id 1nkO6I-00088n-Gi; Fri, 29 Apr 2022 06:43:51 -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=gBLpY sDTcaAhrTn0ztOpbKsu/uZCArDUSGbUwzyZz1wUtclLysKzmWyDXaWm3XmbCbbpu/I2sXqV0+wwp+ g/7TGMI+Gkrbs/pJI+6+ojvhBRwVttWn9Kjf+tsXU2N+ox90nBtScizHeB1/ZO4PE70d2SugIOGGu 1f51FUJpX7o9ackJm+aWyA4jCjWLh9l0CtcuxMJpZxSgktfFYCQq6eU6M/edzn4fceQHiCexBiN81 zkdPonGEp13VjppG81mdYzv6TvrhypgLN1PDsUVnw01qA/j+GElVPvEFGMLNXZHzU3GUY0ULwhe1S 91VO/WCtAE/7EZv3EE8EegzGyI4pQ==; Message-Id: <34f81e9bffd7a3e65fb7aab5b56c107bd0aac960.1651228001.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 29 Apr 2022 12:25:22 +0200 Subject: [PATCH v5 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=34f81e9bffd7a3e65fb7aab5b56c107bd0aac960@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: 1651231137952100001 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 Wed May 8 14:42:28 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=1651231488; cv=none; d=zohomail.com; s=zohoarc; b=hLOIwOw6Qx0G3JkRckqapeaO5AQ1m9PhTPUPJz2grJkAcmtnBplLI8gVstN0ZGUYKZ0a5YcGbY05U2o2/GiM/dQ2j3DlYJwnJMtx8rFc8BUf8VNxekTB8aIoaZAkCEjbdcPEhhow2j62gltxsjF3qZkaH6QVY3FEBaYTJbA6oho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651231488; 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=M8pYgY9HNMhKEkwruRWVG1Le2uLEC0KaabEbJ3It6c8=; b=IL78ePFBZKwVOHr44ik/C18+bTh88tkOdCL9VBLLN9LO5vBX9fMyXJBx4LcsZSuJw+WOyYdeUkKr3r1SKOr3wlAx9glBPp3R8ApTGv2zjPUmzsW7RAJz53lK+r4XCMdeBlCJDskKfgYmjkXt782Zfa4mKMyCPvu5j2UnkzbMKM4= 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 1651231488457550.9412269813042; Fri, 29 Apr 2022 04:24:48 -0700 (PDT) Received: from localhost ([::1]:42846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkOju-0000bR-QA for importer@patchew.org; Fri, 29 Apr 2022 07:24:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkO6R-0007VJ-23; Fri, 29 Apr 2022 06:43:59 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:47481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkO6P-0008DO-Kt; Fri, 29 Apr 2022 06:43:58 -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=M8pYgY9HNMhKEkwruRWVG1Le2uLEC0KaabEbJ3It6c8=; b=PNhwX KLj8zlsk7gQ5eB/AtLIDuVgM5xZSLjQLp07I9xWxTTa3tzanrD7nj++pgn1PnGbh6yaT9BH9b4XH6 Jw3/mPDAyoqK6saIVgLUuKw8622tqE617WaZQzyYpji7/+M98XjFJpGPzuBqmWgKcMNClvZBRQTjl a3wYHIXl7fwngcXzVDJoe8xcCntSRi6EBpY3rmlpKQB7ecZEZ830UYw8fybnAT93mbDRKMMTh8gYh MBj05/F/J+E0cVs+u7pmRSbkAIvy0W9s5hUL8I37z53mQdTjEPaD/Umjo4bjj8ZthzERAIjMg+H1z rjiEzuMY17LobYxhAYcAdxu45joeQ==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 29 Apr 2022 12:25:29 +0200 Subject: [PATCH v5 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=c714b5e1cae225ab7575242c45ee0fe4945eb6ad@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: 1651231489292100001 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 619c403ba7..a5f8707bb8 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.32.0 (Apple Git-132)