Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Feb 2005 14:41:09 +0200
From:      Peter Pentchev <roam@ringlet.net>
To:        kamalp@acm.org
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Opening and wriiting to file in Kern
Message-ID:  <20050206124109.GA29361@straylight.m.ringlet.net>
In-Reply-To: <20050206122241.63590.qmail@web52702.mail.yahoo.com>
References:  <4206008F.2060100@freebsd.org> <20050206122241.63590.qmail@web52702.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <scottl@freebsd.org> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050206124109.GA29361>