Coder Social home page Coder Social logo

linux-raw-sys's Introduction

linux-raw-sys

Generated bindings for Linux's userspace API

Github Actions CI Status zulip chat crates.io page docs.rs docs

This crate contains bindgen-generated bindings for Linux's userspace API.

This is primarily of interest if you want to make raw system calls directly, which is tedious and error prone and not necessary for most use cases. For a minimal type-safe, memory-safe, and I/O-safe API to the Linux system calls built on these bindings, see the rustix crate.

The full bindings are quite large, so they've been split up into modules and cargo features. By default, general and errno are enabled, which provide most things needed by general-purpose code.

To regenerate the generated bindings, run cargo update && cd gen && cargo run --release.

Similar crates

This is similar to linux-sys, except the bindings are generated offline, rather than in a build.rs, making downstream builds simpler. And, this crate has bindings for more headers, as well as supplementary definitions not exported by Linux's headers but nonetheless needed by userspace.

Minimum Supported Rust Version (MSRV)

This crate currently works on the version of [Rust on Debian stable], which is currently Rust 1.63. This policy may change in the future, in minor version releases, so users using a fixed version of Rust should pin to a specific version of this crate.

linux-raw-sys's People

Contributors

arctic-alpaca avatar bjorn3 avatar carbotaniuman avatar cyanoxygen avatar dblouis avatar dignifiedquire avatar dirreke avatar heiher avatar jordanisaacs avatar joshtriplett avatar kraj avatar krh avatar mek101 avatar morr0ne avatar nivkner avatar notgull avatar parrotmac avatar ryanseipp avatar sunfishcode avatar tarka avatar zhaixiaojuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linux-raw-sys's Issues

Missing ioctl arguments

I noticed certain ioctl arguments such as BLKPBSZGET and BLKSSZGET are missing. Where are those bindings generated from?

build error on loongarch64

with cargo build on loongarch64, I get the error:

error[E0433]: failed to resolve: use of undeclared crate or module `general`
  --> src/lib.rs:67:20
   |
67 | impl PartialEq for general::__kernel_timespec {
   |                    ^^^^^^^ use of undeclared crate or module `general`

error[E0433]: failed to resolve: use of undeclared crate or module `general`
  --> src/lib.rs:79:13
   |
79 | impl Eq for general::__kernel_timespec {}
   |             ^^^^^^^ use of undeclared crate or module `general`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `linux-raw-sys` due to 2 previous errors

Missing struct msghdr

I am looking to implement sendmsg and recvmsg for rustix, and as far as I understand structs like msghdr should be pulled from this crate for the implementation of linux_raw backend.

Please let me know if this assumption is correct, and if so what the steps are to getting it added.

Ioctl generation with linux HEAD fails

@joshtriplett As a followup to #53, I was investigating running the generator script with linux HEAD, but I'm hitting this error:

list.c: In function ‘list’:
include/linux/ext4.h:47:54: error: invalid application of ‘sizeof’ to incomplete type ‘struct compat_ext4_new_group_input’
   47 | #define EXT4_IOC32_GROUP_ADD            _IOW('f', 8, struct `)
      |                                                      ^~~~~~

It seems compat_ext4_new_group_input isn't defined in the uapi headers, but EXT4_IOC32_GROUP_ADD isn't usable without it. Should compat_ext4_new_group_input be moved into uapi?

Signal handler union in `sigaction` on x86_64

The generated bindings to sigaction does not pick up that the handler can be a union of either f(int) or f(int, siginfo_t, void/ucontext). See man(2) sigaction. This may not be an issue with the generated bindings as it seems it is not defined as a union for x86_64 architecture: https://sourcegraph.com/github.com/torvalds/linux/-/blob/arch/x86/include/uapi/asm/signal.h?L82%3A12=

Not sure if it should be manually updated in linux-raw-sys or just create my own sigaction struct?

Add CAP_* constants?

They're currently hardcoded in rustix which seems odd. Ideally they'd be auto-generated here.

Add support for select() macros

Looking at this crate on docs.rs, the macros for the select function (FD_SET, FD_ISSET etc) don't exist. However, it doesn't look like fd_set exists either. Would you mind if I added support for these macros/types to this crate?

Better module organization

Currently each module includes the entirety of the syscall interface as of the respective kernel version with all types duplicated between modules. I think it would be nicer to have each module only include the diff with the previous kernel version and maybe a glob re-export of all items of the previous version.

This is probably not very easy to do with bindgen though.

seteuid missing

setuid and setreuid are present, but seteuid is missing for some reason. Same for gid.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.