Reputation: 2141
I am creating a simple debugfs
file inside /sys/kernel/debug/test/testFile
using the following code:
pDebugfs = debugfs_create_dir(name, NULL);
if (!pDebugfs)
goto fail;
if (!debugfs_create_file("testFile", MODE_T, pDebugfs,
NULL, &debugfs_fops)) {
goto fail;
}
And now when I write to this file, open
method will be called which has the definition:
static ssize_t debugfs_open(struct inode *inode, struct file *filp)
Now the pDebugfs
which is of type dentry
has a pointer to an inode
called d_inode
as defined here.
My question is what is the relationship between this inode
pointer and the one called in open
? Are they related? If yes, how? I tried to print the i_flags
value in both the i_node
definitions but they don't match, I assign i_flags
in init
and just check its value in open
but they don't match.
Upvotes: 0
Views: 238
Reputation: 3892
In your code you have two dentry
. One that create the directory in /sys/kernel/debug/
pDebugfs = debugfs_create_dir(name, NULL);
and, you are not storing it but it is there, one that create the file you open(2)
:
pDebugfs_file = debugfs_create_file("testFile", MODE_T, pDebugfs, NULL, &debugfs_fops)
The inode
you see in debugfs_open
is the one associated to the file
and not to the directory.
Upvotes: 1