-
Notifications
You must be signed in to change notification settings - Fork 166
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
Add shm_open
/shm_unlink
(POSIX shared memory)
#848
Conversation
e691ee1
to
3c9bd10
Compare
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.
Thanks for the patch! Overall this looks good.
My main concern here is that I'm not sure shm_open
and shm_unlink
belong in rustix::fs
. There is no clear rule, but my instinct is that the shared-memory namespace is distinct from the filesystem namespace, even if there is aliasing on Linux, that it justifies putting these in a new rustix::shm
module. What would you think about that?
src/backend/linux_raw/fs/syscalls.rs
Outdated
|
||
pub(crate) fn shm_unlink(name: &CStr) -> io::Result<()> { | ||
let path = get_shm_name(name)?; | ||
let path = &path[..=path.iter().position(|x| *x == 0).unwrap()]; |
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.
We could avoid these position
calls by having get_shm_name
also return the length of the name, which it already knows.
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.
Good point. I originally wrote it with from_bytes_until_nul
, but then CI complained since that's too new of a standard library addition.
Either from_bytes_with_nul
or from_bytes_until_nul
still need to traverse the string. method.from_bytes_with_nul_unchecked
would avoid that.
I put it next to |
Of course, moving |
Here's a rough sketch for how we might group all the things in this space that we may eventually add:
The unifying themes for the Does that make sense? |
But you're right that |
Ultimately, what we're talking about here is just the top-level API organization. You can always call Interestingly, POSIX did add a "future direction" note that |
b4f2bf9
to
acd6364
Compare
Moving it out of Though looking at the POSIX spec and But |
It'd be ok to have shm depend on fs, with
A custom flags type for this makes sense to me. Also, looking at the
Makes sense. We can declare a type alias in the |
eb57a17
to
9a3bd8d
Compare
Ah, I should have thought about This now has a passes that and has a separate flags type. |
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.
Looks good, thanks!
This is now released in |
Fixes #705.