From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E985065748 for ; Thu, 23 Jul 2020 12:58:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E6D3E2854C for ; Thu, 23 Jul 2020 12:58:52 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 0A95728542 for ; Thu, 23 Jul 2020 12:58:52 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B94E343323 for ; Thu, 23 Jul 2020 12:58:51 +0200 (CEST) Date: Thu, 23 Jul 2020 12:58:43 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20200723093824.20056-1-m.limbeck@proxmox.com> In-Reply-To: <20200723093824.20056-1-m.limbeck@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1595500927.o7a7kiv177.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.059 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pbs-devel] [PATCH 1/2] add tempfile helper without O_TMPFILE or memfd_create X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jul 2020 10:58:53 -0000 On July 23, 2020 11:38 am, Mira Limbeck wrote: > As WSL does not support O_TMPFILE nor memfd_create, we need a different > way to create tempfiles if we want to support windows host backups > through WSL (without ADS). > The workaround is to use mkstemp in /tmp and unlinking the file > right after creation. >=20 > Add FIXME comment to change it back to O_TMPFILE once we no longer requir= e > the mkstemp workaround for windows support. >=20 > Signed-off-by: Mira Limbeck > --- > src/tools.rs | 1 + > src/tools/tempfile.rs | 13 +++++++++++++ > 2 files changed, 14 insertions(+) > create mode 100644 src/tools/tempfile.rs >=20 > diff --git a/src/tools.rs b/src/tools.rs > index 44db796d..5e892d41 100644 > --- a/src/tools.rs > +++ b/src/tools.rs > @@ -30,6 +30,7 @@ pub mod fs; > pub mod format; > pub mod lru_cache; > pub mod runtime; > +pub mod tempfile; > pub mod ticket; > pub mod timer; > pub mod statistics; > diff --git a/src/tools/tempfile.rs b/src/tools/tempfile.rs > new file mode 100644 > index 00000000..a91ce806 > --- /dev/null > +++ b/src/tools/tempfile.rs > @@ -0,0 +1,13 @@ > +use nix::unistd::{mkstemp, unlink}; > +use std::fs::File; > +use std::os::unix::io::FromRawFd; > +use anyhow; > + > +// FIXME change to O_TMPFILE once a native windows backup client exists shouldn't we try O_TMPFILE first, and only if it fails fall back to=20 mkstemp? or guard this with a feature ("wsl")? also not sure whether all=20 current (and future) callers are okay with the different semantics (with=20 mkstemp the file is briefly available via a path even if you unlink it=20 directly afterwards..). it also might be better off in proxmox instead of proxmox-backup, it's a=20 very generic function after all.. > +pub fn tempfile() -> anyhow::Result { > + let (fd, path) =3D mkstemp("/tmp/proxmox-backup-client_XXXXXX")?; > + unlink(path.as_path())?; > + let file =3D unsafe { File::from_raw_fd(fd) }; > + > + Ok(file) > +} > --=20 > 2.20.1 >=20 >=20 >=20 > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel >=20 >=20 >=20 =