CNier
February 16, 2023, 10:40am
1
I'm working on linux kernel and current is a macro that returns the pointer to the current process descriptor.
Specifically, current->mm is the pointer to the memory descriptors of the current process.
This is the code as follows:
struct vm_area_struct *vma = find_vma(current->mm, start);
if (vma != NULL)
{
do something();
return 0;
}
else
{
pr_err("error");
return 1;
}
How can i express this in Rust? i found crates as Struct kernel::vm:mm:Area but i didn't find something that regards the current process.
cuviper
February 16, 2023, 5:48pm
2
If you're working with the in-tree kernel bindings, I think you want Task::current()
. Off-hand, I don't see bindings to get its ->mm
though.
There are also more specific venues to ask kernel questions listed here:
# Rust for Linux
The goal of this project is to add support for the Rust language to the Linux kernel. This repository contains the work that will be eventually submitted for review to the LKML.
Feel free to [contribute](https://github.com/Rust-for-Linux/linux/contribute)! To start, take a look at [`Documentation/rust`](https://github.com/Rust-for-Linux/linux/tree/rust/Documentation/rust).
General discussions, announcements, questions, etc. take place on the mailing list at rust-for-linux@vger.kernel.org ([subscribe](mailto:majordomo@vger.kernel.org?body=subscribe%20rust-for-linux), [instructions](http://vger.kernel.org/majordomo-info.html), [archive](https://lore.kernel.org/rust-for-linux/)). For chat, help, quick questions, informal discussion, etc. you may want to join our Zulip at https://rust-for-linux.zulipchat.com ([request an invitation](https://lore.kernel.org/rust-for-linux/CANiq72kW07hWjuc+dyvYH9NxyXoHsQLCtgvtR+8LT-VaoN1J_w@mail.gmail.com/T/)).
All contributors to this effort are understood to have agreed to the Linux kernel development process as explained in the different files under [`Documentation/process`](https://www.kernel.org/doc/html/latest/process/index.html).
<!-- XXX: Only for GitHub -- do not commit into mainline -->