public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mtk dot manpages at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/5939] New: mkostemp() strangeness
Date: Fri, 14 Mar 2008 13:16:00 -0000	[thread overview]
Message-ID: <20080314131552.5939.mtk.manpages@gmail.com> (raw)

glibc 2.7 added mkostemp(), but with little information.  I'm trying to write
the man page for it, and I observe some strangeness:

mkostemp() calls __gen_tempname(), which contains the following code

  __gen_tempname (char *tmpl, int flags, int kind)
  {
   ...

          fd = __open (tmpl,
                       (flags & ~ACCESSPERMS)
                       | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
          break;

The second argument of open() is the bitmask of O_* flags.  To mask this against
 ACCESSPERMS appears to be a thinko, since that constant is defined in
io/sys/stat.h as

# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */

Should the constant used in __gen_tempname() actually have been O_ACCMODE,
defined as

#define O_ACCMODE        0003

?

That would appear to be the case, given the definitions from <fcntl.h>

#define O_ACCMODE          0003
#define O_RDONLY             00
#define O_WRONLY             01
#define O_RDWR               02
#define O_CREAT            0100 /* not fcntl */
#define O_EXCL             0200 /* not fcntl */
#define O_NOCTTY           0400 /* not fcntl */
#define O_TRUNC           01000 /* not fcntl */
#define O_APPEND          02000
#define O_NONBLOCK        04000
#define O_NDELAY        O_NONBLOCK
#define O_SYNC           010000
#define O_FSYNC          O_SYNC
#define O_ASYNC          020000

#ifdef __USE_GNU
# define O_DIRECT        040000 /* Direct disk access.  */
# define O_DIRECTORY    0200000 /* Must be a directory.  */
# define O_NOFOLLOW     0400000 /* Do not follow links.  */
# define O_NOATIME     01000000 /* Do not set atime.  */
#endif

-- 
           Summary: mkostemp() strangeness
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: mtk dot manpages at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=5939

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


             reply	other threads:[~2008-03-14 13:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-14 13:16 mtk dot manpages at gmail dot com [this message]
2008-03-30  4:30 ` [Bug libc/5939] " drepper at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080314131552.5939.mtk.manpages@gmail.com \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).