From owner-freebsd-hackers Sat Aug 15 10:58:44 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA18641 for freebsd-hackers-outgoing; Sat, 15 Aug 1998 10:58:44 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from word.smith.net.au (castles334.castles.com [208.214.167.34]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA18635 for ; Sat, 15 Aug 1998 10:58:40 -0700 (PDT) (envelope-from mike@word.smith.net.au) Received: from word.smith.net.au (localhost [127.0.0.1]) by word.smith.net.au (8.8.8/8.8.8) with ESMTP id KAA00653; Sat, 15 Aug 1998 10:11:27 GMT (envelope-from mike@word.smith.net.au) Message-Id: <199808151011.KAA00653@word.smith.net.au> X-Mailer: exmh version 2.0.2 2/24/98 To: wjw@IAEhv.nl cc: mike@smith.net.au (Mike Smith), hackers@FreeBSD.ORG Subject: Re: Adding system calls In-reply-to: Your message of "Sat, 15 Aug 1998 12:28:58 +0200." <199808151028.MAA20095@surf.IAE.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 15 Aug 1998 10:11:26 +0000 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > You ( Mike Smith ) write: > => > > => > What/were is the receipe to add new system calls. > => > I'd like to add my own sysctl_* calls. > => > => You don't feel that you can overload the current calls? > > Well I'd like to make a nsysctl call for starters, just to able to leave > everything in place, and add my own version in parallel. This would make the > migration a lot simpler: I don't have to take care of all kinds of pitfalls > which pop up due to unforseen loop-holes. Fair enough, especially for testing. > And there are structures for the new functionality which I cannot get into > the original call without making it a real mess. I consider the current > implementation already warped. (appologies to phk) Poul didn't invent it, just made it more useful. > => > Are there any directives on what "design" to use while defining these calls. > => > Like: > => > - Use only one syscall as a multiplexer > => > (Which created a not so trivial mess is the current sysctl) > => > => This is good if all the subcalls share similar data. > > Well think about this one: > sysctl_node *sysctl_getnext( sysctl_node *node); > > It allows you to give a kernel pointer, and gets you a pointer to a next > structure. > > Would this be a sensible move? It's easy but will allow invallid accesses to > memory, if somebody uses garbage as pointer. No, it's an extremely bad move unless it can validate its argument. > It is a little faster, since it doesn't have to find the starting point, but > that doesn't outweigh the disavantage. Correct. The 'correct' way to implement the above would be: char *sysctl_next(const char *name); where the return value would be a malloc()ed buffer containing the name of the next node, or NULL on error. Errno would be set to EINVAL if (name) did not exist, or ENOENT if there was no next node. You would use your hashtable to locate (name), and then pick the next node. If (name) had been deleted, you would have to perform a best-guess search. Keeping nodes sorted by name would trivialise this. > => > - What parameters are a bad idea to transfer from > => > user to kernel space? > => > => Just the ones you need. > > Well, kernel-pointers are perhaps an issue. > And or structures with kernel-pointers. None of these should ever be exposed. > => > And answers to questions like: > => > - Where can I find the "user"-data > => > => Such as? > > I'm still trying to parse the code which does something called > "userland_sysctl", which I thing does a lookup in userland data?? No, it just handles sysctl calls where the data portion may be in user space. > > => > - Hoe to I return results for "call-by-ref" parameters > => > => Use copyin/copyout and the fu*/su* calls, all of which have manpages in > => -current. > > Oke, I have some current-version on my disk. I'll put it at the end of my > MANPATH. But then I'd still need some happy guesses as to their names. copyin, copyout, fubyte, subyte. -- \\ Sometimes you're ahead, \\ Mike Smith \\ sometimes you're behind. \\ mike@smith.net.au \\ The race is long, and in the \\ msmith@freebsd.org \\ end it's only with yourself. \\ msmith@cdrom.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message