Skip to content

rust: Add uapi crate

Asahi Lina asahi lkml rust-for-linux 2 versions – Applied

Status from this message: Applied to `rust-next`, with added support for the `rustdoc` and

Get series with b4
b4 am [email protected] change-id 20230329-rust-uapi-894421e9a5d2

Versions newest first

  1. v2 Latest2 patches 1 replyApplied
  2. v12 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- Fixed the trailing '\' warning (mirroring the fix from Vicenzo
Palazzo)
- Pulled in the ioctl module patch into this series. Per the discussion
in the meeting, this could be moved into the uapi crate in principle,
but we can decide to do that later since the whole buildsystem is
likely to undergo major changes anyway.
- Link to v1: https://lore.kernel.org/r/[email protected]

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/2rust: uapi: Add UAPI craterust/.gitignore rust/Makefile rust/kernel/lib.rs +2 more+54 -20 replies
2/2rust: ioctl: Add ioctl number manipulation functionsrust/kernel/ioctl.rs rust/kernel/lib.rs+72 -00 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchMartin Rodriguez Reboredo
1/2R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] rust: Add uapi crate

In general, direct bindgen bindings for C kernel APIs are not intended to be used by drivers outside of the kernel crate. However, some drivers do need to interact directly with UAPI definitions to implement userspace APIs.

Instead of making this an exception to the use of the bindings crate, introduce a new uapi crate that will contain only these publicly usable definitions. The build logic mirrors the bindings crate, but there is no helper support since UAPIs are only intended to contain constant and type definitions, not function prototypes.

In the future, we would like to extend this to also auto-derive and validate certain safety properties for UAPI structure definitions, such as that they are safely castable to/from "bag of bits" buffers.

The first patch introduces the uapi crate proper and stands on its own, while the second patch introduces the ioctl module in the kernel crate that uses it.

(Miguel: this series should apply stand-alone now)

---
Changes in v2:
- Fixed the trailing '\' warning (mirroring the fix from Vicenzo
Palazzo)
- Pulled in the ioctl module patch into this series. Per the discussion
in the meeting, this could be moved into the uapi crate in principle,
but we can decide to do that later since the whole buildsystem is
likely to undergo major changes anyway.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Asahi Lina (2):
rust: uapi: Add UAPI crate
rust: ioctl: Add ioctl number manipulation functions

 rust/.gitignore         |  1 +
 rust/Makefile           | 18 +++++++++++--
 rust/kernel/ioctl.rs    | 71 +++++++++++++++++++++++++++++++++++++++++++++++++
 rust/kernel/lib.rs      |  2 ++
 rust/uapi/lib.rs        | 27 +++++++++++++++++++
 rust/uapi/uapi_helper.h |  9 +++++++
 6 files changed, 126 insertions(+), 2 deletions(-)

---
base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
change-id: 20230329-rust-uapi-894421e9a5d2

Thank you,
~~ Lina