Project

General

Profile

Actions

Feature #4015

closed

File::DIRECT Constant for O_DIRECT

Added by runpaint (Run Paint Run Run) over 13 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:33018]

Description

=begin
A couple of the open(2) flags on Linux don't have corresponding File:: constants:

  • O_DIRECT

    <<Try to minimize cache effects of the I/O to and from this file. In general this will degrade performance, but it is useful in special situations, such as
    when applications do their own caching. File I/O is done directly to/from user space buffers. The O_DIRECT flag on its own makes at an effort to trans‐
    fer data synchronously, but does not give the guarantees of the O_SYNC that data and necessary metadata are transferred. To guarantee synchronous I/O the
    O_SYNC must be used in addition to O_DIRECT.>>

This is added with the attached patch. With the patch applied:

run@paint:~$ strace ruby -e 'open("/tmp/foo", File::DIRECT, 0644)' 2>&1|grep O_DIRECT
open("/tmp/foo", O_RDONLY|O_DIRECT) = 3

  • O_CLOEXEC

This has a patch pending in #1291.

  • O_DIRECTORY

man 2 open notes "This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3)." We can probably ignore this one.

  • O_LARGEFILE

We already handle large-file support automatically, so this can be ignored, too.
=end


Files

io.c-o_direct.patch (468 Bytes) io.c-o_direct.patch runpaint (Run Paint Run Run), 11/03/2010 06:50 AM
io-advise.patch (4.92 KB) io-advise.patch IO#advise runpaint (Run Paint Run Run), 11/06/2010 03:59 AM
io-advise.patch (5.23 KB) io-advise.patch runpaint (Run Paint Run Run), 11/08/2010 09:48 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #4038: IO#adviseClosed11/09/2010Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0