Conceptual
Login

Generated C Bindings and Why Drivers Never Call Them

The kernel is millions of lines of C, and a tool called bindgen reads its header files and mechanically produces Rust declarations for every C function and struct it finds, collected in a module named bindings. Those declarations are raw and completely unchecked: calling one is exactly as dangerous as writing C. The rule in Linux is that a driver calls the reviewed safe wrappers instead, and only the small set of abstraction authors is allowed to touch bindings directly. Ignore the rule and you lose the only thing Rust was brought in to provide, because the compiler can no longer see the rules you are breaking.

Questions this Concept answers

  • Why is a driver that calls `bindings::` functions directly considered to have thrown away the benefit of writing it in Rust?