syscalls icon indicating copy to clipboard operation
syscalls copied to clipboard

Add a way to call syscall by number (as opposed to Sysno)

Open safinaskar opened this issue 2 years ago • 1 comments

Please, add a variant of syscalls::raw_syscall, which allows calling syscall by raw number as opposed to Sysno.

Why this is needed? Let's assume at some point of the future this crates will stop updating. And I will want to call some syscall, which is not added to Sysno. Attempting to craft fake Sysno instance (using transmute or something) is undefined behavior. So I need a way to call syscall by number

safinaskar avatar Jan 26 '24 08:01 safinaskar

I can see how having a way to call a syscall with a raw integer can be useful not just because of the maintenance aspect.

To avoid code duplication, I think the best way to implement this is as follows:

  1. Change all syscalls::syscall::syscall[0-6] to take a usize instead of Sysno.
  2. Rename those to syscalls::syscall::raw_syscall[0-6].
  3. Add syscalls::syscall[0-6] which just call the raw architecture-specific raw_syscall[0-6].
  4. Change the raw_syscall!() macro to do an as usize conversion on the first argument and call the new raw_syscall* functions instead. I think this is backwards compatible, but I'm not 100% sure.

Happy to take a pull request for this. I don't have much time to dedicate to this library these days.

jasonwhite avatar Jan 26 '24 13:01 jasonwhite