From owner-freebsd-hackers Tue Mar 23 15: 3:16 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from herring.nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by hub.freebsd.org (Postfix) with ESMTP id 1B4D2153B2 for ; Tue, 23 Mar 1999 15:03:08 -0800 (PST) (envelope-from dfr@nlsystems.com) Received: from localhost (dfr@localhost) by herring.nlsystems.com (8.9.3/8.8.8) with ESMTP id XAA81590; Tue, 23 Mar 1999 23:06:19 GMT (envelope-from dfr@nlsystems.com) Date: Tue, 23 Mar 1999 23:06:19 +0000 (GMT) From: Doug Rabson To: Dan Seguin Cc: freebsd-hackers@freebsd.org Subject: Re: syscalls In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 23 Mar 1999, Dan Seguin wrote: > > > Hi all. > > Is it possible to make syscalls from KLDs? I had assumed that the indirect > syscall(SYS_call, ...) would do the trick, but all I get is a panic (12, > page fault) when I try to load the KLD. Is there anything special I need > to do before calling syscall()? What I'm trying to do is create a > socket/connect channel for auditing purposes. So... > > /* Code snippet */ > { > > #include > #include > > int sockfd; > > sockfd = syscall(SYS_socket, AF_UNIX, SOCK_STREAM, 0); > > } > > > etc, etc. This appears in a function that is called upon KLD LOAD. > > > I've tried __syscall((quad_t) SYS_socket, AF_UNIX, SOCK_STREAM, 0), to no > avail. > > > Thanks for your help. Syscalls are the interface from user code to kernel code. The code in a KLD is kernel code and as such should not (can't) use syscalls to obtain kernel services. In many cases, it is possible to call the underlying kernel implementation for these services directly using the internal kernel apis. For most of these apis, the only documentation is the kernel sources. -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 181 442 9037 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message