我正在创建一个玩井字游戏的角色设备模块。我正在尝试对其进行编程,以便将其/dev/ticactoe模式设置为666,而不是让用户使用该chmod命令。
我的main.c包含以下内容以及和tictactoe的实现(为了简洁而进行了编辑):initexit
static dev_t device_number;
static struct cdev our_cdev;
static struct class* my_class = NULL;
static struct file_operations fops = {
.owner = THIS_MODULE,
.read = tictactoe_read,
.write = tictactoe_write,
.open = tictactoe_open,
.release = tictactoe_release,
};
Run Code Online (Sandbox Code Playgroud)
我有一个tictactoe.h包含以下内容:
#define MODULE_NAME "tictactoe"
int tictactoe_open(struct inode *pinode, struct file *pfile);
ssize_t tictactoe_read(struct file *pfile, char __user *buffer, size_t length, loff_t *offset);
ssize_t tictactoe_write(struct file *pfile, const char __user …Run Code Online (Sandbox Code Playgroud) c device-driver kernel-module linux-device-driver linux-kernel