From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) by sourceware.org (Postfix) with ESMTPS id 54AAC383E826 for ; Mon, 8 Feb 2021 10:34:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 54AAC383E826 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1My6xz-1m81yO2WEB-00zTCr for ; Mon, 08 Feb 2021 11:34:03 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id D8152A80934; Mon, 8 Feb 2021 11:34:02 +0100 (CET) Date: Mon, 8 Feb 2021 11:34:02 +0100 From: Corinna Vinschen To: cygwin-developers@cygwin.com Subject: Re: Extending domain of O_TMPFILE? Message-ID: <20210208103402.GP4251@calimero.vinschen.de> Reply-To: cygwin-developers@cygwin.com Mail-Followup-To: cygwin-developers@cygwin.com References: <20210205112650.GO4251@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:Ws7f8+Q6lX1h7HHkcMu0fGBQgT2L5fXrc/HZK6b8JKrOd9aWkSY iXrPkLdDX6HBrWMDg20IsHmAJTFg6qI9XUP2EtAC3BY1qQtEpF/jpWhVVhRRAywyM9EXcvA ADwPtHkC885QitJx6iHyibqhM4iRCxxn2ED+iYrDq2xmXKkIOOGuk4JlHc8d/0xMnK1HF27 oPnYNlnntc83d6v+VrNEA== X-UI-Out-Filterresults: notjunk:1;V03:K0:0FbQYzne5kw=:Ij0ZFZpocX4T+a3pCxB1CP FmBOzgqj1C4JUjRAhc/sOtfMDOPlx/+58LKsVAiVnAy/enU5atQiV3ulA7FwM8Uc3rhLNdNK0 h3e30N4w61wz8jhyFw1hNU99ZfGTvf201v8SLRa0kTk4PCnV0GjZ7Sa3tuXHkSzL7u71yYbcX wf0RNQb7csNuDPDa2EPgkeK+6e95cSrDWcfIO7eo+lt7vgDzge9LkHu+si9H05pGglp1uV8Jr o1qAjWvjghy3wLre84De0mgB2GYZ1LNJKA/hGQWbkDK7tPISbwLLgEmi8COe+7//kZGqoRSc9 Et2fSWqA1DqFTdJi2ts419HgRM3pfWBAyVzyM+fqf5ZLZX6rpiguFFmjmMtHbJdHpmkQQWk6B KXDtdzdD0ecg8/tUhxsLNMkBtcEkEcUMoYrVZf4p6NIcFYRlxgq1qq1nW5wFEubONyxWUMTeH 3EHvvOx4tQ+w1w46tc+YyyCh/79RMbm5mmfsJFpb01ETs2ca8xDHgflfp3vGbN8wEV4zpTeGp w== X-Spam-Status: No, score=-101.2 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Feb 2021 10:34:10 -0000 On Feb 5 23:56, Mark Geisert wrote: > On Fri, 5 Feb 2021, Corinna Vinschen via Cygwin-developers wrote: > > On Feb 5 02:31, Mark Geisert wrote: > > > Hi folks, > > > I've been following up on a response I made to a Cygwin user in > > > https://cygwin.com/pipermail/cygwin/2021-January/247306.html . > > > I've figured out that Cygwin's implementation of the open() flag O_TMPFILE > > > follows Linux in that one can't specify the name of a file when using this > > > flag. User supplies only the path, and Cygwin chooses an obscure file name > > > for you. > > > > > > That means the OP's suggested improvement of applying O_TMPFILE semantics to > > > files created by tmpfile() won't work. > > > > I don't understand the problem. tmpfile(3) does not take filenames, it > > creates its own filenames. Thus, just adding O_TMPFILE in _tmpfile_r's > > and _tmpfile64's calls to open() on systems supporting this flag and not > > calling _remove_r subsequently would already do the trick. > > That's what I thought too. But the open() fails and strace reveals ENOENT > is being generated at syscalls.cc:1516. The unix_path arg to open() needs > to indicate a directory, but _tmpfile_r is currently passing in a filename > path generated by _tmpnam_r. > > So that's what led me to contemplate extending the domain of O_TMPFILE such > that one could proactively name the temporary file. But it's probably more > sane to just have _tmpfile_r skip the generation of a file name and instead > pass in a directory name to open(), either from environment variable TMPDIR > or the libc #define P_tmpdir. > Does this sound OK? Yes, the matching patch should be in _tmpfile_r / _tmpfile64_r. Alternatively, and probably much simpler, you could define our own tmpfile / tmpfile64 in Cygwin's syscalls.cc, kind of like this: extern "C" FILE * tmpfile (void) { [...] } EXPORT_ALIAS (tmpfile, tmpfile64) Thanks, Corinna