Question

I've skimmed through the Linux Kernel Module Programming guide, but can't figure out:

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

Where do I find that function's implementation? (the respective driver within the Linux code tree)?

Était-ce utile?

La solution

fs/block-dev.c defines file operations and address space operations as 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,
};
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top