From owner-freebsd-hackers@FreeBSD.ORG Sun Feb 6 12:41:13 2005 Return-Path: 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 19BCD16A4CE for ; Sun, 6 Feb 2005 12:41:13 +0000 (GMT) Received: from gandalf.online.bg (gandalf.online.bg [217.75.128.9]) by mx1.FreeBSD.org (Postfix) with SMTP id 9149D43D39 for ; Sun, 6 Feb 2005 12:41:11 +0000 (GMT) (envelope-from roam@ringlet.net) Received: (qmail 1036 invoked from network); 6 Feb 2005 12:41:06 -0000 Received: from unknown (HELO straylight.ringlet.net) (213.16.36.109) by gandalf.online.bg with SMTP; 6 Feb 2005 12:41:06 -0000 Received: (qmail 37492 invoked by uid 1000); 6 Feb 2005 12:41:09 -0000 Date: Sun, 6 Feb 2005 14:41:09 +0200 From: Peter Pentchev To: kamalp@acm.org Message-ID: <20050206124109.GA29361@straylight.m.ringlet.net> Mail-Followup-To: kamalp@acm.org, freebsd-hackers@freebsd.org References: <4206008F.2060100@freebsd.org> <20050206122241.63590.qmail@web52702.mail.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZGiS0Q5IWpPtfppv" Content-Disposition: inline In-Reply-To: <20050206122241.63590.qmail@web52702.mail.yahoo.com> User-Agent: Mutt/1.5.6i cc: freebsd-hackers@freebsd.org Subject: Re: Opening and wriiting to file in Kern X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Feb 2005 12:41:13 -0000 --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 06, 2005 at 04:22:41AM -0800, Kamal R. Prasad wrote: >=20 > --- Scott Long wrote: >=20 > > Ashwin Chandra wrote: > >=20 > > > Does anyone know the correct calls to open a file, > > write to it, and close it, IN *kernel* mode.=20 > > >=20 > > > Ash > >=20 > > There is no common API for doing this, which is > > pretty much on purpose.=20 > > First, you need to ask yourself why your task > > needs it done in the=20 > > kernel and not in userland. >=20 > A feature implemented within the kernel that requires > making stuff persistent would almost certainly require > file I/O. For that matter, a kernel (module) that > reads a configuration file will also need the same > facility. I don't see anything wrong with providing a > stream (like) interface to the filesystem. While there might indeed be nothing wrong with it, besides added complexity, the traditional way to do it would be to have a userland configuration utility that communicates with the kernel module either via ioctl's on some standard device, or via ioctl's or reading/writing of a driver-specific device. This has the advantage of being a bit more portable - while different OS's implement disk/file I/O within the kernel in wildly different ways, all OS's provide relatively simple ways for a kernel module to define a new device and handle ioctl's to it, and all OS's provide basically the same userland-to-kernel interface for having a program open a device and issue ioctl's to it :) Another way would be, again, communication between a userland utility and a kernel module, but this time using mmap'd files/devices instead of ioctl's. G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@cnsys.bg roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 This sentence was in the past tense. --ZGiS0Q5IWpPtfppv Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFCBhBl7Ri2jRYZRVMRAg8PAKCnuRtriq792sCo6XNJ23hAzHSgcwCgoZI2 Tw3DyJDCymoLdFrbnOp0lOw= =0uuZ -----END PGP SIGNATURE----- --ZGiS0Q5IWpPtfppv--