Skip to content

Commit ec7ee80

Browse files
committed
Add inode_operations to match documentation
The "Manage /proc file with standard filesystem" section describes using struct inode_operations with a permission function, but the referenced procfs3.c example was missing this implementation. Close #131
1 parent 78a7265 commit ec7ee80

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/procfs3.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ static int procfs_close(struct inode *inode, struct file *file)
6161
return 0;
6262
}
6363

64+
/*
65+
* In recent kernels, this would typically be handled through other mechanisms
66+
* like security modules, but we keep it here for educational purposes.
67+
*/
68+
static int module_permission(struct mnt_idmap *idmap, struct inode *inode,
69+
int mask)
70+
{
71+
pr_info("procfs: permission called with mask %d\n", mask);
72+
return 0;
73+
}
74+
75+
/*
76+
* inode_operations structure to demonstrate the relationship between
77+
* file operations and inode operations as mentioned in the documentation
78+
*/
79+
static struct inode_operations procfs_inode_operations = {
80+
.permission = module_permission,
81+
};
82+
6483
#ifdef HAVE_PROC_OPS
6584
static struct proc_ops file_ops_4_our_proc_file = {
6685
.proc_read = procfs_read,

0 commit comments

Comments
 (0)