From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 29 09:55:48 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E9A3C16A41C for ; Wed, 29 Jun 2005 09:55:48 +0000 (GMT) (envelope-from sebastien.b@swissinfo.org) Received: from md1.swissinfo.org (md1.swissinfo.org [146.159.4.92]) by mx1.FreeBSD.org (Postfix) with ESMTP id E68DA43D4C for ; Wed, 29 Jun 2005 09:55:47 +0000 (GMT) (envelope-from sebastien.b@swissinfo.org) Received: from mail.swissinfo.org ([194.6.181.33]) by md1.swissinfo.org (phad1.swissinfo.org [146.159.6.9]) (MDaemon.PRO.v7.2.1.R) with ESMTP id 08-md50000546895.msg for ; Wed, 29 Jun 2005 11:55:39 +0200 Received: from oasis (82.216.69.248) by mail.swissinfo.org (7.0.020) (authenticated as sebastien.b) id 4153942004444D79 for freebsd-hackers@freebsd.org; Wed, 29 Jun 2005 11:55:38 +0200 From: Seb To: freebsd-hackers@freebsd.org Date: Wed, 29 Jun 2005 11:55:50 +0200 User-Agent: KMail/1.8 References: <200506251203.13569.sebastien.b@swissinfo.org> <200506291051.01760.sebastien.b@swissinfo.org> <20050629091211.GA438@pm514-9.comsys.ntu-kpi.kiev.ua> In-Reply-To: <20050629091211.GA438@pm514-9.comsys.ntu-kpi.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200506291155.50929.sebastien.b@swissinfo.org> X-Spam-Processed: phad1.swissinfo.org, Wed, 29 Jun 2005 11:55:39 +0200 (not processed: message from valid local sender) X-MDRemoteIP: 194.6.181.33 X-Return-Path: sebastien.b@swissinfo.org X-MDaemon-Deliver-To: freebsd-hackers@freebsd.org X-MDAV-Processed: phad1.swissinfo.org, Wed, 29 Jun 2005 11:55:40 +0200 Subject: Re: Accessing filesystem from a KLD X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2005 09:55:49 -0000 > Why not to use VOP_READ? See how it is called in dev/md.c:mdstart_vnode, > check kern/vfs_vnops.c:vn_open_cred for information how to lookup a file > name and open it. That's what I do, however I use the wrapper functions vn_open(), vn_rdwr() and so. But I have a problem, when I call this code : void *request_firmware(const char *name, size_t *size) { int flags; char filename[40]; struct nameidata nd; struct thread *td = curthread; [...] NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, &filename[0], td); flags = FREAD; vn_open(&nd, &flags, 0, -1); [...] } from the KLD handler function (for testing) it works. But when I call it from a thread created by kthread_create() in another KLD, I have a page fault. A few printfs show that the call to vn_open() is responsible for the fault. I have not forgotten to lock Giant in my kernel thread. Any ideas ? Thanks, Sebastien