mount 内核源码_struct vfsmount中的mnt_mountpoint和mnt_root在什么情况下会不相等?

在do_kern_mount函数中:

struct vfsmount *

do_kern_mount(const char *fstype, int flags, const char *name, void *data)

{

struct file_system_type *type = get_fs_type(fstype);

struct super_block *sb = ERR_PTR(-ENOMEM);

struct vfsmount *mnt;

int error;

char *secdata = NULL;

if (!type)

return ERR_PTR(-ENODEV);

mnt = alloc_vfsmnt(name);

if (!mnt)

goto out;

if (data) {

secdata = alloc_secdata();

if (!secdata) {

sb = ERR_PTR(-ENOMEM);

goto out_mnt;

}

error = security_sb_copy_data(type, data, secdata);

if (error) {

sb = ERR_PTR(error);

goto out_free_secdata;

}

}

sb = type->get_sb(type, flags, name, data);

if (IS_ERR(sb))

goto out_free_secdata;

error = security_sb_kern_mount(sb, secdata);

if (error)

goto out_sb;

mnt->mnt_sb = sb;

mnt->mnt_root = dget(sb->s_root);

mnt->mnt_mountpoint = sb->s_root;

mnt->mnt_parent = mnt;

mnt->mnt_namespace = current->namespace;

up_write(&sb->s_umount);

put_filesystem(type);

return mnt;

out_sb:

up_write(&sb->s_umount);

deactivate_super(sb);

sb = ERR_PTR(error);

out_free_secdata:

free_secdata(secdata);

out_mnt:

free_vfsmnt(mnt);

out:

put_filesystem(type);

return (struct vfsmount *)sb;

}

这里很明确的将mnt_mountpoint 和 mnt_root 初始化成mount目录的dentry.

不知道在其他什么地方会修改mnt_root或者mnt_mountpoint 的值?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值