-
Notifications
You must be signed in to change notification settings - Fork 0
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
allow re-use of OpenOptions in other crates #1
base: neon
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,33 +11,23 @@ use std::path::Path; | |||||||||||
#[allow(dead_code)] | ||||||||||||
pub(crate) struct Open { | ||||||||||||
pub(crate) path: CString, | ||||||||||||
pub(crate) flags: libc::c_int, | ||||||||||||
} | ||||||||||||
|
||||||||||||
impl Op<Open> { | ||||||||||||
/// Submit a request to open a file. | ||||||||||||
pub(crate) fn open(path: &Path, options: &OpenOptions) -> io::Result<Op<Open>> { | ||||||||||||
use io_uring::{opcode, types}; | ||||||||||||
let path = super::util::cstr(path)?; | ||||||||||||
let flags = libc::O_CLOEXEC | ||||||||||||
| options.access_mode()? | ||||||||||||
| options.creation_mode()? | ||||||||||||
| (options.custom_flags & !libc::O_ACCMODE); | ||||||||||||
|
||||||||||||
// Get a reference to the memory. The string will be held by the | ||||||||||||
// operation state and will not be accessed again until the operation | ||||||||||||
// completes. | ||||||||||||
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Turn formatting to https://rust-lang.github.io/rust-clippy/master/#/undocumented as I could imagine that is expected as the lint has been enabled in pageserver as well. Without re-reading the tokio-uring I am unable to answer this. Regardless I don't think it makes sense to include "get a reference to the memory" or anything like reading the code aloud, instead the comment should say how are the requirements fulfilled. Accessing or not accessing the |
||||||||||||
let sqe = unsafe { | ||||||||||||
let p_ref = path.as_c_str().as_ptr(); | ||||||||||||
crate::fs::OpenOptionsIoUringExt::as_openat_sqe(options, p_ref)? | ||||||||||||
}; | ||||||||||||
CONTEXT.with(|x| { | ||||||||||||
x.handle() | ||||||||||||
.expect("Not in a runtime context") | ||||||||||||
.submit_op(Open { path, flags }, |open| { | ||||||||||||
// Get a reference to the memory. The string will be held by the | ||||||||||||
// operation state and will not be accessed again until the operation | ||||||||||||
// completes. | ||||||||||||
let p_ref = open.path.as_c_str().as_ptr(); | ||||||||||||
|
||||||||||||
opcode::OpenAt::new(types::Fd(libc::AT_FDCWD), p_ref) | ||||||||||||
.flags(flags) | ||||||||||||
.mode(options.mode) | ||||||||||||
.build() | ||||||||||||
}) | ||||||||||||
.submit_op(Open { path }, move |_| sqe) | ||||||||||||
}) | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.