GNU bug report logs - #6657
mkstemp on cygwin creates binary files

Previous Next

Package: coreutils;

Reported by: Paolo Bonzini <bonzini <at> gnu.org>

Date: Fri, 16 Jul 2010 20:40:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 6657 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Paolo Bonzini <bonzini <at> gnu.org>
Cc: 6657 <at> debbugs.gnu.org, Paul Eggert <eggert <at> CS.UCLA.EDU>
Subject: Re: bug#6657: mkstemp on cygwin creates binary files
Date: Mon, 19 Jul 2010 07:28:32 -0600
[Message part 1 (text/plain, inline)]
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   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 13 years and 315 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.