浅尝辄止82-NTFS文件系统1-内核1-挂载

2019-02-23  本文已影响0人  阿棍儿_Leon

NTFS文件系统挂载

看这个挂载函数就知道,和FAT32套路是一样的,要看ntfs_fill_super

static struct dentry *ntfs_mount(struct file_system_type *fs_type,
    int flags, const char *dev_name, void *data)
{
    return mount_bdev(fs_type, flags, dev_name, data, ntfs_fill_super);
}

ntfs_fill_super

老套路,struct super_block *sb是VFS层的数据结构,其成员s_fs_info是给每个具体的文件系统用的,我理解它就是一个指向具体文件系统的自定义超级块的指针,NTFS的自定义超级块的结构体就是ntfs_volume

sb->s_fs_info = kmalloc(sizeof(ntfs_volume), GFP_NOFS);

vol就是ntfs_volume的实例指针,这里把它成员sb指向了VFS超级块sbsuper_blockntfs_volume就形成了一种亲密关系,互相很容易找到对方。

    *vol = (ntfs_volume) {
        .sb = sb,
        ///...
    };

这里在加载boot sector,也就是把分区的0号扇区读到内存里来。read_ntfs_boot_sector里面和FAT32一样,也是用sb_bread(sb, 0)读取分区的0号扇区,然后用parse_ntfs_boot_sector来解析它。

bh = read_ntfs_boot_sector(sb, silent)

在进一步机械boot sector之前,我需要先说一下NTFS的设计。

上一篇下一篇

猜你喜欢

热点阅读