您的位置:首页 > 运维架构

嘿!single_open 原来在这里

2014-08-07 21:54 288 查看
嘿!single_open 原来在这里

找了一会儿,没找到,后面找某搜索引擎也没有很多关于single_open的信息

其实single_open和single_release 都在/linux/seq_file.h
里面

int single_open(struct file *file, int (*show)(struct seq_file *, void *),
void *data)
{
struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
int res = -ENOMEM;

if (op) {
op->start = single_start;
op->next = single_next;
op->stop = single_stop;
op->show = show;
res = seq_open(file, op);
if (!res)
((struct seq_file *)file->private_data)->private = data;
else
kfree(op);
}
return res;
}

找single_open和single_release的初衷是因为在LDD的demo里面看到这个函数了,但是书上又没有。。。

囧~不知道是不是内核版本的原因诶。。

LDD的demo里面这样用的

static int jit_timer_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, jit_timer_proc_show, NULL);
}


传入了一个struct file结构体指针和inode指针传进去了,inode没用



真希望能再去一次啊~ 腿疼神马的木有关系~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: