源码位置
kernel/driver/misc/uinput.c
#define UINPUT_NAME "uinput"
static const struct file_operations uinput_fops = {
.owner = THIS_MODULE,
.open = uinput_open,
.release = uinput_release,
.read = uinput_read,
.write = uinput_write,
.poll = uinput_poll,
.unlocked_ioctl = uinput_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = uinput_compat_ioctl,
#endif
.llseek = no_llseek,
};
static struct miscdevice uinput_misc = {
.fops = &uinput_fops,
.minor = UINPUT_MINOR,
.name = UINPUT_NAME,
};
从驱动代码看,uinput是注册的混杂设备,节点是/dev/uinput
对于其open,read,write,ioctl这些方法,打算放到下一篇文章和应用一起分析
为了增加一些篇幅,这里简单的看一下uinput_device结构体
struct uinput_device {
struct input_dev *dev;
struct mutex mutex;
enum uinput_state state;
wait_queue_head_t waitq;
unsigned char ready;
unsigned char head;
unsigned char tail;
struct input_event buff[UINPUT_BUFFER_SIZE];
unsigned int ff_effects_max;
struct uinput_request *requests[UINPUT_NUM_REQUESTS];
wait_queue_head_t requests_waitq;
spinlock_t requests_lock;
};
可以看到,uinput是包含input_dev的,另外还有head,tail,buff,看起来又是一套缓冲区,对于request相关的,暂时看不出来什么信息。