From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173419; cv=none; d=zohomail.com; s=zohoarc; b=H1kgi2+1g8wLrngTqdn6m5y6mYda7obHBu82pOY4k3mwQEnN0YzfosK/jOnWBJiJYUOi7ck750WZhFOyCdvGzyc9jXW37c2qKz5IPfOjbkFjQedfVjyBcxHLwB9HP3DYLm+dDsFMBpR8XVdlt1gTWWllEr/4C9nDqGibMOSxf50= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173419; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XX/jGrUjlGVuib4H2fZzgMtat+B8v1Q0qiLhHS8LE0c=; b=ZRii5osU4N7usuII9uKdXry8/hMcxclJe8xSCiG1wZo1Rohwx6NJX16tiViZFZ1cAl2nlOemvLXqXqKB/Y8ll/423NZd3hmm3RY6lXqPVNlTooXQ2LdUaBMDeJZeOXfpuDwYpQ2P2ZW/IJWVsSFDK4r73d+XtUpD52DGNcJgjAw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173419036137.2264868686907; Wed, 13 Oct 2021 18:03:39 -0700 (PDT) Received: from localhost ([::1]:54858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1map9l-0006EQ-Vg for importer@patchew.org; Wed, 13 Oct 2021 21:03:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIK-0003yn-HQ for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:22 -0400 Received: from mail-qv1-xf2e.google.com ([2607:f8b0:4864:20::f2e]:35641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIJ-00034n-1X for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:20 -0400 Received: by mail-qv1-xf2e.google.com with SMTP id a16so2726536qvm.2 for ; Wed, 13 Oct 2021 16:04:18 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XX/jGrUjlGVuib4H2fZzgMtat+B8v1Q0qiLhHS8LE0c=; b=qgJNUjdO+2CXhT1qncR4+/ws8RPirLMRWchgFbAPNTAdxf4dpkqcuO7MtbXf7NAgua jrxA/Ugk23uudHR0rjazp6HDh0LYoPvURS9dCmXDdBf1YRaufXJiMvtOcxNniAm3pz73 +GjNmabkf3dXcAu53IetYQxr1UMe8FEPtDd4XxYhDLSO33lugKEg63NgMxp0LTcQ9z10 DM+cgIVoHNYbfiRCaR15lMjBfstUJU4Gmm2O6w29X9EgLa7zlVEI8Cc6UMCwnl/Ton59 nGGBcQ1kdbHIkXHmk1kEKUKMn8QMB0BkGgtig9GGvsjK2le5N/o1ymzKKSTxyuDNoGNy 5TOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XX/jGrUjlGVuib4H2fZzgMtat+B8v1Q0qiLhHS8LE0c=; b=QVYvCXMpkaKKMj+yOy6ObA4fAMcNIL6qZb5PD7k1Uz1rUBuJVP9fXyRp90WL59j8fE 4sIVH+e89194GiuTkw4xrarRqR0ioClP3z4BRhsMRdvHbDqx/iexb09gE7esXug55OxA CKkJkmzRtfFECpH3go8crs47MAwrE6QgY/ch2robP82zJsVrd5hjINIex/ZPq+zk6h7N JgvqUGF++tepare8l6SxPZfs97uH1Ht2OCAh/QYEVBmacESHAZ8kDLfBCVNf32jNMaqc heXxagyl1HrTxNhGcqbdouRX4WSp6pEc9YkhqTcZj+8yKT9ifctBbSiJ3svS4bC7lh0C GFtw== X-Gm-Message-State: AOAM531FjFBxtTrBKf7uv6EjpZ+0+omuwvI59MaTzF3gMkoo4mnubkCV 7bFBqM+XJrg2PO7DDiMjWCdw5W75DbqezQ== X-Google-Smtp-Source: ABdhPJzoXpT3FXU/WGFjB9mf4Fq8RkY/02zpYXDU9mlmnC5lfydBqVf/JV09Nxq4XgX/IYSIlePtWQ== X-Received: by 2002:a0c:f806:: with SMTP id r6mr1782166qvn.49.1634166257777; Wed, 13 Oct 2021 16:04:17 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 01/11] 9p: linux: Fix a couple Linux assumptions Date: Wed, 13 Oct 2021 19:03:55 -0400 Message-Id: <20211013230405.32170-2-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::f2e; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2e.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , Keno Fischer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173419903100001 Content-Type: text/plain; charset="utf-8" From: Keno Fischer - Guard Linux only headers. - Add qemu/statfs.h header to abstract over the which headers are needed for struct statfs - Define `ENOATTR` only if not only defined (it's defined in system headers on Darwin). Signed-off-by: Keno Fischer --- fsdev/file-op-9p.h | 2 +- hw/9pfs/9p-local.c | 2 ++ hw/9pfs/9p.c | 2 +- include/qemu/statfs.h | 19 +++++++++++++++++++ include/qemu/xattr.h | 4 +++- 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 include/qemu/statfs.h diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 42f677cf38..d9d058b756 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -16,7 +16,7 @@ =20 #include #include -#include +#include "qemu/statfs.h" #include "qemu-fsdev-throttle.h" =20 #define SM_LOCAL_MODE_BITS 0600 diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 210d9e7705..1a5e3eed73 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -32,10 +32,12 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include +#ifdef CONFIG_LINUX #include #ifdef CONFIG_LINUX_MAGIC_H #include #endif +#endif #include =20 #ifndef XFS_SUPER_MAGIC diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index c857b31321..2f0e960162 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -32,7 +32,7 @@ #include "migration/blocker.h" #include "qemu/xxhash.h" #include -#include +#include =20 int open_fd_hw; int total_open_fd; diff --git a/include/qemu/statfs.h b/include/qemu/statfs.h new file mode 100644 index 0000000000..dde289f9bb --- /dev/null +++ b/include/qemu/statfs.h @@ -0,0 +1,19 @@ +/* + * Host statfs header abstraction + * + * This work is licensed under the terms of the GNU GPL, version 2, or any + * later version. See the COPYING file in the top-level directory. + * + */ +#ifndef QEMU_STATFS_H +#define QEMU_STATFS_H + +#ifdef CONFIG_LINUX +# include +#endif +#ifdef CONFIG_DARWIN +# include +# include +#endif + +#endif diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h index a83fe8e749..f1d0f7be74 100644 --- a/include/qemu/xattr.h +++ b/include/qemu/xattr.h @@ -22,7 +22,9 @@ #ifdef CONFIG_LIBATTR # include #else -# define ENOATTR ENODATA +# if !defined(ENOATTR) +# define ENOATTR ENODATA +# endif # include #endif =20 --=20 2.33.0 From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173106; cv=none; d=zohomail.com; s=zohoarc; b=SUv/Xs044QXPmTP7zEyLx2w/HMRMZSxG5fegVEP8dXJL9BQNRKwalL+ukA8Jby7C7XOcEXBcL34WomCrhnM7/33gv3KMVrsLOrfawW+8CnML1BuOIMxZ2Ejd/9PdA+gTJRRozWvarFq2FnF4ZFAowxBR700FPxLxCX/xSqMrRnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173106; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NiXYdyvLdDkYrckOfygRcIbU5uw8eEtfOT8dVCkJXPk=; b=oEjzgtBHkkAzgsSi47p2+8MotU7xvP68b8Cw36XjD2hOft9ETx4b6eHG4TT4A7DH6QdspFxCcrbqTAb/7grzFeGEGvwt3XmwxZztaNdBC+jllFnpeDoE/RO4GUx/YjJbCpAlHTFAegDgyWTMTpcGvE4oijWqGuINk1BmzymhNzI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173106466873.4675351400857; Wed, 13 Oct 2021 17:58:26 -0700 (PDT) Received: from localhost ([::1]:38306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1map4j-0003Rm-GZ for importer@patchew.org; Wed, 13 Oct 2021 20:58:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIV-000436-QH for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:31 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:39815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIU-0003t8-4I for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:31 -0400 Received: by mail-qt1-x834.google.com with SMTP id i1so4195423qtr.6 for ; Wed, 13 Oct 2021 16:04:29 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NiXYdyvLdDkYrckOfygRcIbU5uw8eEtfOT8dVCkJXPk=; b=gGdJKYzntdhZ8jJ6EWy5jreZelgkdVBhzXhN3jWSBuo+EZEcMlQencpz4gDy8N5En3 V1NJ+OJjQUzIKi0t7qgAk1QCoYDaS2hfWSRiD0RGi7BLnJFX3kDyh2Y0Jf6GfoX2qgnO qSzMWO8jG2AzjtbBvEpQRy4udWiVHxxps6MOuo44MIEI4HrzDHyG+7z5Dy9LHyGK8UPh Pvn9wKd6AC97AxMY5IT/6GWfpBSrUo6JHUQyG0qbBFVRorQxgLAwNkDYm/S0ZX1HfOet +gx0T5ymuJS0Iu9rfQrsZmnbvEFKBVXyuP5vzjk+ZXLSpdMhChh8Ylvlk5nN58NrQuAv TxrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NiXYdyvLdDkYrckOfygRcIbU5uw8eEtfOT8dVCkJXPk=; b=6/UOWcTZnZiFx6SYiV3pR2WskcNf6zGktG6jYBKhyb5+CMd+wVBAcrs1R90IB+EcrC WsFoyFFSXDU6hUGZUoBFe8pBtS1vtK6onH3Zj4YpNaRNcBVXAMTie/fu43MpcZmI2YWJ aaZHdSZSlcFbLHXwDb/sbHSlBgemsakZHll6PIi1CCUrqjxu5ZSUiVTW/kyPz2x4n0Y/ FYmZqlUDIwnGNrU8OFUJ9lp/2TOmVo/2OEXt+S1m+/V4QpMa6e98r83mHdK6XQ7/GM9a ZAzyL077AYgHPIUDbvWsaOHsdTdQZwZEmZoyouEZ42MCJbjfvZTN8j9+8thRBqaU94D3 iyOw== X-Gm-Message-State: AOAM531NEhZfT+XFRPsECkQb5eR+FdCXGzyq9MvHv9Qyuh0cIb556kN+ NuwwvZYFYkE0TaABTKL/RXa304v8/I11rQ== X-Google-Smtp-Source: ABdhPJwTlx0WSYReYlAXlkThyyvs0bsTusMg/xiUPU0db82qlYk+/QW+r0mzfUx8TZKYz0RBpN1ikw== X-Received: by 2002:a05:622a:1187:: with SMTP id m7mr2518283qtk.336.1634166269146; Wed, 13 Oct 2021 16:04:29 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 02/11] 9p: Rename 9p-util -> 9p-util-linux Date: Wed, 13 Oct 2021 19:03:56 -0400 Message-Id: <20211013230405.32170-3-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::834; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x834.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , Michael Roitzsch Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173108312100001 Content-Type: text/plain; charset="utf-8" From: Keno Fischer The current file only has the Linux versions of these functions. Rename the file accordingly and update the Makefile to only build it on Linux. A Darwin version of these will follow later in the series. Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch --- hw/9pfs/{9p-util.c =3D> 9p-util-linux.c} | 2 +- hw/9pfs/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename hw/9pfs/{9p-util.c =3D> 9p-util-linux.c} (97%) diff --git a/hw/9pfs/9p-util.c b/hw/9pfs/9p-util-linux.c similarity index 97% rename from hw/9pfs/9p-util.c rename to hw/9pfs/9p-util-linux.c index 3221d9b498..398614a5d0 100644 --- a/hw/9pfs/9p-util.c +++ b/hw/9pfs/9p-util-linux.c @@ -1,5 +1,5 @@ /* - * 9p utilities + * 9p utilities (Linux Implementation) * * Copyright IBM, Corp. 2017 * diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 99be5d9119..1b28e70040 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -4,7 +4,6 @@ fs_ss.add(files( '9p-posix-acl.c', '9p-proxy.c', '9p-synth.c', - '9p-util.c', '9p-xattr-user.c', '9p-xattr.c', '9p.c', @@ -14,6 +13,7 @@ fs_ss.add(files( 'coth.c', 'coxattr.c', )) +fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss) =20 --=20 2.33.0 From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173286; cv=none; d=zohomail.com; s=zohoarc; b=kCBa6M7E1O9GlF2E5toOT86xqyT9jlTxkwkLTK2ZZgGc/YV5YCF6MEj+yr89whNS+obXM17r88apwcPbg2DUmqv0eXOxnJk1K9sK8QanPrCkx33Iq9eyoVXuhno6M68XujGW8G3QLXXwuw1/kZtWGcYK4z4JxsdviiqYkflb3f8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173286; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HhaTOax/FfoOVfXQIocoBV26WPxX91xBz5LLueJKqw0=; b=lm9RrFHRun1UtYF/Q7Eir0CXFHtUhAfpRlnXxAfVAdaSHZoUcpO+ycUWcIsngceKp3BL7jsmrl+g89lOwhHh/I2x/dO0eebHO303y7MmA50DCxfCFQngsdj4ZBOSbWWgzVxaszkCD+neHXpFvfeJNyZG54ewipR4/CICbQT6PUc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173286683266.8675375842703; Wed, 13 Oct 2021 18:01:26 -0700 (PDT) Received: from localhost ([::1]:46840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1map7d-0000hA-Ix for importer@patchew.org; Wed, 13 Oct 2021 21:01:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIY-00045O-Qv for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:34 -0400 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:46921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIX-00047X-40 for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:34 -0400 Received: by mail-qt1-x835.google.com with SMTP id y11so4152583qtn.13 for ; Wed, 13 Oct 2021 16:04:32 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HhaTOax/FfoOVfXQIocoBV26WPxX91xBz5LLueJKqw0=; b=elHAOTd4jvduKzgFiapnqVwKNpptdw3JT9d4SQ5mzQ3z305PRNXdrtKPgjz5KFTqkl E51DZHqS2UREbqXUKh6WeWCpdv8HwIQmr7tNnKPzwd7tXFXdd3t31TZAFfJk1OEfbiAv z3LmqOC1K8PzdSRLbcw+1vC1D3SvaHGuxXYjX7KL3L7Y/c5Bde/BnxBjYvPz8tTalZR7 bIND3PGOLjGWBfcELHhXN+kUnl1sLbe2imCG4oaeNXrsq0VYJgiSSmI9oatIeP3qxZIV ySq7x+D8mek2ClbM0H0IBLgyj0JAEkfkLy+vmfkt3hYiIheQeW/6TSL9JWL04Tq4kQ6S gqtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HhaTOax/FfoOVfXQIocoBV26WPxX91xBz5LLueJKqw0=; b=wVphC/4U7FR80O27M54hlBBicjLExV+XlLwrr5EeTmwGz0ZNU4iipEmYpjFNXvi/IK 8j7luTOHt16qTVK28BTk968ppFwtk3Qqze1891p0OtsmNbqSnpGfJuIRFr4dltKIQKEE k8pN33hZ0wqWM0RZGoB1yl35Ie5z0aUyJKIQGaGDEAMDqnaLphTOrztQgCf8mIoGbdfU YRmOh9NlORDYY0JXiPnwuhyKfAzqGTz59+3WVHNOdtnVE8VCbFnnrf98mxwBgNktM2ou Cgidhg3efTO+E+T82MS7k08AxMqvzGFe+j62Mrusc3nOtxOWFX/90/pwKJRL/XQg2hzH yP5Q== X-Gm-Message-State: AOAM533lRj1VE3UgQ9qYznbKUWMV8qoOcxqWVdlQoqtRB/2ml5wy0Nbs Z5/1J6rt5iDtGEQun+1Mw+x2SoS60A8c9w== X-Google-Smtp-Source: ABdhPJzAp1YioUQdQQaTJXHwbyL6fHiGlcuQsWk4b2xTUpc0CCwWoS5Aus+rVNjbmWm010AOcSKvNQ== X-Received: by 2002:a05:622a:1a24:: with SMTP id f36mr2533117qtb.321.1634166271926; Wed, 13 Oct 2021 16:04:31 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 03/11] 9p: darwin: Handle struct stat(fs) differences Date: Wed, 13 Oct 2021 19:03:57 -0400 Message-Id: <20211013230405.32170-4-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::835; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x835.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173287101100001 Content-Type: text/plain; charset="utf-8" From: Keno Fischer Signed-off-by: Keno Fischer --- hw/9pfs/9p-proxy.c | 17 ++++++++++++++--- hw/9pfs/9p-synth.c | 2 ++ hw/9pfs/9p.c | 16 ++++++++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index 09bd9f1464..be1546c1be 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -123,10 +123,15 @@ static void prstatfs_to_statfs(struct statfs *stfs, P= roxyStatFS *prstfs) stfs->f_bavail =3D prstfs->f_bavail; stfs->f_files =3D prstfs->f_files; stfs->f_ffree =3D prstfs->f_ffree; +#ifdef CONFIG_DARWIN + stfs->f_fsid.val[0] =3D prstfs->f_fsid[0] & 0xFFFFFFFFU; + stfs->f_fsid.val[1] =3D prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; +#else stfs->f_fsid.__val[0] =3D prstfs->f_fsid[0] & 0xFFFFFFFFU; stfs->f_fsid.__val[1] =3D prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; stfs->f_namelen =3D prstfs->f_namelen; stfs->f_frsize =3D prstfs->f_frsize; +#endif } =20 /* Converts proxy_stat structure to VFS stat structure */ @@ -143,12 +148,18 @@ static void prstat_to_stat(struct stat *stbuf, ProxyS= tat *prstat) stbuf->st_size =3D prstat->st_size; stbuf->st_blksize =3D prstat->st_blksize; stbuf->st_blocks =3D prstat->st_blocks; - stbuf->st_atim.tv_sec =3D prstat->st_atim_sec; - stbuf->st_atim.tv_nsec =3D prstat->st_atim_nsec; + stbuf->st_atime =3D prstat->st_atim_sec; stbuf->st_mtime =3D prstat->st_mtim_sec; - stbuf->st_mtim.tv_nsec =3D prstat->st_mtim_nsec; stbuf->st_ctime =3D prstat->st_ctim_sec; +#ifdef CONFIG_DARWIN + stbuf->st_atimespec.tv_nsec =3D prstat->st_atim_nsec; + stbuf->st_mtimespec.tv_nsec =3D prstat->st_mtim_nsec; + stbuf->st_ctimespec.tv_nsec =3D prstat->st_ctim_nsec; +#else + stbuf->st_atim.tv_nsec =3D prstat->st_atim_nsec; + stbuf->st_mtim.tv_nsec =3D prstat->st_mtim_nsec; stbuf->st_ctim.tv_nsec =3D prstat->st_ctim_nsec; +#endif } =20 /* diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index b38088e066..4a4a776d06 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -427,7 +427,9 @@ static int synth_statfs(FsContext *s, V9fsPath *fs_path, stbuf->f_bsize =3D 512; stbuf->f_blocks =3D 0; stbuf->f_files =3D synth_node_count; +#ifndef CONFIG_DARWIN stbuf->f_namelen =3D NAME_MAX; +#endif return 0; } =20 diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 2f0e960162..17b62d72fc 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1276,11 +1276,17 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const = struct stat *stbuf, v9lstat->st_blksize =3D stbuf->st_blksize; v9lstat->st_blocks =3D stbuf->st_blocks; v9lstat->st_atime_sec =3D stbuf->st_atime; - v9lstat->st_atime_nsec =3D stbuf->st_atim.tv_nsec; v9lstat->st_mtime_sec =3D stbuf->st_mtime; - v9lstat->st_mtime_nsec =3D stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_sec =3D stbuf->st_ctime; +#ifdef CONFIG_DARWIN + v9lstat->st_atime_nsec =3D stbuf->st_atimespec.tv_nsec; + v9lstat->st_mtime_nsec =3D stbuf->st_mtimespec.tv_nsec; + v9lstat->st_ctime_nsec =3D stbuf->st_ctimespec.tv_nsec; +#else + v9lstat->st_atime_nsec =3D stbuf->st_atim.tv_nsec; + v9lstat->st_mtime_nsec =3D stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_nsec =3D stbuf->st_ctim.tv_nsec; +#endif /* Currently we only support BASIC fields in stat */ v9lstat->st_result_mask =3D P9_STATS_BASIC; =20 @@ -3503,9 +3509,15 @@ static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *p= du, struct statfs *stbuf) f_bavail =3D stbuf->f_bavail / bsize_factor; f_files =3D stbuf->f_files; f_ffree =3D stbuf->f_ffree; +#ifdef CONFIG_DARWIN + fsid_val =3D (unsigned int)stbuf->f_fsid.val[0] | + (unsigned long long)stbuf->f_fsid.val[1] << 32; + f_namelen =3D MAXNAMLEN; +#else fsid_val =3D (unsigned int) stbuf->f_fsid.__val[0] | (unsigned long long)stbuf->f_fsid.__val[1] << 32; f_namelen =3D stbuf->f_namelen; +#endif =20 return pdu_marshal(pdu, offset, "ddqqqqqqd", f_type, f_bsize, f_blocks, f_bfree, --=20 2.33.0 From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173420; cv=none; d=zohomail.com; s=zohoarc; b=cNYqiNw7JEvLWd+Q3m28G/jj4qkHv4UOKsGoTxzrYmOVYxpvYWjkMXTgtRfPzkcsZtY0xu5pyWQMswoLxhKAS6cWeHGpBX5i0WhyZ0654zaBczoiqa4cH4n1hT/VnmUugZDhnYZ2Dn+BsFv2+fYuG3xXbWl3L4AMXgQPvcWC8YE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173420; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3vVs/dBq7+SyTYJ14HganCJ9O2Sc24EHmVDkbP22ig4=; b=lBI2/2Sb/iY+M2HmLWwxI/SlBTyChdeVV8N6KUjRCaCI60nwbuOlY0iUqQN0Y2zUSNPBq3dIxGNiLdGkArK3GJOvjQhmtlWuBS3D6kmv7wTtXRbW0WCPmc4OfqeYJiKogY60pLBzX4xmW7ifV2S8499/nKl3jGsZKSDnr21WbuM= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173420348419.2605764486516; Wed, 13 Oct 2021 18:03:40 -0700 (PDT) Received: from localhost ([::1]:54922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1map9n-0006HA-2p for importer@patchew.org; Wed, 13 Oct 2021 21:03:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIi-00048e-Hl for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:47 -0400 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:34659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIa-0004Im-JI for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:42 -0400 Received: by mail-qt1-x831.google.com with SMTP id v17so4214812qtp.1 for ; Wed, 13 Oct 2021 16:04:35 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3vVs/dBq7+SyTYJ14HganCJ9O2Sc24EHmVDkbP22ig4=; b=YUtYsRP1Z+CFn8DJ1FPhfUwPW0ynHEaDZ5x1ans6+xNKYqrEVsM6JI2Uw1PLpoTyjI 3KnYAMekgKxyoz+BiCSIt8J71nwo3DjNgJkjOVKxeF3yldCrfSOWFpOylnVADMGH8260 hKjPyj596oCKz/BEr+fsbw6xNZ2f3hN9UT9vxsrRKHdKZwLYhCmDfvF/iY5XHo+l6B0v coT5Xir5IHXBJTvUw/s9WMCqg8m1gHiBrnQOh7v30QmAPtWUBNxm26QTnAPrddnL5Bn1 7IwResJNXmgaqFK5f7kWZxUTMe4ZzY+ZUKSOfzl9FzKiMbw0uKgcxNgb2T0RqsLj3ofd MbpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3vVs/dBq7+SyTYJ14HganCJ9O2Sc24EHmVDkbP22ig4=; b=EgFJrsBPtYfx0rW4aKPBvRwmKXBpQ/xdT/VX5m1gdax6dkxfuUPqturRPnGx+++Cjc OzE1FKhIRi5+lmg37sd3AUlm6uIBb5TUCMEN+c0NvFStO9nHUeF/2+fOp+fr6vZ97iAs Yp5PHGMEUGlWxI5BJf5wLIdxDDQ0BZqWA6VBVrMWZFiEnhvQRmfjv2oFAcsQWV4mM2YG F5NHkTulETnL9/jUj0VAB86yvYg4+3BQ/Epz2eYzZ/K70APoibxoNnV4vqCLn6q6etrn naXdQgcm8wW0PsYpslpxt864uTFDzfYFZXCbfwxoAuTa6gSmfCe+mScj1EoBVZERmQth IORQ== X-Gm-Message-State: AOAM5312ACRwAkN9DGIvH+YiAXREg+YxIlqG31i18xgG+5ob2e5jlVN2 c8v50JLHMH4Yqqw6rjhRGtHiqySKVsdh3w== X-Google-Smtp-Source: ABdhPJwgnOEIsokMP37nAFy7iRdcwqF/2Y/KXPRbr404BlOMAQ02YC6hXIkSRdZmxY5FDygCNGsgAA== X-Received: by 2002:ac8:10a:: with SMTP id e10mr2534314qtg.406.1634166274964; Wed, 13 Oct 2021 16:04:34 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 04/11] 9p: darwin: Handle struct dirent differences Date: Wed, 13 Oct 2021 19:03:58 -0400 Message-Id: <20211013230405.32170-5-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::831; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x831.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , Michael Roitzsch Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173421808100003 Content-Type: text/plain; charset="utf-8" From: Keno Fischer On darwin d_seekoff exists, but is optional and does not seem to be commonly used by file systems. Use `telldir` instead to obtain the seek offset. Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch --- hw/9pfs/9p-synth.c | 2 ++ hw/9pfs/9p.c | 33 +++++++++++++++++++++++++++++++-- hw/9pfs/codir.c | 4 ++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 4a4a776d06..09b9c25288 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -222,7 +222,9 @@ static void synth_direntry(V9fsSynthNode *node, { strcpy(entry->d_name, node->name); entry->d_ino =3D node->attr->inode; +#ifndef CONFIG_DARWIN entry->d_off =3D off + 1; +#endif } =20 static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 17b62d72fc..2464ffeb94 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2202,6 +2202,25 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pd= u, V9fsFidState *fidp, return offset; } =20 +/** + * Get the seek offset of a dirent. If not available from the structure it= self, + * obtain it by calling telldir. + */ +static int v9fs_dent_telldir(V9fsPDU *pdu, V9fsFidState *fidp, + struct dirent *dent) +{ +#ifdef CONFIG_DARWIN + /* + * Darwin has d_seekoff, which appears to function similarly to d_off. + * However, it does not appear to be supported on all file systems, + * so use telldir for correctness. + */ + return telldir(fidp->fs.dir.stream); +#else + return dent->d_off; +#endif +} + static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, V9fsFidState *fidp, uint32_t max_count) @@ -2265,7 +2284,11 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9= fsPDU *pdu, count +=3D len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos =3D dent->d_off; + saved_dir_pos =3D v9fs_dent_telldir(pdu, fidp, dent); + if (saved_dir_pos < 0) { + err =3D saved_dir_pos; + break; + } } =20 v9fs_readdir_unlock(&fidp->fs.dir); @@ -2404,6 +2427,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu,= V9fsFidState *fidp, V9fsString name; int len, err =3D 0; int32_t count =3D 0; + off_t off; struct dirent *dent; struct stat *st; struct V9fsDirEnt *entries =3D NULL; @@ -2464,12 +2488,17 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pd= u, V9fsFidState *fidp, qid.version =3D 0; } =20 + off =3D v9fs_dent_telldir(pdu, fidp, dent); + if (off < 0) { + err =3D off; + break; + } v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); =20 /* 11 =3D 7 + 4 (7 =3D start offset, 4 =3D space for storing count= ) */ len =3D pdu_marshal(pdu, 11 + count, "Qqbs", - &qid, dent->d_off, + &qid, off, dent->d_type, &name); =20 v9fs_string_free(&name); diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index 032cce04c4..78aca1d98b 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -167,7 +167,11 @@ static int do_readdir_many(V9fsPDU *pdu, V9fsFidState = *fidp, } =20 size +=3D len; +#ifdef CONFIG_DARWIN + saved_dir_pos =3D telldir(fidp->fs.dir.stream); +#else saved_dir_pos =3D dent->d_off; +#endif } =20 /* restore (last) saved position */ --=20 2.33.0 From nobody Fri Mar 29 13:48:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173421141280.6453024589298; Wed, 13 Oct 2021 18:03:41 -0700 (PDT) Received: from localhost ([::1]:54898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1map9n-0006Fx-5t for importer@patchew.org; Wed, 13 Oct 2021 21:03:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIk-00048l-IC for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:47 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:38731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIc-0004U3-SW for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:44 -0400 Received: by mail-qt1-x829.google.com with SMTP id t16so4190636qto.5 for ; Wed, 13 Oct 2021 16:04:37 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hLvo/Ohp80+sBHkJWP+s69vvT0EaEBpeY5AiAd1sZVw=; b=QcM75KtIPIN875cB7KJcYVOVuHyp/VzKq/eUbwx9jTuKSWfoWt5i66+QP7ZWvuTUZo d+RdX71WEdKIL5RyMXvS3vT55Ln7OWKy2NYTIAXbUEpbzrHYSLylmz7GXef4mK1uMtuD zfP3BCiobhvFnhdn29w2JdpX8ge8bQhxzVoFS2eZWOvczQ21G/6bGgLu3dl3ba+ubz8E Ai4vTSiufrRMLeB6FSuvfdpOEBCW/6adwsaRGxUmZEnO0zfLsXdLM8B8TcubbKXPz78o /8N3EDaT3f0UdpYJB2fUDmin1GU96+qM91mWk+PtO65YcyRlKYgKT4XRu6rrr0LwI4v5 RCgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hLvo/Ohp80+sBHkJWP+s69vvT0EaEBpeY5AiAd1sZVw=; b=5tF5QmqibCvhifH1rMk/ooKLTohn4Oug+vwMnKjkBM1XNpp5luKaI/M5nw7VV0wIXc qplIRB4EpJPF03UtNFZ+o4NzZezAPzuv7E47ht28MPXfVDR3jYmJAhARZqAhXn/7YE2O icha26I5QZNr7t+3ITDspwVPvzdqQbMrJ5UPvTn4teSvYnFQalDYhO0td0ziyzYwO4ym tkTRNMai6UPkYiAZ6OFxiDXXgF6CdIBIoKxAcJZVKubx31X/MTLfjC7vZRYEIp5dKNm2 gTwNeDjY89n/wZ1BLfRkCN5XySNZPs7JDX2pxrULht76A09TzJslhIf8LjJ305FcN5eV o/Uw== X-Gm-Message-State: AOAM530bdw4YJG3tgEaWYA8rVx35cQVcCOS430qf+ON3QE+ssBmvcGZY P8aU3V8Ds2/l5ZZypDETVsTGpQQXfjH5fQ== X-Google-Smtp-Source: ABdhPJwo5mJBLAehqaAfknsbz0eZJfKwUpmP+J1vOfn7Kr0yiHD6MfYUEWxIBAd+ClX1gECt80JS6g== X-Received: by 2002:a05:622a:290:: with SMTP id z16mr2525330qtw.358.1634166276535; Wed, 13 Oct 2021 16:04:36 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 05/11] 9p: darwin: Ignore O_{NOATIME, DIRECT} Date: Wed, 13 Oct 2021 19:03:59 -0400 Message-Id: <20211013230405.32170-6-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::829; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x829.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , Michael Roitzsch , Will Cohen , Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634173421944100005 Content-Type: text/plain; charset="utf-8" From: Keno Fischer Darwin doesn't have either of these flags. Darwin does have F_NOCACHE, which is similar to O_DIRECT, but has different enough semantics that other projects don't generally map them automatically. In any case, we don't support O_DIRECT on Linux at the moment either. Signed-off-by: Keno Fischer Reviewed-by: Greg Kurz Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- hw/9pfs/9p-util.h | 2 ++ hw/9pfs/9p.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 546f46dc7d..627baebaba 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -41,6 +41,7 @@ again: fd =3D openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK, mode); if (fd =3D=3D -1) { +#ifndef CONFIG_DARWIN if (errno =3D=3D EPERM && (flags & O_NOATIME)) { /* * The client passed O_NOATIME but we lack permissions to hono= r it. @@ -53,6 +54,7 @@ again: flags &=3D ~O_NOATIME; goto again; } +#endif return -1; } =20 diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 2464ffeb94..97dc8b246f 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -131,11 +131,20 @@ static int dotl_to_open_flags(int flags) { P9_DOTL_NONBLOCK, O_NONBLOCK } , { P9_DOTL_DSYNC, O_DSYNC }, { P9_DOTL_FASYNC, FASYNC }, +#ifndef CONFIG_DARWIN + { P9_DOTL_NOATIME, O_NOATIME }, + /* + * On Darwin, we could map to F_NOCACHE, which is + * similar, but doesn't quite have the same + * semantics. However, we don't support O_DIRECT + * even on linux at the moment, so we just ignore + * it here. + */ { P9_DOTL_DIRECT, O_DIRECT }, +#endif { P9_DOTL_LARGEFILE, O_LARGEFILE }, { P9_DOTL_DIRECTORY, O_DIRECTORY }, { P9_DOTL_NOFOLLOW, O_NOFOLLOW }, - { P9_DOTL_NOATIME, O_NOATIME }, { P9_DOTL_SYNC, O_SYNC }, }; =20 @@ -164,10 +173,12 @@ static int get_dotl_openflags(V9fsState *s, int oflag= s) */ flags =3D dotl_to_open_flags(oflags); flags &=3D ~(O_NOCTTY | O_ASYNC | O_CREAT); +#ifndef CONFIG_DARWIN /* * Ignore direct disk access hint until the server supports it. */ flags &=3D ~O_DIRECT; +#endif return flags; } =20 --=20 2.33.0 From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173791; cv=none; d=zohomail.com; s=zohoarc; b=g/CoPpQNeHvnvMnZlCI4B+rGOp1uN4MxlUgiQDaRIVXyY2sGm2zWTQi2yKtfZFGnldRrU9Hym8Wt3e1oTHH49sKjc3sZrcQy3gW9Gtpdkypn/2Gg/ehvBV6XBI5jJmC2oK2l4IvxdzArEFPxpczIS/1Yyevcg3tHZeDGJ1TfxN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173791; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ceqwCnBnXXlDmYrHzyn9u+EXyIv3S+MBYR3tJiDIsLk=; b=dpxt6lxFF6I1JOvuAmLWs7Hi0ZsovkmDZHLzuY2fjRA8eobe9w4zHFNDV04T/dWTYTi86drEr+YCQcTBJLu5CLjLgrF2fs2qI9PVHU4OfOZJWcZXIe5ca629GZc+7ldHo7KFy4q0NiP1cOopNLK40vOOO0rlDRwgKisTQHPgyaA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173791844570.7941097747723; Wed, 13 Oct 2021 18:09:51 -0700 (PDT) Received: from localhost ([::1]:41036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mapFm-0007dN-G0 for importer@patchew.org; Wed, 13 Oct 2021 21:09:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIk-00048k-Hc for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:47 -0400 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]:41509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIe-0004aj-6Z for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:46 -0400 Received: by mail-qv1-xf2a.google.com with SMTP id d20so2704696qvm.8 for ; Wed, 13 Oct 2021 16:04:38 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ceqwCnBnXXlDmYrHzyn9u+EXyIv3S+MBYR3tJiDIsLk=; b=oFARN8k2Y9yHO3d2UhBydvf6/0tsqJ8ozWg5ulFc11rSatrF4cmY6QyPk+0iNAtQyD 7SwXJ30mPkLhFU4zAgZLJVUtMvCtUy52KbVeE6NUj/82fyJwCCNKWalok8k/zpCSj9bV Paj7kFBehutJV+k4orodoEOLUDbN4EJT5ltn5BMkuVo5Tp2M9UJt1tbXFeJldFiqDUHc OJAYu+fIRx/TLwePjXXCpRYx6VQNZznWU0P9EQtMNwgiYbVApQAqCPUJMVEYgWe95+44 e1RL1emPHLSEWHA6n9F8QO7XQpP/1mLiAtsg9895snbsLKwv6hJ1sgHt2nI7NKmGem0O 9fLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ceqwCnBnXXlDmYrHzyn9u+EXyIv3S+MBYR3tJiDIsLk=; b=QrWq91kN4JlIhczlwrB4jQVYnFOE1Fjr7hSVRGQzOh9x6yknDkF5uDIJMLfsRzXchP GdzUx7KaNX2wLst83nNLgHxgkARxNmPRlKEnLuJLorCZ5rMO4+472lpMZQt5M8/wtKEg /FRKR7S94pzKiNMWUshF4MOf41dIOMx8y+ELZsnQqkTaJ8N864MPul/eJ59sIkn1caot 4AotqwTohlu5bZmd0Z8VwvlHU+D/MtPgRcLyHXeE2vcdZZMFbou9ybmS/ePjV9jYSDey +ThyXnPMwQ7kxK8P41i/NwWx6hlAU5m6aYGTseeMIdj10Wh8b6G8thnlLbQus1NMMOcw IgiQ== X-Gm-Message-State: AOAM531m9KSAvpmxfDwWo7Ou4+5zO2yguO9vqpJaDdDv7vbI0PBmOZOV KfTnJg0vB8atskQq+21e9MG4GdqBYuybOQ== X-Google-Smtp-Source: ABdhPJw9bJrXC/1m8k8EzZHKYUOdtVv+BAsEi9fyrM6i/+gUfSULu5UgBV7I6QnOswzJmWhfv9chzg== X-Received: by 2002:a05:6214:2aac:: with SMTP id js12mr2057069qvb.56.1634166278118; Wed, 13 Oct 2021 16:04:38 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 06/11] 9p: darwin: Compatibility defn for XATTR_SIZE_MAX Date: Wed, 13 Oct 2021 19:04:00 -0400 Message-Id: <20211013230405.32170-7-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2a.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , Will Cohen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173794089100001 Content-Type: text/plain; charset="utf-8" From: Keno Fischer Signed-off-by: Keno Fischer Signed-off-by: Will Cohen --- hw/9pfs/9p.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 97dc8b246f..3fc43cb482 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3927,6 +3927,14 @@ out_nofid: v9fs_string_free(&name); } =20 +#if defined(CONFIG_DARWIN) && !defined(XATTR_SIZE_MAX) +/* + * Darwin doesn't seem to define a maximum xattr size in its user + * space header, but looking at the kernel source, HFS supports + * up to INT32_MAX, so use that as the maximum. + */ +#define XATTR_SIZE_MAX INT32_MAX +#endif static void coroutine_fn v9fs_xattrcreate(void *opaque) { int flags, rflags =3D 0; --=20 2.33.0 From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173103; cv=none; d=zohomail.com; s=zohoarc; b=JdrX6/Rsr//mmEPlTtWqArKVR44WReC0JpdTsbyo/J9HpnftczJW6QWxjaA0BLEswdR1vBbCBiV5Ydog5F9ChO/TQr5I6/OaHM/EpvzPs+kUN1FRf3GDC837R5fCnugss/yNDLbhOmNoEhw6VKbcAxZpgdaDoaBF1eXPffi071A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173103; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VTtIDPrx3HUewUYCzhNC8D4az0OrC264W3SB2KneSJQ=; b=mygZnqDUgsgrgkvih4UxHpaHcZtEJ8aMzgfU3hke6zYR+aTXbb5emnTd8NoEopNHw+PZp90PNBYXrbY80XME97K8UmrLCOkS1F4heHjbMe7lLXBKkQONtHlFsI7eBSHlaNWc8HoYO2BsyQpoDbqHTIA9EEOyR67GFbTKyVOLLnY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173103959959.5164878123278; Wed, 13 Oct 2021 17:58:23 -0700 (PDT) Received: from localhost ([::1]:38010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1map4g-0003G0-L8 for importer@patchew.org; Wed, 13 Oct 2021 20:58:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIm-00049f-Qs for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:49 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:35838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIg-0004dm-HQ for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:48 -0400 Received: by mail-qk1-x72b.google.com with SMTP id bj31so1108911qkb.2 for ; Wed, 13 Oct 2021 16:04:40 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VTtIDPrx3HUewUYCzhNC8D4az0OrC264W3SB2KneSJQ=; b=fuwJ6NSJqId2DPXlX9ULgt6hG4ixQZBEoOV6P5ENbllld2ki74qS1aRSQupBfvID+X gzh+OlFHc5Wi/x36Y3dgXJB3vAhMDd+sPOWbCjJpHYdqBxnMUq6G9UOfWES7He6JcsEn gEryQ11gX6mleAe/tjIjjqPVR+d70R3YIwGufBlAx9sURSHv/KNmhwRECnHk8Udh3naa 2yx33EE1uKeFzRz9jd6rQ54ZsZI1CFVShCpXdyHGLqGJhxYUXTeEMuL8c8SBkeRg03vF Uezajzw9CmtJtqJT8/f+bdQSfkmElShq7SJqy/yqqUbKezJEfLw8pend+7qqMUKd/f9J w1Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VTtIDPrx3HUewUYCzhNC8D4az0OrC264W3SB2KneSJQ=; b=F22irDOVSIgvsaz3bZa5gJCPoxr7ArO0oo0j6XtwANcRyfDUI8kKOS1hW6K2Ub4DZy t3I5TujSV2uYUGBw494IBu3s/CcYoWXy7Q62DUNFMH1v0Bgf0wG4SOFgQBk88tIKBPKQ GDCEkleJ2FugIEZD7bM3hG5MyMpJa8bWCftgrKMLsldfJl38q8EajUIGlZXyUscGURAV 8FpAqkOJmwgcOWA2WshxlgoNqe5/btW+m1dPJCLkurcPg6HQ68PQ/i4Y/sEn0+Q0cDBi 7TYDv+yuJ4HZ2TQOQMYjW4mL4k9fLpU8DDYuX8XtyjulK5chibvH6c08t0Ylukya75ry qWwA== X-Gm-Message-State: AOAM532kVJXhpL85nCmQqG2/7+EKHoRIjiW1Cpff7W/KAWTTpTUq4W9Y gFppvZZ7tatOoARwRlbMzbPb8X+Mvj2rNw== X-Google-Smtp-Source: ABdhPJx7No89KZ+2yNrPAAjrLGqofui9CGHA1XtUcXBcYl4DoALgwDMRfx3AuKu4PgFybyI0gV9Obw== X-Received: by 2002:a37:9445:: with SMTP id w66mr1880130qkd.410.1634166279962; Wed, 13 Oct 2021 16:04:39 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 07/11] 9p: darwin: *xattr_nofollow implementations Date: Wed, 13 Oct 2021 19:04:01 -0400 Message-Id: <20211013230405.32170-8-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::72b; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x72b.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , Michael Roitzsch Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173104199100001 Content-Type: text/plain; charset="utf-8" From: Keno Fischer This implements the darwin equivalent of the functions that were moved to 9p-util(-linux) earlier in this series in the new 9p-util-darwin file. Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch --- hw/9pfs/9p-util-darwin.c | 64 ++++++++++++++++++++++++++++++++++++++++ hw/9pfs/meson.build | 1 + 2 files changed, 65 insertions(+) create mode 100644 hw/9pfs/9p-util-darwin.c diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c new file mode 100644 index 0000000000..cdb4c9e24c --- /dev/null +++ b/hw/9pfs/9p-util-darwin.c @@ -0,0 +1,64 @@ +/* + * 9p utilities (Darwin Implementation) + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/xattr.h" +#include "9p-util.h" + +ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *= name, + void *value, size_t size) +{ + int ret; + int fd =3D openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd =3D=3D -1) { + return -1; + } + ret =3D fgetxattr(fd, name, value, size, 0, 0); + close_preserve_errno(fd); + return ret; +} + +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ + int ret; + int fd =3D openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd =3D=3D -1) { + return -1; + } + ret =3D flistxattr(fd, list, size, 0); + close_preserve_errno(fd); + return ret; +} + +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, + const char *name) +{ + int ret; + int fd =3D openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0= ); + if (fd =3D=3D -1) { + return -1; + } + ret =3D fremovexattr(fd, name, 0); + close_preserve_errno(fd); + return ret; +} + +int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size, int flags) +{ + int ret; + int fd =3D openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0= ); + if (fd =3D=3D -1) { + return -1; + } + ret =3D fsetxattr(fd, name, value, size, 0, flags); + close_preserve_errno(fd); + return ret; +} diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 1b28e70040..12443b6ad5 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -14,6 +14,7 @@ fs_ss.add(files( 'coxattr.c', )) fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) +fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-util-darwin.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss) =20 --=20 2.33.0 From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173560; cv=none; d=zohomail.com; s=zohoarc; b=HNUmL4gSyKkFQcYhbrfIi+fkwi8iJWpG7rjxYUAKMn/DSvaAqZFK47GXhB2hh2pkzw0Je73rIjBWbTzRG2fPE7pJVYUjx9170xfLGY+++mSjoMx7BUofRhcs52zM4+j4kgTwFn93WLfK9MaunDrFaG0abMWU95pR/naJXrq3Hes= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173560; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mxmkAfiWWbatcHjMuwTQ1jtLYAJ25C50o7Sp15K/pSM=; b=SBgRGm9kflZkDWv8ITAMbGQpsuQMvcEbW89rx0O4zdaYAbTEIN3wDRJJWaQW/9a0dLR2Qu7TVnIkYBak6ypa2nSdqqBP9hY0NIp0h5vlCDk0Un8oRxjCByi3bWsMEBr+jpI7EIGBpXERHzkooYiwx7JAWBWD+ZWJZvCDKWSvs0k= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173560456945.103044155855; Wed, 13 Oct 2021 18:06:00 -0700 (PDT) Received: from localhost ([::1]:60444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mapC3-0001Xr-8a for importer@patchew.org; Wed, 13 Oct 2021 21:05:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIo-0004A8-Je for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:50 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:33430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIi-0004ty-Al for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:50 -0400 Received: by mail-qk1-x72c.google.com with SMTP id l7so3902493qkk.0 for ; Wed, 13 Oct 2021 16:04:43 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mxmkAfiWWbatcHjMuwTQ1jtLYAJ25C50o7Sp15K/pSM=; b=A3dThu9iWfrvQnd8VsGuQKY09+NQvUP3KcSAGBk2lDOc6msod+kphnmxMWPYwuAKsy SJLCIxbswO4AV4kbbg5yfUbRHLoDEJCPbGz0ZKnkc0nwVQv+cLgs93rrqFNsfXagdCky eVKNNNVbwdJfR+capUqD7XL4wAo5i98dyh+OzeMiN6sjq7i7YPk3PaNE7FlfKUj2hqA5 /a/Zk54rUKElUfzeoRbf/3P1A2N9fy2cEnGlnpROcOKGxrO2MF314k7GtpJGCFDGKYEf fuPT3VXiPnzOU623YrzNHfeVyAOrIiNvUIUMGihQuQRETQ+voJCXOFP7NTJNC4mLswpc oNlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mxmkAfiWWbatcHjMuwTQ1jtLYAJ25C50o7Sp15K/pSM=; b=O+F/KY8Qi2ZeTUerR92NuLu95GvYjynA0zMhyeZjwIG2M8eZfjyyyU+7G41gEg4B9E edBvIpnujJXcw6RwuPaIF3tN5iZ6PKDat4oAYjUaZY7mqgb0v44XaBqUjm4fdWh4ZeTK KKrHwY684IFa8tUxBRgbqAqhpYLes4CSIegymI2Sjk6aD3HkAE7QVAdnOTFVc4gIcZ6X ElKzn0G/gmA9EkYL25aJNO/Js/xWvfmgwmCnRS4/rAt01FwqadTWrSDv9MWTXm9sU1nI qLtOCFmsYc0KiTtW8CgRq4ms+oZVNt18E1Z9rfcDwvsACTxtVcjdS8ues4oiz6QJYNlm JfFg== X-Gm-Message-State: AOAM531mdyhDP63UY76Hvhd6TEws9rYX2ewKayudbf69s6dx8nNZjPOY 2q1ZjGuzabhHLUMhzAyeWsbe84WKE6XLcw== X-Google-Smtp-Source: ABdhPJzy8mrPG9HtF9ixKjIvtfQxBxceJKw1ouxQ69ubb5oFwvH5n1S+Q9mwsr/Bk7ZGgbwUHsb6Jg== X-Received: by 2002:ae9:dd82:: with SMTP id r124mr1834080qkf.234.1634166282633; Wed, 13 Oct 2021 16:04:42 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 08/11] 9p: darwin: Compatibility for f/l*xattr Date: Wed, 13 Oct 2021 19:04:02 -0400 Message-Id: <20211013230405.32170-9-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x72c.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173561630100003 Content-Type: text/plain; charset="utf-8" From: Keno Fischer On darwin `fgetxattr` takes two extra optional arguments, and the l* variants are not defined (in favor of an extra flag to the regular variants. Signed-off-by: Keno Fischer Reviewed-by: Greg Kurz --- hw/9pfs/9p-local.c | 12 ++++++++---- hw/9pfs/9p-util.h | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 1a5e3eed73..2bfff79b12 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -781,16 +781,20 @@ static int local_fstat(FsContext *fs_ctx, int fid_typ= e, mode_t tmp_mode; dev_t tmp_dev; =20 - if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0)= { + if (qemu_fgetxattr(fd, "user.virtfs.uid", + &tmp_uid, sizeof(uid_t)) > 0) { stbuf->st_uid =3D le32_to_cpu(tmp_uid); } - if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0)= { + if (qemu_fgetxattr(fd, "user.virtfs.gid", + &tmp_gid, sizeof(gid_t)) > 0) { stbuf->st_gid =3D le32_to_cpu(tmp_gid); } - if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) >= 0) { + if (qemu_fgetxattr(fd, "user.virtfs.mode", + &tmp_mode, sizeof(mode_t)) > 0) { stbuf->st_mode =3D le32_to_cpu(tmp_mode); } - if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0= ) { + if (qemu_fgetxattr(fd, "user.virtfs.rdev", + &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev =3D le64_to_cpu(tmp_dev); } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 627baebaba..38ef8b289d 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,6 +19,23 @@ #define O_PATH_9P_UTIL 0 #endif =20 +#ifdef CONFIG_DARWIN +#define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) +#define qemu_lgetxattr(...) getxattr(__VA_ARGS__, 0, XATTR_NOFOLLOW) +#define qemu_llistxattr(...) listxattr(__VA_ARGS__, XATTR_NOFOLLOW) +#define qemu_lremovexattr(...) removexattr(__VA_ARGS__, XATTR_NOFOLLOW) +static inline int qemu_lsetxattr(const char *path, const char *name, + const void *value, size_t size, int flags= ) { + return setxattr(path, name, value, size, 0, flags | XATTR_NOFOLLOW); +} +#else +#define qemu_fgetxattr fgetxattr +#define qemu_lgetxattr lgetxattr +#define qemu_llistxattr llistxattr +#define qemu_lremovexattr lremovexattr +#define qemu_lsetxattr lsetxattr +#endif + static inline void close_preserve_errno(int fd) { int serrno =3D errno; --=20 2.33.0 From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173283; cv=none; d=zohomail.com; s=zohoarc; b=LSa4DGWV0/gi7NYxZv7yrevw0hB5w2uklQl3KYdd0tIFPSUWHk11G6Kka3wxhu7m2qv6ZtWTz9LDBrAPZ5SRod5mRyJ9u3Kw5LBDleqvRTJ8wroWwkEo4oHC7tv86DWALfyTJYBwkSJCD4Esow8PCzD36ktNJ1QbTKxS4gvLBiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173283; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yAjmiIyIXonejlBSNKjPiX6PuZ66veKWZwcLgc4mA+s=; b=P+hJbnVynqGMMkeBJ/blR2rtAEyP2cOupJxccz7blcpWp9nBnxjJAxOwl3eBWfiqM8qpFhp5+9FzZB6TLG6gCx2nvzRwZ6XoJnwyz5QNsN0kEK/mJF6zGMQgW0siLeqXnPoKBD8KObEhmqpohc/gcTp1cIuZHjX3FW8CE0cH4KQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173283899531.5559097913726; Wed, 13 Oct 2021 18:01:23 -0700 (PDT) Received: from localhost ([::1]:46622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1map7a-0000YD-Mt for importer@patchew.org; Wed, 13 Oct 2021 21:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIo-0004A6-D6 for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:50 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:45789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIk-00055i-8m for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:49 -0400 Received: by mail-qk1-x732.google.com with SMTP id q125so3817837qkd.12 for ; Wed, 13 Oct 2021 16:04:45 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yAjmiIyIXonejlBSNKjPiX6PuZ66veKWZwcLgc4mA+s=; b=QXGm5AC9tCUNruC2EFjhAZ6oSWD/Rj+e7ih1n8Dff+b9rQ0pFDYF0AIO+UgfcgmGXz YV6b2UsW8+0Q+FV/0+p36DqidbXcTQ/BAsoKtdMELWAj/OQ43WZwhBdyLQMJKRgNPDk1 zMUoIS3SlpSaJnPdZsQvTfV6/AqIcrwNeYgFFuJ8YPaVsMJk8ePt5nUgyvny2gmP5ckd Sfpz9haxmDyYMgph2NrqxXvNy4+QRHO7gXp5oy7NLJkChXFFnJsBPihDQi7fTiPbkFlU kcqJNfOU7pRqNUX/yJLZdf/x9YFHWBSjjoIjOvypeFwBbRCRVwOLN9XnJiLmpyTBYbWE S6UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yAjmiIyIXonejlBSNKjPiX6PuZ66veKWZwcLgc4mA+s=; b=Rn7xSlkMfpvi5TJYP8p618MCmsq42T9rq43xe20BCr83S4LgCNPpNmxEYzzjsvH8ZZ ESWZ+Uje2l9ziVr+XWOMvdQk3FIL+Y047cvTZj36ICRnHwbJQjpwniV0RKr5GekXGXUD 2TmhSTNknerGp/8KjH7yM3diuitdg6ughbfMXfgRetqf6rMkEf5SsuNCkyaBeZon0xBd 6uFICnYU4oHsI/T/yi7MBEQl/jDuzn9yGfBHZdGl7tIZgdR47NLPe4vFREDZdgwBXnYh xdCAmWu6I7CWk9KL6gT0OsMXqB4LdTynIf/u+6YA1kM51TRWWihgrqlhZDuxaRIF/OnK bO/A== X-Gm-Message-State: AOAM530Ci0i3612KhT3YWwo/GGXoTDUAo22h+h0Ud7ouDNPLCAc1GSSM TdYWiBJi2Xqv+pqC3xIQCmLDZ533S0+klg== X-Google-Smtp-Source: ABdhPJzdA3T8Hp0Q1P0WhjYYz4nMMLylxubAGenS/aojvfnT55Z38OnUD1jSDz0lnUfxqmP8Uxgv3Q== X-Received: by 2002:ae9:df82:: with SMTP id t124mr1800193qkf.69.1634166284466; Wed, 13 Oct 2021 16:04:44 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 09/11] 9p: darwin: Provide a fallback implementation for utimensat Date: Wed, 13 Oct 2021 19:04:03 -0400 Message-Id: <20211013230405.32170-10-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::732; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x732.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173284659100003 Content-Type: text/plain; charset="utf-8" From: Keno Fischer This function is new in Mac OS 10.13. Provide a fallback implementation when building against older SDKs. The complication in the definition comes having to separately handle the used SDK version and the target OS version. - If the SDK version is too low (__MAC_10_13 not defined), utimensat is not defined in the header, so we must not try to use it (doing so would error= ). - Otherwise, if the targetted OS version is at least 10.13, we know this function is available, so we can unconditionally call it. - Lastly, we check for the availability of the __builtin_available macro to potentially insert a dynamic check for this OS version. However, __builti= n_available is only available with sufficiently recent versions of clang and while all Apple clang versions that ship with Xcode versions that support the 10.13 SDK support with builtin, we want to allow building with compilers other than Apple clang that may not support this builtin. Signed-off-by: Keno Fischer --- hw/9pfs/9p-local.c | 2 +- hw/9pfs/9p-util-darwin.c | 96 ++++++++++++++++++++++++++++++++++++++++ hw/9pfs/9p-util-linux.c | 6 +++ hw/9pfs/9p-util.h | 8 ++++ hw/9pfs/9p.c | 1 + 5 files changed, 112 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 2bfff79b12..4268703d05 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1076,7 +1076,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs= _path, goto out; } =20 - ret =3D utimensat(dirfd, name, buf, AT_SYMLINK_NOFOLLOW); + ret =3D utimensat_nofollow(dirfd, name, buf); close_preserve_errno(dirfd); out: g_free(dirpath); diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index cdb4c9e24c..ac414bcbfd 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -62,3 +62,99 @@ int fsetxattrat_nofollow(int dirfd, const char *filename= , const char *name, close_preserve_errno(fd); return ret; } + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +static int update_times_from_stat(int fd, struct timespec times[2], + int update0, int update1) +{ + struct stat buf; + int ret =3D fstat(fd, &buf); + if (ret =3D=3D -1) { + return ret; + } + if (update0) { + times[0] =3D buf.st_atimespec; + } + if (update1) { + times[1] =3D buf.st_mtimespec; + } + return 0; +} + +int utimensat_nofollow(int dirfd, const char *filename, + const struct timespec times_in[2]) +{ + int ret, fd; + int special0, special1; + struct timeval futimes_buf[2]; + struct timespec times[2]; + memcpy(times, times_in, 2 * sizeof(struct timespec)); + +/* Check whether we have an SDK version that defines utimensat */ +#if defined(__MAC_10_13) +# if __MAC_OS_X_VERSION_MIN_REQUIRED >=3D __MAC_10_13 +# define UTIMENSAT_AVAILABLE 1 +# elif __has_builtin(__builtin_available) +# define UTIMENSAT_AVAILABLE __builtin_available(macos 10.13, *) +# else +# define UTIMENSAT_AVAILABLE 0 +# endif + if (UTIMENSAT_AVAILABLE) { + return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); + } +#endif + + /* utimensat not available. Use futimes. */ + fd =3D openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd =3D=3D -1) { + return -1; + } + + special0 =3D times[0].tv_nsec =3D=3D UTIME_OMIT; + special1 =3D times[1].tv_nsec =3D=3D UTIME_OMIT; + if (special0 || special1) { + /* If both are set, nothing to do */ + if (special0 && special1) { + ret =3D 0; + goto done; + } + + ret =3D update_times_from_stat(fd, times, special0, special1); + if (ret < 0) { + goto done; + } + } + + special0 =3D times[0].tv_nsec =3D=3D UTIME_NOW; + special1 =3D times[1].tv_nsec =3D=3D UTIME_NOW; + if (special0 || special1) { + ret =3D futimes(fd, NULL); + if (ret < 0) { + goto done; + } + + /* If both are set, we are done */ + if (special0 && special1) { + ret =3D 0; + goto done; + } + + ret =3D update_times_from_stat(fd, times, special0, special1); + if (ret < 0) { + goto done; + } + } + + futimes_buf[0].tv_sec =3D times[0].tv_sec; + futimes_buf[0].tv_usec =3D times[0].tv_nsec / 1000; + futimes_buf[1].tv_sec =3D times[1].tv_sec; + futimes_buf[1].tv_usec =3D times[1].tv_nsec / 1000; + ret =3D futimes(fd, futimes_buf); + +done: + close_preserve_errno(fd); + return ret; +} diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c index 398614a5d0..d54bf57a59 100644 --- a/hw/9pfs/9p-util-linux.c +++ b/hw/9pfs/9p-util-linux.c @@ -62,3 +62,9 @@ int fsetxattrat_nofollow(int dirfd, const char *filename,= const char *name, g_free(proc_path); return ret; } + +int utimensat_nofollow(int dirfd, const char *filename, + const struct timespec times[2]) +{ + return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); +} diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 38ef8b289d..1c477a0e66 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -36,6 +36,12 @@ static inline int qemu_lsetxattr(const char *path, const= char *name, #define qemu_lsetxattr lsetxattr #endif =20 +/* Compatibility with old SDK Versions for Darwin */ +#if defined(CONFIG_DARWIN) && !defined(UTIME_NOW) +#define UTIME_NOW -1 +#define UTIME_OMIT -2 +#endif + static inline void close_preserve_errno(int fd) { int serrno =3D errno; @@ -96,5 +102,7 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *fil= ename, char *list, size_t size); ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name); +int utimensat_nofollow(int dirfd, const char *filename, + const struct timespec times[2]); =20 #endif diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 3fc43cb482..6fe42e61fc 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -27,6 +27,7 @@ #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" #include "9p-xattr.h" +#include "9p-util.h" #include "coth.h" #include "trace.h" #include "migration/blocker.h" --=20 2.33.0 From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173559; cv=none; d=zohomail.com; s=zohoarc; b=QrCw+qPS8jYqozp/ZPuxPqkshmyJ8K43e2dC6jjw3bEFRX5gP0vHp3l6A8K1Uov8Ri8xR2bKZUJFKXm5dYmUKaLBW7H2HwYT/2nhZWJw53OPZAw1SAKZRn0Bz4ngbdSiunqmL10B3hWo6h3m+3l8qhSmfUAkn6qc6Fi/0C9wGDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173559; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iK7VkZJP7Xh1BP8SXElMLoZneEkphjNP/5mpdr4DGzo=; b=AtPJnIqEw4lYNdaE0A3qLIoFhVb1wulRD/0jtymMOwJ6CNyz2zzyvswcefiqfLIpyaP/VQG8voQFxtXear6x4cTaU54agjlvq363SIJOuLyv/WUETxQW0sCe4nF92v2yCGkRimefUu/frR4i6WlDufk0b9KYnUqbSGunNo0IHy0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173559284973.1618888576672; Wed, 13 Oct 2021 18:05:59 -0700 (PDT) Received: from localhost ([::1]:60468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mapC2-0001Yj-Bs for importer@patchew.org; Wed, 13 Oct 2021 21:05:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIo-0004A7-DC for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:50 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:41514) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIm-0005CP-HN for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:49 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id d20so2704840qvm.8 for ; Wed, 13 Oct 2021 16:04:46 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iK7VkZJP7Xh1BP8SXElMLoZneEkphjNP/5mpdr4DGzo=; b=gZURG3wmxGpjrT6hI46r0aVOg7fgnsDn3+li92IbhVGgRf9RJshBnmWeBnlyINyCNW oPBZ3/LcZtdIitfBUzZwkmtu+QKL83uGOO1O71mZiPXYlzUKs3Ay87k/I2CmIal33VKd 2+Lk7bLeVaNQnMrQkYwlWGgXLz2yIUXs3OuAvjB5Y/2R+hiViMehOeyD5aS6lT/5lb1H +dJWLTo5OXyRZSwloCCE3Ophfx5iWlDWBLaT4rYZjEYtjXOjhVsigersg1aQI/ZG//3e lqFsJuDCuXBWFdlQVXRP1ZnCKe2yevwmABRQ1FwTj8FCfrEiqho+kqWQfHofHtZLL7ib N/Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iK7VkZJP7Xh1BP8SXElMLoZneEkphjNP/5mpdr4DGzo=; b=08GuNFc8Bv57fkjB29iZn+6kQ2O9WOcoKnVC7eqeqEYw59xlsxRlZKiuuyfKTZ+lpW jeTGjVvKOLbU52WD7Thrb5X2138aocRCZ/5F/nEimoNTdfQpbR1t+yPIISVm+ZiYPpmP cDzBBgTL4J/RwdApebF83FA41JmJNsBCzxy5f5YYP/lQ3ENuAoPGqOCaH/ywnOZHee7M F1Ypr2aFxu8Cr6v1rOvtoqiojHy1zwoGz0w620oKW6aEP3Y6C+4gjsvTS0PzhVbcTxGo o1mwTOZ7VKZziq11h35jzXbXRTYJfpwXAnxrWZG2STMhdhxF3ytBjwfJyhAzNA+lEwF6 a8bQ== X-Gm-Message-State: AOAM532A+qVMMoGA5lIl2GS6wervWf/JEm/jrzWD/050lRlJj4GJZhV6 3+9j0P67gFVaeEE5ksfhDRR8G8HkUOgg8A== X-Google-Smtp-Source: ABdhPJzakJi9xnwM7Hb51j236z2NRNLE/QUhXAac08gvG+wW4lCqkXovzga+xskmj78YX0nJdeaBCg== X-Received: by 2002:a05:6214:2b4:: with SMTP id m20mr2075033qvv.54.1634166286202; Wed, 13 Oct 2021 16:04:46 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 10/11] 9p: darwin: Implement compatibility for mknodat Date: Wed, 13 Oct 2021 19:04:04 -0400 Message-Id: <20211013230405.32170-11-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2f.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , Will Cohen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173559803100001 Content-Type: text/plain; charset="utf-8" From: Keno Fischer Darwin does not support mknodat. However, to avoid race conditions with later setting the permissions, we must avoid using mknod on the full path instead. We could try to fchdir, but that would cause problems if multiple threads try to call mknodat at the same time. However, luckily there is a solution: Darwin as an (unexposed in the C library) system call that sets the cwd for the current thread only. This should suffice to use mknod safely. Signed-off-by: Keno Fischer Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 5 +++-- hw/9pfs/9p-util-darwin.c | 33 +++++++++++++++++++++++++++++++++ hw/9pfs/9p-util-linux.c | 5 +++++ hw/9pfs/9p-util.h | 2 ++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 4268703d05..42b65e143b 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -673,7 +673,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir= _path, =20 if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - err =3D mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); + err =3D qemu_mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); if (err =3D=3D -1) { goto out; } @@ -688,7 +688,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir= _path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { - err =3D mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); + err =3D qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err =3D=3D -1) { goto out; } @@ -701,6 +701,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir= _path, =20 err_end: unlinkat_preserve_errno(dirfd, name, 0); + out: close_preserve_errno(dirfd); return err; diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index ac414bcbfd..25e67d5067 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -158,3 +158,36 @@ done: close_preserve_errno(fd); return ret; } + +#ifndef SYS___pthread_fchdir +# define SYS___pthread_fchdir 349 +#endif + +/* + * This is an undocumented OS X syscall. It would be best to avoid it, + * but there doesn't seem to be another safe way to implement mknodat. + * Dear Apple, please implement mknodat before you remove this syscall. + */ +static int fchdir_thread_local(int fd) +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + return syscall(SYS___pthread_fchdir, fd); +#pragma clang diagnostic pop +} + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + int preserved_errno, err; + if (fchdir_thread_local(dirfd) < 0) { + return -1; + } + err =3D mknod(filename, mode, dev); + preserved_errno =3D errno; + /* Stop using the thread-local cwd */ + fchdir_thread_local(-1); + if (err < 0) { + errno =3D preserved_errno; + } + return err; +} diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c index d54bf57a59..4f57d8c047 100644 --- a/hw/9pfs/9p-util-linux.c +++ b/hw/9pfs/9p-util-linux.c @@ -68,3 +68,8 @@ int utimensat_nofollow(int dirfd, const char *filename, { return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); } + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + return mknodat(dirfd, filename, mode, dev); +} diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 1c477a0e66..cac682d335 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -105,4 +105,6 @@ ssize_t fremovexattrat_nofollow(int dirfd, const char *= filename, int utimensat_nofollow(int dirfd, const char *filename, const struct timespec times[2]); =20 +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); + #endif --=20 2.33.0 From nobody Fri Mar 29 13:48:58 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1634173664; cv=none; d=zohomail.com; s=zohoarc; b=heBrHIqaryLOCMJMi3NV2T70Be9aFHDlgyRLhaLW/d+MQ39zVPBf8gHggrUMqz+dOa5dljLoYI5ZrhC82INTgEOgMy+zjPHhGGG2CFF0j65mROFiYJnZpA/aOlVcQILmdqH7srxf9+RxnU6OkuQYVBIQw9blYB2vDx37V7L/3yg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634173664; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mn02ONNGtwenhLF24rtiQX06IODpNJXR8gRnHXMmUbs=; b=oMFtC1UGtnaMAYmceLXFQ7ney1drmDjxzcf6UKo5rmlQMn1NQ1TluszOM9racInK9/nEzFQ2vzFzrb7jA4MxBwjBhLqzUfMg1Q5lbmm3hMbU4xb03ozcsFWJjYp6p+p51K/l5ptJNryp1Wq7Qmkz+YpodbINwfdzINIyyxZB/fw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634173664904661.242119397621; Wed, 13 Oct 2021 18:07:44 -0700 (PDT) Received: from localhost ([::1]:36530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mapDj-0004a2-Ue for importer@patchew.org; Wed, 13 Oct 2021 21:07:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1manIp-0004B8-Mu for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:52 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:39807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1manIo-0005DK-4U for qemu-devel@nongnu.org; Wed, 13 Oct 2021 19:04:51 -0400 Received: by mail-qt1-x82a.google.com with SMTP id i1so4195947qtr.6 for ; Wed, 13 Oct 2021 16:04:48 -0700 (PDT) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w11sm778680qta.50.2021.10.13.16.04.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 16:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mn02ONNGtwenhLF24rtiQX06IODpNJXR8gRnHXMmUbs=; b=bqQG0jUBCG1LK4V4xMMWma6szjVS2NW5A2RXWEfJtiuPFWuueZ4v5r1Eo5avlpkIf2 YBbjnU0bCttcjiaIVeniW55xqjuYhWiY2UscVfssy09vKO2qqLIVmSz+hsEH5IuwbRN/ 7A45JpalNViMWXneytXUwedA9IY+sTForH4SC1cBgeyeZdHvN3XUYERh41qzPCscIrRr W7wH7yU+X+j72D/sxIdblH68Qp8PVFml5OKZ7snlflMZwlZK8bDjC0PUew5UqZ7u1VAT qA7OqQY70WzdYGiWncelehgu5M6xWtRrQFCgQRHgjwlnCVDEOIb5y1Dews+RPbU+MNeL AL+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mn02ONNGtwenhLF24rtiQX06IODpNJXR8gRnHXMmUbs=; b=fG+KcmphIQqkDDl6hVMuXfoZTptLfTDxwpf7gComS3Whi0Rwys41KYpQMWsP4FUU4x ivIyMFbic5vHR52UxxHrd1Y4WL9tl8p3kKh+NfdMxhIjZ+8pZqhISvrkYLgDThvKKf9F kX3nO1Q5AKlVMDV1YLPHhhabudCRBtGmUIaMD8Bk6xl6dJ+Zt8ZOgZ8rZp2Ca2BgJzan DLdPWrlirPS4S2UnWD9VM6rx5FtZ4ztXJN2BM+rXY+QjZHu9cefkM08RJi53ZAJmsxy1 VF2g8Y81E0JXvj2rzG61ExSX8lXYmYEIyET61XJCwdG6PR48LyEfnlBsP4anfmBGffN1 LzLA== X-Gm-Message-State: AOAM531edvvg+StZjUxvJWKVwGwbkDFDYwOygQuSN51NomCv6wzFaoWw pek6+QVCojqGl1gj91100aSPPcXfaL8ydg== X-Google-Smtp-Source: ABdhPJzlro7CBsgDuxZa05n18Jk8x5FxPAgC5PtrgsCNYkESZTjoTwSjySC532cAd043b7cE0mTMZw== X-Received: by 2002:ac8:6b96:: with SMTP id z22mr2495837qts.311.1634166288334; Wed, 13 Oct 2021 16:04:48 -0700 (PDT) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH 11/11] 9p: darwin: meson: Allow VirtFS on Darwin Date: Wed, 13 Oct 2021 19:04:05 -0400 Message-Id: <20211013230405.32170-12-wwcohen@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013230405.32170-1-wwcohen@gmail.com> References: <20211013230405.32170-1-wwcohen@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82a.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Oct 2021 20:55:22 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keno Fischer , Michael Roitzsch Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1634173666704100001 Content-Type: text/plain; charset="utf-8" From: Keno Fischer Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch Reviewed-by: Paolo Bonzini --- fsdev/meson.build | 1 + meson.build | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/fsdev/meson.build b/fsdev/meson.build index adf57cc43e..b632b66348 100644 --- a/fsdev/meson.build +++ b/fsdev/meson.build @@ -7,6 +7,7 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files( 'qemu-fsdev.c', ), if_false: files('qemu-fsdev-dummy.c')) softmmu_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss) +softmmu_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss) =20 if have_virtfs_proxy_helper executable('virtfs-proxy-helper', diff --git a/meson.build b/meson.build index 99a0a3e689..5e777b271d 100644 --- a/meson.build +++ b/meson.build @@ -1203,17 +1203,20 @@ have_host_block_device =3D (targetos !=3D 'darwin' = or # config-host.h # ################# =20 -have_virtfs =3D (targetos =3D=3D 'linux' and - have_system and - libattr.found() and - libcap_ng.found()) +if targetos =3D=3D 'linux' + have_virtfs =3D (have_system and + libattr.found() and + libcap_ng.found()) +elif targetos =3D=3D 'darwin' + have_virtfs =3D have_system +endif =20 -have_virtfs_proxy_helper =3D have_virtfs and have_tools +have_virtfs_proxy_helper =3D targetos =3D=3D 'linux' and have_virtfs and h= ave_tools =20 if get_option('virtfs').enabled() if not have_virtfs - if targetos !=3D 'linux' - error('virtio-9p (virtfs) requires Linux') + if targetos !=3D 'linux' and targetos !=3D 'darwin' + error('virtio-9p (virtfs) requires Linux or Darwin') elif not libcap_ng.found() or not libattr.found() error('virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel= ') elif not have_system --=20 2.33.0