i have written a simple module which is calling the function kern_stat() which is defined in /usr/src/sys/kern/vfs_syscalls.c
the call looks like:
now, uap->path is the path to the thing which shall be stat'ed, td is the struct thread(the current thread which is calling) and sb is a stat buf which was allocated before, to save the results and copy it later back to userland(i dont know what UIO_USERSPACE is doing).
luckily this call works perfectly fine in syscall stat, as it was build for that and got the correct arguments delivered, but i try to use this outside of a function which can deliver me arguments from the userland side. my adjusted code is like:
kernel_path is: /bin/ls
i get a return code of 14(EFAULT) (/usr/include/sys/errno.h) which is for bad address. i assume that the problem here is that i defined kernel_path in kerneland but the address has to be from userspace. now, simply how can i decide to test for something on such a function when it is waiting for an address from userland?
i would like to implement such without complex design like a special userland daemon which passes the arguments to the module ... would be at least nice
thank your for the help,
the call looks like:
Code:
error = kern_stat(td, uap->path, UIO_USERSPACE, &sb);
now, uap->path is the path to the thing which shall be stat'ed, td is the struct thread(the current thread which is calling) and sb is a stat buf which was allocated before, to save the results and copy it later back to userland(i dont know what UIO_USERSPACE is doing).
luckily this call works perfectly fine in syscall stat, as it was build for that and got the correct arguments delivered, but i try to use this outside of a function which can deliver me arguments from the userland side. my adjusted code is like:
Code:
error = kern_stat(td, kernel_path, UIO_USERSPACE, &sb);
i get a return code of 14(EFAULT) (/usr/include/sys/errno.h) which is for bad address. i assume that the problem here is that i defined kernel_path in kerneland but the address has to be from userspace. now, simply how can i decide to test for something on such a function when it is waiting for an address from userland?
i would like to implement such without complex design like a special userland daemon which passes the arguments to the module ... would be at least nice
thank your for the help,