OK6410A 开发板 (八) 111 linux-5.11 OK6410A tmpfs 文件系统 CONFIG_SHMEM=y & CONFIG_TMPFS=n

  • 公有部分
▼ variables
   -shm_mnt

▼ functions
   -__shmem_file_setup(struct vfsmount *mnt, const char *name, loff_t size, unsigned long flags, unsigned int i_flags)
    shmem_file_setup(const char *name, loff_t size, unsigned long flags)
    shmem_file_setup_with_mnt(struct vfsmount *mnt, const char *name, loff_t size, unsigned long flags)
    shmem_kernel_file_setup(const char *name, loff_t size, unsigned long flags)
    shmem_read_mapping_page_gfp(struct address_space *mapping, pgoff_t index, gfp_t gfp)
    shmem_zero_setup(struct vm_area_struct *vma)

————————————————
版权声明:本文为CSDN博主「__pop_」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011011827/article/details/120164707
  • 独有部分
> ▼ macros
>    -BLOCKS_PER_PAGE
>    -BOGO_DIRENT_SIZE
>    -SHMEM_HUGE_ADVISE
>    -SHMEM_HUGE_ALWAYS
>    -SHMEM_HUGE_DENY
>    -SHMEM_HUGE_FORCE
>    -SHMEM_HUGE_NEVER
>    -SHMEM_HUGE_WITHIN_SIZE
>    -SHMEM_INO_BATCH
>    -SHMEM_SEEN_BLOCKS
>    -SHMEM_SEEN_HUGE
>    -SHMEM_SEEN_INODES
>    -SHMEM_SEEN_INUMS
>    -SHORT_SYMLINK_LEN
>    -VM_ACCT
>    -shmem_huge
>    -vm_policy
>
> ▼ prototypes
>    -DEFINE_MUTEX
>    -LIST_HEAD
>    -shmem_getpage_gfp(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, struct vm_fault *vmf, vm_fault_t *fault_type)
>    -shmem_replace_page(struct page **pagep, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_should_replace_page(struct page *page, gfp_t gfp)
>    -shmem_swapin_page(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, vm_fault_t *fault_type)
>
>-shmem_falloc : struct
>     [members]
>    +next
>    +nr_falloced
>    +nr_unswapped
>    +start
>    +waitq
>
>-shmem_options : struct
>     [members]
>    +blocks
>    +full_inums
>    +gid
>    +huge
>    +inodes
>    +mode
>    +mpol
>    +seen
>    +uid

▼ variables
>    -__read_mostly
3a51,58
>     shmem_aops
>     shmem_aops
>     shmem_aops
>    -shmem_dir_inode_operations
>    -shmem_dir_inode_operations
>     shmem_enabled_attr
>    -shmem_file_operations
>    -shmem_file_operations
5a61,68
>    -shmem_fs_context_ops
>    -shmem_fs_type
>    -shmem_fs_type
>    -shmem_inode_cachep
>    -shmem_inode_operations
>    -shmem_inode_operations
>    -shmem_ops
>    -shmem_ops
6a70,74
>    -shmem_special_inode_operations
>    -shmem_special_inode_operations
>     shmem_truncate_range
>    -shmem_vm_ops
>    -shmem_vm_ops

▼ functions
8a77
>    -SHMEM_SB(struct super_block *sb)
9a79,95
>    -is_huge_enabled(struct shmem_sb_info *sbinfo)
>    -shmem_acct_block(unsigned long flags, long pages)
>    -shmem_acct_size(unsigned long flags, loff_t size)
>    -shmem_add_to_page_cache(struct page *page, struct address_space *mapping, pgoff_t index, void *expected, gfp_t gfp, struct mm_struct *charge_mm)
>    -shmem_alloc_and_acct_page(gfp_t gfp, struct inode *inode, pgoff_t index, bool huge)
>    -shmem_alloc_hugepage(gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_alloc_inode(struct super_block *sb)
>    -shmem_alloc_page(gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>     shmem_charge(struct inode *inode, long pages)
>    -shmem_confirm_swap(struct address_space *mapping, pgoff_t index, swp_entry_t swap)
>    -shmem_delete_from_page_cache(struct page *page, void *radswap)
>    -shmem_destroy_inode(struct inode *inode)
>    -shmem_destroy_inodecache(void)
>    -shmem_enabled_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>    -shmem_enabled_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
>    -shmem_evict_inode(struct inode *inode)
>    -shmem_fault(struct vm_fault *vmf)
11a98,119
>    -shmem_fill_super(struct super_block *sb, struct fs_context *fc)
>    -shmem_find_swap_entries(struct address_space *mapping, pgoff_t start, unsigned int nr_entries, struct page **entries, pgoff_t *indices, unsigned int type, bool frontswap)
>    -shmem_format_huge(int huge)
>    -shmem_free_fc(struct fs_context *fc)
>    -shmem_free_in_core_inode(struct inode *inode)
>    -shmem_free_inode(struct super_block *sb)
>    -shmem_free_swap(struct address_space *mapping, pgoff_t index, void *radswap)
>    -shmem_get_inode(struct super_block *sb, const struct inode *dir, umode_t mode, dev_t dev, unsigned long flags)
>    -shmem_get_policy(struct vm_area_struct *vma, unsigned long addr)
>    -shmem_get_sbmpol(struct shmem_sb_info *sbinfo)
>    -shmem_get_tree(struct fs_context *fc)
>     shmem_get_unmapped_area(struct file *file, unsigned long uaddr, unsigned long len, unsigned long pgoff, unsigned long flags)
>    -shmem_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags)
>     shmem_getpage(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp)
>    -shmem_getpage_gfp(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, struct vm_fault *vmf, vm_fault_t *fault_type)
>     shmem_huge_enabled(struct vm_area_struct *vma)
>     shmem_init(void)
>     shmem_init_fs_context(struct fs_context *fc)
>    -shmem_init_inode(void *foo)
>    -shmem_init_inodecache(void)
>    -shmem_inode_acct_block(struct inode *inode, long pages)
>    -shmem_inode_unacct_blocks(struct inode *inode, long pages)
12a121,132
>     shmem_lock(struct file *file, int lock, struct user_struct *user)
>     shmem_mcopy_atomic_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr, unsigned long src_addr, struct page **pagep)
>    -shmem_mfill_atomic_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr, unsigned long src_addr, bool zeropage, struct page **pagep)
>     shmem_mfill_zeropage_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr)
>    -shmem_mmap(struct file *file, struct vm_area_struct *vma)
>    -shmem_parse_huge(const char *str)
>     shmem_partial_swap_usage(struct address_space *mapping, pgoff_t start, pgoff_t end)
>    -shmem_pseudo_vma_destroy(struct vm_area_struct *vma)
>    -shmem_pseudo_vma_init(struct vm_area_struct *vma, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_punch_compound(struct page *page, pgoff_t start, pgoff_t end)
>    -shmem_put_super(struct super_block *sb)
>    -shmem_reacct_size(unsigned long flags, loff_t oldsize, loff_t newsize)
13a134,158
>    -shmem_recalc_inode(struct inode *inode)
>    -shmem_replace_entry(struct address_space *mapping, pgoff_t index, void *expected, void *replacement)
>    -shmem_replace_page(struct page **pagep, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_reserve_inode(struct super_block *sb, ino_t *inop)
>    -shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *mpol)
>    -shmem_setattr(struct dentry *dentry, struct iattr *attr)
>    -shmem_should_replace_page(struct page *page, gfp_t gfp)
>    -shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
>     shmem_swap_usage(struct vm_area_struct *vma)
>    -shmem_swapin(swp_entry_t swap, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_swapin_page(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, vm_fault_t *fault_type)
>     shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
>    -shmem_unacct_blocks(unsigned long flags, long pages)
>    -shmem_unacct_size(unsigned long flags, loff_t size)
>     shmem_uncharge(struct inode *inode, long pages)
>    -shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, bool unfalloc)
>     shmem_unlock_mapping(struct address_space *mapping)
>     shmem_unuse(unsigned int type, bool frontswap, unsigned long *fs_pages_to_unuse)
>    -shmem_unuse_inode(struct inode *inode, unsigned int type, bool frontswap, unsigned long *fs_pages_to_unuse)
>    -shmem_unuse_swap_entries(struct inode *inode, struct pagevec pvec, pgoff_t *indices)
>    -shmem_unused_huge_count(struct super_block *sb, struct shrink_control *sc)
>    -shmem_unused_huge_scan(struct super_block *sb, struct shrink_control *sc)
>    -shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, struct shrink_control *sc, unsigned long nr_to_split)
>    -shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, struct shrink_control *sc, unsigned long nr_to_split)
>    -shmem_writepage(struct page *page, struct writeback_control *wbc)
14a160,161
>    -synchronous_wake_function(wait_queue_entry_t *wait, unsigned mode, int sync, void *key)
>     vma_is_shmem(struct vm_area_struct *vma)
————————————————
版权声明:本文为CSDN博主「__pop_」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011011827/article/details/120164707
第一个问题:挂载
我们关注以下两个内容
	1. super_block 的填充			: shmem_init_fs_context中的shmem_fs_context_ops中的shmem_get_tree中的shmem_fill_super
		// 1. 申请 inode 结构体,该inode 为"目录文件"
		// 2. 创建 该inode 对应的 dentry
		// 3. 将 dentry 赋给 sb->s_root
		
		// inode 是 通过 shmem_get_inode->new_inode->new_inode_pseudo->alloc_inode 获取的 
	2. mnt结构体链接到内核的过程   	: vfs_create_mount
		// 1. 申请一个 struct mount 结构体
		// 2. 赋值 mnt 的成员
		// 3. list_add_tail(&mnt->mnt_instance, &mnt->mnt.mnt_sb->s_mounts);

		// tmpfs 挂载到哪里了?

第二个问题:文件操作
shmem_get_inode
	switch (mode & S_IFMT)
		case S_IFDIR:
			inode->i_op = &shmem_dir_inode_operations;
static const struct inode_operations shmem_dir_inode_operations = {
// 空
};

// 可以看出来, 支持的文件操作为空,也就是根本就不能创建文件
第三个问题:search及真实文件系统中层级目录的维护


第四个问题:文件IO
shmem_get_inode
	switch (mode & S_IFMT)
		case S_IFREG:
			inode->i_fop = &shmem_file_operations;

static const struct file_operations shmem_file_operations = {                        
    .mmap       = shmem_mmap,                                                        
    .get_unmapped_area = shmem_get_unmapped_area,
};

// 可以看出来,不支持 read write
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值