/ dev / sda" I looked at the Linux Kernel Programming Guide , but can't figure it out...">

What kernel module function is called when I say "cat myfile> / dev / sda"

I looked at the Linux Kernel Programming Guide , but can't figure it out:

When I say cat image.iso > /dev/sda , will it call the write function of the file_operations structure, which will be executed by the sda device driver? Or does the file interface not apply to device block nodes?

Where to find this feature? (corresponding driver in Linux code tree )?

+4
source share
1 answer

fs / block-dev.c defines file operations and address space operations applicable to block devices.

 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, }; 
0
source

Source: https://habr.com/ru/post/1482047/


All Articles