Questions tagged [system-calls]

A system call is used by programs to request services from the operating system's kernel.

3690 questions
16
votes
1 answer

close() x86_64 system call weird return value

My xinetd daemon suddenly stopped working after a kernel upgrade (from 2.6.24 to 2.6.33). I've run an strace and found this: [...] close(3) = 0 munmap(0x7f1a93b43000, 4096) = 0 getrlimit(RLIMIT_NOFILE,…
sevenup
  • 170
  • 8
15
votes
4 answers

Any benefit in using WEXITSTATUS macro in C over division by 256 on exit() status?

I was doing an exercise for university where I had to return a value with exit, that value was actually a count of something. This could be above 255 (which exit() can't handle) but the teacher suggested to use test data where the count could never…
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
15
votes
3 answers

how do i add a system call / utility in xv6

Can any one tell me/ point me any references to how to add a system call / utility in XV6 exhaustive search on google was futile and hacking the hard way also was not productive so far . the reference book also did not have any hello world example…
sashank
  • 1,531
  • 2
  • 13
  • 26
15
votes
1 answer

Go syscall v.s. C system call

Go, and C both involve system calls directly (Technically, C will call a stub). Technically, write is both a system call and a C function (at least on many systems). However, the C function is just a stub which invokes the system call. Go does not…
Changkun
  • 1,502
  • 1
  • 14
  • 29
15
votes
5 answers

getrandom syscall in C not found

The problem was resolved by upgrading the C library. I would like to use the syscall getrandom (http://man7.org/linux/man-pages/man2/getrandom.2.html) gcc-5 -std=c11 test.c #include #include #include…
anothertest
  • 979
  • 1
  • 9
  • 24
15
votes
7 answers

Perl: After a successful system call, "or die" command still ends script

I am using the following line to make a simple system call which works: system ("mkdir -p Purged") or die "Failed to mkdir." ; Executing the script does make the system call and I can find a directory called Purged, but the error message is still…
FintleWoodle
  • 157
  • 1
  • 1
  • 7
15
votes
6 answers

What encoding used when invoke fopen or open?

When we invoke system call in linux like 'open' or stdio function like 'fopen' we must provide a 'const char * filename'. My question is what is the encoding used here? It's utf-8 or ascii or iso8859-x? Does it depend on the system or environment…
xeranic
  • 1,391
  • 1
  • 9
  • 16
15
votes
1 answer

Why are the system call numbers different in amd64 linux?

I noticed that the x86 int $0x80 and the amd64 syscall system calls have different numbers. For instance, sys_exit is syscall 1 in x86 and syscall 60 in amd64. Is there a (historical) reason for the different system call numbering schemes?
fuz
  • 88,405
  • 25
  • 200
  • 352
14
votes
2 answers

How to retrieve the user name from the user ID

I am implementing the (ls) command on Unix while learning from a book. During the coding part of my implementation of the (ls) command with the (-l) flag, I see that I have to prompt the user and group names of the file. So far I have the user and…
CompilingCyborg
  • 4,760
  • 13
  • 44
  • 61
14
votes
2 answers

Why is clock_nanosleep preferred over nanosleep to create sleep times in C?

Which one of the two functions is better #include int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp); OR #include int nanosleep(const struct timespec *rqtp, struct timespec…
payyans4u
  • 351
  • 2
  • 5
  • 16
14
votes
2 answers

Bad address when adding a system call

I have downloaded kernel 2.6.38-5 and want to add a system call. I did the following: I have added my system call to system call table; /arc/x86/kernel/syscall_table_32.S .long sys_mycall I have added the system call number;
Majid Azimi
  • 5,575
  • 13
  • 64
  • 113
14
votes
4 answers

In QEMU, is it possible to intercept packets being sent/received by the Linux Guest OS?

We are doing a little project that involves monitoring the Guest OS (for example Linux) from the hypervisor layer (i.e. QEMU). One of the things that we want to monitor is network traffic going in/out of the Guest OS. Is it possible to do so without…
Wasif
  • 161
  • 1
  • 5
14
votes
1 answer

Why do x86-64 Linux system calls modify RCX, and what does the value mean?

I'm trying to allocate some memory in linux with sys_brk syscall. Here is what I tried: BYTES_TO_ALLOCATE equ 0x08 section .text global _start _start: mov rax, 12 mov rdi, BYTES_TO_ALLOCATE syscall mov rax, 60 syscall The…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
14
votes
1 answer

Golang: How to use syscall.Syscall on Linux?

There is a very nice description about loading a shared library and calling a function with the syscall package on Windows (https://github.com/golang/go/wiki/WindowsDLLs). However, the functions LoadLibrary and GetProcAddress that are used in this…
Michael
  • 4,722
  • 6
  • 37
  • 58
14
votes
3 answers

Why do we need to call poll_wait in poll?

In LDD3, i saw such codes static unsigned int scull_p_poll(struct file *filp, poll_table *wait) { struct scull_pipe *dev = filp->private_data; unsigned int mask = 0; /* * The buffer is circular; it is considered full * if "wp"…
demonguy
  • 1,977
  • 5
  • 22
  • 34