The Linux Kernel: System Calls F-G

Discussion in 'Linux Kernel' started by DevynCJohnson, Apr 7, 2014.

  1. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,220
    Likes Received:
    1,019
    Trophy Points:
    113
    Series Index - http://www.linux.org/threads/linux-kernel-reading-guide.5384/

    In this next article, we will continue discussing the system calls. Do not worry, this will not be as long as the configuration part of the kernel series. :D

    faccessat() - The permissions for the specified file is checked, but this is performed using a directory file descriptor.

    NOTE: In the most simplest terms, a file descriptor is a special number used to access a file.

    posix_fadvise() - (commonly called fadvice(), although the actual call is posix_fadvise()) This system call is used to optimize data access. Specifically, this syscall plans ahead what file will be accessed and how to get the data. This speeds up data access for the kernel.

    fallocate() - Disk space of a specified file is manipulated by this kernel call. Obviously, since every filesystem type (XFS, EXT4, NTFS, tmpfs, etc.) is different, this syscall does not work on all filesystems. fallocate() also works on some pseudo/virtual filesystems like tmpfs.

    fchmod() - This syscall is the same thing as chmod(). The difference lies in the fact chmod() accepts a path name and fchmod() accepts a file descriptor instead.

    fchmodat() - This system call changes a file's permissions and the file is specified using a file descriptor. fchmodat() is exactly like chmod() with the difference being their accepted input, a file descriptor and path, respectively. fchmod() and fchmodat() work a little differently from each other.

    fchown() - Just like chown(), the owner of the specified file is changed. However, fchown() knows the file by its file descriptor, not its path.

    fchownat() - This syscall is just like fchown().

    fcntl() - Manipulate the specified file descriptor.

    fgetxattr() - This syscall gets the value of the specified extended file attribute.

    finit_module() - Using a file descriptor, an ELF-image is loaded into the kernel space.

    flistxattr() - Given a file descriptor, this syscall will list the extended attributes owned by the specified file.

    flock() - Create or remove an advisory lock on the specified file (the file must be open).

    fork() - Child processes are commonly created using this kernel call. With this call, the child process gets its own PID and memory space. Many other attributes are not inherited.

    free_hugepages() - Free huge pages (large chunks of memory).

    fremovexattr() - When using a file descriptor, this syscall can remove an extended attribute.

    fsetxattr() - With a known file descriptor, an extended attribute can be set.

    fstat() - The status of a file can be read with this syscall when given a file descriptor.

    fstatat() - With a directory file descriptor, a file's status can be read.

    fstatfs() - The statistics of a filesystem can be retrieved with this kernel call. This system call is directed to the filesystem in question by using a file descriptor of any given file on that filesystem.

    ftruncate() - With a given file descriptor, this kernel call will truncate the specified file to a desired length. This may mean cutting the file, thus losing data, or enlarging the file by adding null bytes. Null bytes are designated as a backslash zero (\0).

    futex() - Futex stands for Fast User-space muTEX. With this syscall, threads and processes can adhere to the futex standard so the executing code can wait for shared resources. Any code that calls futex() must be written in non-portable assembly instructions.

    get_kernel_syms() - All of the exported module and kernel symbols can be read with this system call.

    NOTE: A symbol is a function or variable.

    get_mempolicy() - To get the NUMA memory policy for a process, use this syscall.

    get_robust_list() - The robust-futex list can be retrieved with this kernel call.

    getcpu() - This syscall allows the calling thread to be found on a specific CPU and NUMA node. This is like the thread yelling "I am over here!".

    getcwd(), getwd(), and get_current_dir_name() - GET Current Working Directory. These three syscalls give the same result, but they each function a little differently.

    getdents() - This system call gets directory entries.

    getgid() - The syscall retrieves the real GID of the calling process.

    getegid() - The syscall retrieves the effective GID of the calling process.

    FUN FACT: getgid() and getegid() are claimed to NEVER fail according to the man pages. Do we agree with that, or has someone found an exception?

    getitimer() - This syscall gets the current value of one of the timers of a process. Each process has three timers - ITIMER_REAL (decrements in real time), ITIMER_VIRTUAL (decrements during execution), and ITIMER_PROF (decrements while either the process or system executes). These three timers are called "interval timers".

    getpeername() - The name of a connected peer socket can be retrieved using this syscall.

    getpagesize() - The size of a regular page in memory can be known with this kernel call.

    NOTE: In simplest terms, a page in memory is analogous to a block on a magnetic hard-drive.

    getpgid() - This syscall gets the PGID of the specified process by using its PID.


    getpid() - The PID of the calling process is returned.

    getppid() - The PID of the calling process's parent is returned.

    getpriority() - The scheduling priority of the specified program is returned by this syscall.

    getresuid() - The RUID, EUID, and the SUID of the calling process is returned.

    getresgid()- The RGID, EGID, and the SGID of the calling process is returned.

    NOTE: GID = Group ID. UID = User ID. R = Real. E = Effective. S = Set.

    getrlimit() - This kernel call returns the resource limit of a process.


    In the next article, we will continue discussing system calls. Enjoy!

    Attached Files:

    Last edited: May 11, 2014
  2. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,220
    Likes Received:
    1,019
    Trophy Points:
    113
    One of our best members (Cyber-Berserker) has stopped coming to this site. I would like you all to give him a thanks for his great contributions to this site by posting a thank you or something of that manner to him on this thread.

    Thanks @Cyber-Berserker for your great contributions (like this http://www.linux.org/threads/tips-for-the-fresh-born-linux-newbie.5613/) and many others. I am sure many of the answers you gave in the forums were greatly appreciated by the original-posters and those that read the threads.

Share This Page