一. 情景模式
1. 获取文件的绝对路径,这里指由fd获取
2. 获取进程的绝对路径
二. linux kernel 和路径有关的2个数据结构:
1. struct dentry 文件名保存在这个结构体
结构体原型:
struct dentry {
int d_mounted;
struct inode *d_inode;/* Where the name belongs to - NULL is negative */
struct hlist_node d_hash; /* lookup hash list */
struct dentry *d_parent; /* parent directory */
struct qstr d_name; /* 文件名在这里 */
/* 省略若干内容 */
};
2. struct vfsmount 文件系统的挂载信息,mount 命令
结构体原型:
struct vfsmount {
struct list_head mnt_hash;
struct vfsmount *mnt_parent; /* fs we are mounted on */
struct dentry *mnt_mountpoint; /* dentry of mountpoint */
struct dentry *mnt_root; /* root of the mounted tree */
/* 省略若干内容 */
};