Windows Driver substitue for linux device driver sysfs interface

258 views Asked by At

Let me describe what sysfs does : its a pseudo file system where files, directories are generated by the core kernel or kernel drivers. And these files have read/write access and are a mechanism to control certain kernel level parameters by user space (seperate from ioctls and file operations).

  1. Sysfs from Kernel.org
  2. Sysfs from Wikipedia

The following is an example of how userspace interacts with sysfs.

    $ cat /sys/modules/mydriver/foo_count
    1 
    $ echo "2" > /sys/modules/mydriver/foo_count  $ cat /sys/modules/mydriver/foo_count
    2

The cat command will trigger a read via the show_foo_count() kernel routine, while the echo will trigger a write via the store_foo_count() routine

The following is how the kernel driver/module might intercept the user space activity.

static ssize_t show_foo_count(struct kobject *kobj,struct kobj_attribute *attr,
                                  char *buf)
{
    /* This will perform a read operation and contents of buf will be updated*/
    ...
}
static ssize_t store_foo_count(struct kobject *kobj, struct kobj_attribute *attr,
                               const char *buf,size_t len)
{
    /* Contents are read from buf and stored within the driver's context/state */
    ...

}

A good example is here

How can one achieve the same sysfs usage on windows drivers ?

I see the following windows concepts, but I am unable to map them to be the equivalent of syfs :

A. Device Objects

B. File Object

0

There are 0 answers