Messages in this thread | | | Date | Wed, 26 Jul 2000 16:00:40 +0100 (BST) | From | Tigran Aivazian <> | Subject | Re: How to read kernel parameters from user-space? |
| |
On Wed, 26 Jul 2000, Aleksandr Koltsoff wrote:
> > If you really do not want to have proc filesystem in the kernel but are > > willing to have a slightly hacked version of the kernel you can add a > > simple system call lik this: > > > > asmlinkage long sys_getcmdline(char *buf) > > { > > int len = strlen(saved_command_line); > > > > return copy_to_user(buf, saved_command_line, len) ? -EFAULT : 0; > > } > > Thanks again :-) > > Hmm. Would it be possible to put this into a module? So that I wouldn't > have to patch each and every version of kernel when they come out (the > saved_command_line is pretty standard across kernel versions?) >
yes, it is easy to patch sys_call_table[] on the fly from a module. Do this:
a) download my old timetravel module to learn how to do it:
http://www.ocston.org/~tigran/tt/tt.html
b) find some unused slot in sys_call_table[]. Look in arch/i386/kernel/entry.S for sys_ni_syscall entries (ni means not implemented) but beware that you are not alone there - i.e. some other people are already using those "unused" entries for precisely this purpose - usually comments next to them are descriptive enough.
c) write a module that replaces a chosen (well-known to you) sys_ni_syscall entry with your sys_getcmdline(). You can't do it dynamically because then you will have to invent some means of passing the system call number back from the module to userspace - this could be done via a simple file in /proc - oops we wanted to have no proc, so... :)
d) write a (I meant steal from asm/unistd.h) a _syscall1() interface to your syscall.
e) done.
Regards, Tigran
| |