Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O_DIRECT, core_unix, Open_flags, direct #147

Open
tomjridge opened this issue Oct 28, 2021 · 1 comment
Open

O_DIRECT, core_unix, Open_flags, direct #147

tomjridge opened this issue Oct 28, 2021 · 1 comment
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.

Comments

@tomjridge
Copy link

tomjridge commented Oct 28, 2021

I was looking for a way of opening a file using the O_DIRECT flag. I saw that core_unix has a module Open_flags which includes O_DIRECT. This looks great. However, there appears to be no way to actually open a file with that flag (I think Open_flags are currently only used with fcntl). Is there any way to open a file with the O_DIRECT flag? Do you intend to add this functionality at some point? Do you know any libraries that currently support this flag? Thanks

@github-iron github-iron added the forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system. label Nov 3, 2021
@bcc32
Copy link
Member

bcc32 commented Nov 3, 2021

The O_DIRECT flag isn't supported by Unix.openfile because there's currently two types, Unix.open_flag (which is an alias to the one from the OCaml stdlib) and Open_flags.t, which includes O_DIRECT. Making Unix.openfile support the latter would probably be a decently big change.

As a workaround, could you use fcntl_setfl to set Open_flags.direct on the file descriptor after opening it? I realize the documentation may be a bit out of date on that function, as man fcntl says Linux supports setting O_DIRECT there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.
Projects
None yet
Development

No branches or pull requests

3 participants