-
Notifications
You must be signed in to change notification settings - Fork 666
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
feat: introduce macos mount API support #2347
Conversation
I do not know how to write the MacOS test because MacOS can not support |
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.
Hi, thanks for your interest in contributing to Nix! I have left some comments.
And:
- A changelog entry is needed, please take a look at doc on how to add one.
- There are still some
#[cfg(apple_targets)]
attributes inbsd.rs
, I think we should remove them.
src/mount/apple.rs
Outdated
s.as_ptr(), | ||
t.as_ptr(), | ||
flags.bits(), | ||
d as *mut libc::c_void, |
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.
For pointer casting, we prefer .cast()
and .cast_mut()
over the as
keyword:
d as *mut libc::c_void, | |
d.cast().cast_mut(), |
BTW, we are casting an immutable reference (&P3
) to a muable pinter (*mut c_void
), is this safe?
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.
libc:mount()
needs to recv libc:c_void
type, It's hard to cast type to libc:c_void
by the cast
function, So I have changed it to d.cast_mut() as *mut libc::c_void,
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.
It's hard to cast type to libc:c_void by the cast function, So I have changed it to d.cast_mut() as *mut libc::c_void,
Yeah, .cast().cast_mut()
should not work as the pointee type is unknown, .cast_mut().cast()
should work.
BTW, we are casting an immutable reference (&P3) to a muable pinter (*mut c_void), is this safe?
Will mount(2)
write to that pointer, if so, then a UB could happen:<
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.
From https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/mount.2.html man page
int
mount(const char *type, const char *dir, int flags, void *data);
int
unmount(const char *dir, int flags);
Data is a pointer to a structure that contains the type specific argu-ments arguments
ments to mount. The format for these argument structures is described in
the manual page for each filesystem.
I think it's not be written, but nobody knows how Apple doing I think.
For tests, I think we can just do something simple to ensure that the binding works, e.g., using the following stupid code: $ cat src/main.rs
use nix::{errno::Errno, mount::{mount, MntFlags}};
fn main() {
let res = mount::<str, str, str>("", "", MntFlags::empty(), None);
assert_eq!(res, Err(Errno::ENOENT));
}
$ cargo r -q
mounting "" to ""
$ echo $?
0 I think we should create a directory |
@SteveLauC I have made some changes depending on your comment, Let's continue. |
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.
Thx!
Hello, @SteveLauC, is there a plan to get this PR released? |
Personally, I don't have a plan to do the next release in the near future. Do you guys need to patch? If so, can you use a git dependency? |
Is there a specific reason? I believe it's just a patch update that should have minimal impact.
Yes.
No, we can't release with git dependency. |
Not a strong reason, I simply want to get more work done in a release.
Yeah, I agree, Nix always releases on demand, so I guess I will do a release as requested. |
That will be very helpful! |
What does this PR do
Checklist:
CONTRIBUTING.md