From nobody Sat May 18 13:16:27 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=1651319938; cv=none; d=zohomail.com; s=zohoarc; b=iHaqLt3fYw/nqk8rJkdCIe+0oF3vt3rs2PomxuP/hLcukQrTLZmvWOwzLgQB7j6f1RUpx58MHW8PqSwfhRlmKhx4faQw6ycd5kcbAJxVnQLPHcUJ8SOabGJeyiYM+0i2NAO/3AxkEtQb17efeV5lPFJoSatqUlZ0C/0jhzsMmUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651319938; 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=aiiFJGhH84/QaJggry2kMrjIPGgD/RiOrb8DhBSojQisNZGbwxDw7ZDjwPZNgBLhjoVs1zCwNGtVnUummwFRTHDrAVfX7YibPDc/YNi1ZKhNBI4/0ACd1uDXznPlEyLiU6WRUEeClwYvioaAgMeJpk+Hjb0OlEXmU1NwNfppN3I= 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 1651319938806581.4455857753338; Sat, 30 Apr 2022 04:58:58 -0700 (PDT) Received: from localhost ([::1]:52942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nklkX-0001dJ-Nk for importer@patchew.org; Sat, 30 Apr 2022 07:58:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42196) 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 1nklfi-0002a8-5k for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:53:58 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:54629) 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 1nklfg-0007IN-Hl for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:53: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=hytBxthYet9DFawcgXKMYZNCCM1++ItNvinKuyVuDJ0=; b=CfWfT aBIgVEK10mXC87Oj3jD58KiK14DMITr9vEXwbw0/zqk4fVPQZARe09GmCmjYS762n86jcCB/tA0JW BYsK98FNFxHnXAs7RpnZ5J/mU9zgojIZNwG/q74djt0+J6VkW49956q/Q/fcxlIbu0CL1IUrZkM8G NIVukptWdTRNoiVsnil9nHhLCClC4nCT6RunMi0fLquARwY+H5JPvNSrnk9I3Ztpje6x5BJVm8ghk DujfXDEb7vN5ysmNKW2WcWg+GEkF4vb4P+gpgpP1eiieb1nD1qQ4A6FmyFAc4ppuAojx2VqblCbwv Z0IavF414vIVeZXc2yxCig4Q2tniw==; Message-Id: <0009df31cb51cb2be681f4eebd58a9776d75a580.1651319081.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 30 Apr 2022 13:44:42 +0200 Subject: [PULL 1/7] 9pfs: fix inode sequencing in 'synth' driver To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz 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: 1651319940167100003 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 18 13:16:27 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=1651320115; cv=none; d=zohomail.com; s=zohoarc; b=fX2vlLSHA9h0UopdNlGbs3n988IhMP73mAjBP69Q3BAk+AxQEf+L59wxu/7RF/sKEiPLrlIwwMZ/iiYFsAauuvs6owEgQJW2cPoJJ70dgtfvvTwUX37KqAvSW/iNFUf8eVK/nlt9nNHAOdgAzzgy0JoUfiVOuNbV3yMfrnRb6fM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651320115; 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=SIM4K7MEnoE9jFFwoR/60iTjZATGiQ9Jq/KDxWfFrzBvmEg1HbKGq0AS1CS1noKkrk9tWEkga/cV8U873hIGigAT3SCts7vty9rb5dphTa8ZDUrnufofVyG8dag3G9/7tHdj+EFXkHHo9LgBYdhE3TGxpyXLKoSEzwaVXFVjN2I= 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 165132011556763.952601410120565; Sat, 30 Apr 2022 05:01:55 -0700 (PDT) Received: from localhost ([::1]:58488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nklnO-0005bx-AY for importer@patchew.org; Sat, 30 Apr 2022 08:01:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42232) 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 1nklfq-0002sc-3M for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:06 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:46579) 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 1nklfo-0007Ie-Jc for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:05 -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=SdAK/ Kkk+G5MW1slQoo53y5XfGKANDXN9WJqDHCdXIYH80nkaUWWGITEjOVT4t0iDOCNiSTC2fLXY2+hNp aR7y2RnO614Jf8yiD5VEqWZdErWHPpoFMnJ0wyLiyJNk9N9NM6XPrHyFiiEzQLkv4NaCYfoWReNO8 MqXkTELXYof5SNO79P1i0FjEGUyNFrtXGo9E4L9DtxPeTIeGtKazwKyPBkezAidqnuNiIciGk+AGb jiRWgUGsOeDRnSumCN5GKWbLQNDUuTJd1rZDQMsuB5VSbD5TUSukdbcXXSZD1b1/XcSoki3daH+fV KFrOdhknGt1Wif0jfoVUagoHvCx9g==; Message-Id: <096af171274cc76c51bf11366ae257391ddfed2a.1651319081.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 30 Apr 2022 13:44:42 +0200 Subject: [PULL 2/7] 9pfs: fix qemu_mknodat(S_IFREG) on macOS To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz 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: 1651320116612100001 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 18 13:16:27 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=1651319936; cv=none; d=zohomail.com; s=zohoarc; b=TU54wxCpI2cUI5UgM8ehmaznzaYlG+4mQQwUydClj1WfoGHW/o2Gd7/klXs5/Hz8eSKewRfF8PRUB/HludGryatvDUAzO1UGGsosP4r0qiWWsYV70rhqCzUZvQI586Ck0skmSnqbGuncrbdw1Ug0444Gz8pDp6hLn2ZHwOuARE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651319936; 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=gjkgfLxCldfwjR4FLqJxD/83lR9Um+2s/bvaLbOW/R0=; b=Sw5RSmmxT/6inih+DuN/66uQa6rKL0JR97KxJNFwl5fDwGXuaC3WfD7YN8ZcnMJP+cKc148SECAgkEEjGzQRGYHnLuoveHhoZJfNMb2bKWpK1VXLQjUtDbwp6kJze55mcJkGW6Z4bV4zBh2R9xrbDiCCt1cYY7Cok20PCuiKYrw= 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 1651319936049646.2931830453272; Sat, 30 Apr 2022 04:58:56 -0700 (PDT) Received: from localhost ([::1]:52728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nklkU-0001Uj-Vy for importer@patchew.org; Sat, 30 Apr 2022 07:58:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nklfw-00035g-UD for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:12 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:59507) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nklfv-0007In-Dq for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:12 -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=gjkgfLxCldfwjR4FLqJxD/83lR9Um+2s/bvaLbOW/R0=; b=XGAgE M977TL5ImMhTOYY/Zr8yBgknzYm68o92vrjWAHGXN0ADHkr18qmvUAbMhWammuH0WCyRnYq25HxQG ZWtlZgHUKnwT6nHQ2PrDe/ryL/4O9ZlUbQ957REkJC68NUIhCp9VMPGn+V2q2058L2LvjfOmngw6u 8Aazy9PJjhyQS9vnPmvb7YpxdaTCv7qqXYWkCLNet3RIOM0jjrNxJRPvtiifmeM0n0EHkw3KXgseN C5oi/LVBWF7SamrQXLdgnwG4LMNMKAoOGlNJFRiNLmfN5JjwcK1WDETIYUcwzheAMKicCMshJpazB aq20EL5z35sojoHr9NSlfnY4oHoyw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 30 Apr 2022 13:44:42 +0200 Subject: [PULL 3/7] 9pfs: fix qemu_mknodat(S_IFSOCK) on macOS To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz 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=c621d5c0ba22b25e2d5b3d9d7ee0877461776683@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: 1651319938133100001 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> --- 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.30.2 From nobody Sat May 18 13:16:27 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=1651319838; cv=none; d=zohomail.com; s=zohoarc; b=MdP8QkcsFx+lMYwT13Y+9TcKH6Zjglm5zB9+F++BWFOB9WsXKOVzC/QwSqKuwKwZf0tFb09wuRZg2I+x9RGA30Bz21kyK8rWLtB0UMDTprq27OX0beiYH64WKj5U/xN3dO4mN2+nwDSUcXvJDjM1bj/ajwxMR9a05reHbcW8RyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651319838; 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=fIMxJDuJmpAiYfBv9ixQgtUHavWnkESfZXwysyo9BhqxLYAE9TmlPfcEkVT3TpV7JwVnaRZWwpwf0C/E0H7B3YjOjui6jRZiN3YoWqele3rcTwB31DG7Dr12LMogBy7dG6qiPOITxe87r0CTn6WVDnrHhXL9rXBh9L0FLoGUibc= 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 1651319838759230.83704287739; Sat, 30 Apr 2022 04:57:18 -0700 (PDT) Received: from localhost ([::1]:47118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkliv-00067c-Dt for importer@patchew.org; Sat, 30 Apr 2022 07:57:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nklg7-0003ME-1c for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:23 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:56933) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nklg5-0007J7-CD for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:22 -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=nVd8/ OA7frjzVkZuoqZbwQJtSzMLakNbav5Mi6ZzTcAry65LlNIjNbVumuYML2aXzOHazS0FzZdWt0gNcz xdx86FQVW8RTifHPVqvuo3raDbnOGREup195xg55+f91puv2jliR54Oi0od+NE4+LQ5McQ7IrTRhl SJimOO+jSeqVBaMuV/7Yb2aK9V0bqMpLxUu1jNPeZTbBMpZuWRNMXHFWrNq/j4MVRUF/6NCIQ4YNI MrjBJCg1k/tP0Onl2Z25oaK5dkwZ9V0FV+bzxZV21vV8d7TLJvCPnTvqdPzpcQjQcp3/31Fo2WVzT CTrfZ1G9qLntLjfTdEo9uoyK/1t6Q==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 30 Apr 2022 13:44:42 +0200 Subject: [PULL 4/7] 9pfs: fix wrong encoding of rdev field in Rgetattr on macOS To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz 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=ea39a4bc024582a26ca0786771557f854eaf84f4@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: 1651319841898100001 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 18 13:16:27 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=1651320311; cv=none; d=zohomail.com; s=zohoarc; b=ZY7n3MM5Q9FpqfjjwsX2jrMaMskSV2EAln1Hih6fMPsho4gzzf7JWSQ/iWz0RthfMs9GJhaI8Zi1GvMDoVq1nNFK72HXIYaTouXG2WNnOIxLzbXVlDl7vGUSJbvpcykOkYZKDeZ2x/pqKLbibYTCVHZ72Agmhzx6PPEeJQsWMB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651320311; 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=J2Z2LhV5zWvlndJ27XJSQlDhjkHjA9udmulDIh1oLjVTcbtp5THCVggJgHv8ifwiNE1NiqXVu8EkHO+Th0P9stUsx4P2x/nsfg3eW733sf6/ouf7AcNxP3NkgGelRa758dQiM6MTL7o8soZ87MS1HrkB9x1A6LtuOnrLmj4NcJk= 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 1651320311794755.6386397989071; Sat, 30 Apr 2022 05:05:11 -0700 (PDT) Received: from localhost ([::1]:34296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nklqY-0000YM-0x for importer@patchew.org; Sat, 30 Apr 2022 08:05:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nklgA-0003RU-CT for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:27 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:44017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nklg8-0007JX-Nl for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:26 -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=dcp2b z/UyNGrE6De/EzGRLVfz4YuQpBfkbJ8V5xVupHOY8PwtWTWwxzGfJ/67n8rswO8qWBrbgy0MgW437 o9KBb+SZcjCqyQx7/0ruPTLOAlSqoEoTwKdIPiJ9WXn+GO2TjRYB/mc1j2IKA5EeihEsIY3MvMx2W uHBGmxrWQbILf6C5C1rRfIiXU+g9f5XVSfB22Mn661jRAZk6nPRiJp9JsCMNMfJTOLfzc9bZzQ5Nw MEelhDffhgtGepQQ0ZHyVRqHAZow93nriirqbWASZNGJC5CHle2sNDe/rxGdz5XgyMdL21zjVSqgy 4UUkD3pOmymHTJE3zi7QX0+nsDqRw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 30 Apr 2022 13:44:42 +0200 Subject: [PULL 5/7] 9pfs: fix wrong errno being sent to Linux client on macOS host To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz 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=b3779960b7d5bb9dd438e1d3fbece2b027d2ed48@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: 1651320313397100001 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 18 13:16:27 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=1651319846; cv=none; d=zohomail.com; s=zohoarc; b=EApC7AfIVkeV6BYeCdf+BoW9KRHHHvexicdmfEciklxr+iJV9ufLTCjPf2N1JeTE6eX5swzFW1pFqS1XFE4mNo3noicMtUUea7cQmQtiIbs/CqoSII0xEhLRclBeSgdNDX6UeGMCc3evoluXrDXZN1ufqcMNQSh9kn0lwLpvhUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651319846; 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=W/OwRtoa2w6Cm57B1WkZ8M2g2qNhGEFZvfwA8QI1tQXD8XXOaRPtr2g5gssxQscrAuyFvMeA8x0G/Cpz+GIdNKbsCsf7pvW++ti5YS3TIBDCwpn4dpI2dJfoEwC7tiKLoAvdZmKbv2cq4xeuU21/uAOe4lkOzE+UAsQgExJ2tzw= 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 165131984604432.994485460943224; Sat, 30 Apr 2022 04:57:26 -0700 (PDT) Received: from localhost ([::1]:47690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nklj2-0006VD-IT for importer@patchew.org; Sat, 30 Apr 2022 07:57:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <84a89408326215e2b423f23c1af415cfd773d099@lizzy.crudebyte.com>) id 1nklgG-0003dx-QH for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:32 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:44197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <84a89408326215e2b423f23c1af415cfd773d099@lizzy.crudebyte.com>) id 1nklgF-0007Jt-7q for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:32 -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=JNVAg 6P/DcGbBcJK44SFWcaDoF0/PgtibBkbwPrhXR5lDR2Uei8X3dlpMzVhTLz4G/goqBX2pSGCRdX8/6 +ORSqTJLP1NMDw/MfNEBrBhVHPc1gzvW31/uVLcc9sARgSHid4nwmaWcKL6Qxcl9Hk7rwbgbqRVW1 KdlDvlOiY9AQnr0pwfc4FfVhD6NimCxI2TGeLQFuzuMEp0ei/sIPDZL24pLrs5anmEU/Zjq0fHVpS jaUYqUN+v+jztA0d0j5Ib0cGdX395axKPNT/injwwQ6sCdYU7HQUOGknsrcWNXO+97xO6fr4rXVKt 3G20NV+JsntGoALfkLv2YgBGaSV1w==; Message-Id: <84a89408326215e2b423f23c1af415cfd773d099.1651319081.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 30 Apr 2022 13:44:42 +0200 Subject: [PULL 6/7] 9pfs: fix removing non-existent POSIX ACL xattr on macOS host To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz 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=84a89408326215e2b423f23c1af415cfd773d099@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: 1651319847755100001 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 18 13:16:27 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=1651319983; cv=none; d=zohomail.com; s=zohoarc; b=ZDjLBGhu87vnx2Z7aQ02O3xaGx9IyCdwYFxVBjpZ9IUrSbt3ejNRvJS7EkwEcyjyKPwHVh05BRJhA4foDgCG24SOCqjlDtBlDmOT4xmMpJUeMLlwXexNhjkhz6ZByJdpDTRykm5N7fqJKebqG3Jav3gii+zY/AG5KI83HsOJA44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651319983; 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=xUTz2/T2xUbJYB4ZKgpzvIQ08LtZSxkXnkIGIsocr2I=; b=clVDDHiXfqEJmMoKkhKB3IMJYAH5pQ/rBO2Canug7L5WxI1tpJ5BPrLWMOSJjPa4h8u2ZL5ADMJqQKbbe7wAEC1UDynx0pFfCKnC+no997R74Tmrp5LybjLr8WGxRTvWuGxmX6YkYSSJ/T/U7zTitdGFRZcC3j80gToz6w7sKnk= 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 1651319983679379.39402447796635; Sat, 30 Apr 2022 04:59:43 -0700 (PDT) Received: from localhost ([::1]:54932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkllD-00030m-Fy for importer@patchew.org; Sat, 30 Apr 2022 07:59:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nklgN-0003v7-P0 for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:39 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:47583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nklgM-0007KG-C4 for qemu-devel@nongnu.org; Sat, 30 Apr 2022 07:54:39 -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=xUTz2/T2xUbJYB4ZKgpzvIQ08LtZSxkXnkIGIsocr2I=; b=OLu6n yDKYhIjyD8EF+i+lEJ+pAW6Om55QEhz+3w/+PNY7uyeVEqcmHJVJFjjgfZgO0hDuLZh7iwNvTGT1u /NrvyvqheYAqHcWDZlLfGHdZ3EGghh4KLpA2sK5KH6jLtBlR1KD5GjbCUfAcsG4T1Pfv9yF/2sncz iYqDZylP3FZGRY61hjWgYUzLOa45bja/iAc9VreHkIb8+VWc12nSQu/JWpmfnRNulJOTiZLdfK7Vc jb/CiUS333imwt3k2DpNiqwasYra1a9Ttw/cfotuUWoP6gPf0MEFCIZtuDSxsydVyCEx7hhKs723/ 3/f8lW9ZJY6D4Ks/bDcumy0QoCEBA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 30 Apr 2022 13:44:42 +0200 Subject: [PULL 7/7] 9pfs: fix qemu_mknodat() to always return -1 on error on macOS host To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz 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=e8fb9ed725fe2ed00a275674a84beb5ba6e538a7@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: 1651319985646100001 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 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.30.2