bug-gnulib
[Top][All Lists]
Advanced

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

Re: proposal: module 'mkostemp'


From: Eric Blake
Subject: Re: proposal: module 'mkostemp'
Date: Sat, 22 Aug 2009 20:54:55 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruno Haible on 8/22/2009 5:20 PM:
> Here is a proposal to add a module 'mkostemp', using the source code changes
> from glibc. It also reduces the diffs to glibc, by incorporating parts of this
> glibc commit:

Nice to do some resyncing.  Overall, I'm in favor of this improvement.

> 
> /* Generate a unique temporary file name from TEMPLATE.
>    The last six characters of TEMPLATE must be "XXXXXX";
>    they are replaced with a string that makes the file name unique.
>    Then open the file and return a fd. */
> int
> mkostemp (template, flags)
>      char *template;
>      int flags;

I take it the failure to mention 'flags' in the comment is a glibc oversight?

> +#if @GNULIB_MKOSTEMP@
> +# if address@hidden@
> +/* Create a unique temporary file from TEMPLATE.
> +   The last six characters of TEMPLATE must be "XXXXXX";
> +   they are replaced with a string that makes the file name unique.
> +   The file is then created, with the specified flags, ensuring it didn't 
> exist
> +   before.

Should we mention which FLAGS are portable in the gnulib version
(O_CLOEXEC, O_BINARY, O_TEXT), as you did for accept4?

> -       fd = large_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
> +       fd = __open (tmpl,
> +                    (flags & ~0777) | O_RDWR | O_CREAT | O_EXCL,
> +                    S_IRUSR | S_IWUSR);

Wow - that means any other flags larger than 9  bits, like the sticky bits
at 07000, or even implementation-specific O_* values, are blindly passed
through.  Do we really want that?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqQr38ACgkQ84KuGfSFAYDEzwCfZr8IvFfks9/2T/jrJw6lLqVv
5iMAoIQzPdddj3FfAYpjMNR42LiTKd6O
=7wXs
-----END PGP SIGNATURE-----




reply via email to

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