bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#6657: mkstemp on cygwin creates binary files


From: Eric Blake
Subject: bug#6657: mkstemp on cygwin creates binary files
Date: Mon, 19 Jul 2010 07:28:32 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.0.5

On 07/18/2010 01:19 AM, Paolo Bonzini wrote:
> On 07/18/2010 01:54 AM, Eric Blake wrote:
>> By the way, newer cygwin provides mkostemp() - did you only fix the
>> problem for older cygwin that lacks mkostemp and thus gets the gnulib
>> fallback that doesn't force binary?
> 
> mkostemp also forces binary?  That's a bug IMO, since the caller can
> tell Cygwin if it wants binary or text.

In looking at it more, cygwin 1.7.5 does not provide mkostemp (although
it's planned for the future).  So I will make sure that when cygwin adds
it, that it will allow the user to request O_TEXT or O_BINARY (forced
mode), or 0 (underlying mode of mount point where file is being
created); in addition it supports the O_CLOEXEC/0 option that justifies
mkostemp on glibc.

> 
>> And what's wrong with using
>> setmode() (from<io.h>, or from gnulib's "binary-io.h") on the fd
>> created by mkstemp() to ensure the desired mode, rather than having to
>> use mkostemp?
> 
> I want the default type given by the mount point (using the mount type
> of /tmp is fine), can I get that?

Well, the mount type of /tmp is fine only if you will be rename()ing the
final file into /tmp - really, you want the default type given by the
mount point of where the final file will live.  But you are correct that
mkostemp(,0) is the right way to get that behavior, and since mkostemp
can create a file in any directory (not just /tmp), and since you can
only guarantee an atomic rename() if you don't cross device boundaries
(that is, you should already be creating the temporary file in the same
directory as the final destination), you've convinced me that your
approach of using mkostemp in sed is correct for cygwin.

By the way, I don't see your patch for using mkostemp on cygwin in
git://git.sv.gnu.org/sed.git; am I missing something, or is that not the
latest git repository for sed?

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]