O_DIRECT is missing from correct location in headers
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
Invalid
|
Medium
|
Matthias Klose |
Bug Description
this could possibly be a bug in the man page, but my guess it's in the dev package
man page for open syscall says to include
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
simple test program
----
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main()
{
int fd;
fd = open("/tmp/123", O_RDWR | O_DIRECT);
}
----
attempt to compile
spotter@dent:/tmp$ gcc test.c
test.c: In function ‘main’:
test.c:9: error: ‘O_DIRECT’ undeclared (first use in this function)
test.c:9: error: (Each undeclared identifier is reported only once
test.c:9: error: for each function it appears in.)
its in asm-generic/fcntl.h which is for some reason not being pulled in, I doubt one is meant to #include <asm/fcntl.h> just to get this defined (especially as it will conflict with <fcntl.h>
rejecting, see open(2):
The O_DIRECT flag was introduced in SGI IRIX, where it has alignment restrictions sim‐
restrictions. Support was added under Linux in kernel version 2.4.10. Older Linux
ilar to those of Linux 2.4. IRIX has also a fcntl(2) call to query appropriate align‐
ments, and sizes. FreeBSD 4.x introduced a flag of same name, but without alignment
kernels simply ignore this flag. One may have to define the _GNU_SOURCE macro to get
its definition.