linux中,vfsmount结构记录挂载文件系统。其数据成员mnt_parent指向该文件系统的父文件系统, mnt_mounts是孩子文件系统的链头部,mnt_child指向兄弟结点
例如 系统的根文件系统是ext3格式,在/mnt/winc /mnt/wind /mnt/wine 目录上分别挂载三个分区(可以认为是windows下的c d e 盘)。这样系统就为新挂载的三个文件系统分别分配了vfsmount结构,并将其 mnt_parent 指向根文件系统的vfsmount结构,通过mnt_child链入跟文件系统vfsmount的mnt_mounts 链表,初始化mnt_mounts指向自身.
内核代码中,对一特定vfsmount为根的mount树遍历,用到了先根遍历算法:
static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root)
{
struct list_head *next = p->mnt_mounts.next;
if (next == &p->mnt_mounts) {
while (1) {
if (p == root)
return NULL;
next = p->mnt_child.next;
if (next != &p->mnt_parent->mnt_mounts)
break;
p = p->mnt_parent;
}
}
return list_entry(next, struct vfsmount, mnt_child);
}Linux万能播放器MPlayerFC6下VirtualBox的安装与配置相关资讯 Linux mount树结构
- Linux 即将 25 岁:足够伟大 却不 (01月01日)
- Linux 这么棒是因为开源? (08/28/2015 09:21:02)
- FreeBSD 和 Linux 有什么不同? (07/31/2015 09:15:06)
| - 盘点全球“国家级” Linux 项目 (09/25/2015 06:11:28)
- 庆祝 Linux 24 岁生日! (08/26/2015 06:13:36)
- 【观点】离了Linux,我就活不了! (10/31/2013 19:39:56)
|
本文评论 查看全部评论 (0)