Skip to content

Commit c67cf65

Browse files
braunerMiklos Szeredi
authored andcommitted
ovl: handle idmappings in creation operations
When creating objects in the upper layer we need to pass down the upper idmapping into the respective vfs helpers in order to support idmapped base layers. The vfs helpers will take care of the rest. Cc: <linux-unionfs@vger.kernel.org> Tested-by: Giuseppe Scrivano <gscrivan@redhat.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent b65c20a commit c67cf65

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

fs/overlayfs/overlayfs.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static inline const char *ovl_xattr(struct ovl_fs *ofs, enum ovl_xattr ox)
125125
static inline int ovl_do_rmdir(struct ovl_fs *ofs,
126126
struct inode *dir, struct dentry *dentry)
127127
{
128-
int err = vfs_rmdir(&init_user_ns, dir, dentry);
128+
int err = vfs_rmdir(ovl_upper_mnt_userns(ofs), dir, dentry);
129129

130130
pr_debug("rmdir(%pd2) = %i\n", dentry, err);
131131
return err;
@@ -134,7 +134,7 @@ static inline int ovl_do_rmdir(struct ovl_fs *ofs,
134134
static inline int ovl_do_unlink(struct ovl_fs *ofs, struct inode *dir,
135135
struct dentry *dentry)
136136
{
137-
int err = vfs_unlink(&init_user_ns, dir, dentry, NULL);
137+
int err = vfs_unlink(ovl_upper_mnt_userns(ofs), dir, dentry, NULL);
138138

139139
pr_debug("unlink(%pd2) = %i\n", dentry, err);
140140
return err;
@@ -143,7 +143,7 @@ static inline int ovl_do_unlink(struct ovl_fs *ofs, struct inode *dir,
143143
static inline int ovl_do_link(struct ovl_fs *ofs, struct dentry *old_dentry,
144144
struct inode *dir, struct dentry *new_dentry)
145145
{
146-
int err = vfs_link(old_dentry, &init_user_ns, dir, new_dentry, NULL);
146+
int err = vfs_link(old_dentry, ovl_upper_mnt_userns(ofs), dir, new_dentry, NULL);
147147

148148
pr_debug("link(%pd2, %pd2) = %i\n", old_dentry, new_dentry, err);
149149
return err;
@@ -153,7 +153,7 @@ static inline int ovl_do_create(struct ovl_fs *ofs,
153153
struct inode *dir, struct dentry *dentry,
154154
umode_t mode)
155155
{
156-
int err = vfs_create(&init_user_ns, dir, dentry, mode, true);
156+
int err = vfs_create(ovl_upper_mnt_userns(ofs), dir, dentry, mode, true);
157157

158158
pr_debug("create(%pd2, 0%o) = %i\n", dentry, mode, err);
159159
return err;
@@ -163,7 +163,7 @@ static inline int ovl_do_mkdir(struct ovl_fs *ofs,
163163
struct inode *dir, struct dentry *dentry,
164164
umode_t mode)
165165
{
166-
int err = vfs_mkdir(&init_user_ns, dir, dentry, mode);
166+
int err = vfs_mkdir(ovl_upper_mnt_userns(ofs), dir, dentry, mode);
167167
pr_debug("mkdir(%pd2, 0%o) = %i\n", dentry, mode, err);
168168
return err;
169169
}
@@ -172,7 +172,7 @@ static inline int ovl_do_mknod(struct ovl_fs *ofs,
172172
struct inode *dir, struct dentry *dentry,
173173
umode_t mode, dev_t dev)
174174
{
175-
int err = vfs_mknod(&init_user_ns, dir, dentry, mode, dev);
175+
int err = vfs_mknod(ovl_upper_mnt_userns(ofs), dir, dentry, mode, dev);
176176

177177
pr_debug("mknod(%pd2, 0%o, 0%o) = %i\n", dentry, mode, dev, err);
178178
return err;
@@ -182,7 +182,7 @@ static inline int ovl_do_symlink(struct ovl_fs *ofs,
182182
struct inode *dir, struct dentry *dentry,
183183
const char *oldname)
184184
{
185-
int err = vfs_symlink(&init_user_ns, dir, dentry, oldname);
185+
int err = vfs_symlink(ovl_upper_mnt_userns(ofs), dir, dentry, oldname);
186186

187187
pr_debug("symlink(\"%s\", %pd2) = %i\n", oldname, dentry, err);
188188
return err;
@@ -245,10 +245,10 @@ static inline int ovl_do_rename(struct ovl_fs *ofs, struct inode *olddir,
245245
{
246246
int err;
247247
struct renamedata rd = {
248-
.old_mnt_userns = &init_user_ns,
248+
.old_mnt_userns = ovl_upper_mnt_userns(ofs),
249249
.old_dir = olddir,
250250
.old_dentry = olddentry,
251-
.new_mnt_userns = &init_user_ns,
251+
.new_mnt_userns = ovl_upper_mnt_userns(ofs),
252252
.new_dir = newdir,
253253
.new_dentry = newdentry,
254254
.flags = flags,
@@ -266,15 +266,15 @@ static inline int ovl_do_rename(struct ovl_fs *ofs, struct inode *olddir,
266266
static inline int ovl_do_whiteout(struct ovl_fs *ofs,
267267
struct inode *dir, struct dentry *dentry)
268268
{
269-
int err = vfs_whiteout(&init_user_ns, dir, dentry);
269+
int err = vfs_whiteout(ovl_upper_mnt_userns(ofs), dir, dentry);
270270
pr_debug("whiteout(%pd2) = %i\n", dentry, err);
271271
return err;
272272
}
273273

274274
static inline struct dentry *ovl_do_tmpfile(struct ovl_fs *ofs,
275275
struct dentry *dentry, umode_t mode)
276276
{
277-
struct dentry *ret = vfs_tmpfile(&init_user_ns, dentry, mode, 0);
277+
struct dentry *ret = vfs_tmpfile(ovl_upper_mnt_userns(ofs), dentry, mode, 0);
278278
int err = PTR_ERR_OR_ZERO(ret);
279279

280280
pr_debug("tmpfile(%pd2, 0%o) = %i\n", dentry, mode, err);

0 commit comments

Comments
 (0)