Date: Fri, 28 Sep 2001 21:15:13 +0000 From: Vladimir Dozen <vladimir-dozen@mail.ru> To: Robert Watson <rwatson@FreeBSD.org> Cc: hackers@FreeBSD.org Subject: Re: calling open() from inside kernel Message-ID: <20010928211513.A294@eix.do-labs.spb.ru> In-Reply-To: <Pine.NEB.3.96L.1010928082423.31337D-100000@fledge.watson.org>; from rwatson@FreeBSD.org on Fri, Sep 28, 2001 at 08:29:10AM -0400 References: <20010927234624.A403@eix.do-labs.spb.ru> <Pine.NEB.3.96L.1010928082423.31337D-100000@fledge.watson.org>
next in thread | previous in thread | raw e-mail | index | archive | help
ehlo. > Generally speaking, you don't want to invoke system call functionss from > within the kernel due to address space expectations, you want to invoke > the supporting service calls. Probably what that maps into in your case is > using NDINIT()/namei() on a string in UIO_SYSSPACE, and then using > vn_open(). You'll want to look carefully at the open() code to see if > there are other things to do/watch out for. That was exactly what I've done. The problem here is that each time someone in kernel space will try to open a file, he/she has to retype the same code already in vfs_syscalls.c. I would like to see more general version of open and two short wrappers -- one for userspace and one for kernel space, something like: /* generic */ open_generic(struct proc* proc,struct open_args* oa,boolean_t inkernel) { if( inkernel ) NDINIT(...,UIO_SYSSPACE,...); else NDINIT(...,UIO_USERSPACE,...); ... } /* user-space */ open(proc,oa){ return open_generic(proc,oa,0); } /* kernel space */ open_sysspace(proc,oa){ return open_generic(proc,oa,1); } Well, I see I was wanted too much. > In the Linux emulation code, when the kernel wants to change arguments > around and keep them in userspace, it uses space allocated out of the > stack gap, a section of VM I assume is otherwise unused in userspace (and > presumably is per-stack, or there would be problems with linux threading). This cure is more dangerous than illness itself. ;) -- dozen @ home To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010928211513.A294>