How to create sysfs file and associate it with file operations like mmap

Niroj Pokhrel nirojpokhrel at
Wed Sep 18 06:19:56 EDT 2013

Hi all,
I want to create a sysfs file and associate it with several file opeations
like open,close and mmap.
But when coming across sysfs file creation I saw that I can create a file
device_create_file(struct device*,struct device_attributes*);
The device attributes were initialized using following
But I want to associate my file with following operations
struct file_operations my_fops
      .open = my_open,
      .close = my_close,
      .mmap = my_mmap,

I was able to do this using
But is there anyway if I want to put this file in sec_class.
Thanking you in advance.

Thanks and Regards,
Niroj Pokhrel
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Kernelnewbies mailing list