Powered by
Movable Type 3.38 mod_perl/2

Linux, Programmierung Direct I/O filesystem access in Linux with O_DIRECT

I just tried to read files from the filesystem using direct i/o to avoid the operating systems caching effects.
The manpage of open lists the flag O_DIRECT for this. Although I included fcntl.h, my compiler complained that it couldn't find O_DIRECT:

contrib/myfile.c:44: error: ‘O_DIRECT’ undeclared (first use in this function)

The solution was easy:
You just have to

#define _GNU_SOURCE

before including fnctl.h.

This is actually mentioned in the manpage, but only in a footnote that is easy to overlook.


TrackBack

» Linux, use O_DIRECT, should define _GNU_SOURCE firstly (manual trackback)
Recently, I want to write a program, to read/write the raw disk. I just tried to read files from the filesystem using direct i/o to avoid the operating systems caching effects.The manpage of open lists the flag O_DIRECT for this. Although I included...

TrackBack URL for this entry:
http://anti.teamidiot.de/mt-tb/54


Comments (1)

You save me!