This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/5939] New: mkostemp() strangeness
- From: "mtk dot manpages at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 14 Mar 2008 13:15:53 -0000
- Subject: [Bug libc/5939] New: mkostemp() strangeness
- Reply-to: sourceware-bugzilla at sourceware dot org
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.