System calls are a special set of procedures that regular programs (user space processes) can submit to the Linux kernel for working with files, interacting with hardware, accessing internal OS functionality, implement all sorts of communication and process management and basically do anything else that’s sensitive or performance critical enough that OS kernel must enforce strict controls around it.
Regular processes interface with the OS kernel by supplying a system call name and parameters, the kernel then verifies validity of a system call and executes it within kernel space, returning data and execution status back.
For instance, __NR_mount indicates the syscall name - the actual name is the word without __NR_ bit, so in this case it’s mount. 21 is the syscall number in your Linux.
Syscall Man Pages
To get more information about using a system call, just use man command. Because syscalls are a pretty core part of man pages, they have their own section - it’s section number 2. So add .2 to the name of a syscall when looking for it:
greys@srv:~ $man mount.2
MOUNT(2) Linux Programmer's Manual MOUNT(2)
NAME
mount - mount filesystem
SYNOPSIS
#include <sys/mount.h>
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
DESCRIPTION
mount() attaches the filesystem specified by source (which is often a pathname referring to a device, but can also be the pathname of a directory or file, or a dummy string)
to the location (a directory or file) specified by the pathname in target.
Appropriate privilege (Linux: the CAP_SYS_ADMIN capability) is required to mount filesystems.
Values for the filesystemtype argument supported by the kernel are listed in /proc/filesystems (e.g., "btrfs", "ext4", "jfs", "xfs", "vfat", "fuse", "tmpfs", "cgroup",
"proc", "mqueue", "nfs", "cifs", "iso9660"). Further types may become available when the appropriate modules are loaded.
The data argument is interpreted by the different filesystems. Typically it is a string of comma-separated options understood by this filesystem. See mount(8) for details
of the options available for each filesystem type.
SysCall Numbers
Don’t forget: although oldest syscalls match across multiple distributions, there’s always a chance that a particular syscall will have a different number in your OS.
This is only relevant if you’re trying to use syscalls directly - which you probably shouldn’t. Use glibc instead - I’ll be sure to write a small article on it sometime in the future.
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!