探究Linux中驱动器挂载点目录的结构和访问方式
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); } (编辑:银川站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |