Danett song wrote:
int uid;mm_segment_t old_fs;
old_fs = get_fs();
set_fs(get_ds());
uid = __NR_getuid;
printk("\nUID %d",uid);
All the above will do is print out the number __NR_getuid, this is not a pointer to the function. It is a number used by the system call handler. Also it is unsafe to call a function that depends on a user context from inside the kernel: 1 - you may not have a user context and 2 - especially on multi processor machines you may not get the user context you were hoping for.
Ok, but in this case (if worked) i will be callin the
getuid. If i will call a syscall (sys_*) i need use get_fs() and set_fs() ? Why if i'm already in kernel-space ?
Anyway, doesn't exist a way to access libc functions ? For example feof(), etc ?
You can not access any of the user space functions from inside the kernel.
This is just plan bad. If you want to over write a function you should modify the function itself or modify the operations structure to point to your function instead.
int init_module(void) {
vfat_rmdir_Rc0ad670e=new_vfat_rmdir; return 0;
}
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/