Skip to content

Commit 556208e

Browse files
mihalicynMiklos Szeredi
authored andcommitted
fuse: support idmap for mkdir/mknod/symlink/create/tmpfile
We have all the infrastructure in place, we just need to pass an idmapping here. Signed-off-by: Alexander Mikhalitsyn <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent d561254 commit 556208e

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

fs/fuse/dir.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,9 @@ static void free_ext_value(struct fuse_args *args)
614614
* If the filesystem doesn't support this, then fall back to separate
615615
* 'mknod' + 'open' requests.
616616
*/
617-
static int fuse_create_open(struct inode *dir, struct dentry *entry,
618-
struct file *file, unsigned int flags,
619-
umode_t mode, u32 opcode)
617+
static int fuse_create_open(struct mnt_idmap *idmap, struct inode *dir,
618+
struct dentry *entry, struct file *file,
619+
unsigned int flags, umode_t mode, u32 opcode)
620620
{
621621
int err;
622622
struct inode *inode;
@@ -673,11 +673,11 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
673673
args.out_args[1].size = sizeof(*outopenp);
674674
args.out_args[1].value = outopenp;
675675

676-
err = get_create_ext(&nop_mnt_idmap, &args, dir, entry, mode);
676+
err = get_create_ext(idmap, &args, dir, entry, mode);
677677
if (err)
678678
goto out_free_ff;
679679

680-
err = fuse_simple_request(NULL, fm, &args);
680+
err = fuse_simple_request(idmap, fm, &args);
681681
free_ext_value(&args);
682682
if (err)
683683
goto out_free_ff;
@@ -734,6 +734,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
734734
umode_t mode)
735735
{
736736
int err;
737+
struct mnt_idmap *idmap = file_mnt_idmap(file);
737738
struct fuse_conn *fc = get_fuse_conn(dir);
738739
struct dentry *res = NULL;
739740

@@ -758,7 +759,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
758759
if (fc->no_create)
759760
goto mknod;
760761

761-
err = fuse_create_open(dir, entry, file, flags, mode, FUSE_CREATE);
762+
err = fuse_create_open(idmap, dir, entry, file, flags, mode, FUSE_CREATE);
762763
if (err == -ENOSYS) {
763764
fc->no_create = 1;
764765
goto mknod;
@@ -769,7 +770,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
769770
return err;
770771

771772
mknod:
772-
err = fuse_mknod(&nop_mnt_idmap, dir, entry, mode, 0);
773+
err = fuse_mknod(idmap, dir, entry, mode, 0);
773774
if (err)
774775
goto out_dput;
775776
no_open:
@@ -779,9 +780,9 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
779780
/*
780781
* Code shared between mknod, mkdir, symlink and link
781782
*/
782-
static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args,
783-
struct inode *dir, struct dentry *entry,
784-
umode_t mode)
783+
static int create_new_entry(struct mnt_idmap *idmap, struct fuse_mount *fm,
784+
struct fuse_args *args, struct inode *dir,
785+
struct dentry *entry, umode_t mode)
785786
{
786787
struct fuse_entry_out outarg;
787788
struct inode *inode;
@@ -803,12 +804,12 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args,
803804
args->out_args[0].value = &outarg;
804805

805806
if (args->opcode != FUSE_LINK) {
806-
err = get_create_ext(&nop_mnt_idmap, args, dir, entry, mode);
807+
err = get_create_ext(idmap, args, dir, entry, mode);
807808
if (err)
808809
goto out_put_forget_req;
809810
}
810811

811-
err = fuse_simple_request(NULL, fm, args);
812+
err = fuse_simple_request(idmap, fm, args);
812813
free_ext_value(args);
813814
if (err)
814815
goto out_put_forget_req;
@@ -869,13 +870,13 @@ static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir,
869870
args.in_args[0].value = &inarg;
870871
args.in_args[1].size = entry->d_name.len + 1;
871872
args.in_args[1].value = entry->d_name.name;
872-
return create_new_entry(fm, &args, dir, entry, mode);
873+
return create_new_entry(idmap, fm, &args, dir, entry, mode);
873874
}
874875

875876
static int fuse_create(struct mnt_idmap *idmap, struct inode *dir,
876877
struct dentry *entry, umode_t mode, bool excl)
877878
{
878-
return fuse_mknod(&nop_mnt_idmap, dir, entry, mode, 0);
879+
return fuse_mknod(idmap, dir, entry, mode, 0);
879880
}
880881

881882
static int fuse_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
@@ -887,7 +888,8 @@ static int fuse_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
887888
if (fc->no_tmpfile)
888889
return -EOPNOTSUPP;
889890

890-
err = fuse_create_open(dir, file->f_path.dentry, file, file->f_flags, mode, FUSE_TMPFILE);
891+
err = fuse_create_open(idmap, dir, file->f_path.dentry, file,
892+
file->f_flags, mode, FUSE_TMPFILE);
891893
if (err == -ENOSYS) {
892894
fc->no_tmpfile = 1;
893895
err = -EOPNOTSUPP;
@@ -914,7 +916,7 @@ static int fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir,
914916
args.in_args[0].value = &inarg;
915917
args.in_args[1].size = entry->d_name.len + 1;
916918
args.in_args[1].value = entry->d_name.name;
917-
return create_new_entry(fm, &args, dir, entry, S_IFDIR);
919+
return create_new_entry(idmap, fm, &args, dir, entry, S_IFDIR);
918920
}
919921

920922
static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
@@ -930,7 +932,7 @@ static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
930932
args.in_args[0].value = entry->d_name.name;
931933
args.in_args[1].size = len;
932934
args.in_args[1].value = link;
933-
return create_new_entry(fm, &args, dir, entry, S_IFLNK);
935+
return create_new_entry(idmap, fm, &args, dir, entry, S_IFLNK);
934936
}
935937

936938
void fuse_flush_time_update(struct inode *inode)
@@ -1124,7 +1126,7 @@ static int fuse_link(struct dentry *entry, struct inode *newdir,
11241126
args.in_args[0].value = &inarg;
11251127
args.in_args[1].size = newent->d_name.len + 1;
11261128
args.in_args[1].value = newent->d_name.name;
1127-
err = create_new_entry(fm, &args, newdir, newent, inode->i_mode);
1129+
err = create_new_entry(NULL, fm, &args, newdir, newent, inode->i_mode);
11281130
if (!err)
11291131
fuse_update_ctime_in_cache(inode);
11301132
else if (err == -EINTR)

0 commit comments

Comments
 (0)