结构体,并将file_operations结构体放入cdev-> ops 里*/
void cdev_init(struct cdev *cdev, const struct file_operations.../module.h>
#include
#include
#include
#include
#include
static int hello_fops1_open(struct inode *inode, struct file *file)...hello"); //动态分配字符设备: (major,0) (major,1) (major,2) (major,3)
major=MAJOR(devid);
cdev_init...major,1)
cdev_init(&hello2_cdev, &hello2_fops);
cdev_add(&hello2_cdev,MKDEV(major,2), 2);