Linux源代码中的MOUNT API在哪里实现?

发布于 2025-01-29 00:25:15 字数 109 浏览 3 评论 0原文

我是Linux内核的新手,我从Github上的存储库中克隆了Linux源。我找不到文件sys/mount。

您知道这个文件位于源代码中吗?在哪里可以找到它的实施?

I am newbie for Linux kernel, I cloned the Linux source from its repo on GitHub. I cannot find the file sys/mount.h nor the mount function.

Do you know where is this file located in source code? Where can I find its implementation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦幻之岛 2025-02-05 00:25:15

如果您不知道内核中的系统调用在哪里实现,则可以使用一系列步骤来找到它。您将需要将内核源下载到计算机上。

首先找到Syscall所需的参数数量。例如。 mount(2)需要五个参数。

由于安装座(2)需要5个参数,因此请搜索syscall_define5(内核来源中的Mount

grep -nr 'SYSCALL_DEFINE5(mount'

这将需要一段时间才能运行,但最终会发现:

./fs/compat.c:92:COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
./fs/namespace.c:3026:SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,

因此,您正在寻找的SYSCALL IS IS位于3026行上的In ./fs/namespace.c(我使用的Linux 4.19.99,因此内核上的线号可能会有所不同。)

If you don't know where a system call is implemented in the kernel, there's a general sequence of steps you can use to find it. You will need to download the kernel source to your machine.

Begin by finding the number of parameters the syscall requires. eg. mount(2) requires five parameters.

Since mount(2) requires 5 parameters, search for SYSCALL_DEFINE5(mount in the kernel source:

grep -nr 'SYSCALL_DEFINE5(mount'

This will take a while to run, but it will eventually find:

./fs/compat.c:92:COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
./fs/namespace.c:3026:SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,

So, the syscall you're looking for is located at in ./fs/namespace.c on line 3026. (I'm using Linux 4.19.99, so the line number will probably be different on your kernel.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文