From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 11 18:12:10 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2E1E016A41F; Thu, 11 Aug 2005 18:12:10 +0000 (GMT) (envelope-from gouders@et.bocholt.fh-gelsenkirchen.de) Received: from alice.et.bocholt.fh-gelsenkirchen.de (alice.et.bocholt.fh-gelsenkirchen.de [193.175.197.63]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7FB6343D46; Thu, 11 Aug 2005 18:12:08 +0000 (GMT) (envelope-from gouders@et.bocholt.fh-gelsenkirchen.de) Received: from musashi.et.bocholt.fh-gelsenkirchen.de (musashi.et.bocholt.fh-gelsenkirchen.de [193.175.197.95]) by alice.et.bocholt.fh-gelsenkirchen.de (8.12.9/8.12.9) with ESMTP id j7BIC6eD003303 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Thu, 11 Aug 2005 20:12:07 +0200 Received: from sora.hank.home ([10.8.0.6]) by musashi.et.bocholt.fh-gelsenkirchen.de (8.13.3/8.13.3) with ESMTP id j7BIC5Cn079314; Thu, 11 Aug 2005 20:12:05 +0200 (CEST) (envelope-from hank@et.bocholt.fh-gelsenkirchen.de) Received: from localhost (localhost.hank.home [127.0.0.1]) by sora.hank.home (8.13.3/8.13.3) with ESMTP id j7BIDeFP055360; Thu, 11 Aug 2005 20:13:40 +0200 (CEST) (envelope-from hank@sora.hank.home) Message-Id: <200508111813.j7BIDeFP055360@sora.hank.home> To: Sergey Uvarov In-Reply-To: Message from Sergey Uvarov of "Thu, 11 Aug 2005 21:50:02 +0400." <42FB8FCA.2050803@mail.pnpi.spb.ru> Date: Thu, 11 Aug 2005 20:13:40 +0200 From: Dirk GOUDERS X-Scanned-By: MIMEDefang 2.43 Cc: freebsd-hackers@freebsd.org Subject: Re: preferable way to control kernel module X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2005 18:12:10 -0000 > >>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