Skip to content

Latest commit

 

History

History
76 lines (58 loc) · 1.18 KB

README.md

File metadata and controls

76 lines (58 loc) · 1.18 KB

mod-sysfs-netns

Sample kobject usage with net namespaces. Based on fs/nfs/sysfs.c and samples/kobject/kobject-example.c.

About module

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

Building & using module

Using make

# 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

Using DKMS

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