-
Notifications
You must be signed in to change notification settings - Fork 724
mount: optional arguments are expected to be NULL-ptr #1236
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
Conversation
|
As suggested in #1213 I run a separate commit for rustfmt on I'm not too happy with the naming of things, but I couldn't come with a better one. |
|
Why do you think that null pointers are preferable to empty strings? I can't find anything in the man pages for either FreeBSD or Linux that says one way or the other. |
|
I'm trying to reimplement some behavior of unshare(1) (from https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/) and well, it's calling with a NULL pointer, and I can't reproduce that behavior. I have to agree that NULL behavior is not documented in the manpage. |
|
All the tests in the linux kernel suggests it is supposed to be used with a NULL pointer as well. I can't find any good API documentation tough :/ |
Before this commit, the mount calls with None fstype or data, would show
up with empty strings:
mount("none", "/", 0x561882d38498, MS_REC|MS_PRIVATE, 0x561882d38498)
I believe they are expected to be passed as NULL instead like:
mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL) = 0
29da25b to
43bcf8f
Compare
|
a second version a bit less intrusive. |
|
Turns out the root-cause of my problem was elsewhere. It works without this "fix" but I still think we should be using NULL pointers. |
|
I'm not sure why we decided to treat empty arguments as empty strings instead of null pointers in the first place. That behavior was introduced by PR #231 by @kamalmarhubi . Perhaps he would know. However, I realize now that we have a bigger problem that just mount(2). Since we implement A sensible if naive API for nix functions that need to take path arguments would be to take them as |
|
I would think this is a reasonable argument. I can work on that. As for the empty-string vs NULL-ptr, as far as I can tell, strace does not display empty-strings correctly. It just dumps the address, which makes it a bit more difficult to understand at first. |
|
I got carried away; I'll have a patch soon. I'll try to do some more research RE empty strings vs null pointers. Have you checked what Linux's mount(8) does? |
|
Actually, the answer is simple: the |
Before this commit, the mount calls with None fstype or data, would show
up with empty strings:
mount("none", "/", 0x561882d38498, MS_REC|MS_PRIVATE, 0x561882d38498)
I believe they are expected to be passed as NULL instead like:
mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL) = 0