system-calls

Does mmap() update the page table after every page fault?

Does mmap() update the page table after every page fault? Based on my research on mmap(), I understand that mmap uses demand paging to copy in data to the kernel page cache only when the virtual memory address is touched, through page fault. If we are reading files that are bigger than the page cache, …

Total answers: 1

getdents() syscall appears to be returning different results within a container

getdents() syscall appears to be returning different results within a container I’m trying to read what type of file /dev/null is. If I use stat() it reports correctly that it’s a character device. If I use getdents(), it also reports that it’s a character device – unless I run it in a container, in which …

Total answers: 1

Linux syscalls: advantage of copy_file_range over sendfile?

Linux syscalls: advantage of copy_file_range over sendfile? I understand that classically, the Linux Kernel was conservative about adding new syscalls. But, I’ve learned about the existence of copy_file_range, which seems to do the exact same thing as sendfile. The only differences I could spot are: doesn’t work on sockets at all, only on proper regular …

Total answers: 1

man syscalls is missing in arch linux

man syscalls is missing in arch linux I just can’t find it. I’ve installed linux-docs with sudo pacman -S linux-docs but still man syscalls does not work. Asked By: Corel || Source The syscalls man page is provided by the Arch Linux package man-pages. Install it with pacman -S man-pages. Answered By: Johan Myréen syscalls …

Total answers: 2

Debugging strange EACCES (Permission denied) permission error

Debugging strange EACCES (Permission denied) permission error I have a symlink to a world-readable file that a c program is being unable to read. redshift is supposed to pick up configuration from $HOME/.config/redshift/redsihft.conf automatically, but it wasn’t. I tried tracing system calls to understand what files are being tried: debian-x1-7th][redshift-1.12][130]$ strace -fe trace=file redshift execve("/usr/bin/redshift", …

Total answers: 1

Man pages, syscalls, and libc

Man pages, syscalls, and libc Why is epoll_create not listed as a library function (man pages, section 3), but accept is? While both functions are provided by libc and both refers to kernel syscalls? I know that "why" questions are not usually welcomed, but it’s my way to ask for a better fine-grained understanding on …

Total answers: 1

Terminal syscalls in Assembly

Terminal syscalls in Assembly I would like to write a chess engine for Linux. It will be in pure X64 Assembly language without any C/C++ or any other high level languages external libraries. It will run in full screen text/console/terminal mode. No GUI. It will use Unicode characters to display the chess pieces. I know …

Total answers: 1

Why isn't something like compound syscalls implemented?

Why isn't something like compound syscalls implemented? Syscalls (system calls) cause some performance penalty due to the isolation between kernel and user space. Therefore, it sounds like a good idea to reduce syscalls. So what I thought is, that we could pack together syscalls into a single one. So, the idea is to place the syscalls and arguments …

Total answers: 3

Cannot write into /sys/power/mem_sleep in Fedora 36

Cannot write into /sys/power/mem_sleep in Fedora 36 Since I failed to find a way to tell systemctl to go to sleep in a one-time specified mode (see previous question), I decided to write some script to change whether the system goes to sleep in shallow or deep mode by writing directly into /sys/power/mem_sleep. Available values …

Total answers: 1

What happened to llseek and e2fsck?

What happened to llseek and e2fsck? lseek man page: When users complained about data loss caused by a miscompilation of e2fsck(8), glibc 2.1.3 added the link-time warning "the llseek function may be dangerous; use `lseek64 instead." This makes this function unusable if one desires a warning-free compilation. Since glibc 2.28, this function symbol is no …

Total answers: 1

What is difference between sleep and NOP in depth?

What is difference between sleep and NOP in depth? I am trying to learn operating system concepts. Here is two simple python code: while True: pass and this one: from time import sleep while True: sleep(0.00000001) Question: Why when running first code CPU usage is 100% but when running the second one it is about …

Total answers: 5

Using System calls directly

Using System calls directly I have a big confusion regarding the system calls in OS. According to the book "operating systems concepts 9th ", it is mentioned (in page 63) that : Most programmers never see this level of detail, however. Typically, application developers design programs according to an application programming interface (API). Behind the …

Total answers: 4

Can a library call invoke more than one system call?

Can a library call invoke more than one system call? I understand that, for example, calling the library function printf invokes the write(2) system call. My question is: Is there a library call that can invoke more than one system call? In other words: Do system calls always map 1:1 to library calls? Asked By: …

Total answers: 2

How does a linux GUI work at the lowest level?

How does a linux GUI work at the lowest level? I’m basically trying to figure out how one would go about making a GUI from absolute scratch with nothing but the linux kernel and programming in C. I am not looking to create a GUI desktop environment from scratch, but I would like to create …

Total answers: 4

Why are there no file insertion syscalls

Why are there no file insertion syscalls To my understanding, for manipulating files there is only the sys_write syscall in Linux, which overwrites the file content (or extends it, if at the end). Why are there no syscalls for inserting or deleting content in files in Linux? As all current file systems do not require …

Total answers: 2

What is interrupted system call?

What is interrupted system call? I am reading APUE and the Interrupted System Calls chapter confuses me. I would like to write down my understanding based on the book, please correct me. A characteristic of earlier UNIX systems was that if a process caught a signal while the process was blocked in a ‘‘slow’’ system …

Total answers: 2

Atomically write a file without changing inodes (preserve hard link)

Atomically write a file without changing inodes (preserve hard link) The normal way to safely, atomically write a file X on Unix is: Write the new file contents to a temporary file Y. rename(2) Y to X In two steps it appears that we have done nothing but change X “in-place”. It is protected against …

Total answers: 1

Why I can not drop sudo root privileges?

Why I can not drop sudo root privileges? I am debugging a program and not quite sure why I can not drop privileges. I have root permissions via sudo and I can call setgid/setuid, but the operation [is] is not supported. Basic code to reproduce (golang): package main import ( “fmt” “os” “strconv” “syscall” ) …

Total answers: 3