Simple Traversal of uClinux kernel VFS

Source: Internet
Author: User

After the kernel unlocks rootfs. initramfs, VFS builds a tree in the kernel. We write a simple code to traverse the tree:

Static void vfswalk (cvfswalk * pwalk, void * pparent, dentry * pentry)

{

// Insert all child nodes

Struct dentry * pnode;

Void * plast = NULL;

List_for_each_entry (struct dentry, pnode, & pentry-> d_subdirs, d_u.d_child)

{

Plast = pwalk-> insert (char *) pnode-> d_name.name, pparent, plast );

Vfswalk (pwalk, plast, pnode );

}

}

 

Void vfswalk (cvfswalk * pwalk)

{

// Insert all nodes

Struct dentry * pentry = Current-> nsproxy-> mnt_ns-> root-> mnt_root;

Void * proot = pwalk-> insert ("/", null, null );

Vfswalk (pwalk, proot, pentry );

}

Cvfswalk encapsulates the insertitem function of ctreectrl, so that each node found in VFS will be created on the tree control accordingly.

Traverse the dentry from the root file system and use only the d_subdirs Member of the struct dentry struct.

The experiment results show that:

1. Each common file or directory is represented by a dentry struct.

2. For the symbolic file linked to the directory, the dentry subnode is empty.

Well, continue learning about the kernel ~~~

 

 

Recently, my 6-year-old girl took part in the sixth pop National Children's English style competition, canvassing in progress (Before ).

Click the link of the New Oriental Website:

Http://popdasai.xdf.cn/toupiao.php? Do = Space & UUID = 4237

Vote for her. Thank you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.