- Disappointed, 'cause they don't wanna take your brand new syscall into the kernel ? + No problem, I'll do it for you. - Can't recompile the kernel, otherwise you gonna lose RedHat guarantee ? Or some ISVs like whose name starts with an "O" and terminates with "racle" ain't gonna support it ? + No problem, I'll load your syscall in a module. - Got a syscall number conflict 'cause of an exotic patch slipped in before your one ? + No problem, I'll find a free syscall number for you dynamically. - Wanna try your own version of a syscall without recompiling the kernel or rebooting it ? + No problem, I'll hijack the syscall for you. - Fed up with the infinite number of different kernel configurations ? Can't follow any more what .config you've done for which of your clients ? + No problem, make a minimal kernel with almost nothing in it and load dynamically the syscalls actually needed. My loadable kernel module "dyn_syscall.ko" provides for registering / unregistering or hijacking / restoring system calls. Sure, it's a loadable kernel module, who wants to modify the kernel ? :-) My patch is against the version 2.6.4. As there is not much in the way of direct dependency on the kernel, it should work with more recent versions, too. Playing with the system call mechanism is very much architecture dependent. Its key element is written in assembly. I've got an IA64 version only. How can it be used ? -------------------- Assuming you've got a system call like "asmlinkage long sys_foo(...)" in a loadable kernel module. You can register it with an unused system call number: const char name[] = "foo"; rc = dyn_syscall_reg(name, syscall_no, (dyn_syscall_t) sys_foo); If "syscall_no" is zero, I'll find a free system call number for you. (Do check the return code. On success, it's your system call number.) Or you can register your system call over an existing one: rc = hijack_syscall(name, syscall_no, (dyn_syscall_t) sys_foo); Having fully initialized your system call, you can make it available: rc = syscall_unlock(name, syscall_no); This sequence is usually included in the "module_init(...)" function. User applications can find out what your system call number is by consulting "/proc/sys/kernel/dynamic_syscalls/foo" or "/proc/sys/kernel/hijacked_syscalls/foo", respectively. Having played enough with your system call, you can launch the module unload procedure, without worrying about the "living calls" which may be "part way" through your module: rc = prep_restore_syscall(name, syscall_no); This function locks out further calls to the "syscall_no" (they will be refused with the return code "-ENOSYS"). It returns "-EAGAIN" if there is still someone inside your system call. In this latter case you can wait until your last client leaves: while((rc = syscall_trylock(name, syscall)) == -EAGAIN) schedule(); If you have a blocking system call, then instead of busy waiting, wake up the waiting tasks and go to sleep a bit in the mean time. Finally, you can invoke: rc = dyn_syscall_unreg(name, syscall_no); or rc = restore_syscall(name, syscall_no); to remove completely your registered or hijacked system call, respectively. This sequence is usually included in the "module_exit(...)" function. The function prototypes are in "asm/dyn_syscall.h". In order to configure this module, say "m" in: Processor type and features: Support for dynamic system calls The patch & the demos arrive in the next mails. Your remarks will be appreciated. Zoltán Menyhárt