From: Thadeu Lima de Souza Cascardo Date: Tue, 8 Dec 2009 09:15:41 +0000 (-0200) Subject: Added comments. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fkernel%2Fsamples%2F03.proc%2F.git;a=commitdiff_plain;h=8bd3dbd375e30ab65e2de8d365283482a7b22071 Added comments. --- diff --git a/hello_procfs.c b/hello_procfs.c index 4420ad4..a3ce21d 100644 --- a/hello_procfs.c +++ b/hello_procfs.c @@ -18,23 +18,28 @@ #include +/* Needed for procfs register functions */ #include +/* Needed for using the seq_file infrastructure */ #include MODULE_AUTHOR("Thadeu Lima de Souza Cascardo "); MODULE_LICENSE("GPL"); +/* write our message to the sequential file */ static int hello_show(struct seq_file *file, void *data) { seq_puts(file, "Hello, world!\n"); return 0; } +/* use the single sequential file */ static int hello_procfs_open(struct inode *inode, struct file *file) { return single_open(file, hello_show, NULL); } +/* our file operations use the seq_file stuff to make it an easy task */ static const struct file_operations hello_procfs_fops = { .open = hello_procfs_open, @@ -45,6 +50,8 @@ static const struct file_operations hello_procfs_fops = static int hello_procfs_init(void) { + /* create the proc entry and set its fops: there is a potential race + * here */ struct proc_dir_entry *entry; entry = create_proc_entry("gnu", 0666, NULL); entry->proc_fops = &hello_procfs_fops; @@ -53,6 +60,7 @@ static int hello_procfs_init(void) static void hello_procfs_exit(void) { + /* remove our proc entry */ remove_proc_entry("gnu", NULL); }