How to get full mountpoint path name by the sturct fc_context
I currently have a syscall hook named "fsconfig" within my own module because I need to perform some operations regarding remounting readonly mountpoints.
For example, if a user issues the command: mount /dev/sda /tmp/mytest -o remount,ro, I would like to obtain the string "/tmp/mytest" within the fsconfig hook.
Within fsconfig, I have referred to the kernel's approach, which allows obtaining an fs_context structure through an fd. What I aim to do is to obtain the mount point path through this structure (or any other method).
It seems that the fs_context provides all the information available at this step.
Currently, I have attempted:
Starting from fc_context->dentry, I have found some functions like dentry_path_raw, but the returned string is "/", which does not meet my requirements.
There is some information on the internet suggesting the use of d_path, but it requires a path structure containing dentry and vfsmount, which I cannot obtain within fsconfig. Therefore, this method seems impractical.
I have referenced the approach used in /proc/mounts, where they iterate through each mountpoint using the list within mnt_namespace. However, we cannot access the members of mnt_namespace and mount structures within the module (kernel declare them in fs/namespace), making this method unusable.
I would like to ask if there are any other methods (perhaps some kernel APIs I am not aware of) to meet my requirements. Thank you very much.
And i want my module to support kernel version 6.6
|