【Linux】linux5.6引入struct proc_ops,用以替代struct file_operations在/proc下进行文件操作

一. 问题引入

linux5.10生成在/proc目录下的文件时,利用cat读取文件,提示:

operation not permitted

该报错是错误码:EPERM,不允许操作

二. 问题原因

发现是在移植内核代码时,未对proc接口进行适配。
linux-5.6引入结构体struct proc_ops,用以替代struct file_operations在/proc下进行文件操作。
proc_create中的proc_ops结构体类型定义改变,导致不匹配

//struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops);
struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);

struct proc_ops定义:

//proc_fs.h
struct proc_ops {
   
	int	(*proc_open)(struct inode *, struct file *
  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值