Get all mount points in kernel module
There are flags for it in the dentry struct. d_flags. and there is a flag DCACHED_MOUNTED. Get the current pointer. The fs_struct in there. then the root. this gives you the root of the current filesystem. from there loop though all the subdirs and if d_flags & DCACHE_MOUNTED passes then it is a mount point.
ssize_t read_proc(struct file *filp, char *buf, size_t len, loff_t *offp )
{
struct dentry *curdentry;
list_for_each_entry(curdentry, ¤t->fs->root.mnt->mnt_root->d_subdirs, d_child)
{
if ( curdentry->d_flags & DCACHE_MOUNTED)
printk("%s is mounted", curdentry->d_name.name);
}
return 0;
}
get filesystem mount point in kernel module
You can get the list of file systems from current->namespace
. By iterating current->namespace->list
(items being struct vfsmount
) you can get all mounted file systems. vfsmount->mnt_mountpoint
is the directory entry you want.
You can follow the code that prints /proc/mounts
(e.g. base.c/mountstats_open
, namespace.c/m_start
) to get more details (e.g. some locking is needed).
I don't know if you can do it in a kernel module, however.
Related Topics
How to Send a Sequence of at Commands to a Serial Port in Bash
Best Way Elevate the Privileges Programmatically Under Different Versions of Linux
Qt Creator: Add Qt Module to Project
Bash Echo with an $ Character Outside the String
Create a Dedicated Folder for Every Zip Files in a Directory and Extract Zip Files
Get First Line of a Shell Command's Output
Error While Loading Shared Libraries: Libncurses.So.5:
How to Wait for First Command to Finish
Using Linux, How to Specify Which Ethernet Interface Data Is Transmitted On
How to Get Cmake to Use the Default Compiler on System Path
If I Have a Process, and I Clone It, Is the Pid the Same
Cmake Auto Header File Dependency
Explicitly Invoke Sig_Dfl/Sig_Ign Handlers on Linux
How to Copy Folder with Files to Another Folder in Unix/Linux
How to Map a Hostname *And* a Port with /Etc/Hosts
Determine Target Isa Extensions of Binary File in Linux (Library or Executable)