'How to get syscall number (without compiling)?

I am trying to invoke syscalls from Java like in this answer. (Specifically, mount.) The answer says to invoke syscall.

Is there a way to get the syscall number programmatically?

Assuming no and I have to hard-code it or dig for it in include files, could you answer:

  • On Linux, What is the difference between /usr/include/asm/unistd.h (/usr/include/x86_64-linux-gnu/asm/unistd on Ubuntu x86_64) and /usr/include/asm-generic/unistd.h? What is asm-generic and why does it have different values?
  • Why does linux-arm64 only have asm-generic?
  • Is there a better way to call mount? What library is it in?
  • What about MacOS and BSD?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source