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
31 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 ...
1
vote
2answers
33 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 ...
-1
votes
1answer
44 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); ...
1
vote
1answer
58 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 ...
5
votes
1answer
239 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: ...
0
votes
0answers
15 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 ...
0
votes
0answers
25 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 ...
0
votes
0answers
22 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", ...
1
vote
0answers
33 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 ...
0
votes
0answers
35 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 ...
0
votes
0answers
32 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 ...
0
votes
1answer
15 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 ...
0
votes
1answer
106 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 &...
3
votes
0answers
73 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 ...
0
votes
1answer
19 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 ...
0
votes
0answers
34 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 ...
0
votes
0answers
32 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 ...
0
votes
0answers
56 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=...
0
votes
0answers
85 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>&...
1
vote
1answer
71 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 ...
-1
votes
1answer
69 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; ...
0
votes
1answer
53 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....
0
votes
0answers
39 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 ...
0
votes
1answer
37 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> ...
0
votes
0answers
251 views

Using macros list_for_each and list_entry in linux kernel

I'm trying to add a new system call to Linux kernel (using virtual machine VMWARE with Ubuntu 18 and Linux version 4.15.0). This system call iterates all the decedents of a given process and uses ...
1
vote
2answers
190 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'...
-1
votes
1answer
86 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 ...
0
votes
0answers
19 views

Understanding sysinfo Ouput for Custom Init Process

With qemu: qemu-system-x86_64 -s -S -enable-kvm -m 512M -drive format=raw,file=myos.img -kernel {5.11.6-kernel} -append "root=/dev/sda init=/sbin/myint nokaslr" The C code (omitted libc ...
4
votes
2answers
379 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 ...
0
votes
0answers
68 views

syscall types logged by auditd vs. sysdig

I am new to Sysdig and auditd to be honest. I am wondering about the difference I notice in the syscalls recorded by each following the same user command. I checked the records logged by auditd after ...
2
votes
1answer
71 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. ...
1
vote
2answers
138 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 ...
0
votes
0answers
29 views

finding the system calls of a screen recorder resposible for interaction with the display server

Many resources online such as this and this point to the fact that screen recorders do not make any system calls to capture the screen. so how does a screen recorder capture the screen ? i came ...
3
votes
1answer
85 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~...
3
votes
1answer
150 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 ...
1
vote
1answer
51 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 ...."); ...
1
vote
2answers
47 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....
0
votes
1answer
179 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 ~/....
0
votes
0answers
20 views

Catch Seccomp Violation of Docker Container

I would like to catch any violations of prohibited systemcalls a container, started with a seccomp profile, executed. For example, my profile defines chown as blocked, which is also prevented within ...
1
vote
1answer
89 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, ...
-1
votes
1answer
46 views

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

the manpage of fsfreeze states: FSFREEZE(8) System Administration FSFREEZE(8) ...
1
vote
1answer
94 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 ...
3
votes
1answer
361 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
739 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 ...
1
vote
2answers
187 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
82 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
351 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
602 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
1answer
266 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
336 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
2 3 4 5
8