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
0answers
14 views

How a not generic driver uses all the functions that a hardware device implements?

Its said that in order to use advanced functions for a hardware device, its recommended to use not generic drivers. But if system calls are the ones which call routines or functions from a driver, and ...
0
votes
1answer
13 views

Does BTRFS support the ioctl(fd, FIFREEZE) system call?

the manpage of fsfreeze states: FSFREEZE(8) System Administration FSFREEZE(8) ...
1
vote
1answer
25 views

Is there a better method than ptrace for intercepting (“catching”) Linux syscalls coming from a forked process?

I would like to catch all syscalls coming from a forked process, modify them, send them to the kernel, and then pass them back to the forked process. Is this possible, and if so, how might I go about ...
1
vote
0answers
29 views

Correctly implementing seeking in FUSE readdir() operation

I'm trying to implement a toy file system and I'm struggling to understand how to correctly implement the readdir() operation in an efficient, scalable way. To understand the interface used by FUSE, I'...
0
votes
1answer
101 views

disable rtkit-daemon.service service when selinux is disabled

we have Hadoop cluster , each machine in the cluster is rhel 7.6 version since the provider - hortonworks recommended to disable the selinux then we disabled the selinux on all rhel machines now about ...
0
votes
2answers
61 views

Why does rmdir (the system call) only work on empty directory?

Is it not possible to atomically unlink the directory from its parent's inode? Is there any historical reason behind this?
0
votes
1answer
29 views

Zombie processes and exiting init

Assuming that I decide, for some reason, to never use the syscall wait ever again in any of the programs I write. Does it mean that my memory will be cluttered with all the finished processes that ...
0
votes
0answers
23 views

How do you call a driver function from a user space program (assuming you have properly registered the driver)

I suppose my question must seem hopelessly amateur, but I only started using linux seriously recently, and I cannot find a clear answer to this, rather simple question. I also have some additional ...
2
votes
1answer
83 views

Why is the type of stat.st_size not unsigned int?

I was trying to rely on the stat(2) system-call to determine the size of a file in order to allocate an appropriate buffer for it. More specifically I was using the stat.st_size of the structure that ...
1
vote
0answers
15 views

How pass the file's content through Named Pipe and then copy it into another one?

I wrote 2 programs that normally 1.create the named pipe(server) and 2. pass the string from the shell to the server part. I understand how to hand over a string from the terminal to the server part ...
0
votes
2answers
92 views

Does fork() also copy the file descriptor for the executable binary that the calling process is currently executing?

I've read the man pages on fork(), and they say something along the lines of "all file descriptors open in the calling process are copied". It is not 100% clear to me if the file descriptor ...
1
vote
2answers
71 views

What is the behaviour of a file-backed memory map when reading from or writing to an address larger than the length of the file?

I'm trying to figure out whether it would be undefined behaviour to open a memory map to a file with a very large length. My use-case is that I want to be able to see new data when the file is ...
0
votes
3answers
227 views

What is the relation between SIGCHLD and `waitpid()` or`wait()`?

If I am correct, a process waits for its children to terminate or stop by calling the waitpid() or wait() function. What is the relation between SIGCHLD signal and the waitpid() orwait() functions? ...
0
votes
1answer
102 views

Where to find the syscall_64.tbl in Linux?

I was following this guide to add my own custom system call inside the Linux kernel "Adding a Hello World System Call to Linux Kernel". In Step 5, it asks to modify the system call table by ...
-1
votes
2answers
47 views

Can a library call invoke more than one system call?

I understand that for example the library call printf invokes the write(2) syscall. My question is: Is there a library call that can invoke more than one system call? So in other words: Do system ...
1
vote
0answers
150 views

Implementing own system call linux

I got an assignment to implement my own system call and I have to use latest kernal v5.9. Downloaded linux-5.9-rc8(even stable version is giving same error) and extracted. Then cd into this directory. ...
2
votes
2answers
88 views

Why can kernel features that are reimplemented in user-space be faster than in kernel-space?

I was reading a blog post and noticed the following sentence: Then he said something really surprising: that in the Seastar HTTP framework, they wrote their own TCP stack, and it made everything ...
0
votes
1answer
42 views

can read system call experience short count after it is interrupted by a signal?

Let's say I call read to read 1000 bytes, and when read is reading the 501th bytes then a signal interrupts it, so does read return 500?
0
votes
1answer
91 views

Is it safe to restart system calls?

I was reading a textbook which describes how to deal with system call when interrupted: System calls can be interrupted. System calls such as read, wait, and accept that can potentially block the ...
0
votes
1answer
111 views

How does an open(at) syscall result in a file being written to disk?

I'm trying to learn as as much as I can about about the interplay between syscalls, the VFS, device driver handling and ultimately, having the end device do some operation. I thought I would look at a ...
3
votes
2answers
62 views

How do I feed data to a pipe until it's full, no more no less?

I want to use pipes on Linux as a synchronization primitive between a master process and a slave process. The classic way is to create two pipes, but I believe there's a way to use a single fd instead....
2
votes
1answer
295 views

CIFS mount is returning errors when operating on remote files (file exists, interrupted system call)

I need to replace a string in a file located in a CIFS mount (NTFS NAS). It is mounted with sudo mount -t cifs -o rw,guest,vers=1.0 //192.168.1.1/hdd /hdd I never faced this problem until a week ago, ...
0
votes
2answers
91 views

Syscalls: How does a user processs pass/receive data to/from the kernel?

The relationship between user and kernel virtual addresses has been discussed in a few questions before (links below), but as far as I understand it, the user process cannot read nor write to the ...
0
votes
1answer
38 views

What can a debugger do with /proc that cannot be done with ptrace?

The Wikipedia article on ptrace says: Communications between the controller and target take place using repeated calls of ptrace, passing a small fixed-size block of memory between the two (...
0
votes
0answers
51 views

With io_uring is it possible to do an atomic write and tell?

I would like to append to a file opened in O_APPEND and know where the data was written. Writing and then making a tell call isn't useful as between the system calls there could be a context switch ...
2
votes
1answer
300 views

Counting the number of issued syscalls

Is there any tool to count the number of system-calls issued for example in one-second in the entire system (like a global strace) ? ( Something like what vmstat does for number of interrupts or ...
1
vote
1answer
99 views

strace reports a system call which is taking too long

The problem The following code snippet shows the time it took to my system to open inkscape plus the time it took to me to immediately close the inkscape window. $ /usr/bin/time -p inkscape real 26....
0
votes
1answer
23 views

Module (un)loading procedure in the linux kernel

I would like to know how a userspace program like modprobe can inject an executable file from userspace to kernel memory? What kind of syscalls does it issue and what interfaces are provided by the ...
1
vote
2answers
109 views

How to log, which processes did specific syscalls?

Recently I've found that many processes/demons like to issue unneeded fsync() syscalls, increasing a little bit their stability, on the price of hugely decreasing the general performance of the whole ...
1
vote
0answers
129 views

File utility returns Bad system call

I have a weird error when I'm trying to run the command file. For example if I do file /etc/passwd I get the following output : [neolex@neolex-manjaro ~]$ file /etc/passwd /etc/passwd: ASCII text Bad ...
-2
votes
2answers
63 views

execlp() system call

I want to call the ulimit shell command through a C program. right now, I have: execlp("ulimit", "ulimit", "-u", "%d", ulimit_a); It compiles fine, but does not actually edit the user-id max ...
0
votes
1answer
139 views

Why are “new” syscall faster than “interupt” syscalls?

I'm trying to understand the difference between "old" syscall mechanism using interrupt and the current one relying on specific processor instruction. AFAIK both are working in the same way in terms ...
0
votes
1answer
41 views

How do linux syscalls implementations handle a caught signal?

I understand how signals work in general and I understand that syscalls are changing the task state to TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE to prevent signal interruption on critical sections. ...
2
votes
1answer
174 views

How well do concurrent writes scale with io_uring?

Background: I'm very intrigued by the potential performance gains of io_uring, but I don't have enough familiarity with C, the Linux kernel, or the inner workings of block devices to implement ...
0
votes
0answers
17 views

Linux kernel process execution with logging all IO

Is there option to have sort of proxy on executing binary file, that reads and handles all it's syscalls? I know it's KVM, but I need to access this data on what application is doing, is there open ...
49
votes
4answers
7k views

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 ...
2
votes
1answer
81 views

Question about a process lifecycle

I've managed to question myself about the wait(2) and _exit(2) system calls in a process lifecycle. My question about the wait(2) system call is... does the parent process issue it to the kernel? Or ...
3
votes
1answer
112 views

strace all but specified system calls

How can I run strace, and record all of syscall , but not read and not write?
2
votes
1answer
434 views

problem understanding system(“/bin/sh”)

I'm having problems understanding why this program #include <stdio.h> #include <stdlib.h> int main() { int iRetval = 0; unsigned int uiNum; printf("Enter number: "); ...
4
votes
1answer
230 views

Why we need to set no_new_privs while before calling SECCOMP_MODE_FILTER?

At the man page I read the following line: cause an attempt to use setuid(2) to set the caller's user IDs to nonzero values to instead return 0 without actually making the system call I can't ...
0
votes
0answers
72 views

How to intercept any call to the kernel to spawn a process

I am attempting to make a program that is a system security watchdog. Any processes or ports that are not supposed to be open will be closed by the watchdog to mitigate a breech in security. I'm ...
0
votes
0answers
60 views

Can kernel guarantee that POSIX close frees the descriptor?

Linux developers argue that it's pointless to retry close operation in case of an error, since the kernel "always releases the file descriptor early" (emphasis mine). While in general fildes state ...
0
votes
2answers
127 views

Cryptography and the kernel, System calls

Is cryptography implemented in user space or kernel space? Are public/private key pairs generated in the kernel space? What about encryption or decryption using a given public key or a given private ...
0
votes
1answer
1k views

How to use sys_read() in kernel space properly

I wrote a system call that searches for the given input in a file. But my code is not working because sys_read() is not working. #include <linux/kernel.h> #include <linux/unistd.h> #...
1
vote
1answer
329 views

hrtimer_nanosleep explanation

I have searched the Internet and did not find any explanation for hrtimer_nanosleep. What is the usage of this function and how does it differ from the clock_nanosleep API? Can someone please explain ...
3
votes
0answers
107 views

sendfile doesn't work for empty stdin

Output from strace for non-empty stdin: execve("./cat", ["./cat"], 0x7fff610af090 /* 37 vars */) = 0 sendfile(1, 0, NULL, 1048576) = 4 sendfile(1, 0, NULL, 1048576) = 0 close(0) ...
1
vote
0answers
290 views

why are there so many mmap system call in strace?

I am trying to understand strace command. I started by using strace on some basic commands as shown below. [root@localhost]# strace ls execve("/bin/ls", ["ls"], 0x7ffd79175190 /* 27 vars */) = 0 brk(...
3
votes
1answer
74 views

Why is this code exiting with return code 16?

I am trying my hands on clone() system call to create a Thread. However program is terminating itself as it return from t2_thread() function. Why is this behaviour? What am I missing? #define ...
1
vote
0answers
36 views

System call time measurement

I have implemented a data copying loop using system functions write() and read() if -s command is used or C library functions if -l otherwise. I am trying to measure the time for the system call ...
-1
votes
1answer
99 views

How to break down signal system call prototype in Linux?

I am reading "The Linux Programming Interface", where I find signal system call prototype as stated: #include <signal.h> void ( *signal(int sig, void (*handler)(int)) ) (int); What is signal ...

1
2 3 4 5
7