On Sun, Feb 06, 2005 at 04:22:41AM -0800, Kamal R. Prasad wrote: > > --- Scott Long <[EMAIL PROTECTED]> wrote: > > > Ashwin Chandra wrote: > > > > > Does anyone know the correct calls to open a file, > > write to it, and close it, IN *kernel* mode. > > > > > > Ash > > > > There is no common API for doing this, which is > > pretty much on purpose. > > First, you need to ask yourself why your task > > needs it done in the > > kernel and not in userland. > > 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 -- Peter Pentchev [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] 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.
pgpIe37hBohxn.pgp
Description: PGP signature