Date: Thu, 19 Jul 2001 10:53:58 +0400 (MSD) From: "Eugene L. Vorokov" <vel@bugz.infotecs.ru> To: suid@kjell.utb.falun.se Cc: freebsd-hackers@freebsd.org Subject: Re: KLD Programming Message-ID: <200107190653.f6J6rwa01563@bugz.infotecs.ru> In-Reply-To: <Pine.SOL.4.21.0107181430230.14676-100000@jade> "from Zhihui Zhang at Jul 18, 2001 02:32:39 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
> > Yes. But it is not easy. Look at code vfs_vnops.c. You can let a user > process open a file and then push the file descriptor into kernel via a > special system call. Search the mailing list archive and you will find > discussions on how to add a new system call. > Well, if you aren't going to do intensive file i/o, this is possible (especially on MOD_LOAD) with a very ugly, but working hack: you can simulate that current process is doing the i/o. Take curproc, allocate some memory in it's address space using mmap() (or, preferably, vm_mmap()) with MAP_ANON flag for i/o buffer and then call open(), read(), etc, passing curproc and allocated buffer to them. Do note, however, that you generally can't access the buffer directly with C operators; you should rather use copyin()/copyout(), fubyte()/subyte() functions (see the manual page for them for details). Of course this is no brilliant solution, I'm currently looking for a better one, but this works for me so far for reading a config file on load. Regards, Eugene 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?200107190653.f6J6rwa01563>