/dev/sda"时,调用了什么内核模块函数-6ren"> /dev/sda"时,调用了什么内核模块函数-我浏览了Linux Kernel Module Programming指导,但无法弄清楚: 当我说 cat image.iso > /dev/sda ,会不会导致write file_operatio-6ren">
gpt4 book ai didi

kernel - 当我说 "cat myfile >/dev/sda"时,调用了什么内核模块函数

转载 作者:行者123 更新时间:2023-12-01 06:34:06 24 4
gpt4 key购买 nike

我浏览了Linux Kernel Module Programming指导,但无法弄清楚:

当我说 cat image.iso > /dev/sda ,会不会导致write file_operations structure的功能由 sda 执行设备驱动?还是文件接口(interface)不适用于 block 设备节点?

我在哪里可以找到该函数的实现? (Linux code tree 中的相应驱动程序)?

最佳答案

fs/block-dev.c 定义了适用于 block 设备的文件操作和地址空间操作。

static const struct address_space_operations def_blk_aops = {
.readpage = blkdev_readpage,
.writepage = blkdev_writepage,
.write_begin = blkdev_write_begin,
.write_end = blkdev_write_end,
.writepages = generic_writepages,
.releasepage = blkdev_releasepage,
.direct_IO = blkdev_direct_IO,
.is_dirty_writeback = buffer_check_dirty_writeback,
};

const struct file_operations def_blk_fops = {
.open = blkdev_open,
.release = blkdev_close,
.llseek = block_llseek,
.read = do_sync_read,
.write = do_sync_write,
.aio_read = blkdev_aio_read,
.aio_write = blkdev_aio_write,
.mmap = generic_file_mmap,
.fsync = blkdev_fsync,
.unlocked_ioctl = block_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_blkdev_ioctl,
#endif
.splice_read = generic_file_splice_read,
.splice_write = generic_file_splice_write,
};

关于kernel - 当我说 "cat myfile >/dev/sda"时,调用了什么内核模块函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16683183/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com