syscall

Linux Virtual Timer Behavior on Clone Threads

I have done the following: Create a virtual timer that triggers repeatedly. Install signal handler for SIGVTALRM Call clone syscall Set sched_affinity such that the cloned thread runs on a different CPU Will the cloned thread also be listening for SIGVTALRM? So will both the threads call the signal handler when SIGVTALRM is triggered...

Cross platform way of testing whether a file is a directory

Currently I have some code like (condensed and removed a bunch of error checking): dp = readdir(dir); if (dp->d_type == DT_DIR) { } This works swimmingly on my Linux machine. However on another machine (looks like SunOS, sparc): SunOS HOST 5.10 Generic_127127-11 sun4u sparc SUNW,Ultra-5_10 I get the following error at compile time...

select()-able timers

select() is a great system call. You can pack any number of file descriptors, socket descriptors, pipes, etc. and get notified in a synchronous fashion when input becomes available. Is there a way to create an interval/oneshot timer and use it with select()? That would save me from having multiple threads for IO and timing. ...

Conflict between system call number and system call handler pointer

When I was reading Operating System Concepts (7e, Silberschatz, Galvin, Gagne), I encountered a study project about adding a system call to the linux kernel. The book says that The system call numbers for recent versions of the Linux kernel are listed in /usr/src/linux-2.x/include/asm-i386/unistd.h. (for instance, __NR_close, whic...

In a Linux user space process what is the address of the vsyscall page?

I would like to acquire the address of the vsyscall page for my own uses. I only have two ideas here: alter the compiler to store this information in some known location after it is given to __start, or read /proc/[pid]/maps. I really don't want to read /proc/ as that is slow and shouldn't be necessary. I also don't want to make compi...

libmysqlclient hangs on vmsplice()

Hi I am running an executable that uses libmysqlclient.so.15 on a 64bit kernel & 32bit user space compatibility mode. Once in a while, my program hangs on something from libmysql: #0 0xf7f01430 in __kernel_vsyscall () #1 0xf7b451e3 in vmsplice () from /lib/i686/cmov/libc.so.6 #2 0xf7e72c10 in ?? () from /usr/lib/libmysqlclient.so.1...

How does a syscall knows where the wrapper function put its parameters in?

I'm trying to implement a syscall in Linux (RedHat Enterprise 8) and I'm a bit confused about the way it works. From what I understand, I implement a wrapper in user mode which puts the syscall number in eax and parameters in ebx, ecx, edx, etc, and then invokes int 0x80 which calls the appropriate syscall. My question is, since a syscal...

What are the calling conventions for UNIX & Linux system calls on x86-64

Explains both UNIX (BSD flavor) & Linux system call conventions for x86-32: http://www.int80h.org/bsdasm/#system-calls http://www.freebsd.org/doc/en/books/developers-handbook/x86-system-calls.html Can any one please tell me or point me to similar doc for x86-64 on both UNIX & Linux? ...

Why does the rename() syscall prohibit moving a directory that I can't write to a different directory?

I am trying to understand why this design decision was made with the rename() syscall in 4.2BSD. There's nothing I'm trying to solve here, just understand the rationale for the behavior itself. 4.2BSD saw the introduction of the rename() syscall for the purpose of allowing atomic renames/moves of files. From 4.3BSD-Reno/src/sys/ufs/uf...

How to get high resolution time using sparc assembly ?

I use syscall SYS_time, but its resolution is 1 second. Is there any other solution? ...

List of and documentation for system calls for XNU kernel in OSX

I'm trying to figure out how to get a list of and documentation for the system calls available in the XNU kernel in OSX. I've googled around quite a bit, but haven't been able to find anything of use. As I understand the calling conventions match BSD, is that correct? Thanks ...

Invalid argument when calling linux splice()

Hi I wanted to try out the splice syscall. I have this function - it should copy content of one file to another: static void test_splice( int in, int out ) { int i = 0, rcvd = 0; int filedes[2]; off_t off = 0; if ( pipe( filedes ) < 0 ) { perror( "Kicha pipe" ); exit( EX...

How do I know which DLL a syscall belongs to?

I have a long list of all the calls a program I have does. What i need to know is which DLL each call belongs to. How would I find this out? Thanks, ...

How do I write x86 Debug registers from user space on OSX?

I'd like to play around with the debug MSRs defined in the x86 spec (DR0-7) from my OSX user-space program. Unfortunately, these require CPL == 0 (aka ring 0). I've thumbed through the OSX syscalls and with the exception of kernel_debug nothing really jumps out as a way to access these. It may be the case that they are only available vi...

Where are the files necessary to modify when adding a system call to linux-2.6.31

Hi, when i search for adding a system call, i get many articles but they seem to be for old versions, it also seems like a trivial process. But the problem is, the directories that articles suggest does not hold for the version 2.6.31. does anyone know where unistd.h, syscall_table.S and syscalls.h or their corresponding files are? Th...

x86 Assembly: Before Making a System Call on Linux Should You Save All Registers?

I have the below code that opens up a file, reads it into a buffer and then closes the file. The close file system call requires that the file descriptor number be in the ebx register. The ebx register gets the file descriptor number before the read system call is made. My question is should I save the ebx register on the stack or somew...

Is there a way to have a bit bucket pointer? (C/C++)

Is there a way to have a bit bucket pointer? A lot of IO (specifically input related) system calls return data to a buffer of a specific size. Is there a trick or way to make a sorta bit bucket pointer, so I can accept any amount of data that will be thrown away. Doing something like "char tmp[INT_MAX]" is crazy. The behavior I am looki...

Is there a POSIX syscall to resolve file system paths?

Is there a POSIX syscall to resolve filesystem paths? I have the CWD for a path, as well as the path to a file from that CWD. I can't use chdir to switch to the directory because I need to resolve paths from multiple threads simultaneously. I considered appending a / in between the CWD and the path, but for some reason it feels like that...

How to Dynamically Allocate Memory Using Assembly and System Calls Under Linux

I'm looking for some good code examples of dynamic memory allocation using an assembly language under Linux and using system calls, not malloc and friends. What are some of the simplest but effective ways to do this? On Intel 386+ computers. ...

getpid from syscall with 32 bit app and kernel on snow leopard

Hi, I successfully called the exit syscall from assembly but I'm strugling to call the _getpid syscall and use it's return value. Here is the code I'm using .text .globl _getpiddirect _getpiddirect: pushl %ebp movl %esp, %ebp subl $8, %esp movl $39, %eax int $0x80 addl $8, %esp popl %ebp ret and #inc...