From owner-freebsd-hackers Wed Jul 18 23:40: 7 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from bugz.infotecs.ru (bugz.infotecs.ru [195.210.139.22]) by hub.freebsd.org (Postfix) with ESMTP id C335437B401 for ; Wed, 18 Jul 2001 23:39:41 -0700 (PDT) (envelope-from vel@bugz.infotecs.ru) Received: (from root@localhost) by bugz.infotecs.ru (8.11.1/8.11.1) id f6J6rwa01563; Thu, 19 Jul 2001 10:53:58 +0400 (MSD) (envelope-from vel) From: "Eugene L. Vorokov" Message-Id: <200107190653.f6J6rwa01563@bugz.infotecs.ru> Subject: Re: KLD Programming In-Reply-To: "from Zhihui Zhang at Jul 18, 2001 02:32:39 pm" To: suid@kjell.utb.falun.se Date: Thu, 19 Jul 2001 10:53:58 +0400 (MSD) Cc: freebsd-hackers@freebsd.org X-Mailer: ELM [version 2.4ME+ PL82 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > 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