Example

Recall the kprobes example discussed earlier in the chapter as an example for the sequential file mechanism. The resulting file is exported via debugfs in only a couple of lines — as simple as can be!

kernel/kprobes.c

#ifdef CONFIG_DEBUG_FS

static int _kprobes debugfs_kprobe_init(void)

struct dentry *dir, *file; unsigned int value = 1;

dir = debugfs_create_dir("kprobes", NULL);

file = debugfs_create_file("list", 0444, dir, NULL,

&debugfs_kprobes_operations);

debugfs_create_dir is used to create a new directory, and debugfs_create_file establishes a new file in this directory. debugfs_kprobes_operations was discussed above as an example for the sequential file mechanism.

Continue reading here: Programming Interface

Was this article helpful?

0 0