[英]get linux file system information via kernel function
I have to write a linux module and I can't find a proper function to list all mounted file system and their information. 我必须编写一个linux模块 ,找不到适合的功能来列出所有已挂载的文件系统及其信息。 I know command "df -T" can achieve this and sadly I can't use that. 我知道命令“ df -T”可以实现这一点,可惜我不能使用它。 Is there a kernel function that can do this or other way? 是否有可以执行此操作或其他方法的内核功能 ?
Why not see the kernel code which fills /proc/mounts
为什么看不到填充/proc/mounts
的内核代码
mountstats_open()
in base.c
mountstats_open()
中base.c
refer get filesystem mount point in kernel module 请参阅在内核模块中获取文件系统安装点
Your code could open/read the /proc/mounts
file, line by line. 您的代码可以逐行打开/读取/proc/mounts
文件。 It contains everything that is mounted, including many mount points that you would not expect. 它包含已安装的所有内容,包括许多您不期望的安装点。
In general, the format is the same as the /etc/fstab
file, but will also include all the mounts that the OS adds. 通常,格式与/etc/fstab
文件相同,但是还将包括操作系统添加的所有安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.