From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 25 10:15:26 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 80DA916A41C for ; Sat, 25 Jun 2005 10:15:26 +0000 (GMT) (envelope-from ssouhlal@FreeBSD.org) Received: from efnet-math.org (efnet-math.org [69.60.109.125]) by mx1.FreeBSD.org (Postfix) with ESMTP id 292DF43D55 for ; Sat, 25 Jun 2005 10:15:26 +0000 (GMT) (envelope-from ssouhlal@FreeBSD.org) Received: from [192.168.1.12] (63-170-138-118.cst-sg.blacksburg.ntc-com.net [63.170.138.118]) (authenticated bits=0) by efnet-math.org (8.13.1/8.13.1) with ESMTP id j5PAFOt5030601 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO); Sat, 25 Jun 2005 06:15:24 -0400 In-Reply-To: <200506251203.13569.sebastien.b@swissinfo.org> References: <200506251203.13569.sebastien.b@swissinfo.org> Mime-Version: 1.0 (Apple Message framework v730) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <42F160E7-9B19-4A8A-8656-A86E0076EBB3@FreeBSD.org> Content-Transfer-Encoding: 7bit From: Suleiman Souhlal Date: Sat, 25 Jun 2005 06:15:18 -0400 To: Seb X-Mailer: Apple Mail (2.730) Cc: freebsd-hackers@FreeBSD.org 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: Sat, 25 Jun 2005 10:15:26 -0000 Hi, On Jun 25, 2005, at 6:03 AM, Seb wrote: > Hello, > How can I access the filesystem from a kernel module ? > In fact, I want my device driver to retreive a firmware image > stored on the > filesystem (instead of putting the firmware data in a static array at > compile-time) for memory usage and legal concerns. Blocking calls > are OK. > I have searched the manpages and the web, but I haven't found anything > relevant. > Thanks, > Sebastien You can use vn_open() to open the file, and then read it using vn_rdwr (), and finally, vn_close() to close it. Look at src/sys/kern/ link_elf_obj.c for an example. -- Suleiman Souhlal | ssouhlal@vt.edu The FreeBSD Project | ssouhlal@FreeBSD.org