Skip to content

Improve documentation for ioctl #641

Closed
@Susurrus

Description

@Susurrus

I'm working on converting my crate to use nix instead of ioctl-rs as nix is better maintained. The big issue here is that the documentation for using ioctls with nix is not good from a user's point of view. Here are some issues I ran into:

  • The difference between using ioctl! and using ior!, iow!, iorw!, and ioc is not listed clearly. I'm sure one is preferred over the other, but I'm not certain which. The example only uses ioctl!.
  • It should be clarified that ioctl constants should be upstreamed into 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.
  • The ioctl! example only uses read and write. Looking at the macro there are 8 forms of it, but the documentation doesn't actually describe any of them.
  • It's unclear how to use 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?
  • There are various constants that are also a part of the 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 of nix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions