Skip to content

Commit

Permalink
Continuing with combining proc_mkdir into one more generic usable fun…
Browse files Browse the repository at this point in the history
…ction and switching to it
  • Loading branch information
tpiekarski committed Mar 31, 2020
1 parent 9725d06 commit 9b13fe3
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions lkm_mem.c
Expand Up @@ -70,6 +70,21 @@ void lkm_proc_create_single_data(struct proc_dir_entry *entry,
}
}

void lkm_proc_mkdir(struct proc_dir_entry *entry, const char *name,
struct proc_dir_entry *parent)
{
entry = proc_mkdir(name, parent);

if (entry == NULL) {
printk(KERN_ERR
"lkm_mem: Failed to create parent %s in proc.\n",
name);

// todo: How to abort loading module?
// For details see lkm_proc_create_single_data.
}
}

void lkm_remove_proc_entry(struct proc_dir_entry *entry, const char *name,
struct proc_dir_entry *parent)
{
Expand All @@ -81,25 +96,8 @@ void lkm_remove_proc_entry(struct proc_dir_entry *entry, const char *name,

static int __init lkm_mem_init(void)
{
lkm_proc_parent = proc_mkdir(LKM_PROC_PARENT, NULL);

if (lkm_proc_parent == NULL) {
printk(KERN_ERR
"lkm_mem: Failed to create parent /proc/%s for lkm.\n",
LKM_PROC_PARENT);

return 1;
}

mem_proc_parent = proc_mkdir(LKM_MEM_PROC_PARENT, lkm_proc_parent);

if (mem_proc_parent == NULL) {
printk(KERN_ERR
"lkm_mem: Failed to create parent /proc/%s/%s for mem.\n",
LKM_PROC_PARENT, LKM_MEM_PROC_PARENT);

return 1;
}
lkm_proc_mkdir(lkm_proc_parent, LKM_PROC_PARENT, NULL);
lkm_proc_mkdir(mem_proc_parent, LKM_MEM_PROC_PARENT, lkm_proc_parent);

si_meminfo(&si);

Expand Down

0 comments on commit 9b13fe3

Please sign in to comment.