From patchwork Mon Nov 22 00:49:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC6B8C433F5 for ; Mon, 22 Nov 2021 00:50:56 +0000 (UTC) Received: from localhost ([::1]:46886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxXr-0006eB-Qe for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:50:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxWS-0003zc-CL for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:28 -0500 Received: from [2607:f8b0:4864:20::f36] (port=42677 helo=mail-qv1-xf36.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxWQ-0000wa-Bb for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:28 -0500 Received: by mail-qv1-xf36.google.com with SMTP id b17so11328019qvl.9 for ; Sun, 21 Nov 2021 16:49:26 -0800 (PST) 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=PAA64zpjMOFdawCQAcn6F45dhsKweSXc7go9O2m/FPo=; b=oR8ec3YtpGnwhb7J8fHWwltp5Ev4N3en4WIOt8J6/THMrfgZ9oO/3TDAJu8r9cmND/ MBQNyv75ZHHRCyg/mF/DlipHwQ4o591O39DKN6rKHAUfAMfmQzXOxPBIUG7TOpUj/RCS Q9NG2f0K51iWjz+bvzTxxlpFkozBJSZe/PqyLvLtdY5+ifPaRscaLF7gfR9+eUpnz9L6 a/td7PpuBTYFXPJ0+U6+e4C4vgU61y5N8k3fBn6GVZK4pf8//StKZ6eMw1xkYiWdulGZ uynksfH6iN2sHTYh6XTI1NSjgivHed7v4mkTPXJTMmO4lMi/Rq3i66rsllxturCpyOTh X4Vg== 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=PAA64zpjMOFdawCQAcn6F45dhsKweSXc7go9O2m/FPo=; b=3yUiqVp8HtOauGhjBKrdAI7M6+M5CkPS0hI2lV8jk5IZ+xahf5jw0WtHgBHQHqENJ6 YcGXpU5bNt+jgmCQAUGcGvZUWb08yYLJtvxcVq01/n6+20wjoHvfggEmSD6UgkPYXLho OvBiyxwGE9/8U3Aq75NJBxNFZQNuymIUaOg7SzD4Nei/eJ4FPsvldMo3xecQi/8Pk6dz yi3Gv7CkvM9IFq3TjCcEqh5mQvP0K/M006732GX8eM7aaJ2ndB7inPa6TwyJR5dEhUXI 7aUZOOchMXe8Y+ado4DrlHxdAWcu6Zi/7qtHLq35o0xKhG1OgU8h0830ciV0M1Vv/aqJ ZfpQ== X-Gm-Message-State: AOAM533njrzmlz8H+1nhPrCS74jForddU/k/1Hkst65WbxAbbnNedCun 94cTLT8ecaKnqFzriPa8iIh+mAyukvSOkg== X-Google-Smtp-Source: ABdhPJyZv6y4NeddVUsDG+PKyal2gCSDFoTIx4BQ0Lb2FP1kCNP5B8sFjqBBxb5G85Koeq5O97qQRw== X-Received: by 2002:a05:6214:1c8d:: with SMTP id ib13mr97863154qvb.64.1637542165312; Sun, 21 Nov 2021 16:49:25 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:25 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 01/11] 9p: linux: Fix a couple Linux assumptions Date: Sun, 21 Nov 2021 19:49:03 -0500 Message-Id: <20211122004913.20052-2-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f36 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f36; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf36.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Fix headers for Alpine] Signed-off-by: Will Cohen --- fsdev/file-op-9p.h | 2 +- hw/9pfs/9p-local.c | 2 ++ hw/9pfs/9p.c | 4 ++++ include/qemu/statfs.h | 19 +++++++++++++++++++ include/qemu/xattr.h | 4 +++- 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 include/qemu/statfs.h diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 8fd89f0447..16c1a9d9fe 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -16,7 +16,7 @@ #include #include -#include +#include "qemu/statfs.h" #include "qemu-fsdev-throttle.h" #include "p9array.h" 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 #ifndef XFS_SUPER_MAGIC diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 15b3f4d385..9c63e14b28 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -32,7 +32,11 @@ #include "migration/blocker.h" #include "qemu/xxhash.h" #include +#ifdef CONFIG_LINUX #include +#else +#include +#endif 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 From patchwork Mon Nov 22 00:49:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D220AC433EF for ; Mon, 22 Nov 2021 00:52:54 +0000 (UTC) Received: from localhost ([::1]:55662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxZl-00044r-Vp for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:52:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxWS-00040O-PR for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:28 -0500 Received: from [2607:f8b0:4864:20::736] (port=42629 helo=mail-qk1-x736.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxWQ-0000wf-UJ for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:28 -0500 Received: by mail-qk1-x736.google.com with SMTP id g28so16438322qkk.9 for ; Sun, 21 Nov 2021 16:49:26 -0800 (PST) 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=wfvDuN4c+KD+ZY9ZO1rBZCxrfBxNV/dpt9cgp26yubM=; b=Q292t0QmbzK/2IccnKBFmjFaxx/iNaI1DUGeYM1vM2z9wBNxAHNuNvh58TA3gSaWA0 H9VqNxRtjdH8CstIMOsXEGb6x0Mj41v+fmaLN6aCoTI6SO/MZaaur0j4xweRCuPYjnKQ 5VjZczxv55oEa6HuLgOSZ7Ys830qrhKzYHUs0i579zvmc8hPQw8KYkKxDNNlBhjuSADf +wWGGgipoZ77ScsPRGu13FabzDu4a5yg7LwkFldrZN12izDAbERAePT3WWbY5GHUMA18 QaMuonS9La67DS8kUYXYZndZgMkyNHMlxl8uY8AK0kh832mpKo7GlCO49hmEdGTkzHr3 /O1g== 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=wfvDuN4c+KD+ZY9ZO1rBZCxrfBxNV/dpt9cgp26yubM=; b=RT4HaQRQb/xaxcXrZvbj64AnUV73IkNeiqCG3/TOT+QFsNW4VKhnEOZMzVjNOxNN/M XuwwE3KFEE2WuX6Z2yOvr4lbuml6w65kI0W/IRhCZMS/uo6b315DHl79DU7R1cLUr8tX ek+NuCJ5ZswEtL1SfF1/3DmeK27+GV4nm9Ci5xQBefLJeYZOT8P//K9marCVRjIhMDPD Xh8qjl498d3iNjEpPZ79ATUXKWLYJrsdCaurcwFyx03WJxKSlT8urOopspEfa2jAO7BE PbP2ZbVzwZL/xXiwr+GqYE4u7ji4kT+/MA/EqVtYlEClBE/i8iNA+PvpwfrRKy4IpqnK 9PDg== X-Gm-Message-State: AOAM532BvTwKf10KLtuF1N3lrOuYWVdP78NG0ENWJFtKPPlnHaMpxm4R 4ZSqnKZvBAjveGbPgYfE0syABxcxPVv+Bw== X-Google-Smtp-Source: ABdhPJxMIQGfiC7pI7OsocUSK3v9ziKeDqUTF8JIyTS+qy/HHee7rs74f6FacX9IVwjOQbSsYSc00w== X-Received: by 2002:a05:620a:298a:: with SMTP id r10mr44411601qkp.447.1637542166055; Sun, 21 Nov 2021 16:49:26 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:25 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 02/11] 9p: Rename 9p-util -> 9p-util-linux Date: Sun, 21 Nov 2021 19:49:04 -0500 Message-Id: <20211122004913.20052-3-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::736 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x736.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- hw/9pfs/{9p-util.c => 9p-util-linux.c} | 2 +- hw/9pfs/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename hw/9pfs/{9p-util.c => 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) From patchwork Mon Nov 22 00:49:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AC161C433F5 for ; Mon, 22 Nov 2021 00:56:17 +0000 (UTC) Received: from localhost ([::1]:38080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxd2-0002mc-Sv for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:56:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxbd-0001L2-6g for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:54:49 -0500 Received: from [2607:f8b0:4864:20::833] (port=38607 helo=mail-qt1-x833.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxbb-0001UQ-8c for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:54:48 -0500 Received: by mail-qt1-x833.google.com with SMTP id 8so15119143qtx.5 for ; Sun, 21 Nov 2021 16:54:46 -0800 (PST) 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=cCK2bUbse7yru7oE1n3A+8naGre4JcOd9jVp/ZAIUxM=; b=V4uB/tK301o/sHWQ8ssd0lIN0pqz8ioxcbUMnJugpzEt+Q/iATSIVdg76G8y0mL4TW rNxQxRdQTUbYfuw+bkkmO9E60GRbwMvWf28VXN6gvEbhu2hKeE3mqmmc5+hVpzfDaDdV A4hY/VTZBUlV87C3GMshbpPTmQ7w1wWQFGBa1z0e4yFn6Vni0+G6dZ8cz9Q4Gpegp5vt Ty2qVO4ydAmOI4PccD9EoLGNNqTKdsWfgzNRBr/OoQvz2L3GehgkyHGtg5CF0CPsig3s 4ojoLpdNt54+XJq3WtNQIFnc8OizV6wSl+Haiw55iCOVc5Mtfpbf+Rh9KZZbdPaGFiPA o34A== 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=cCK2bUbse7yru7oE1n3A+8naGre4JcOd9jVp/ZAIUxM=; b=duNd7eb0/i89NMERj906uTzecjW7xIYQoyR1Ktr4Ry0pjAZ5FkMgFCjw42fRM5oADo WVovjGX7wdPUySaj3v18RhIwkQSJS7duqcY/Qn7rnCs0ui9AI+Rd1yJ9jSLqsCO1FsqE q2i+Np0QV/tvAfnmyb7B5zssBaE5JiKlMyBAGC53on8B3R9vYT1raQeu3rWmh5Vc8wiT 2N+mlAzFk7jspMXVTfsZCeN9QilD0Z6CHwyZgsz0zIaNNrD/gmhEVlaQvS5lp4G+oQba 9Rak0DR5gOu6lp0oLE+hMumnfi5RqgcGKX65B4YZCVr5+fxrZl4accyUinP0VzMe4Olt wmQQ== X-Gm-Message-State: AOAM532OdS9vkEghHAlKHJ3QhQY+VgMjIEf5ovranOJlJLPFKltFF2rf u172Ja//X079jjHk4QRLs+cEGFAbEy6D1g== X-Google-Smtp-Source: ABdhPJxNR/EqNGMRJGOY3UXv538omMxTB1E2yuqnhAwnGs9EpYBxdLTvdAmhkO5NAPumbHq+I3/u6g== X-Received: by 2002:a37:491:: with SMTP id 139mr45353356qke.418.1637542166865; Sun, 21 Nov 2021 16:49:26 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:26 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 03/11] 9p: darwin: Handle struct stat(fs) differences Date: Sun, 21 Nov 2021 19:49:05 -0500 Message-Id: <20211122004913.20052-4-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::833 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x833.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- 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, ProxyStatFS *prstfs) stfs->f_bavail = prstfs->f_bavail; stfs->f_files = prstfs->f_files; stfs->f_ffree = prstfs->f_ffree; +#ifdef CONFIG_DARWIN + stfs->f_fsid.val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU; + stfs->f_fsid.val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; +#else stfs->f_fsid.__val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU; stfs->f_fsid.__val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; stfs->f_namelen = prstfs->f_namelen; stfs->f_frsize = prstfs->f_frsize; +#endif } /* Converts proxy_stat structure to VFS stat structure */ @@ -143,12 +148,18 @@ static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat) stbuf->st_size = prstat->st_size; stbuf->st_blksize = prstat->st_blksize; stbuf->st_blocks = prstat->st_blocks; - stbuf->st_atim.tv_sec = prstat->st_atim_sec; - stbuf->st_atim.tv_nsec = prstat->st_atim_nsec; + stbuf->st_atime = prstat->st_atim_sec; stbuf->st_mtime = prstat->st_mtim_sec; - stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec; stbuf->st_ctime = prstat->st_ctim_sec; +#ifdef CONFIG_DARWIN + stbuf->st_atimespec.tv_nsec = prstat->st_atim_nsec; + stbuf->st_mtimespec.tv_nsec = prstat->st_mtim_nsec; + stbuf->st_ctimespec.tv_nsec = prstat->st_ctim_nsec; +#else + stbuf->st_atim.tv_nsec = prstat->st_atim_nsec; + stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec; stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec; +#endif } /* 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 = 512; stbuf->f_blocks = 0; stbuf->f_files = synth_node_count; +#ifndef CONFIG_DARWIN stbuf->f_namelen = NAME_MAX; +#endif return 0; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 9c63e14b28..f4f0c200c7 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1313,11 +1313,17 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, v9lstat->st_blksize = stat_to_iounit(pdu, stbuf); v9lstat->st_blocks = stbuf->st_blocks; v9lstat->st_atime_sec = stbuf->st_atime; - v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; v9lstat->st_mtime_sec = stbuf->st_mtime; - v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_sec = stbuf->st_ctime; +#ifdef CONFIG_DARWIN + v9lstat->st_atime_nsec = stbuf->st_atimespec.tv_nsec; + v9lstat->st_mtime_nsec = stbuf->st_mtimespec.tv_nsec; + v9lstat->st_ctime_nsec = stbuf->st_ctimespec.tv_nsec; +#else + v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; + v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_nsec = stbuf->st_ctim.tv_nsec; +#endif /* Currently we only support BASIC fields in stat */ v9lstat->st_result_mask = P9_STATS_BASIC; @@ -3519,9 +3525,15 @@ static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf) f_bavail = stbuf->f_bavail / bsize_factor; f_files = stbuf->f_files; f_ffree = stbuf->f_ffree; +#ifdef CONFIG_DARWIN + fsid_val = (unsigned int)stbuf->f_fsid.val[0] | + (unsigned long long)stbuf->f_fsid.val[1] << 32; + f_namelen = MAXNAMLEN; +#else fsid_val = (unsigned int) stbuf->f_fsid.__val[0] | (unsigned long long)stbuf->f_fsid.__val[1] << 32; f_namelen = stbuf->f_namelen; +#endif return pdu_marshal(pdu, offset, "ddqqqqqqd", f_type, f_bsize, f_blocks, f_bfree, From patchwork Mon Nov 22 00:49:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62F12C433F5 for ; Mon, 22 Nov 2021 00:51:27 +0000 (UTC) Received: from localhost ([::1]:48860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxYM-0007wq-HF for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:51:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxWV-00044m-AO for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:31 -0500 Received: from [2607:f8b0:4864:20::f2b] (port=41631 helo=mail-qv1-xf2b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxWS-0000x0-OE for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:31 -0500 Received: by mail-qv1-xf2b.google.com with SMTP id m17so11306471qvx.8 for ; Sun, 21 Nov 2021 16:49:28 -0800 (PST) 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=ooNc9C+/G+PaEVIqBJRV5jh7i77KYYOu/GB9/LuUlxA=; b=kbCGJnl4MEe0FBxsKhNp5c0N91Uvz2Rb9d+0jGJ2ymkLwt7b0jfJI+8FJYz4KFu3ce UofQ1SkljAyh0dKoveFQWfzKQo+qW64PDqjxn99iY3+rG3GhXNS7bx+KyFeGpeIzqTMa CRadpvMFM7cUxT+ezX1MQhEqz3lZ0hUVOIJ9snBMWWK0UKM4z+f553tzN22SWaP7PNEK zR1PSuWTQ2BKvOIggl6R0xQPqoFnuatiQmQE+twy2Ii7WY/Pa0uAp5iev4Z2hnW071Xa rB+XGwIcentVUVy4nyse9345kgHHKBMf+x8ufBPoEjUWM8UEfj8CFwX8kNB2cR9vvqQM Nw7g== 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=ooNc9C+/G+PaEVIqBJRV5jh7i77KYYOu/GB9/LuUlxA=; b=fCetWyr1n/1sRdFmJfSjqbDzSbY/LFFNhooEFgE5pm7pMLKullFTwEniNcY5O/ONdc DxMOyv3lMaqwMfayMPeOXn6lykT0900H+SHIcwFQvY1WkoV2fn3+C+LOmh0lLAQGav3L a0srCAUaOhAxAILrYPcJ1GMMFUG9phhXEpHyv31rMSOvNQEYIv+eLxGFkpHxyzn3uwdg n6ayAIsPZmJkubUJ3WzKyUWNG/2rgwmi2J2v8MpkpDyrlxeerJpGWsDwVJ4yTe9cpjy0 aWItUaesuWI8onGKALTzp0MSPk9Rh6DNljrWj4s5j9NIvM/9N8meP+RjcAVcKhf4gg2Z vJYw== X-Gm-Message-State: AOAM532hP7V/fS6U7/3ShwyhL1iwdQPxLJ+f/2OXAg6xhSar9tA/lZf7 s8oU0ChIp2elmWoRLqhlr1Bn50bZep4+zw== X-Google-Smtp-Source: ABdhPJx2fklUq3Dw9JtudVYe9w0qF7q7bPF2nTkbNnYvdm/ox9QI1W7C5aYgFx+IC8KI+L10l3QmpA== X-Received: by 2002:ad4:40c6:: with SMTP id x6mr95054211qvp.32.1637542167824; Sun, 21 Nov 2021 16:49:27 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:27 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 04/11] 9p: darwin: Handle struct dirent differences Date: Sun, 21 Nov 2021 19:49:06 -0500 Message-Id: <20211122004913.20052-5-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2b; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- 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 = node->attr->inode; +#ifndef CONFIG_DARWIN entry->d_off = off + 1; +#endif } static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index f4f0c200c7..c06e8a85a0 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2218,6 +2218,25 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp, return offset; } +/** + * Get the seek offset of a dirent. If not available from the structure itself, + * 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) @@ -2281,7 +2300,11 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, count += len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos = dent->d_off; + saved_dir_pos = v9fs_dent_telldir(pdu, fidp, dent); + if (saved_dir_pos < 0) { + err = saved_dir_pos; + break; + } } v9fs_readdir_unlock(&fidp->fs.dir); @@ -2420,6 +2443,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString name; int len, err = 0; int32_t count = 0; + off_t off; struct dirent *dent; struct stat *st; struct V9fsDirEnt *entries = NULL; @@ -2480,12 +2504,17 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, qid.version = 0; } + off = v9fs_dent_telldir(pdu, fidp, dent); + if (off < 0) { + err = off; + break; + } v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); /* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */ len = pdu_marshal(pdu, 11 + count, "Qqbs", - &qid, dent->d_off, + &qid, off, dent->d_type, &name); 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, } size += len; +#ifdef CONFIG_DARWIN + saved_dir_pos = telldir(fidp->fs.dir.stream); +#else saved_dir_pos = dent->d_off; +#endif } /* restore (last) saved position */ From patchwork Mon Nov 22 00:49:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7D26C433F5 for ; Mon, 22 Nov 2021 00:54:35 +0000 (UTC) Received: from localhost ([::1]:34296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxbP-0000Db-0S for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:54:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxWi-0004hG-V9 for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:44 -0500 Received: from [2607:f8b0:4864:20::835] (port=43864 helo=mail-qt1-x835.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxWT-0000xG-SR for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:44 -0500 Received: by mail-qt1-x835.google.com with SMTP id q14so15060167qtx.10 for ; Sun, 21 Nov 2021 16:49:29 -0800 (PST) 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=UVU8u0+3eX0ac/dq4jOrxKpAcQS3bi3Tumsmx/2i3VE=; b=C97AEHaT0qXCq+5Y6ZV8m97iIlP2CoBT2u6fzKZZG5DUx8tTVRL7n3weYSei83ojHy WSy+QvgRH15VUdDiP3NNAofv5xkCJkg4o+afsNxXl0Q0HJlcVpHuA29H4GBHl6litlBs bY3f9OgDkag7k2wGRtGLsS+qAD4+URgEmm1IVga5CyshkCyqzpbKkrSPa6EOekuMsRcN Ki7dquh90NcH/zIIAR0EnupJCu9w6X9CF1SMgMwLBNiY5BCmj+7xO8Di2WYZpAPo4n5U UCfSJHOE2ywWygTN7nRAvKfot2LQmWcKZSAkyyqc5rBYoc0/kOwGrR4J073OzcVT2jTX 4r/Q== 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=UVU8u0+3eX0ac/dq4jOrxKpAcQS3bi3Tumsmx/2i3VE=; b=LrJISdpUcsJHL/nMw1otkwSbpapixqrHj98HEAp3eYqqgn6jZVUDQMUas8FU08+mrw H2CBwO+3lGMLZvKutKUnuPTGc9JAA4TUjWpJkkOlt3ekMy704tVobWOrqnnnA1LCpgXk 92Qru6Vnri6LjktKO+T9IzumWlOFv4SCNNimwDaCb7goF40YspT/VYEZyNNyeCB1Mb1k XV/8ld8+N6uwYALnydSENFaw9n6eWzxjmh7UtXYREfnFfGh7t+XbVidbCV4zgcH0laD+ e/JbYoHzEYMTbUd6yBG9sVorg9XfmJy7hTnwnqY6wAekGtnBffMuRo8iHLtqDaDLR0yp IjMw== X-Gm-Message-State: AOAM531rT55tTpxCI2+YfNa2E3q6LLM/QhvHfnkSahW9rWyNNBMbrDYS zLxs95u5OglgE0zuR6JhaMYm6bsKwl1VJg== X-Google-Smtp-Source: ABdhPJxTKhyEj8rhl6dB+LaUgCGvJ3O/BJ7LyQlEHU0jbhGqJQaUQye1YbB0CXcut4vkJcxkq/NHTA== X-Received: by 2002:a05:622a:391:: with SMTP id j17mr27322449qtx.228.1637542168804; Sun, 21 Nov 2021 16:49:28 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:28 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 05/11] 9p: darwin: Ignore O_{NOATIME, DIRECT} Date: Sun, 21 Nov 2021 19:49:07 -0500 Message-Id: <20211122004913.20052-6-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::835 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust coding style] 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 = openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK, mode); if (fd == -1) { +#ifndef CONFIG_DARWIN if (errno == EPERM && (flags & O_NOATIME)) { /* * The client passed O_NOATIME but we lack permissions to honor it. @@ -53,6 +54,7 @@ again: flags &= ~O_NOATIME; goto again; } +#endif return -1; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index c06e8a85a0..c941b46f60 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -137,11 +137,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 }, }; @@ -170,10 +179,12 @@ static int get_dotl_openflags(V9fsState *s, int oflags) */ flags = dotl_to_open_flags(oflags); flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT); +#ifndef CONFIG_DARWIN /* * Ignore direct disk access hint until the server supports it. */ flags &= ~O_DIRECT; +#endif return flags; } From patchwork Mon Nov 22 00:49:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20850C433F5 for ; Mon, 22 Nov 2021 00:53:25 +0000 (UTC) Received: from localhost ([::1]:57396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxaG-0005Fn-9z for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:53:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxWW-00047V-32 for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:32 -0500 Received: from [2607:f8b0:4864:20::834] (port=39699 helo=mail-qt1-x834.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxWU-0000xM-Pn for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:31 -0500 Received: by mail-qt1-x834.google.com with SMTP id l8so15086623qtk.6 for ; Sun, 21 Nov 2021 16:49:30 -0800 (PST) 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=gHJPyg96EiGaZTwMNA9CxKSWCqvgoAEHKGY19qxWG4E=; b=AXRLHCIreDU226QBunwXH2GIDh6rzVZaAhgjeSdexT7MXWO4X2XH9ZuVNWeeXLJDUW nkkVrqWct4FvSx1EU4Wvi6dGyeRhPJOV/qUws2AM5gMkG/o8saCkkjXyJvSOroXrYDdu BPJ/wLy5ZdMzeAYXEMgHyvpMahArPL2e90ktZNMqedgvgXtvX450uZdGtlS506f3jewK Mj3uy0Tg4M6qVHN4bTxnqMTqI+bmw5+or3tdSJLoh2T0H5DGke0O2PcEu2mrbzuTsARy cVeklnNWmMdrJQuOJcFORAoF62sH8kOgpWjjxOEs+NsTpAE8/GgbWpMo8MuPewT72ahK sDwA== 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=gHJPyg96EiGaZTwMNA9CxKSWCqvgoAEHKGY19qxWG4E=; b=o64reRwgbJkUEMAmiy/0yGz2WNZZOf/pzutvnGkHwu6mEQmODXgG3vXSQgzQZar2QF pQJEB3k0c7ZzgV6REp2b1/Xr7srT56TCutjSRJqyaKE+JDkLxQErDX3zMEwINSkQDrch ZEtid5CbZnqJzmVJOYi78cGjrk/zc9FIeskO4P4tLynmfY9m1JsMEn5miRIfHN1VvSnG 7sme/8z7G57Pl+k5azf8gzcKDzLLAOfUMY6qrixR4HKasEK0fiO/iCoNjcYYBFjbolzC Hw6qm9dlfzaIdasOqaMVb4UT/Es73bNT+6nDip+8jbznOy1FkxXaiKldEmm1ix5Ft+pS +9BA== X-Gm-Message-State: AOAM533jeTpX2dtk7vYd09PZdFs7OgWxG1TYD3HoBbuqPkcP3Vb1u5/6 6YAHcnFTKJ1Ff3KW+ZNVV43cVABGYcMk3A== X-Google-Smtp-Source: ABdhPJwN4EavcUpOuSwnDDZJK9LYNeNkNta++fdQF9xAejkxeIEH5eL2qfHhc5jM+W+Kk9VFN7/3cg== X-Received: by 2002:a05:622a:1a03:: with SMTP id f3mr26880193qtb.141.1637542169549; Sun, 21 Nov 2021 16:49:29 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:29 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 06/11] 9p: darwin: Compatibility defn for XATTR_SIZE_MAX Date: Sun, 21 Nov 2021 19:49:08 -0500 Message-Id: <20211122004913.20052-7-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::834 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust coding style] 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 c941b46f60..d671995aa4 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3943,6 +3943,14 @@ out_nofid: v9fs_string_free(&name); } +#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 = 0; From patchwork Mon Nov 22 00:49:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5495CC433EF for ; Mon, 22 Nov 2021 00:54:52 +0000 (UTC) Received: from localhost ([::1]:35374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxbf-0000x3-Dx for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:54:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxWW-000496-Re for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:33 -0500 Received: from [2607:f8b0:4864:20::f2f] (port=38628 helo=mail-qv1-xf2f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxWV-0000xQ-4m for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:32 -0500 Received: by mail-qv1-xf2f.google.com with SMTP id a24so11340305qvb.5 for ; Sun, 21 Nov 2021 16:49:30 -0800 (PST) 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=LtTpcGKmGqBvRmAbEh2LW1gO3KOlVqc7je6R2Ml/UdE=; b=pCbt4vJk6d5jKitQXf2Ind3dDSKBKQE7gfc+Iaj4X1usXM/TBa86vu99MwX5bGQt8m o4jKllaufBeevjwxW2y0jVoUuifRwgQSVKNGwVvAfWMqlfGEptrcqQgArLmuHLpxN3df XPPcWdoIIi0fT/usPGHYhJcYtlHBRzRwNtUxw2MZJFKChZ+0eVDlmHuJQo0WgPmu7I8a 3Hr/4ZmGx4Kbpil6O2lpvQ9v/B2TrE1LBGqjgac8WekvXryvkgBMjMfjuqJfmgswcgJa 7LwxfmxEWrU9v0gKNJU97tzB7mz5dBWAleyQMFAsPVK6CzS+lGhuUZW+Sl112YEhWzOz 2ydg== 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=LtTpcGKmGqBvRmAbEh2LW1gO3KOlVqc7je6R2Ml/UdE=; b=02qm4XGvSros50MzkRNQeMX/KF+m57rKsdZ6shYjrdljPotMGGMpZ+mIgwA6bsc558 p7kGnCjOlm9YcjsFwORCO78MxDUub+u5dquwuSDtwvdMptrJnTmS0MfglNTSs4HLuBNy 3G7W7SMw2UbAEJXZqENe3Og8uVm6L9tXwqKlPCycQKc2Yjt8ou8D0EPX+LqEk3BLEVju vM7qHIobyP2hqAyFklsSznI/SqdDhmPNqemW9ICGiAcO9QwsbSMlaQKRtc+ryedsRWKq Xl6zEAgQTo3LgTDdsYn+2C0n/GpU1ql2lasDZL5rw1hkNnm+r4HZ13X6j/ujE9DDYLvk Lt6g== X-Gm-Message-State: AOAM530OL58tQ/oFDONcb4Rk47xJp2gUZqmGwVxqr9XnLRMJW+eUrOfA 2JnTstwnljFGdHaTRdFASNyOD9KJ9KKkiA== X-Google-Smtp-Source: ABdhPJz0C7oHGmzY0konzKbGNWngn+3FMaY1c7uqaXsBmRDXGrl3Web2Z5I/wO8+aFnxccF6//vwMw== X-Received: by 2002:a05:6214:d8e:: with SMTP id e14mr98756075qve.50.1637542170210; Sun, 21 Nov 2021 16:49:30 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:29 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 07/11] 9p: darwin: *xattr_nofollow implementations Date: Sun, 21 Nov 2021 19:49:09 -0500 Message-Id: <20211122004913.20052-8-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2f (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- 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 later. + * 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 = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = 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 = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = 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 = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = 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 = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = 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) From patchwork Mon Nov 22 00:49:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3BB6AC433F5 for ; Mon, 22 Nov 2021 00:51:04 +0000 (UTC) Received: from localhost ([::1]:47388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxXz-0006zG-80 for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:51:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxWX-00049p-Gc for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:33 -0500 Received: from [2607:f8b0:4864:20::82e] (port=37722 helo=mail-qt1-x82e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxWV-0000xd-OP for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:33 -0500 Received: by mail-qt1-x82e.google.com with SMTP id f20so15071959qtb.4 for ; Sun, 21 Nov 2021 16:49:31 -0800 (PST) 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=zcMIBtIRje8FHwrfkPF9thMagQnucgcETi34ZcFHWNQ=; b=hfy0KqMgETqsTRrR4MWt2u6fQSxzZA3jNhqFUvyn4gbRC5+LZt+wnY0OR9GWzLB33e 4WTbULhdJqpalISPwIujy6rwiDSgy1h8oDNBdNT60FeKPJ4wyNoZWlWVAtS13QSTly9k az4b1tueSm5rzdIfnMZm93liC7MnvQquoWrmelzOHHtNKY47ya9dHSftARQYO0OtBKtC 9DE83NOQw6SKxyY02JbWPMxx/lsctYGP1JubDaj6ncKREUBrSTYpSpMkwWt9O9rczPui z4jqBy/mF9eONWKaUh877yzgRvIck3lET1jOQXB8g4Q90f4OqkI5C7RjjJh1wSLRyc7v 0ZJA== 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=zcMIBtIRje8FHwrfkPF9thMagQnucgcETi34ZcFHWNQ=; b=CvDxElmESDeAupnB+CIiIKzxozF4/fL5NHITVgoMTWql+EC5qx93XGyj0f4R8Ayu17 PRtoU18uSSe4Y3U/ZOzeGfvD2r+ATkvzesHCUpL/zvWuEHtHtRyL9Ung3HkhKcD3eqbU 5EFHgaZRzwwhf+U54QHn2SoChy0mdpNk3bDiYaFxYN/1MtcKDBy/Dj9aeyYiphG/G0nS lpO/ekATDvOiZQV3wJFK6EmfIBS3G9V+2V0O/E9uPlF4+LSZ99gqUZWf+PapVYkke5GW zQnV6H+qslYeULW8s1hWPm4ilPcHGxDgAy5l0LvOd8HylwqLlfT4FNL3XALYrtBmq2YU QV6g== X-Gm-Message-State: AOAM532yKGqRd5QB6x1JmjlmeP70RlaFwDMEydCUMoR59W7ofF/fQvn+ 76lPjb0lDpajsbyo42DyS12HMepRrqfC3w== X-Google-Smtp-Source: ABdhPJzcbQiLPYdper7XJoNkNQi3lAW3pgPRNOnVQhnSd7fsedwNLMsP00K1RGLEJ5S3yq2sV5YS3Q== X-Received: by 2002:ac8:202:: with SMTP id k2mr27013059qtg.398.1637542170865; Sun, 21 Nov 2021 16:49:30 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:30 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 08/11] 9p: darwin: Compatibility for f/l*xattr Date: Sun, 21 Nov 2021 19:49:10 -0500 Message-Id: <20211122004913.20052-9-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82e.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- 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_type, mode_t tmp_mode; dev_t tmp_dev; - 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 = 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 = 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 = 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 = 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 +#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 = errno; From patchwork Mon Nov 22 00:49:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7214C433EF for ; Mon, 22 Nov 2021 00:57:17 +0000 (UTC) Received: from localhost ([::1]:40938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxe1-0004pf-2p for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:57:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxcb-0002k1-NL for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:55:49 -0500 Received: from [2607:f8b0:4864:20::f30] (port=42694 helo=mail-qv1-xf30.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxcZ-0001is-MZ for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:55:49 -0500 Received: by mail-qv1-xf30.google.com with SMTP id b17so11336070qvl.9 for ; Sun, 21 Nov 2021 16:55:47 -0800 (PST) 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=6/FI/gIVcuCmFj1315nRIJkD7aP2LvmufA/USxsxLcc=; b=mzlsLH8f/35XTn8DtNuvyA1rrOZGhtjkzN/fA67MQ/C8wl8HNBpkMqsopfMcBRRriJ QONxcVdvMRB3qR9cKSDRtm050P3C3Va4HWs0ccx1R3AjfhFfgYRjnyXMdvdlWGSdzFSR xetjNUufRODT5I+JlntxNwOMDSmWXz6U4/R2cLIvKRMuKZLgbRSng+q+2KiHF9BauUIA x9RILtNxI+6RmQ069LVGcMUKCIrhNoq86MuElX/jkLnZ3S0kILlrT60+wrZoGircCuNT /+AClePVOLCCcNwDLuYhED7wD6KFKd2ryPM5N3vSry2DuJUtzhsx9L7IP5woLeG0/yUS +XiA== 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=6/FI/gIVcuCmFj1315nRIJkD7aP2LvmufA/USxsxLcc=; b=xhAX1Hz5xrsjMu1XdvX+cIQxoZ3ufO/RJwX4ePktS46UtvbmT6YUg2Mm3NA1+WqfS0 aSjAWy+TyIazeTWy4emvqPf/K7Cf8GmwVGGkzNKXPtF+ZOrpnrrUdXDGOQx9Go5MuTiO i7M4wltfxgjKmHoas9YqgiEuApVoszpPqnjfr+Uj08/vXWhg5jt/dm/aUeT8A0M2rSi5 VrT38qEIZW0pfAcaY7CGl+wXZV3cZlz+huP1gNnlrQhuCkfM2D2weFMoghX48+05Wdi5 uc+J5oAT3/Kbav6EGygWQfQxoVPsMyrTZx370cu2aLpPV6qvSZH/njwJO2/pvVPdXsD8 m+Cg== X-Gm-Message-State: AOAM531NTy7DPePKJcL5K9FjYb4QZmJHX4P7eEPYAHePmcU9ILFrCUZ+ gAokGQHadat2aPiByNEouWbGnQLoWR+F/A== X-Google-Smtp-Source: ABdhPJxGjJc0MnaPRgPPEJ9tzOKcyWiMMLanMrJYRVYSv9Eh/ZheqTqHBT8tgMtZjCkmZv1rnUepfg== X-Received: by 2002:ad4:5aa4:: with SMTP id u4mr96575131qvg.7.1637542171477; Sun, 21 Nov 2021 16:49:31 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:31 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 09/11] 9p: darwin: Provide fallback impl for utimensat Date: Sun, 21 Nov 2021 19:49:11 -0500 Message-Id: <20211122004913.20052-10-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f30 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf30.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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, __builtin_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 Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- 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; } - ret = utimensat(dirfd, name, buf, AT_SYMLINK_NOFOLLOW); + ret = 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 = fstat(fd, &buf); + if (ret == -1) { + return ret; + } + if (update0) { + times[0] = buf.st_atimespec; + } + if (update1) { + times[1] = 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 >= __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 = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + + special0 = times[0].tv_nsec == UTIME_OMIT; + special1 = times[1].tv_nsec == UTIME_OMIT; + if (special0 || special1) { + /* If both are set, nothing to do */ + if (special0 && special1) { + ret = 0; + goto done; + } + + ret = update_times_from_stat(fd, times, special0, special1); + if (ret < 0) { + goto done; + } + } + + special0 = times[0].tv_nsec == UTIME_NOW; + special1 = times[1].tv_nsec == UTIME_NOW; + if (special0 || special1) { + ret = futimes(fd, NULL); + if (ret < 0) { + goto done; + } + + /* If both are set, we are done */ + if (special0 && special1) { + ret = 0; + goto done; + } + + ret = update_times_from_stat(fd, times, special0, special1); + if (ret < 0) { + goto done; + } + } + + futimes_buf[0].tv_sec = times[0].tv_sec; + futimes_buf[0].tv_usec = times[0].tv_nsec / 1000; + futimes_buf[1].tv_sec = times[1].tv_sec; + futimes_buf[1].tv_usec = times[1].tv_nsec / 1000; + ret = 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 +/* 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 = errno; @@ -96,5 +102,7 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *filename, 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]); #endif diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index d671995aa4..3d676405c7 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" From patchwork Mon Nov 22 00:49:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20BC0C433EF for ; Mon, 22 Nov 2021 00:52:49 +0000 (UTC) Received: from localhost ([::1]:55322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxZg-0003qz-9c for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:52:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxWZ-0004Ez-78 for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:35 -0500 Received: from [2607:f8b0:4864:20::82b] (port=38581 helo=mail-qt1-x82b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxWX-0000y2-9T for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:34 -0500 Received: by mail-qt1-x82b.google.com with SMTP id 8so15110829qtx.5 for ; Sun, 21 Nov 2021 16:49:32 -0800 (PST) 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=OppviOV0ENXWhcHY3INrgnTZBqYXRIokhy4By5SCg1Y=; b=MS83UT5+I5MW5elJkEpF7rdB6pRY+YeS5xNFlTNAL3IWgH/BU/9sDLS2Xa1+T+0SJV CpPcqo4wC4zBJccS4L03r6thqG2HnQBqpWMD49WIqT/cMMfn9dInezN6Jodft3UxVkjp IDX4TqpDHBTBMStC/cbPOrVDD3ppfXlb2Xm2RoOgUvxCcGtTQhpeVTbKuWU/Y9szPxgY JGwnzQ+NT/GyQ1NleWcuE50hTI+CFILzwaU2udBqp5jH0QVYtxr8rFlnj82DLRKmfXD2 vJ5rtg2XmrxKYv74Ovz5vCP9vwOqjxdpl427HOgBCMfxWZ2qwNZAcv0opmKdDg3eo05x Er8w== 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=OppviOV0ENXWhcHY3INrgnTZBqYXRIokhy4By5SCg1Y=; b=MAtxo6fMFDKgHnLNoI7Pp1qejaYY4b8X4LWeUzJevb/NJPkB51yZ235CCfk9IADTbu hAkPQ5QFLFN+0nee2LcV0vqdPuc48nQ6f5VZdZlGiwqdj2+1PdYERlvcvOHM19XMY9wr QqsELqp2o8JhAzLH8BjFsPA1hH2TU5Tuayuf1gPEVDUZ9UfTSBntR93NoeZ5S361llOG ZMh/prUw9romw0wIkmxd/djryFslqmtnw+vXW9gnTBxXFC61YYTstpei+qryCYvZhbOH lOuse0Cg1i5JJKkW8quS1+35aKYZXIRdNf2iFkCejBfswjWOEOfuXc/SFMIDYH/p+Ef/ /GQA== X-Gm-Message-State: AOAM533ZLFzxl9nNJ1GWR345yyD5AhsW+F438sSsQ/M4LWZxGVEh35i7 alazMjSdt905vW+YG0gDspd4YnuLvrpEDQ== X-Google-Smtp-Source: ABdhPJyZkdwa3kBOMGnRk+NmjYhwzKE3WcPbwkH2LipF+b+bj5y16M0kTdsNYeVB94uQAwhI9zFUMw== X-Received: by 2002:ac8:7f85:: with SMTP id z5mr26400402qtj.171.1637542172132; Sun, 21 Nov 2021 16:49:32 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:31 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 10/11] 9p: darwin: Implement compatibility for mknodat Date: Sun, 21 Nov 2021 19:49:12 -0500 Message-Id: <20211122004913.20052-11-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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: Michael Roitzsch [Will Cohen: - Adjust coding style] 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, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - err = mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); + err = qemu_mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); if (err == -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 = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); + err = qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; } @@ -701,6 +701,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, 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 = mknod(filename, mode, dev); + preserved_errno = errno; + /* Stop using the thread-local cwd */ + fchdir_thread_local(-1); + if (err < 0) { + errno = 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]); +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); + #endif From patchwork Mon Nov 22 00:49:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12631121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4CEE7C433F5 for ; Mon, 22 Nov 2021 00:52:55 +0000 (UTC) Received: from localhost ([::1]:55742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moxZm-00047M-8g for qemu-devel@archiver.kernel.org; Sun, 21 Nov 2021 19:52:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moxWZ-0004F1-76 for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:35 -0500 Received: from [2607:f8b0:4864:20::72c] (port=46683 helo=mail-qk1-x72c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moxWX-0000yE-RV for qemu-devel@nongnu.org; Sun, 21 Nov 2021 19:49:34 -0500 Received: by mail-qk1-x72c.google.com with SMTP id a11so16418108qkh.13 for ; Sun, 21 Nov 2021 16:49:33 -0800 (PST) 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=sVL92mTvh6v8iF1R3vWkKRUUlyjnSFC3fOOV0v2z5ak=; b=I4B0dGE16e8GGX5KPhiJLJm7kAmblYHohvqe6SU0cwXXIARJrlEg/9f6zBSjLdm/Fd 47/K9hgy4tNwnalJjqAavKI9+bWWqGwZBWqG0ZmXNyXhk023Z/DnFhhYxafJQtabcT9W Y943vRFxCEwbYbirjGG53tnMgoenxh2Rq1kvBkE2aPOpGav4U9F5xLdbD8psAr8SB1en 1yE/NT6RYqfUzQAQdEM7uoHxTx3RPgsEuFtn66Eu1xi80v5HORZxbSDvZg0mXbJSSzba VMRQVAv0fSPsfaJooH9YeXxRr6yo5D0qvAPgYboN0HTNxisrffnHdrx3Eg1Wq2ggq4bh jO7w== 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=sVL92mTvh6v8iF1R3vWkKRUUlyjnSFC3fOOV0v2z5ak=; b=L41A7pkqv3I6jur04x4CmbqY0xUTcgJoNwOuc1qcOzDWr9h2rZYOALnUsbahhgn6P7 ymVW4jknMf55yPmZWhCigZrYr5RoXKzIR7vtuxwKtNmBnIez5ddvqKDAmj+jMU8bVHwE 7ZIoA9PjXusEovqrlYka0lckpNKeOtjVYQjaFCfCU1GuQdyq3CUPq/t4P0KXLABmX8PV YJMSS+4E9YX+YnK2ZuVtH8n3u9T97TB6INtuvUyDawLrO2p39EqO2EQ8D3hxE9nY2TDZ NxX5rgommPqRe+3qFaY96SBAedBWVIbV0f3Xev9yzaN1tb37N0WO25CeES2HLcs8isXc +t1w== X-Gm-Message-State: AOAM5327hjesi8CfeTI3Z6/9NusQ3xr2cIdPLn6BqHo75kWC4LDCJ9V5 7aRU9fp29ce6Fk87NR9B8U7qmn+yswzW3w== X-Google-Smtp-Source: ABdhPJzJO7+38kVv+boOowRn0tnopMwGe4hD7SDOxbnLf93sKeMumLmQ/wSljH5+CgG14XO6AvQgFQ== X-Received: by 2002:a05:620a:915:: with SMTP id v21mr44140257qkv.449.1637542172997; Sun, 21 Nov 2021 16:49:32 -0800 (PST) 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 x17sm3651745qta.66.2021.11.21.16.49.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Nov 2021 16:49:32 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v2 11/11] 9p: darwin: meson: Allow VirtFS on Darwin Date: Sun, 21 Nov 2021 19:49:13 -0500 Message-Id: <20211122004913.20052-12-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122004913.20052-1-wwcohen@gmail.com> References: <20211122004913.20052-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::72c (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Christian Schoenebeck , Keno Fischer , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Rebase to master] Signed-off-by: Will Cohen --- fsdev/meson.build | 1 + meson.build | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 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) if have_virtfs_proxy_helper executable('virtfs-proxy-helper', diff --git a/meson.build b/meson.build index 96de1a6ef9..0f92adea52 100644 --- a/meson.build +++ b/meson.build @@ -1383,17 +1383,21 @@ endif have_host_block_device = (targetos != 'darwin' or cc.has_header('IOKit/storage/IOMedia.h')) -have_virtfs = (targetos == 'linux' and +if targetos == 'darwin' + have_virtfs = have_system +else + have_virtfs = (targetos == 'linux' and have_system and libattr.found() and libcap_ng.found()) +endif -have_virtfs_proxy_helper = have_virtfs and have_tools +have_virtfs_proxy_helper = targetos == 'linux' and have_virtfs and have_tools if get_option('virtfs').enabled() if not have_virtfs - if targetos != 'linux' - error('virtio-9p (virtfs) requires Linux') + if targetos != 'linux' and targetos != '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