# make make -C /usr/src/linux-2.6.5-1.358 SUBDIRS=/root/sysfs_example modules make[1]: Entering directory '/usr/src/linux-2.6.5-1.358' CC [M] /root/sysfs_example/sysfs_example.o Building modules, stage 2. MODPOST CC /root/sysfs_example/sysfs_example.mod.o LD [M] /root/sysfs_example/sysfs_example.ko make[1]: Leaving directory '/usr/src/linux-2.6.5-1.358' # insmod sysfs_example.ko # cd /sys # ls block bus class devices firmware power sysfs_example # cd sysfs_sample # ls hex integer string # cat hex 0xdeadbeef # cat integer 123 # cat string test # echo 0xbabeface > hex # echo 456 > integer # echo hello > string # cat hex 0xbabeface # cat integer 456 # cat string hello # cd .. # rmmod sysfs_example # ls block bus class devices firmware power
Example 2: Interactive session in which the module sysfs_example.c is compiled, inserted, and tested. Attributes are inspected, changed, and inspected again.