Lines Matching +full:- +full:- +full:root

1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* getroot.c: get the root dentry for an NFS mount
36 * Set the superblock root dentry.
41 /* The mntroot acts as the dummy root dentry for this superblock */ in nfs_superblock_set_dummy_root()
42 if (sb->s_root == NULL) { in nfs_superblock_set_dummy_root()
43 sb->s_root = d_make_root(inode); in nfs_superblock_set_dummy_root()
44 if (sb->s_root == NULL) in nfs_superblock_set_dummy_root()
45 return -ENOMEM; in nfs_superblock_set_dummy_root()
55 spin_lock(&d_inode(sb->s_root)->i_lock); in nfs_superblock_set_dummy_root()
56 spin_lock(&sb->s_root->d_lock); in nfs_superblock_set_dummy_root()
57 hlist_del_init(&sb->s_root->d_u.d_alias); in nfs_superblock_set_dummy_root()
58 spin_unlock(&sb->s_root->d_lock); in nfs_superblock_set_dummy_root()
59 spin_unlock(&d_inode(sb->s_root)->i_lock); in nfs_superblock_set_dummy_root()
65 * get an NFS2/NFS3 root dentry from the root filehandle
72 struct dentry *root; in nfs_get_root() local
75 int error = -ENOMEM; in nfs_get_root()
78 name = kstrdup(fc->source, GFP_KERNEL); in nfs_get_root()
82 /* get the actual root for this mount */ in nfs_get_root()
87 error = server->nfs_client->rpc_ops->getroot(server, ctx->mntfh, &fsinfo); in nfs_get_root()
89 dprintk("nfs_get_root: getattr error = %d\n", -error); in nfs_get_root()
90 nfs_errorf(fc, "NFS: Couldn't getattr on root"); in nfs_get_root()
94 inode = nfs_fhget(s, ctx->mntfh, fsinfo.fattr); in nfs_get_root()
96 dprintk("nfs_get_root: get root inode failed\n"); in nfs_get_root()
98 nfs_errorf(fc, "NFS: Couldn't get root inode"); in nfs_get_root()
106 /* root dentries normally start off anonymous and get spliced in later in nfs_get_root()
108 * exists, we'll pick it up at this point and use it as the root in nfs_get_root()
110 root = d_obtain_root(inode); in nfs_get_root()
111 if (IS_ERR(root)) { in nfs_get_root()
112 dprintk("nfs_get_root: get root dentry failed\n"); in nfs_get_root()
113 error = PTR_ERR(root); in nfs_get_root()
114 nfs_errorf(fc, "NFS: Couldn't get root dentry"); in nfs_get_root()
118 security_d_instantiate(root, inode); in nfs_get_root()
119 spin_lock(&root->d_lock); in nfs_get_root()
120 if (IS_ROOT(root) && !root->d_fsdata && in nfs_get_root()
121 !(root->d_flags & DCACHE_NFSFS_RENAMED)) { in nfs_get_root()
122 root->d_fsdata = name; in nfs_get_root()
125 spin_unlock(&root->d_lock); in nfs_get_root()
126 fc->root = root; in nfs_get_root()
127 if (server->caps & NFS_CAP_SECURITY_LABEL) in nfs_get_root()
129 if (ctx->clone_data.sb) { in nfs_get_root()
130 if (d_inode(fc->root)->i_fop != &nfs_dir_operations) { in nfs_get_root()
131 error = -ESTALE; in nfs_get_root()
135 error = security_sb_clone_mnt_opts(ctx->clone_data.sb, in nfs_get_root()
139 clone_server = NFS_SB(ctx->clone_data.sb); in nfs_get_root()
140 server->has_sec_mnt_opts = clone_server->has_sec_mnt_opts; in nfs_get_root()
142 error = security_sb_set_mnt_opts(s, fc->security, in nfs_get_root()
147 if (server->caps & NFS_CAP_SECURITY_LABEL && in nfs_get_root()
149 server->caps &= ~NFS_CAP_SECURITY_LABEL; in nfs_get_root()
161 dput(fc->root); in nfs_get_root()
162 fc->root = NULL; in nfs_get_root()