Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12369

How to get mount point for a given path in custom linux kernel module

$
0
0

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 vvvvvvvvFilesystem     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!


Viewing all articles
Browse latest Browse all 12369

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>