问题描述
我试图从以下源代码中了解 Linux 内核中的读取系统调用:https://github.com/torvalds/linux/tree/35e43538af8fd2cb39d58caca1134a87db173f75/fs
开头:(我在https://github.com/torvalds/linux/blob/16f73eb02d7e1765ccab3d2018e0bd98eb93d973/fs/read_write.c#L542中找到了这个函数)
SYSCALL_DEFINE3(read,unsigned int,fd,char __user *,buf,size_t,count)
{
struct fd f = fdget_pos(fd);
ssize_t ret = -EBADF;
if (f.file) {
loff_t pos = file_pos_read(f.file);
ret = vfs_read(f.file,count,&pos);
if (ret >= 0)
file_pos_write(f.file,pos);
fdput_pos(f);
}
return ret;
}
在这一步之后,我试图追踪所有起诉链接的函数:https://www.programmersought.com/article/41274530299/
所以,现在我的问题是我无法找到数据块的定义位置。我需要找到包含要读取的 inode 的磁盘块。
一些参考:
- https://tldp.org/LDP/lki/lki-3.html(检查read_inode)
- https://linux-kernel-labs.github.io/refs/heads/master/so2/lec8-filesystems.html#opening-a-file(检查从文件中读取数据)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)