4 ms·
I don't know where you got the idea that you can't mmap a buffer or call an ioctl in Rust. You certainly can do those things.
by pcwalton 12y ago
I don't know where you got the idea that you can't mmap a buffer or call an ioctl in Rust. You certainly can do those things.
- ajross 12y agoI got the idea from the docs, honestly, which don't talk about system interfacing at all. Though I do now see the "unsafe" page, which at least has assembly hooks. Serious question though: has anyone ever done this? I mean, are there kernel header import utilities I can use to get the flag definitions and parameter structs, etc...? You can sneer and downvote me all you want, but it seems that the clear truth is that Rust has not been used as a "systems programming language" in the only regime where IMHO that term has any meaning. Basically: drilling a hole through the compiler to the assembler (which I'll state again is done in Rust as yet more complicated syntax users need to learn and not as, say, a native library interface) is a valuable tool, but it does not a syscall interface make.
- pcwalton 12y agoThere is rust-bindgen, which you can use to convert C headers to Rust FFI declarations. This should be able to convert the kernel userland headers to Rust declarations, so that you can call directly to the kernel. (I didn't downvote you.)
- Ygg2 12y ago> Rust has not been used as a "systems programming language" in the only regime where IMHO that term has any meaning. Rust has been used to make a toy kernel (as in press key, get message printed and/or change the color of the message). And this was several months ago. I'm pretty sure that makes it a decent systems programming language.
- eridius 12y agoPeople are writing kernels in Rust. If that doesn't qualify as systems programming language, I don't know what does.
- deleted 12y ago[deleted]
- dbaupp 12y agoThe Rust language provides the tools required for people to write a system call interface (which can be in the standard distribution or outside it, both have the same power), I don't think building such a thing into the language (rather than in a library) is at all sensible. As others have pointed out people have written linux kernel modules, kernels and all sorts of other low-level things in Rust. (Rust's inline assembly interface is essentially "write in ASM"... If you're truly needing to go that far down yourself, then knowing assembly seems very reasonable. However, this shouldn't be needed much, just use libraries that do it internally.)