Add shm_open/shm_unlink (POSIX shared memory)#848
Add shm_open/shm_unlink (POSIX shared memory)#848sunfishcode merged 1 commit intobytecodealliance:mainfrom
shm_open/shm_unlink (POSIX shared memory)#848Conversation
e691ee1 to
3c9bd10
Compare
sunfishcode
left a comment
There was a problem hiding this comment.
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?
|
|
||
| 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.
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.
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. |
|
This is now released in |
Fixes #705.