format files to comply with kernel coding standards, rename .config to config
This commit is contained in:
19
09/main.c
19
09/main.c
@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
@ -27,18 +28,18 @@ static const struct proc_ops proc_fops = {
|
||||
.proc_release = single_release,
|
||||
};
|
||||
|
||||
static int __init mounts_init(void)
|
||||
{
|
||||
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);
|
||||
if (IS_ERR(proc_file))
|
||||
return PTR_ERR(proc_file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void __exit mounts_exit(void)
|
||||
{
|
||||
static void __exit mounts_exit(void)
|
||||
{
|
||||
proc_remove(proc_file);
|
||||
}
|
||||
}
|
||||
|
||||
module_init(mounts_init);
|
||||
module_init(mounts_init);
|
||||
module_exit(mounts_exit);
|
||||
|
||||
|
10
09/rw.c
10
09/rw.c
@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include <linux/module.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
@ -21,17 +22,16 @@ int list_mounts(struct seq_file *m, void *v)
|
||||
cur = current->nsproxy->mnt_ns->mnt_first_node;
|
||||
|
||||
buf = kmalloc(sizeof(char) * PATH_MAX, GFP_KERNEL);
|
||||
while(cur)
|
||||
{
|
||||
while (cur) {
|
||||
mnt = rb_entry(cur, struct mount, mnt_node);
|
||||
|
||||
struct path p = {
|
||||
.mnt = &mnt->mnt,
|
||||
.dentry = mnt->mnt.mnt_root,
|
||||
.mnt = &mnt->mnt,
|
||||
.dentry = mnt->mnt.mnt_root,
|
||||
};
|
||||
|
||||
path = d_path(&p, buf, PATH_MAX);
|
||||
if(IS_ERR(path))
|
||||
if (IS_ERR(path))
|
||||
path = 0;
|
||||
seq_printf(m, "%-10s %s\n", mnt->mnt_devname, path);
|
||||
cur = rb_next(cur);
|
||||
|
Reference in New Issue
Block a user