Sample kobject usage with net namespaces.
Based on fs/nfs/sysfs.c
and samples/kobject/kobject-example.c
.
This module shows how to create a simple subdirectory in sysfs called
/sys/kernel/kset_sysfs_netns/net/data
with file property
in this directory
where we can read & write integers with following commands:
# to read property
cat /sys/kernel/kset_sysfs_netns/net/data/property
# to write property
echo 1 > /sys/kernel/kset_sysfs_netns/net/data/property
# build
make KSRC=/lib/modules/$(uname -r)/build
# load module
insmod mod-sysfs-netns.ko
# unload module
rmmod mod-sysfs-netns.ko
# clean up
make KSRC=/lib/modules/$(uname -r)/build clean
cd mod-sysfs-netns
# add module source to /usr/src tree
dkms add $(pwd)
# build & install module to /lib/modules/$(uname -r) tree
dkms install mod-sysfs-netns/1.0
# load module
modprobe -v mod-sysfs-netns
# unload module
rmmod mod-sysfs-netns
# remove it from DKMS tree
dkms remove mod-sysfs-netns/1.0 --all