-
Notifications
You must be signed in to change notification settings - Fork 175
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
Remove incorrect mount API and allow null data arg #1112
Conversation
I have to disagree with the assertion that the API introduced in #1024 is flawed. The current implementation adheres to the documented requirements and allows necessary functionality. It is ultimately the responsibility of the user to utilize the kernel apis appropriately. The crate offers safe wrappers, and the mount2 function does not introduce unsound behavior. That said, I am not against this changes to the api, provided they maintain backward compatibility. However, it appears that deprecating mount2 offers no tangible benefit. Additionally, I would like to point out that I am unsure whether the proposed use of impl syntax is supported by the current msrv. As such, this change may not actually be backward compatible. |
That's not how rustix works: we don't add APIs that directly mirror the kernel syscalls. Instead, rustix APIs are "actions" that may or may not use the same underlying syscall. For examples, look at epoll, fcntl, ioctl, the entire net module, etc etc etc. If you want user responsibility, use C. :)
We've been using the impl trait syntax for ages, it's fine. |
I am familiar with rustix's functionality. However, I fail to identify any significant flaws in the mount2 api. The suggestion to switch to C is neither helpful nor professional. I added an api tailored to an use case which rustix did not address. These changes were approved, and I have not been presented with sufficient evidence to justify their deprecation. |
|
One thing I forgot to address is the |
Rustix often does think in this direction, though I wouldn't consider it an absolute rule. And on the other hand, Rustix also thinks in the direction of splitting functions that have overloaded meanings into multiple functions to avoid meaningless arguments; see Concerning I don't know which Rust version introduced |
Are there other examples of c-like rustix interfaces? Off the top of my head an obvious one is open, but there's an item in the 1.0 release to consider splitting it between create and open so the Mode argument isn't meaningless in non-create cases. In general, I think rustix should strive to avoid meaningless arguments as much as possible—IIRC the nix crate was more focused on matching the c APIs so I kinda see folks using either crate depending on their preferred approach. I don't have a strong preference regarding not using |
Actually I kind of like the idea of leaving Also I just saw the futex rework landed! That further reinforces the idea that rustix is moving away from c like APIs— |
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.
I think this makes sense to do.
src/mount/mount_unmount.rs
Outdated
@@ -49,6 +49,8 @@ pub fn mount<Source: path::Arg, Target: path::Arg, Fs: path::Arg, Data: path::Ar | |||
/// | |||
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html | |||
#[inline] | |||
#[deprecated(note = "This API was added in error, use the expressive mount APIs instead.")] | |||
#[doc(hidden)] |
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.
Since we're nearing a 1.0 release, we can just delete this function instead of deprecating it.
src/mount/mount_unmount.rs
Outdated
@@ -19,18 +19,18 @@ pub fn mount<Source: path::Arg, Target: path::Arg, Fs: path::Arg, Data: path::Ar | |||
target: Target, | |||
file_system_type: Fs, | |||
flags: MountFlags, | |||
data: Data, | |||
data: impl Into<Option<Data>>, |
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.
Also, could you change Data
to &CStr
?
I know that's not quite as fun as path::Arg
, but as discussed earlier in the issue, that's for filesystem paths. The idea of splitting an ffi::Arg
out seems fun, but there seem to be very few things in rustix that would use it, so it's not clearly worth it. And now that Rust has C-string literals, plain &CStr
is pretty ergonomic in common cases.
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.
Fair enough, done.
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Thanks! |
Oh wait shoot, sorry I forgot to move the |
Fixed in #1317 |
Added in error in #1024 due to a misunderstanding of how the API works. I've made a tweak to the existing API to allow passing in null options (should be backwards compatible!) as some poorly designed FS might require this, but in practice you could have just passed in the empty string.