public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/5939] New: mkostemp() strangeness
@ 2008-03-14 13:16 mtk dot manpages at gmail dot com
  2008-03-30  4:30 ` [Bug libc/5939] " drepper at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: mtk dot manpages at gmail dot com @ 2008-03-14 13:16 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-02  6:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-5939-131@http.sourceware.org/bugzilla/>
2014-07-02  6:03 ` [Bug libc/5939] mkostemp() strangeness fweimer at redhat dot com
2008-03-14 13:16 [Bug libc/5939] New: " mtk dot manpages at gmail dot com
2008-03-30  4:30 ` [Bug libc/5939] " drepper at redhat dot com

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).