-
Notifications
You must be signed in to change notification settings - Fork 669
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
Improve documentation for ioctl #641
Comments
Even the most basic question, of how do I convert an ioctl that looks like |
Yeah, there's not enough docs for me to convert a simple no-data ioctl to use nix, so I'm going to give up for now. Any help would be appreciated here. cc @posborne as you wrote a big chunk of the current documentation and probably understand the system enough to help me with my first trivial use case. |
The docs also refer to a |
@cmr it looks like you originally wrote the macros. Could you please add some documentation? |
I spent some time using the ioctl module, so I have a pretty good understanding of it. First, the The The Finally, the
There are multiple variants that depend on the ioctl definition :
I guess there's a mistake in the documentation concerning this. I think a good plan would be this :
PS: the |
They aren't just an implementation detail. The I don't know about "read buf". I'm willing to bet it's buggy, I haven't had to use it. At one point I scraped and auto-generated https://github.com/cmr/ioctl/blob/master/src/platform/linux-generated-x86_64.rs from the Linux headers. The original idea with my |
(Sorry for slow response, busy at OPLSS) |
One example that isn't addressed here is for |
Is there value in providing such a wrapper ? Technically speaking, the module does export |
@roblabla What do you mean by that comment? You mean we should re-export |
My use case for |
@roblabla If you look at the rust-spidev source you'll see that the |
I'm also trying to figure out if the generated |
Also, if you wanted to see what the API looks like for a new project, I've added a branch for replacing my |
I don't think we can ever correctly make these generated functions safe. In order to make the calls safe many system calls require additional semantics (that go well beyond the ioctl call itself) be followed. A common pattern for libraries will be to use the macros to get the FFI bindings in a convenient, declarative way and then provide safe wrappers around those. |
This leads me to ask, should these functions take references then or are raw pointers still better semantics? And if we're not providing a safe API here, why is this in |
References can't be null. Some ioctl might need this ?
…On July 13, 2017 10:43:48 PM GMT+02:00, Susurrus ***@***.***> wrote:
This leads me to ask, should these functions take references then or
are raw pointers still better semantics? And if we're not providing a
safe API here, why is this in `nix`?
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#641 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
@roblabla That's a good point, I wonder if there are any ioctls that actually do that. Do you know of any other Rust projects using I think it's better that I keep the raw pointers for now in #670. I think after that this should be good to review. Would you have some time soon to look it over @roblabla? |
Sorry, had an extended week-end. I'll take a look at #670 :) |
670: Improve ioctl docs r=asomers Integrates suggestions and comments made in #641. Basically we hid a lot of the internal workings of things and also revised the docs to make it more clear the exact API that `nix` is exposing. There is a small amount of code cleanup I did in the macros. I also fixed the `bad` version of the `ioctl!` macro and also added a `bad none` version for use with no-data, hardcoded-number `ioctl`s. Would appreciate any and all feedback. Please especially fetch this code locally and generate the pretty docs for it (`cargo doc --no-deps --open`) so you can see what our users will see. Closes #641. Closes #573. cc @cmr @roblabla
I'm working on converting my crate to use
nix
instead ofioctl-rs
asnix
is better maintained. The big issue here is that the documentation for usingioctl
s withnix
is not good from a user's point of view. Here are some issues I ran into:ioctl!
and usingior!
,iow!
,iorw!
, andioc
is not listed clearly. I'm sure one is preferred over the other, but I'm not certain which. The example only usesioctl!
.libc
and then those should be used as inputs/outputs. The example doesn't do that, so we'll have tons of people reimplementing everything per-crate.ioctl!
example only usesread
andwrite
. Looking at the macro there are 8 forms of it, but the documentation doesn't actually describe any of them.ioc_dir
and friends. There are no docs and they don't take clear types, but there are constants that have similar names in the module, so maybe those are related?ioctl
module, but those don't seem attached to these functions.nix
doesn't provide helpful wrapper functions for ioctls even if they're quite common (TIOCEXCL
would be an example) and well-defined. I'd suggest that wrapper functions be provided for well-defined ioctls. This may be controversial, as I think it's come up before, because ioctl's are unbounded and defined by kernel drivers. So maybe there is a role for an ioctl crate that does this on top ofnix
.The text was updated successfully, but these errors were encountered: