Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Aug 2005 20:13:40 +0200
From:      Dirk GOUDERS <gouders@et.bocholt.fh-ge.de>
To:        Sergey Uvarov <uvarovsl@mail.pnpi.spb.ru>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: preferable way to control kernel module 
Message-ID:  <200508111813.j7BIDeFP055360@sora.hank.home>
In-Reply-To: Message from Sergey Uvarov <uvarovsl@mail.pnpi.spb.ru> of "Thu, 11 Aug 2005 21:50:02 %2B0400." <42FB8FCA.2050803@mail.pnpi.spb.ru> 

next in thread | previous in thread | raw e-mail | index | archive | help

 > >>Shouldn't that be no problem if he sets the offset parameter to
 > >>SYSCALL_MODULE to NO_SYSCALL (get the next free offset)?
 > > 
 > > 
 > > But then you have to communicate the syscall number out to your userland 
 > > applications somehow, and the applications have to know how to invoke a 
 > > syscall by hand (perhaps they could use the syscall() function, but still)
 > .
 > > 
 > It is not a big problem. Look at the following piece of code:
 > 
 > 
 > /* Kernel module portion of code. */
 > static int my_syscall = NO_SYSCALL;
 > static struct sysent my_sysent = {
 > 	2,				/* sy_arg */
 > 	(sy_call_t *)&my_func		/* sy_call */
 > };
 > SYSCALL_MODULE(my_syscall_name, &my_syscall, &my_sysent,
 > 	       NULL, NULL);
 > 
 > 
 > /* User-land portion of code. */
 > int get_syscall(const char *syscall_name)
 > {
 > 	struct module_stat	stat;
 > 	int			mod_id;
 > 	int			syscall_num;
 > 
 > 	if ((mod_id = modfind(syscall_name)) < 0)
 > 		return (-1);
 > 
 > 	stat.version = sizeof(stat);
 > 	if (modstat(mod_id, &stat) < 0)
 > 		return (-1);
 > 
 > 	return (stat.data.intval);
 > }
 > 
 > ...
 > 
 > syscall_num = get_syscall("my_syscall_name");
 > 
 > /* Issue a syscall with necessary parameters. */
 > syscall(syscall_num, ...);

That is roughly what I accidently played with, today.
Don't know about the probability that there may be no free offset,
though.

Dirk



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508111813.j7BIDeFP055360>