syscall

where did the _syscallN macros go in <linux/unistd.h>?

It used to be the case that if you needed to make a system call directly in linux without the use of an existing library, you could just include <linux/unistd.h> and it would define a macro similar to this: #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ type name(type1 arg1,type2 arg2,type3 arg3) \ { \ long __res; \ __a...

Invalid argument in sendfile() with two regular files

I'm trying to test the sendfile() system call under Linux 2.6.32 to zero-copy data between two regular files. As far as I understand, it should work: ever since 2.6.22, sendfile() has been implemented using splice(), and both the input file and the output file can be either regular files or sockets. The following is the content of sendf...

syscall from within GCC inline assembly

is it possible to write a single character using a syscall from within an inline assembly block? if so, how? it should look "something" like this: __asm__ __volatile__ ( " movl $1, %%edx \n\t" " movl $80, %%ecx \n\t" " movl $0, %%ebx \n\t" ...

Is there a need for file descriptor control program/syscall ?

I am currently thinking of implementing a syscall in some BSD flavours in order to close a given file descriptor. The file descriptor would be defined as a pair of PID and file descriptor number. It will be useful in order to test/debug a program or others strange purposes. I think that I will do it anyway, you know, for learning purpo...

Multiple select() syscalls from one thread in Python.

I'm using a couple of Python libraries, and they both use a select() syscall. I was wondering if it was safe to have two select() syscalls from within the same thread (assuming there are no shared descriptors between them)? ...

Process state when calling syscall?

What process state has when it calls a syscall? I mean, don't asume it's an I/O syscall like read or write... It's the process itselft that executes kernel code, or the process is suspendes and there's like a "kernel thread" that execute the syscall handler (and knows wich process called (current))? I'm not sure if changes from execu...

What is an OpenSolaris syscall calling convention (x86)?

What is an OpenSolaris syscall calling convention (x86)? F.e. I'd like to write a program in 32bit assembly which displays a string to the console. For this I'd like to use "write" syscall (no. 4). C definition for write is: ssize_t write(int fildes, const void *buf, size_t nbyte) what registers should hold fildes, buf and nbyte argu...

How to hook syscall table at runtime on PPC Linux ?

Hello All - Subject: PPC Assembly Language - Linux Loadble Kernel Module Detail: How access local TOC area (r2) when called from kernel in syscall table hook? I have written a loadable kernel module for Linux that uses syscall table hooking to intercept system calls and log information about them before passing the call on to the orig...

How does compiler know that the function you used is a system call?

For the following snippet of code, int n; char buf[100]; int fd = open ("/etc/passwd", O_RDONLY); n = read ( fd, buf, 100); How the compiler comes to know that read is a system call not any library function? How it retrieves the system call number (__NR_read)? ...

How to reimplement (or wrap) a syscall function in linux ?

Suppose I want to completely take over the open() system call, maybe to wrap the actual syscall and perform some logging. One way to do this is to use LD_PRELOAD to load a (user-made) shared object library that takes over the open() entry point. The user-made open() routine then obtain the pointer to the glibc function open() by dlsym()i...

not enough variables to fit a sentinel

According to exec reference, calls to exec (or stack checking vararg functions in general) requires a (char*)NULL aka 0 at the end of the parameter list. GCC, however, is complaining about the following code char cmdFullPath[4096]; //yes this 4096 thing is bad coding practice ... execl(cmdFullPath, (char*)NULL); //warning: not enough ...

Linux Kernel Programming: “Unable to handle kernel NULL pointer dereference at virtual address [address]”

For a class assignment, we are writing a custom syscall which pulls certain information about the existing process tree. The syscall is working fine for the most part and gets the appropriate information. However, a few processes it, in crashes with the error message, "Unable to handle kernel NULL pointer dereference at virtual address...

Adding a "useful" syscall not normally available to a non-root user....

Hey guys, I've implemented a simple Hello World syscall with limited functionality - that simply transitions from user mode to kernel mode, prints a message that is logged with the kernel messages, and transitions back to user mode. The next step for extra credit is to add a useful (new) syscall that is not normally available to a non-...