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
1 vote
0 answers
23 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 ...
user avatar
1 vote
1 answer
46 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 ...
user avatar
  • 171
1 vote
0 answers
28 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 ...
user avatar
0 votes
0 answers
28 views

How to get schedule delay information of each cpu?

I know that the scheduling information of each process can be obtained from procfs, but I don't know how to get the schedule delay information of each cpu. It's better to use procfs or syscall.
user avatar
  • 1
-1 votes
1 answer
35 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 ...
user avatar
  • 341
1 vote
2 answers
69 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 ...
user avatar
1 vote
2 answers
80 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 (...
user avatar
1 vote
1 answer
55 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 =...
user avatar
0 votes
0 answers
27 views

Are iodepth and iodepth_batch the same in fio?

Wanted to know the difference between iodepth parameter and iodepth_batch parameter in fio. Here is what is mentioned in fio read the docs : iodepth=int Number of I/O units to keep in flight against ...
user avatar
7 votes
4 answers
2k 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 ...
user avatar
  • 87
0 votes
0 answers
32 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 ...
user avatar
  • 1
1 vote
1 answer
86 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 ...
user avatar
0 votes
0 answers
77 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 ...
user avatar
  • 101
2 votes
2 answers
145 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 ...
user avatar
-1 votes
1 answer
147 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); ...
user avatar
1 vote
1 answer
71 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 ...
user avatar
  • 67
5 votes
1 answer
308 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: ...
user avatar
0 votes
0 answers
30 views

How to use syscall to change vDSO content

I am trying to implement a syscall on x86 that is able to modify the content of vDSO. Given vDSO content is read-only for userspace, I believe a syscall is needed. Otherwise it will cause segmentation ...
user avatar
0 votes
0 answers
51 views

Is there an (easy) way to intercept a system call sysconf(_SC_PHYS_PAGES) in Linux to tell Chrome that we only have 1GB, use it wisely?

I understand when Chrome sees any free RAM it allocates it for cache etc. And there is no option to tell it to minimise its memory usage (please correct me if there is). Is there an (easy) way to ...
user avatar
0 votes
0 answers
28 views

Why does sleep() call returns when attaching to the process with a debugger?

While debugging one C application I added a code like this: #include <unistd.h> // ... if( /* some condition violated */ ) { log(WARNING, "condition violated! run `lldb -p %d`\n", ...
user avatar
1 vote
0 answers
35 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 ...
user avatar
  • 111
0 votes
2 answers
112 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 ...
user avatar
  • 1,976
0 votes
0 answers
33 views

How specifically do userspace programs interact with read-only files/hardware?

In my quest to understand *nix architecture more fully, I came across a situation that I feel probably touches quite a lot of complex topics that I don't quite understand around how programs end up ...
user avatar
0 votes
1 answer
38 views

How can I set the supplementary groups of a process?

I can see the supplementary groups of a process by running cat /proc/$PID/status and looking at the Groups: line. How can I modify this value for a process? I know that these values are normally ...
user avatar
  • 147
0 votes
1 answer
233 views

getaddrinfo() return both ipv4 and ipv6 while local system has ipv4 only

I use getaddrinfo(3) to get list ip address from a domain which support both ipv4 and ipv6, but the local system support ipv4 only or both ipv4 & ipv6, As I expect, if system support both ipv4 &...
user avatar
3 votes
0 answers
112 views

What could cause EROFS error for an openat call of a symlinked path, but only sometimes?

I'm trying to debug an issue which I see only intermittently, often only once or twice per server and then it goes away. I have an application which attempts to open a lock file using openat() with ...
user avatar
  • 7,740
0 votes
1 answer
22 views

How find out through terminal that if any system command uses specific system call internally?

I am new to linux.I want to that how to find out through terminal that if any system command uses specific system call internally? Suppose hard linking is to be performed . So "ln" command ...
user avatar
  • 101
0 votes
0 answers
45 views

seccomp-bpf program in linux

my question is can I use seccomp-bpf program widespread in system in Linux? I mean: we can use seccomp in our program or in our child program to filter syscalls for example, OK, now I want to use this ...
user avatar
  • 1
0 votes
0 answers
60 views

Selinux avc denied read write to shm key

I am new to selinux concept and I want httpd to access shared memory, but some how httpd is not able to access the shared memory, as per audit log the message tells read write is denied for shm class ...
user avatar
0 votes
0 answers
103 views

httpd, avc: denied { unix_read unix_write }

I am new to selinux concept and here I am stuck on how to make httpd perform {unix_read unix_write} Below is the audit log message. type=IPC msg=audit(1624375715.312:4225): ouid=0 ogid=0 mode=0666 obj=...
user avatar
0 votes
0 answers
155 views

Strace displaying results in ASCII only at process ending and not runtime

I'm searching a way for strace to print the content of the write(...) syscall to ASCII and not useless bytes ! The Strace command I use : sudo strace -e write=1 -e trace=write -s9999 -p 551 2>&...
user avatar
  • 123
1 vote
1 answer
104 views

how to declare a new variable in vvar.h |create a vdso in linux

I am trying to declare a new variable in vvar.h and define it near my new VDSO function. So that I could use this variable in my vdso function. I have a trouble about VVar. According to the ...
user avatar
-1 votes
1 answer
133 views

ptrace PTRACE_PEEKTEXT error

Why I get this error when I use ptrace PTRACE_PEEKTEXT in my C program?? the part of program that I use PTRACE_PEEKTEXT in it is: static void read_file(pid_t child, char *file) { char *child_addr; ...
user avatar
0 votes
1 answer
80 views

Kernel: Intercept listen call with module

I am writing an application that will detect any application calling listen(2) to open a socket for incoming connections and look up with a table of rules. It is much like ApplicationFirewall in macOS....
user avatar
  • 21
0 votes
0 answers
63 views

Linux kernel - Syscall Implentation - Page Table Walk

I am trying to learn a few things about the linux kernel and I have come across a kind of exercise which asks to implement two system calls on th 4.15.0+ linux kernel which aim at reading the pages ...
user avatar
0 votes
1 answer
50 views

Sysdig does not show exit event for write syscall

I'm trying to capture write to stdout (or stderr), but apparently the actual data is related to the exit event. I wrote a simple C program that writes to stdout and stderr. #include <stdio.h> ...
user avatar
1 vote
2 answers
665 views

How to determine, whether a file is open?

My code needs to go through files in a directory, picking only those, which are currently opened (for writing) by any other process on the system. The ideal solution would apply for all Unixes, but I'...
user avatar
-1 votes
1 answer
178 views

Can a program execute another program without the shell as an intermediate?

This might be a silly question. Can a program written for Linux (for example written in Golang), invoke a system call to execute another program directly, or does it have to call the shell first and ...
user avatar
  • 121
4 votes
2 answers
498 views

Why is the stack argument required for the clone wrapper?

I've been carefully reading the linux man page for clone(), and I understand the difference between the clone() wrapper and the "raw" system call. But what I don't understand is why the ...
user avatar
2 votes
1 answer
125 views

API/syscall to read or list BSD/macOS file flags

I've learned that besides the standard *nix file permissions, macOS also has file flags, and that they originated with BSD Unix. macOS's set of such flags is: UF_NODUMP Do not dump the file. ...
user avatar
2 votes
2 answers
257 views

How can I mount /dev from C?

How can I mount /dev from C? I'm writing a simple init, and I know this sounds stupid but I would like to have /dev mounted to another folder. The manpages for mount() don't show dev as a supported ...
user avatar
  • 33
3 votes
1 answer
101 views

What could be a cause for getdents returning different results on 2 systems?

I have a weird situation that on one server I am getting following results: vagrant@shopping:/vagrant/deployer-example$ uname -a Linux shopping 4.19.0-0.bpo.9-amd64 #1 SMP Debian 4.19.118-2+deb10u1~...
user avatar
  • 495
3 votes
1 answer
325 views

Strace shows that the time spent in syscalls is much longer than the total time elapsed. Why?

I am running an AI inference program based on Tensorflow-gpu. By running /usr/bin/strace -c -f /usr/bin/time ./program, I got the following output: <my program's output> 367.91user 1032.14system ...
user avatar
1 vote
1 answer
97 views

LD_LIBRARY_PATH env var missing in subshell from system(3) call

We have a huge client server business application, the server written in C, which does printouts on user request with something like: system("/usr/local/sisis-pap/cups/bin/lpr ...."); ...
user avatar
  • 31
1 vote
2 answers
102 views

How do you pull the syscalls from an application and are they same as the functions used in source code?

I'm trying to pull out SysCalls from source code but I'm a little confused. I've found source like https://chromium.googlesource.com/chromiumos/docs/+/master/constants/syscalls.md and https://filippo....
user avatar
  • 1,682
0 votes
1 answer
370 views

Invalid system call error when executing file command

I noticed a strange thing. When I run the file command as a regular user, I always get an invalid system call error. For example in zsh: $ file ~/.zshrc [1] 18553 invalid system call file ~/....
user avatar
  • 1,471
1 vote
1 answer
145 views

strace calls from running process and count them

I have a background process that will run for many many hours. I would like to trace and count the number of write calls live. sudo strace -p27861 -s50 -e write It gives me lines like this: write(1, ...
user avatar
-1 votes
1 answer
65 views

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

the manpage of fsfreeze states: FSFREEZE(8) System Administration FSFREEZE(8) ...
user avatar
  • 517
1 vote
1 answer
126 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 ...
user avatar
4 votes
1 answer
531 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'...
user avatar

1
2 3 4 5
8