corrections on 03 and 08, 09 done
This commit is contained in:
44
09/main.c
Normal file
44
09/main.c
Normal file
@ -0,0 +1,44 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
#include <linux/sched.h>
|
||||
#include <linux/nsproxy.h>
|
||||
#include <linux/mount.h>
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("create /proc/mymounts file that lists mounts");
|
||||
|
||||
struct proc_dir_entry *proc_file;
|
||||
|
||||
int list_mounts(struct seq_file *m, void *v);
|
||||
|
||||
static int list_mounts_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, list_mounts, NULL);
|
||||
}
|
||||
|
||||
static const struct proc_ops proc_fops = {
|
||||
.proc_open = list_mounts_open,
|
||||
.proc_read = seq_read,
|
||||
.proc_lseek = seq_lseek,
|
||||
.proc_release = single_release,
|
||||
};
|
||||
|
||||
static int __init mounts_init(void)
|
||||
{
|
||||
proc_file = proc_create("mymounts", 0444, 0, &proc_fops);
|
||||
if(IS_ERR(proc_file)) return PTR_ERR(proc_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit mounts_exit(void)
|
||||
{
|
||||
proc_remove(proc_file);
|
||||
}
|
||||
|
||||
module_init(mounts_init);
|
||||
module_exit(mounts_exit);
|
||||
|
Reference in New Issue
Block a user