[lxc-devel] Understanding - LXCFS source code to add /sys/power/state as an entry in LXCFS

Souvik Datta sd.souvikdatta at gmail.com
Sun Jun 7 19:29:04 UTC 2020

I am now able to read "/var/lib/lxcfs/sys/power/state" correctly
through the FUSE file system. However, when I am trying to do a $echo
"mem" > /var/lib/lxcfs/sys/power/state, I am getting "Operation not
permitted" error.

I have ensured that /var/lib/lxcfs/sys/power/state mode is 644 through

My objective here is to capture the writing to file /sys/power/state
and then start a thread to call "lxc-freeze" of the container OS.

When I issue as root - $echo "mem" >  /var/lib/lxcfs/sys/power/state,
following is the sequence of function calls printed on the console
using using lxcfs_info(...):-
do_sys_getattr and path=/sys
do_sys_getattr and path=/sys/power
do_sys_getattr and path=/sys/power/state
do_sys_open and path=/sys/power/state
Inside funcion get_sysfile_size:
Inside sys_open - length of buflen is:528
do_sys_release and path=/sys/power/state

lxcfs_write(...) is never getting called.

Can you please give me some pointers - what could be wrong?

Thanks and Regards,

On 6/3/20, Souvik Datta <sd.souvikdatta at gmail.com> wrote:
> Hello,
> I am trying to understand the source code of LXCFS. My final objective
> is to add /sys/power/state file as an entry. I understand the changes
> that need to be done in sysfs_fuse.c/h to support this.
> To do this, first I am first trying to understand, how the sys entry -
> "/sys/devices/system/cpu/online" has been added in the "target
> directory - /var/lib/lxcfs" but I am not able to figure that out.
> Can you please give me some pointers so that I can understand how this
> is achieved?
> Regards,

More information about the lxc-devel mailing list