获取写Linux内核模块,当用户进程的PID [英] Getting user process pid when writing Linux Kernel Module

查看:479
本文介绍了获取写Linux内核模块,当用户进程的PID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能得到它触发了我的内核模块的 file_operation.read 程序(用户进程的PID即哪些进程正在读的/ dev / mydev的)?

How can I get the PID of the user process which triggered my Kernel module's file_operation.read routine (i.e., which process is reading /dev/mydev) ?

推荐答案

当你读功能执行时,它这样做在发行系统调用的进程上下文。你应该这样PE能够使用电流,即电流 - 方式> PID

When your read function is executing, it's doing so in the context of the process that issued the system call. You should thus pe able to use current, i.e. current->pid.

这篇关于获取写Linux内核模块,当用户进程的PID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆