Skip to main content

Questions tagged [system-calls]

Questions concerning the details of how a program uses system calls to interact with the kernel API, what calls are available, how they work etc.

Filter by
Sorted by
Tagged with
0 votes
0 answers
59 views

Running find on NFS mount much slower on RHEL8 vs RHEl7

I'm in the process of replacing some RHEL7 NFS server/client systems with RHEL8 systems, performing the same functions. On the RHEL8 NFS client, I noticed running a find command on the NFS mount, is ...
keyboard_banger's user avatar
10 votes
1 answer
1k views

What is the rationale for the change of syscall calling convention in new Linuxes?

Quoting from https://www.kernel.org/doc/Documentation/process/adding-syscalls.rst: At least on 64-bit x86, it will be a hard requirement from v4.17 onwards to not call system call functions in the ...
Petr Skocik's user avatar
  • 29.1k
6 votes
1 answer
716 views

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 ...
prajasek's user avatar
6 votes
1 answer
282 views

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 ...
Colourful's user avatar
0 votes
0 answers
52 views

How to "wake-up" user space threads from kernel?

Suppose you have a kernel device driver receiving data and a user space threads waiting for the data. You want to avoid wasted cycles by having the user space thread block and wake-up once the kernel ...
FourierFlux's user avatar
2 votes
1 answer
260 views

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....
sina bala's user avatar
  • 506
0 votes
0 answers
25 views

Impact of using SHM_HUGE_1GB for a size much smaller than 1GB (say, 64MB)

I'm relatively new to actually using (not understanding) a shared memory in Linux. I'm dealing with the situation now where I need to allocate a contiguous chunk of shared 64MB memory. While picking ...
Gwangmu Lee's user avatar
0 votes
1 answer
42 views

Synchronous syscalls and uninterruptible sleep

My application entered uninteruptible sleep. The process is stuck at linkat. ❯ sudo cat /proc/1308028/syscall 265 0xffffffffffffff9c 0x7fbd9f32a120 0xffffffffffffff9c 0x7fbd9f395930 0x400 ...
mq7's user avatar
  • 101
3 votes
1 answer
110 views

is stat(2) read-after-write consistent with write(2)?

man 2 write states: POSIX requires that a read(2) that can be proved to occur after a write() has returned will return the new data. Note that not all filesystems are POSIX conforming. In Linux, is ...
Shivaram Lingamneni's user avatar
1 vote
1 answer
368 views

Where does the signal that causes EINTR come from?

I Understand that EINTR is an error which so-called interruptible system calls may return. My question is where does the signal that causes EINTR come from? I faced this quite often when using fnctl ...
chewing gum's user avatar
0 votes
0 answers
19 views

Issue with open syscall in /tmp folder with uid 0 [duplicate]

I have conducted a small test which raised an issue i could not figure out. Create file in /tmp named what as shell user (uid 1000), then make it 0666 (rw-rw-rw-) Try to call open with uid 0 (root) ...
TOK's user avatar
  • 1
0 votes
2 answers
277 views

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.
Corel's user avatar
  • 103
2 votes
1 answer
984 views

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....
ealfonso's user avatar
  • 955
3 votes
1 answer
489 views

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" ...
ABu's user avatar
  • 556
0 votes
0 answers
129 views

Why: error: implicit declaration of function 'sys_close'?

I am trying to install the latest NVIDIA driver in Debian 12; part of the process involves building some kernel modules. Most of these compile without error, but it fails near then end (around 96%, ...
j4nd3r53n's user avatar
  • 717
0 votes
1 answer
127 views

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/...
Danny Cohen's user avatar
0 votes
0 answers
237 views

Parallelism and I/O in Linux

I'm a bit confused about how the Linux kernel handles parallelism during I/O operations (if it handles it at all). I assume it can concurrently operate on file descriptors, but does it achieve ...
asnail's user avatar
  • 1
0 votes
2 answers
281 views

exec() system call in Linux

Accoding to this link, we need to terminate the list of argumnets by a null pointer. This is stated as : The list of arguments must be terminated by a null pointer. My question is why we need to ...
John adams's user avatar
11 votes
3 answers
2k views

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 ...
drahnoel's user avatar
  • 333
3 votes
0 answers
264 views

Lower system call perfermance on aarch64 vs. x86-64

Does anyone know why system calls take longer to execute on 64-bit ARM (aarch64) compared to 64-bit Intel CPUs (x86-64)? Please see below my benchmarking setup. 64-bit ARM CPU: Ampere Altra Q80-30, ...
Dumi Loghin's user avatar
9 votes
1 answer
4k views

Why can Wine convert Windows systemcall to Linux systemcall?

As long as the architectures are the same, it is no wonder that Windows .exe file can run on the Linux system (if it is properly loaded on the RAM). But systemcalls of Linux and Windows are entirely ...
user356126's user avatar
0 votes
1 answer
117 views

syscall accept4() returns an invalid value

I created a program similar to "strace" which is able to log the syscalls. Also I installed a webserver and watched the syscalls from 'strace' and from my program and compared them. For each ...
user554179's user avatar
2 votes
0 answers
21 views

system call poll for /tmp/.X11-unix/X1 takes too long

I have a GUI program that takes too long to respond, so I used strace -T to report all its system calls. I find the reason causing the program slow is poll costs too much time. For example, the ...
Simon's user avatar
  • 170
2 votes
1 answer
69 views

How do I insert my own lib to other binaries in Linux?

My goal is developing a tool for educational purposes which logs commands on a system. Until now have found primitive ways to do this but all these ways can be easily bypassed so I had this idea to ...
Jugert Mucoimaj's user avatar
2 votes
0 answers
456 views

How to get the current cgroup ID from C/C++?

The eBPF helper functions define bpf_get_current_cgroup_id for eBPF programs, which does the obvious thing u64 bpf_get_current_cgroup_id(void) Return A 64-bit integer containing the current ...
user547386's user avatar
3 votes
1 answer
3k views

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 ...
Silmathoron's user avatar
1 vote
1 answer
473 views

How can I efficiently read entries in a directory?

I would like my program to efficiently detect if a file was added to a directory between two invocations. That analysis might block user input (this would be for the fish shell), so I want it to run ...
Narrateur du chaos's user avatar
0 votes
1 answer
2k views

Get executable name in syscall?

So I am writing a system call in Linux. I want to print a message that looks like printk(KERN_DEBUG "PROC_DEBUG [%s, %s]: %s", executable, current->pid, message); Where executable is the ...
TheIncrediblyStupidOne's user avatar
9 votes
1 answer
531 views

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 ...
user3528438's user avatar
2 votes
1 answer
550 views

Why do syscalls not accept userspace callback functions?

This question is an extension of why do we need to pass buffers to system calls in order to have information returned? Why can't system calls allocate the buffer internally? since memory ...
Isaac's user avatar
  • 23
2 votes
1 answer
625 views

How are system call functions linked to an executable?

Say I write a non-sensical program that features a single system call, open: #include <fcntl.h> void main() { int hi = open("does not exist", 0); } When I compile the program ...
Izzo's user avatar
  • 971
1 vote
3 answers
118 views

How to detect when a terminal emulator closes from an orphaned process

I have a command line utility that spawns a daemon process which then becomes orphaned. How can I make the daemon exit along with the terminal emulator?
Rillian Grant's user avatar
8 votes
5 answers
3k views

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 ...
Mojtaba Kamyabi's user avatar
1 vote
0 answers
89 views

Under what conditions are unix (Mac OS ) sytem calls restarted after getting interrupted by a signal ? What do the man page mean by "calls committed"?

I'm reading a book on unix systems and I'm at the part where signals are discussed. I'm a bit confused when it comes to what happens when a system call is running and a signal is received. It says ...
user529815's user avatar
1 vote
1 answer
370 views

Why is the linux system call interface architecture-dependent?

So one thing I'm not clear on is why transitioning from user space to kernel space is architecture-dependent. For example, the linux kernel v5.4 code for system calls entering kernel space is ...
user49404's user avatar
  • 181
2 votes
0 answers
153 views

What is the complete list of file functions equivalent to the "strace -e file" options?

According to man strace the -e file option traces all syscalls which take a file name as an argument. What is the whole set? %file file Trace all system calls which take a file ...
guronanak's user avatar
-1 votes
1 answer
459 views

Can the stdout (1) file descriptor be re-used after closing?

I first call close(1) and then later open a file using open() syscall. Is it possible that open() returns 1 because it will use the lowest free file descriptor? I have read that open() uses the lowest ...
zomega's user avatar
  • 972
1 vote
2 answers
741 views

why do we need to pass buffers to system calls in order to have information returned? Why can't system calls allocate the buffer internally?

I'm reading TLPI, and in section 4.4: System calls don’t allocate memory for buffers that are used to return information to the caller. Instead, we must pass a pointer to a previously allocated ...
sudeepdino008's user avatar
2 votes
2 answers
556 views

X11: what system calls does X.Org Server use to realize GUI environment?

Recently, I am studying Xlib and come to have a question: What system calls (API's) does X.Org Server use to realize GUI environment. In terms of output, what system calls enable us to draw windows (...
user356126's user avatar
1 vote
1 answer
709 views

Timing system call with ltrace: Adding `syscall` + `clock_gettime`?

I'm looking for some clarity in terms of the system calls. I tried avoiding the vDSO by calling a system call clock_gettime directly. Here is a snippet of a program named sys_clock_gettime. int clock =...
Xavier Merino's user avatar
7 votes
4 answers
4k views

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 ...
AAA's user avatar
  • 207
0 votes
0 answers
107 views

Is there a darwin (arm64) equivalent of `O_PATH` for open?

I want to get the file descriptor without opening the file which can be attained by using the O_PATH flag on linux. (ref) This flag doesn't seem to be there on darwin. Context I'm trying to use open ...
Alan's user avatar
  • 101
1 vote
1 answer
633 views

Retrieve the virtual page id from a virtual address

We know this following function from Linux kernel, which takes a pointer to the struct page and outputs the virtual address of the page frame: void * page_address(struct page *page) So I wonder if a ...
JGL's user avatar
  • 147
0 votes
0 answers
350 views

How to track open() syscalls in FUSE filesystem?

I want to track all open() syscalls of a process inside a FUSE filesystem. Two concerns: Is there any usecase, when open() syscall will not trigger a FUSE filesystem operation? For example syscall ...
Kuchara's user avatar
  • 133
2 votes
2 answers
708 views

Linux Page Cache Performance versus memcpy

I am benchmarking the write performance in the case that Linux writes the data to the page cache without throttling the process or syncing the data to the disk. The simple experiment I am doing looks ...
Gongotar's user avatar
-1 votes
1 answer
1k views

Empty hostname (sethostname)

For some unrelated reason I want to set the hostname of a Linux machine to an empty string using the sethostname system call. #include <unistd.h> int main() { sethostname("", 0); ...
Simon Fromme's user avatar
2 votes
1 answer
217 views

Why fcntl() range lock (some offset to length) is slower as compared to fcntl full file lock (0 offset to EOF)? [closed]

I am trying to write on 1 GB file from 8 different processes (every process will start writing from 0th offset till EOF) simultaneously; while following two different approaches. Before writing every ...
MankPan's user avatar
  • 77
5 votes
1 answer
744 views

Difference between posix_fadvise and readahead

As per manpage, readahead is Linux specific: CONFORMING TO The readahead() system call is Linux-specific, and its use should be avoided in portable applications. and posix_fadvise is portable: ...
arunanshub's user avatar
1 vote
0 answers
88 views

Output redirection ownership

When i execute cat file.txt > newfile.txt, which process or program is executing the syscall? I've tried using strace cat file.txt > newfile.txt to identify this, but havent been successful in ...
Hysii's user avatar
  • 111
1 vote
2 answers
866 views

Using statvfs to get total and free filesystem size

I want to use the return values from statvfs to get the total and free filesystem size. unsigned long f_bsize; /* Filesystem block size */ unsigned long f_frsize; /* Fragment size */ fsblkcnt_t ...
finefoot's user avatar
  • 3,132

1
2 3 4 5
7