From mboxrd@z Thu Jan 1 00:00:00 1970 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 08921C433F5 for ; Mon, 7 Feb 2022 01:11:55 +0000 (UTC) Received: from localhost ([::1]:43364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGsZO-0003YD-Mv for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 20:11:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGsYK-0002m8-2T for qemu-devel@nongnu.org; Sun, 06 Feb 2022 20:10:49 -0500 Received: from [2a00:1450:4864:20::131] (port=40800 helo=mail-lf1-x131.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGsYE-0000T3-CF for qemu-devel@nongnu.org; Sun, 06 Feb 2022 20:10:46 -0500 Received: by mail-lf1-x131.google.com with SMTP id a28so23782300lfl.7 for ; Sun, 06 Feb 2022 17:10:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xoMZB4ohnNU2e1QV/2Wg2eRzPnpP79h3Cb7uY8wGFpY=; b=bAZmVaS0+HnPMVLWOgFJyx76IfDXH3BKDOl8ifCHtPINZ1Zcfb4p8V/mgsplw1+GFj 2kL6hpJJYrz5AGTUgGWJtQdLfYaipy5+9kJe2c631bJZfiSuM3sgb6knLibn8wTQHXoP GSZgPv4/des/7pVSK31xFe2eLsJytcqEr5FK9VzOGVPeflqzG/jvWGbOCYqjOYNHthFb HLmB4rTTKzma9bGz3yGUqgJ3iTuSviNx/Fjd4TDjTx8Tu8xNhpDiiyVhpqRCf3EkOBQv UIlGlieqPp32YQu3OYzA57tVkT33r/Hs2qOxXmyuwwGclifn2OLPVS+k7RAe+d4P+jHI H7Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xoMZB4ohnNU2e1QV/2Wg2eRzPnpP79h3Cb7uY8wGFpY=; b=OruX8fYUIUdemjkudUJNKkrMwlNApDVx0WSmYY5G16vXLitWD9Y3B/c1EnoCTZmt/T dH/awpogXT5hZ84Xfvs021LM8MgibNoDvYWe/3gUpomcUEZXZdU1MznwBZNemBIFmRX7 oY5FILqQDrWER3OsYdxA6IswSOuV2WbhS5dsi7AObZsTlsse+8BePjNJ/eu3I7z9ncQJ 59K/tDLaqoa+C5Qn+wojuoN7s9c0pMvXHJog5oc4jXAcH5lECVcRUmZRPtOlzTnYLIyt N7QvPWeawfVwEWCdccuf3gIvWgRaZtzCvY2uylIff+EDQytJeCnQq9/etXe0ud3bTUuv fpUw== X-Gm-Message-State: AOAM532n6pdh0y4Cw7va9KDjPxXPCUwrRLFsP8ioryBgbZ55hJymRw2m MH2Zympa2k4vHgag6nFIH/MiLLNLQ3U3tZEYou0= X-Google-Smtp-Source: ABdhPJws4epUTM9aF1hgTGjAsfEqFAJwzDJACQubtHRJ6Sx1QH7F5TNjibbDbTLE2+/zL58iwn3l+h3F26X9520fUwg= X-Received: by 2002:a05:6512:3123:: with SMTP id p3mr7170690lfd.298.1644196235042; Sun, 06 Feb 2022 17:10:35 -0800 (PST) MIME-Version: 1.0 References: <20220206200719.74464-1-wwcohen@gmail.com> <20220206200719.74464-10-wwcohen@gmail.com> In-Reply-To: From: Will Cohen Date: Sun, 6 Feb 2022 20:10:23 -0500 Message-ID: Subject: Re: [PATCH v4 09/11] 9p: darwin: Implement compatibility for mknodat To: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Content-Type: multipart/alternative; boundary="00000000000087e34a05d7634493" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::131 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::131; envelope-from=wwcohen@gmail.com; helo=mail-lf1-x131.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, HTML_MESSAGE=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, T_SCC_BODY_TEXT_LINE=-0.01 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: Laurent Vivier , Thomas Huth , Christian Schoenebeck , qemu-devel@nongnu.org, Greg Kurz , hi@alyssa.is, Michael Roitzsch , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000087e34a05d7634493 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This patch set currently places it in 9p-util only because 9p is the only place where this issue seems to have come up so far and we were wary of editing files too far afield, but I have no attachment to its specific location! On Sun, Feb 6, 2022 at 4:21 PM Philippe Mathieu-Daud=C3=A9 wrote: > On 6/2/22 21:07, Will Cohen wrote: > > 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 includes a function > > that sets the cwd for the current thread only. > > This should suffice to use mknod safely. > > > > This function (pthread_fchdir_np) is protected by a check in > > meson in a patch later in tihs series. > > > > Signed-off-by: Keno Fischer > > Signed-off-by: Michael Roitzsch > > [Will Cohen: - Adjust coding style > > - Replace clang references with gcc > > - Note radar filed with Apple for missing syscall > > - Replace direct syscall with pthread_fchdir_np and > > adjust patch notes accordingly] > > Signed-off-by: Will Cohen > > --- > > hw/9pfs/9p-local.c | 5 +++-- > > hw/9pfs/9p-util-darwin.c | 27 +++++++++++++++++++++++++++ > > hw/9pfs/9p-util-linux.c | 5 +++++ > > hw/9pfs/9p-util.h | 2 ++ > > 4 files changed, 37 insertions(+), 2 deletions(-) > > > diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h > > index 8e610ad224..f6fed963bf 100644 > > --- a/hw/9pfs/9p-util.h > > +++ b/hw/9pfs/9p-util.h > > @@ -97,6 +97,8 @@ ssize_t flistxattrat_nofollow(int dirfd, const char > *filename, > > ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, > > const char *name); > > > > +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t > dev); > > I think this belong to "osdep.h" & os-posix.c. > --00000000000087e34a05d7634493 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This patch set currently places it in 9p-util only because= 9p is the only place where this issue seems to have come up so far and we = were wary of editing files too far afield, but I have no attachment to its = specific location!

On Sun, Feb 6, 2022 at 4:21 PM Philippe Mathieu-Daud= =C3=A9 <f4bug@amsat.org> wrote= :
On 6/2/22 21:0= 7, Will Cohen wrote:
> From: Keno Fischer <keno@juliacomputing.com>
>
> 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 includes a function
> that sets the cwd for the current thread only.
> This should suffice to use mknod safely.
>
> This function (pthread_fchdir_np) is protected by a check in
> meson in a patch later in tihs series.
>
> Signed-off-by: Keno Fischer <keno@juliacomputing.com>
> Signed-off-by: Michael Roitzsch <reactorcontrol@icloud.com>
> [Will Cohen: - Adjust coding style
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- Replace clang = references with gcc
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- Note radar fil= ed with Apple for missing syscall
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- Replace direct= syscall with pthread_fchdir_np and
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0adjust pa= tch notes accordingly]
> Signed-off-by: Will Cohen <wwcohen@gmail.com>
> ---
>=C2=A0 =C2=A0hw/9pfs/9p-local.c=C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 5 +++= --
>=C2=A0 =C2=A0hw/9pfs/9p-util-darwin.c | 27 +++++++++++++++++++++++++++<= br> >=C2=A0 =C2=A0hw/9pfs/9p-util-linux.c=C2=A0 |=C2=A0 5 +++++
>=C2=A0 =C2=A0hw/9pfs/9p-util.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 ++<= br> >=C2=A0 =C2=A04 files changed, 37 insertions(+), 2 deletions(-)

> diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h
> index 8e610ad224..f6fed963bf 100644
> --- a/hw/9pfs/9p-util.h
> +++ b/hw/9pfs/9p-util.h
> @@ -97,6 +97,8 @@ ssize_t flistxattrat_nofollow(int dirfd, const char = *filename,
>=C2=A0 =C2=A0ssize_t fremovexattrat_nofollow(int dirfd, const char *fil= ename,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0const char *name); >=C2=A0 =C2=A0
> +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t = dev);

I think this belong to "osdep.h" & os-posix.c.
--00000000000087e34a05d7634493--