Article 6MRA5 How to call path_has_submounts(struct path *path) if I have dentry as a input

How to call path_has_submounts(struct path *path) if I have dentry as a input

by
Pravin Shedage
from LinuxQuestions.org on (#6MRA5)
I was writing kernel module in which I am trying to find out the current dentry is of sub-mount or not using function path_has_submounts().
I am using Ubuntu24.04 6.8 linux kernel.

int test_submount(struct dentry *dentry)
{
struct path path;
path.dentry = dentry;
path.mnt = ? // how to convert dentry to vfsmount

return path_has_submounts(&path);
}

Solution I get which is not possible because struct namespace is private to VFS fs/mount.h

struct path path;
path.dentry = parent;
path.mnt = NULL;

struct mnt_namespace *ns = current->nsproxy->mnt_ns;
struct rb_root *tree = &ns->mounts;
struct mount *l_mount, *n;
bool is_covered = false;

down_read(&namespace_sem);
rbtree_postorder_for_each_entry_safe(l_mount, n, tree, mnt_node) {
is_covered = (l_mount->mnt_mountpoint == parent);
if (is_covered) {
path.mnt = l_mount->mnt;
break;
}
}
up_read(&namespace_sem);

ret = path_has_submounts(&path);

You help or any pointer is really helpful to compile and successfully test submounts in 6.8 kernel.
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments