文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>linux中mount树结构及遍历

linux中mount树结构及遍历

时间:2007-04-22  来源:hauto

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); }
相关阅读 更多 +
排行榜 更多 +
迅猛兔加速器

迅猛兔加速器

游戏工具 下载
弹琴吧

弹琴吧

学习教育 下载
猿辅导

猿辅导

休闲益智 下载