在内核模块中获取文件系统挂载点 [英] get filesystem mount point in kernel module
问题描述
我想在我的内核模块中获得文件系统的文件系统挂载点,这是一个可堆叠的文件系统。 我不知道你是否可以在内核模块中执行它。 I want to get the filesystem mount point for a file system in my kernel module, which is a stackable filesystem.
Eg. if /home/ab/abc is a file and /home is mounted on a different filesystem I want to have a dentry or path struct to /home.
I want to do this in a module without modifying kernel code.
e.g. there is a file in /home/user/ and now I want to know in which partition this file is. For example this file might be in the partition same as "/" or this file might be in another partition mounted on /home or /home/user. You can get the list of file systems from You can follow the code that I don't know if you can do it in a kernel module, however. 这篇关于在内核模块中获取文件系统挂载点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
例如。如果/ home / ab / abc是一个文件,/ home被安装在不同的文件系统上,我想要一个dentry或路径结构到/ home。
我想在模块中做这个,而不用修改内核代码。
例如/ home / user /中有一个文件,现在我想知道这个文件在哪个分区中。例如,该文件可能位于与/相同的分区中,或者该文件可能位于/ home或/ home / user上的另一个分区中。你可以从 current->命名空间获得文件系统列表$ c $> C>。通过迭代
current->命名空间 - >列表
(项目是 struct vfsmount
),您可以获得所有挂载的文件系统。 vfsmount-> mnt_mountpoint
是您想要的目录条目。 您可以按照打印/ proc / mounts
(例如 base.c / mountstats_open
, namespace.c / m_start $ c
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.prints /proc/mounts
(e.g. base.c/mountstats_open
, namespace.c/m_start
) to get more details (e.g. some locking is needed).