2

As the title says I have a problem with my custom kernel module. My goal is to retrieve the root mount point of a given path. Just like using df:

df "/tmp/some_dir/some_file"
vvvvvvvv out vvvvvvvv
Filesystem     1K-blocks  Used Available Use% Mounted on <---
tmpfs            8125932   120   8125812   1% /tmp <----

I was trying to achieve it with path struct by using both mnt and dentry fields but when I printed mnt_root or superblock root it always returned '/' so not associated mounting point.

Maybe I'm just digging in the wrong place. I don't know if path/dentry/etc... are suitable structures for these operations (I'm beginning my adventure with kernel modules and probably I'm overkilling it :D)

Kernel version: 5.6.2

Thanks in advice!

Radoj11
  • 31
  • 4

1 Answers1

0

I have managed to reach my goal!

It turns out that there is follow_up function in namei.c which does exactly what I needed.

Radoj11
  • 31
  • 4