From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH v2] Cygwin: Have tmpfile(3) use O_TMPFILE
Date: Fri, 12 Feb 2021 10:20:23 +0100 [thread overview]
Message-ID: <20210212092023.GH4251@calimero.vinschen.de> (raw)
In-Reply-To: <20210211065306.457-1-mark@maxrnd.com>
On Feb 10 22:53, Mark Geisert wrote:
> Per discussion on cygwin-developers, a Cygwin tmpfile(3) implementation
> has been added to syscalls.cc. This overrides the one supplied by
> newlib. Then the open(2) flag O_TMPFILE was added to the open call that
> tmpfile internally makes.
>
> This v2 patch removes O_CREAT from open() call as O_TMPFILE obviates it.
> Note that open() takes a directory's path but returns an fd to a file.
> ---
> winsup/cygwin/release/3.2.0 | 4 ++++
> winsup/cygwin/syscalls.cc | 17 +++++++++++++++++
> 2 files changed, 21 insertions(+)
>
> diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0
> index f748a9bc8..d02d16863 100644
> --- a/winsup/cygwin/release/3.2.0
> +++ b/winsup/cygwin/release/3.2.0
> @@ -19,6 +19,10 @@ What changed:
>
> - A few FAQ updates.
>
> +- Have tmpfile(3) make use of Win32 FILE_ATTRIBUTE_TEMPORARY via open(2)
> + flag O_TMPFILE.
> + Addresses: https://cygwin.com/pipermail/cygwin/2021-January/247304.html
> +
>
> Bug Fixes
> ---------
> diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
> index 52a020f07..4cda69033 100644
> --- a/winsup/cygwin/syscalls.cc
> +++ b/winsup/cygwin/syscalls.cc
> @@ -5225,3 +5225,20 @@ pipe2 (int filedes[2], int mode)
> syscall_printf ("%R = pipe2([%d, %d], %y)", res, read, write, mode);
> return res;
> }
> +
> +extern "C" FILE *
> +tmpfile (void)
> +{
> + char *dir = getenv ("TMPDIR");
> + if (!dir)
> + dir = P_tmpdir;
> + int fd = open (dir, O_RDWR | O_BINARY | O_TMPFILE, S_IRUSR | S_IWUSR);
> + if (fd < 0)
> + return NULL;
> + FILE *fp = fdopen (fd, "wb+");
> + int e = errno;
> + if (!fp)
> + close (fd); // ..will remove tmp file
> + set_errno (e);
> + return fp;
> +}
The patch was missing the EXPORT_ALIAS for tmpfile64, as outlined in
https://cygwin.com/pipermail/cygwin-developers/2021-February/012039.html
I added this to the patch and pushed it.
Thanks,
Corinna
next prev parent reply other threads:[~2021-02-12 9:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 6:53 Mark Geisert
2021-02-12 9:20 ` Corinna Vinschen [this message]
2021-02-12 10:15 ` Mark Geisert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210212092023.GH4251@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin-patches@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).