Accessing allocated space in a debugfs file

ymdatta ymdatta.work at gmail.com
Wed Sep 30 13:02:05 EDT 2020


Hello everyone,

I am trying to create a debugfs file for exposing some information to the
userspace. (I am exploring on how to use debugfs)

>From the documentation (Documentation/filesystems/debugfs.txt), i came
across a function called

       struct dentry *debugfs_create_file_size(...,loff_t file_size);

This essentially creates a file with an initial size.

I want to write in this file, how should i be accessing the space created
from previous function call.

I have looked through the source code, but i have found very few places
where this function is used. In one of the use cases [0], the memory
equal to the size is allocated in the open file operation, and the
private_data member is pointed to this. (Looking at [0] helps in
understanding this). But from #kernelnewbies channel, i found that
private_data is a pointer for tty/char drivers.

Thanks for the help.

[0]: https://elixir.bootlin.com/linux/latest/source/drivers/usb/gadget/udc/atmel_usba_udc.c#L140

ymdatta.



More information about the Kernelnewbies mailing list