我的模块位于哪里?

发布于 2024-08-21 17:55:55 字数 392 浏览 2 评论 0原文

我制作了一个内核模块并使用下面的代码尝试创建 /dev/mytimer 条目。

#define DEVICE_NAME "mytimer"
#define MAJOR_NUM 61
static struct class *fc;


fc = class_create(THIS_MODULE, DEVICE_NAME);
device_create(fc, NULL, MAJOR_NUM, "%s", DEVICE_NAME);

我在 /dev 中没有看到我的模块为 /dev/mytimer... 但是当我 lsmod 时,我在列表中看到它作为条目 mytimer。

在哪里以及如何找到我的模块?有没有办法把它放在/dev 中?

谢谢!

I made a kernel module and used the code below to try to make a /dev/mytimer entry.

#define DEVICE_NAME "mytimer"
#define MAJOR_NUM 61
static struct class *fc;


fc = class_create(THIS_MODULE, DEVICE_NAME);
device_create(fc, NULL, MAJOR_NUM, "%s", DEVICE_NAME);

I don't see my module in /dev as /dev/mytimer...
But when I lsmod, I see it in the list as entry mytimer.

Where and how do I find my module? Is there anyway to put it in /dev?

Thanks!

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

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

发布评论

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

评论(1

泪意 2024-08-28 17:55:55

设备节点的自动创建是 devfs 负责的。然而,由于担心在内核中实现设备命名策略,它最终被删除。创建设备节点的现代方法是使用 udev,它可以响应 sys 设备事件并按需创建设备节点。

否则,您的另一个选择是在静态文件系统上使用 mknod 手动创建设备节点。

Automatic creation of device nodes was something the devfs was responsible for. However it was eventually removed due to concerns about implementing device naming policy in the kernel. The modern way to create device nodes is using udev which can respond to sys device events and create the device nodes on demand.

Otherwise manually creating device nodes with mknod on a static filesystem is your other option.

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