hello ron,

> On 9/12/07, Ron Lee <[EMAIL PROTECTED]> wrote:
> > Hello all,
> >
> > I would like to pass arguments/parameters to a kernel module. My current
> > method is to use the proc file system but I was told that sysfs would be
> > a cleaner way. Does anyone have an example for how to do this? Is there
> > a way to register callback functions that are invoked when a file in the
> > sysfs is read or written? Any help is appreciated!

for reads from the the file the prototype is:
ssize_t show_foo
(struct device *dev, struct device_attribute *attr, char *buf);

for writes:
ssize_t store_foo
(struct device *dev, struct device_attribute *attr, const char *buf,
ssize_t buflen);

both of these need to return the number
of bytes read/written. then you use the
DEVICE_ATTR macro as so:
DEVICE_ATTR(foofilename, S_IRWXO | S_IXGRP, show_foo, store_foo);

this macro will create: dev_attr_foofilename
which you register with:
device_create_file(&dev, &dev_attr_foofilename);

and unregister with:
device_remove_file(&dev, &dev_attr_foofilename);

hope this helps.

-- ilya

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to