delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/01/06/12:17:19

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 47CD43858036
Authentication-Results: sourceware.org; dmarc=none (p=none dis=none)
header.from=SystematicSw.ab.ca
Authentication-Results: sourceware.org;
spf=none smtp.mailfrom=brian DOT inglis AT systematicsw DOT ab DOT ca
X-Authority-Analysis: v=2.4 cv=INe8tijG c=1 sm=1 tr=0 ts=5ff5f06d
a=kiZT5GMN3KAWqtYcXc+/4Q==:117 a=kiZT5GMN3KAWqtYcXc+/4Q==:17
a=IkcTkHD0fZMA:10 a=CCpqsmhAAAAA:8 a=w_pzkKWiAAAA:8 a=GcyzOjIWAAAA:8
a=uYT-Tk0qkVT609LjNaIA:9 a=QEXdDO2ut3YA:10 a=-CAve4IeekYA:10
a=n0-SFN-9dxgA:10 a=zdGQctanYEAA:10 a=ul9cdbp4aOFLsgKbc677:22
a=sRI3_1zDfAgwuvI8zelB:22 a=hQL3dl6oAZ8NdCsdz28n:22
To: cygwin AT cygwin DOT com
References: <7990f8e3-ebd7-c865-58da-ddb97bd59d5f AT gmail DOT com>
<295cd16c-9f43-a6b7-9a48-a3aa52310a4f AT maxrnd DOT com>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Organization: Systematic Software
Subject: Re: FILE_ATTRIBUTE_TEMPORARY ?
Message-ID: <184cd588-4f0e-ac53-de0f-4b59c644095d@SystematicSw.ab.ca>
Date: Wed, 6 Jan 2021 10:16:28 -0700
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.6.0
MIME-Version: 1.0
In-Reply-To: <295cd16c-9f43-a6b7-9a48-a3aa52310a4f@maxrnd.com>
X-CMAE-Envelope: MS4xfA2HwQVEQ2SN++eLCVOun3DAUx5kD9kfnBmbk6Nlbq1KUF9/tLvh94JtkuJJUwW53F502BMR0XpPcM5OPB0vyc8RlD5c9j89lAoE2hGmoyKISJW5G+Pa
9XAlJOymlcYSP8uPT/ID4luQYTQQpVxEEphxOvn638oRWvyvy4RWgNkB8I9OZiHWJby+5ceaC2URpFKQRs+O3ftZoot3LlO8QQU=
X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, BODY_8BITS,
KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, NICE_REPLY_A,
RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,
SPF_NONE, SUBJ_ALL_CAPS, TXREP autolearn=no 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 AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 106HH1Us003303

On 2021-01-06 02:44, Mark Geisert wrote:
> Hi Noel,
> 
> Noel Grandin via Cygwin wrote:
>> Hi
>>
>> Does the cygwin
>>      tempfile()
>> API use the Win32
>>      FILE_ATTRIBUTE_TEMPORARY
>> flag on the files it creates?
>>
>> Asking because that makes a fairly significant performance difference when 
>> creating very short lived temp files.
> 
> Good question!  If one specifies O_TMPFILE as one of the flags on an open() 
> call, Cygwin does set that Win32 attribute as desired.  Unfortunately, Cygwin's 
> tmpfile() is supplied by newlib and it does not specify O_TMPFILE on its 
> underlying open() call.
> 
> That looks like a bug to me, unless I'm missing something subtle there; I'll 
> submit a patch and find out.

O_TMPFILE is only implemented under winsup/cygwin, and only defined for newlib 
under Cygwin:

https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/sys/_default_fcntl.h

see:

https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=0aa99373c1d01b19a7f8ba53e8c7749358480f3e

	https://cygwin.com/pipermail/cygwin/2018-February/236018.html

and:

	https://cygwin.com/pipermail/cygwin/2018-February/235869.html

https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=7ae73be14194ccadc9a7557be33c3940ca4667cb

You should allow linkat to reverse the applied attributes to make the file 
permanent, which may be taken care of in the patch above to 
fhandler_disk_file::link;
from Linux open(2) see

	https://man7.org/linux/man-pages/man2/open.2.html:

"O_TMPFILE must be specified with one of O_RDWR or O_WRONLY and,
optionally, O_EXCL. If O_EXCL is not specified, then linkat(2) can be
used to link the temporary file into the filesystem, making it
permanent, using code like the following:

	char path[PATH_MAX];
	fd = open("/path/to/dir", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);

	/* File I/O on 'fd'... */

	snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd);
	linkat(AT_FDCWD, path, AT_FDCWD, "/path/for/file",
					AT_SYMLINK_FOLLOW);
"

although the implementation may not currently handle O_EXCL.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019