2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
5 This program can be distributed under the terms of the GNU GPL.
11 #include <linux/pagemap.h>
12 #include <linux/file.h>
13 #include <linux/sched.h>
14 #include <linux/namei.h>
15 #include <linux/slab.h>
16 #include <linux/xattr.h>
18 static bool fuse_use_readdirplus(struct inode *dir, struct dir_context *ctx)
20 struct fuse_conn *fc = get_fuse_conn(dir);
21 struct fuse_inode *fi = get_fuse_inode(dir);
23 if (!fc->do_readdirplus)
25 if (!fc->readdirplus_auto)
27 if (test_and_clear_bit(FUSE_I_ADVISE_RDPLUS, &fi->state))
34 static void fuse_advise_use_readdirplus(struct inode *dir)
36 struct fuse_inode *fi = get_fuse_inode(dir);
38 set_bit(FUSE_I_ADVISE_RDPLUS, &fi->state);
41 #if BITS_PER_LONG >= 64
42 static inline void fuse_dentry_settime(struct dentry *entry, u64 time)
47 static inline u64 fuse_dentry_time(struct dentry *entry)
53 * On 32 bit archs store the high 32 bits of time in d_fsdata
55 static void fuse_dentry_settime(struct dentry *entry, u64 time)
58 entry->d_fsdata = (void *) (unsigned long) (time >> 32);
61 static u64 fuse_dentry_time(struct dentry *entry)
63 return (u64) entry->d_time +
64 ((u64) (unsigned long) entry->d_fsdata << 32);
69 * FUSE caches dentries and attributes with separate timeout. The
70 * time in jiffies until the dentry/attributes are valid is stored in
71 * dentry->d_time and fuse_inode->i_time respectively.
75 * Calculate the time in jiffies until a dentry/attributes are valid
77 static u64 time_to_jiffies(unsigned long sec, unsigned long nsec)
80 struct timespec ts = {sec, nsec};
81 return get_jiffies_64() + timespec_to_jiffies(&ts);
87 * Set dentry and possibly attribute timeouts from the lookup/mk*
90 static void fuse_change_entry_timeout(struct dentry *entry,
91 struct fuse_entry_out *o)
93 fuse_dentry_settime(entry,
94 time_to_jiffies(o->entry_valid, o->entry_valid_nsec));
97 static u64 attr_timeout(struct fuse_attr_out *o)
99 return time_to_jiffies(o->attr_valid, o->attr_valid_nsec);
102 static u64 entry_attr_timeout(struct fuse_entry_out *o)
104 return time_to_jiffies(o->attr_valid, o->attr_valid_nsec);
108 * Mark the attributes as stale, so that at the next call to
109 * ->getattr() they will be fetched from userspace
111 void fuse_invalidate_attr(struct inode *inode)
113 get_fuse_inode(inode)->i_time = 0;
117 * Mark the attributes as stale due to an atime change. Avoid the invalidate if
120 void fuse_invalidate_atime(struct inode *inode)
122 if (!IS_RDONLY(inode))
123 fuse_invalidate_attr(inode);
127 * Just mark the entry as stale, so that a next attempt to look it up
128 * will result in a new lookup call to userspace
130 * This is called when a dentry is about to become negative and the
131 * timeout is unknown (unlink, rmdir, rename and in some cases
134 void fuse_invalidate_entry_cache(struct dentry *entry)
136 fuse_dentry_settime(entry, 0);
140 * Same as fuse_invalidate_entry_cache(), but also try to remove the
141 * dentry from the hash
143 static void fuse_invalidate_entry(struct dentry *entry)
146 fuse_invalidate_entry_cache(entry);
149 static void fuse_lookup_init(struct fuse_conn *fc, struct fuse_args *args,
150 u64 nodeid, const struct qstr *name,
151 struct fuse_entry_out *outarg)
153 memset(outarg, 0, sizeof(struct fuse_entry_out));
154 args->in.h.opcode = FUSE_LOOKUP;
155 args->in.h.nodeid = nodeid;
156 args->in.numargs = 1;
157 args->in.args[0].size = name->len + 1;
158 args->in.args[0].value = name->name;
159 args->out.numargs = 1;
160 args->out.args[0].size = sizeof(struct fuse_entry_out);
161 args->out.args[0].value = outarg;
164 u64 fuse_get_attr_version(struct fuse_conn *fc)
169 * The spin lock isn't actually needed on 64bit archs, but we
170 * don't yet care too much about such optimizations.
172 spin_lock(&fc->lock);
173 curr_version = fc->attr_version;
174 spin_unlock(&fc->lock);
180 * Check whether the dentry is still valid
182 * If the entry validity timeout has expired and the dentry is
183 * positive, try to redo the lookup. If the lookup results in a
184 * different inode, then let the VFS invalidate the dentry and redo
185 * the lookup once more. If the lookup results in the same inode,
186 * then refresh the attributes, timeouts and mark the dentry valid.
188 static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
191 struct dentry *parent;
192 struct fuse_conn *fc;
193 struct fuse_inode *fi;
196 inode = d_inode_rcu(entry);
197 if (inode && is_bad_inode(inode))
199 else if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) ||
200 (flags & LOOKUP_REVAL)) {
201 struct fuse_entry_out outarg;
203 struct fuse_forget_link *forget;
206 /* For negative dentries, always do a fresh lookup */
211 if (flags & LOOKUP_RCU)
214 fc = get_fuse_conn(inode);
216 forget = fuse_alloc_forget();
221 attr_version = fuse_get_attr_version(fc);
223 parent = dget_parent(entry);
224 fuse_lookup_init(fc, &args, get_node_id(d_inode(parent)),
225 &entry->d_name, &outarg);
226 ret = fuse_simple_request(fc, &args);
228 /* Zero nodeid is same as -ENOENT */
229 if (!ret && !outarg.nodeid)
232 fi = get_fuse_inode(inode);
233 if (outarg.nodeid != get_node_id(inode)) {
234 fuse_queue_forget(fc, forget, outarg.nodeid, 1);
237 spin_lock(&fc->lock);
239 spin_unlock(&fc->lock);
244 if (ret || (outarg.attr.mode ^ inode->i_mode) & S_IFMT)
247 fuse_change_attributes(inode, &outarg.attr,
248 entry_attr_timeout(&outarg),
250 fuse_change_entry_timeout(entry, &outarg);
252 fi = get_fuse_inode(inode);
253 if (flags & LOOKUP_RCU) {
254 if (test_bit(FUSE_I_INIT_RDPLUS, &fi->state))
256 } else if (test_and_clear_bit(FUSE_I_INIT_RDPLUS, &fi->state)) {
257 parent = dget_parent(entry);
258 fuse_advise_use_readdirplus(d_inode(parent));
271 static int invalid_nodeid(u64 nodeid)
273 return !nodeid || nodeid == FUSE_ROOT_ID;
276 const struct dentry_operations fuse_dentry_operations = {
277 .d_revalidate = fuse_dentry_revalidate,
280 int fuse_valid_type(int m)
282 return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) ||
283 S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m);
286 int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name,
287 struct fuse_entry_out *outarg, struct inode **inode)
289 struct fuse_conn *fc = get_fuse_conn_super(sb);
291 struct fuse_forget_link *forget;
297 if (name->len > FUSE_NAME_MAX)
301 forget = fuse_alloc_forget();
306 attr_version = fuse_get_attr_version(fc);
308 fuse_lookup_init(fc, &args, nodeid, name, outarg);
309 err = fuse_simple_request(fc, &args);
310 /* Zero nodeid is same as -ENOENT, but with valid timeout */
311 if (err || !outarg->nodeid)
317 if (!fuse_valid_type(outarg->attr.mode))
320 *inode = fuse_iget(sb, outarg->nodeid, outarg->generation,
321 &outarg->attr, entry_attr_timeout(outarg),
325 fuse_queue_forget(fc, forget, outarg->nodeid, 1);
336 static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
340 struct fuse_entry_out outarg;
342 struct dentry *newent;
343 bool outarg_valid = true;
345 fuse_lock_inode(dir);
346 err = fuse_lookup_name(dir->i_sb, get_node_id(dir), &entry->d_name,
348 fuse_unlock_inode(dir);
349 if (err == -ENOENT) {
350 outarg_valid = false;
357 if (inode && get_node_id(inode) == FUSE_ROOT_ID)
360 newent = d_splice_alias(inode, entry);
361 err = PTR_ERR(newent);
365 entry = newent ? newent : entry;
367 fuse_change_entry_timeout(entry, &outarg);
369 fuse_invalidate_entry_cache(entry);
371 fuse_advise_use_readdirplus(dir);
381 * Atomic create+open operation
383 * If the filesystem doesn't support this, then fall back to separate
384 * 'mknod' + 'open' requests.
386 static int fuse_create_open(struct inode *dir, struct dentry *entry,
387 struct file *file, unsigned flags,
388 umode_t mode, int *opened)
392 struct fuse_conn *fc = get_fuse_conn(dir);
394 struct fuse_forget_link *forget;
395 struct fuse_create_in inarg;
396 struct fuse_open_out outopen;
397 struct fuse_entry_out outentry;
398 struct fuse_file *ff;
400 /* Userspace expects S_IFREG in create mode */
401 BUG_ON((mode & S_IFMT) != S_IFREG);
403 forget = fuse_alloc_forget();
409 ff = fuse_file_alloc(fc);
411 goto out_put_forget_req;
414 mode &= ~current_umask();
417 memset(&inarg, 0, sizeof(inarg));
418 memset(&outentry, 0, sizeof(outentry));
421 inarg.umask = current_umask();
422 args.in.h.opcode = FUSE_CREATE;
423 args.in.h.nodeid = get_node_id(dir);
425 args.in.args[0].size = sizeof(inarg);
426 args.in.args[0].value = &inarg;
427 args.in.args[1].size = entry->d_name.len + 1;
428 args.in.args[1].value = entry->d_name.name;
429 args.out.numargs = 2;
430 args.out.args[0].size = sizeof(outentry);
431 args.out.args[0].value = &outentry;
432 args.out.args[1].size = sizeof(outopen);
433 args.out.args[1].value = &outopen;
434 err = fuse_simple_request(fc, &args);
439 if (!S_ISREG(outentry.attr.mode) || invalid_nodeid(outentry.nodeid))
443 ff->nodeid = outentry.nodeid;
444 ff->open_flags = outopen.open_flags;
445 inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation,
446 &outentry.attr, entry_attr_timeout(&outentry), 0);
448 flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
449 fuse_sync_release(ff, flags);
450 fuse_queue_forget(fc, forget, outentry.nodeid, 1);
455 d_instantiate(entry, inode);
456 fuse_change_entry_timeout(entry, &outentry);
457 fuse_invalidate_attr(dir);
458 err = finish_open(file, entry, generic_file_open, opened);
460 fuse_sync_release(ff, flags);
462 file->private_data = fuse_file_get(ff);
463 fuse_finish_open(inode, file);
475 static int fuse_mknod(struct inode *, struct dentry *, umode_t, dev_t);
476 static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
477 struct file *file, unsigned flags,
478 umode_t mode, int *opened)
481 struct fuse_conn *fc = get_fuse_conn(dir);
482 struct dentry *res = NULL;
484 if (d_in_lookup(entry)) {
485 res = fuse_lookup(dir, entry, 0);
493 if (!(flags & O_CREAT) || d_really_is_positive(entry))
497 *opened |= FILE_CREATED;
502 err = fuse_create_open(dir, entry, file, flags, mode, opened);
503 if (err == -ENOSYS) {
512 err = fuse_mknod(dir, entry, mode, 0);
516 return finish_no_open(file, res);
520 * Code shared between mknod, mkdir, symlink and link
522 static int create_new_entry(struct fuse_conn *fc, struct fuse_args *args,
523 struct inode *dir, struct dentry *entry,
526 struct fuse_entry_out outarg;
529 struct fuse_forget_link *forget;
531 forget = fuse_alloc_forget();
535 memset(&outarg, 0, sizeof(outarg));
536 args->in.h.nodeid = get_node_id(dir);
537 args->out.numargs = 1;
538 args->out.args[0].size = sizeof(outarg);
539 args->out.args[0].value = &outarg;
540 err = fuse_simple_request(fc, args);
542 goto out_put_forget_req;
545 if (invalid_nodeid(outarg.nodeid))
546 goto out_put_forget_req;
548 if ((outarg.attr.mode ^ mode) & S_IFMT)
549 goto out_put_forget_req;
551 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
552 &outarg.attr, entry_attr_timeout(&outarg), 0);
554 fuse_queue_forget(fc, forget, outarg.nodeid, 1);
559 err = d_instantiate_no_diralias(entry, inode);
563 fuse_change_entry_timeout(entry, &outarg);
564 fuse_invalidate_attr(dir);
572 static int fuse_mknod(struct inode *dir, struct dentry *entry, umode_t mode,
575 struct fuse_mknod_in inarg;
576 struct fuse_conn *fc = get_fuse_conn(dir);
580 mode &= ~current_umask();
582 memset(&inarg, 0, sizeof(inarg));
584 inarg.rdev = new_encode_dev(rdev);
585 inarg.umask = current_umask();
586 args.in.h.opcode = FUSE_MKNOD;
588 args.in.args[0].size = sizeof(inarg);
589 args.in.args[0].value = &inarg;
590 args.in.args[1].size = entry->d_name.len + 1;
591 args.in.args[1].value = entry->d_name.name;
592 return create_new_entry(fc, &args, dir, entry, mode);
595 static int fuse_create(struct inode *dir, struct dentry *entry, umode_t mode,
598 return fuse_mknod(dir, entry, mode, 0);
601 static int fuse_mkdir(struct inode *dir, struct dentry *entry, umode_t mode)
603 struct fuse_mkdir_in inarg;
604 struct fuse_conn *fc = get_fuse_conn(dir);
608 mode &= ~current_umask();
610 memset(&inarg, 0, sizeof(inarg));
612 inarg.umask = current_umask();
613 args.in.h.opcode = FUSE_MKDIR;
615 args.in.args[0].size = sizeof(inarg);
616 args.in.args[0].value = &inarg;
617 args.in.args[1].size = entry->d_name.len + 1;
618 args.in.args[1].value = entry->d_name.name;
619 return create_new_entry(fc, &args, dir, entry, S_IFDIR);
622 static int fuse_symlink(struct inode *dir, struct dentry *entry,
625 struct fuse_conn *fc = get_fuse_conn(dir);
626 unsigned len = strlen(link) + 1;
629 args.in.h.opcode = FUSE_SYMLINK;
631 args.in.args[0].size = entry->d_name.len + 1;
632 args.in.args[0].value = entry->d_name.name;
633 args.in.args[1].size = len;
634 args.in.args[1].value = link;
635 return create_new_entry(fc, &args, dir, entry, S_IFLNK);
638 void fuse_update_ctime(struct inode *inode)
640 if (!IS_NOCMTIME(inode)) {
641 inode->i_ctime = current_fs_time(inode->i_sb);
642 mark_inode_dirty_sync(inode);
646 static int fuse_unlink(struct inode *dir, struct dentry *entry)
649 struct fuse_conn *fc = get_fuse_conn(dir);
652 args.in.h.opcode = FUSE_UNLINK;
653 args.in.h.nodeid = get_node_id(dir);
655 args.in.args[0].size = entry->d_name.len + 1;
656 args.in.args[0].value = entry->d_name.name;
657 err = fuse_simple_request(fc, &args);
659 struct inode *inode = d_inode(entry);
660 struct fuse_inode *fi = get_fuse_inode(inode);
662 spin_lock(&fc->lock);
663 fi->attr_version = ++fc->attr_version;
665 * If i_nlink == 0 then unlink doesn't make sense, yet this can
666 * happen if userspace filesystem is careless. It would be
667 * difficult to enforce correct nlink usage so just ignore this
670 if (inode->i_nlink > 0)
672 spin_unlock(&fc->lock);
673 fuse_invalidate_attr(inode);
674 fuse_invalidate_attr(dir);
675 fuse_invalidate_entry_cache(entry);
676 fuse_update_ctime(inode);
677 } else if (err == -EINTR)
678 fuse_invalidate_entry(entry);
682 static int fuse_rmdir(struct inode *dir, struct dentry *entry)
685 struct fuse_conn *fc = get_fuse_conn(dir);
688 args.in.h.opcode = FUSE_RMDIR;
689 args.in.h.nodeid = get_node_id(dir);
691 args.in.args[0].size = entry->d_name.len + 1;
692 args.in.args[0].value = entry->d_name.name;
693 err = fuse_simple_request(fc, &args);
695 clear_nlink(d_inode(entry));
696 fuse_invalidate_attr(dir);
697 fuse_invalidate_entry_cache(entry);
698 } else if (err == -EINTR)
699 fuse_invalidate_entry(entry);
703 static int fuse_rename_common(struct inode *olddir, struct dentry *oldent,
704 struct inode *newdir, struct dentry *newent,
705 unsigned int flags, int opcode, size_t argsize)
708 struct fuse_rename2_in inarg;
709 struct fuse_conn *fc = get_fuse_conn(olddir);
712 memset(&inarg, 0, argsize);
713 inarg.newdir = get_node_id(newdir);
715 args.in.h.opcode = opcode;
716 args.in.h.nodeid = get_node_id(olddir);
718 args.in.args[0].size = argsize;
719 args.in.args[0].value = &inarg;
720 args.in.args[1].size = oldent->d_name.len + 1;
721 args.in.args[1].value = oldent->d_name.name;
722 args.in.args[2].size = newent->d_name.len + 1;
723 args.in.args[2].value = newent->d_name.name;
724 err = fuse_simple_request(fc, &args);
727 fuse_invalidate_attr(d_inode(oldent));
728 fuse_update_ctime(d_inode(oldent));
730 if (flags & RENAME_EXCHANGE) {
731 fuse_invalidate_attr(d_inode(newent));
732 fuse_update_ctime(d_inode(newent));
735 fuse_invalidate_attr(olddir);
736 if (olddir != newdir)
737 fuse_invalidate_attr(newdir);
739 /* newent will end up negative */
740 if (!(flags & RENAME_EXCHANGE) && d_really_is_positive(newent)) {
741 fuse_invalidate_attr(d_inode(newent));
742 fuse_invalidate_entry_cache(newent);
743 fuse_update_ctime(d_inode(newent));
745 } else if (err == -EINTR) {
746 /* If request was interrupted, DEITY only knows if the
747 rename actually took place. If the invalidation
748 fails (e.g. some process has CWD under the renamed
749 directory), then there can be inconsistency between
750 the dcache and the real filesystem. Tough luck. */
751 fuse_invalidate_entry(oldent);
752 if (d_really_is_positive(newent))
753 fuse_invalidate_entry(newent);
759 static int fuse_rename2(struct inode *olddir, struct dentry *oldent,
760 struct inode *newdir, struct dentry *newent,
763 struct fuse_conn *fc = get_fuse_conn(olddir);
766 if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
770 if (fc->no_rename2 || fc->minor < 23)
773 err = fuse_rename_common(olddir, oldent, newdir, newent, flags,
775 sizeof(struct fuse_rename2_in));
776 if (err == -ENOSYS) {
781 err = fuse_rename_common(olddir, oldent, newdir, newent, 0,
783 sizeof(struct fuse_rename_in));
789 static int fuse_link(struct dentry *entry, struct inode *newdir,
790 struct dentry *newent)
793 struct fuse_link_in inarg;
794 struct inode *inode = d_inode(entry);
795 struct fuse_conn *fc = get_fuse_conn(inode);
798 memset(&inarg, 0, sizeof(inarg));
799 inarg.oldnodeid = get_node_id(inode);
800 args.in.h.opcode = FUSE_LINK;
802 args.in.args[0].size = sizeof(inarg);
803 args.in.args[0].value = &inarg;
804 args.in.args[1].size = newent->d_name.len + 1;
805 args.in.args[1].value = newent->d_name.name;
806 err = create_new_entry(fc, &args, newdir, newent, inode->i_mode);
807 /* Contrary to "normal" filesystems it can happen that link
808 makes two "logical" inodes point to the same "physical"
809 inode. We invalidate the attributes of the old one, so it
810 will reflect changes in the backing inode (link count,
814 struct fuse_inode *fi = get_fuse_inode(inode);
816 spin_lock(&fc->lock);
817 fi->attr_version = ++fc->attr_version;
819 spin_unlock(&fc->lock);
820 fuse_invalidate_attr(inode);
821 fuse_update_ctime(inode);
822 } else if (err == -EINTR) {
823 fuse_invalidate_attr(inode);
828 static void fuse_fillattr(struct inode *inode, struct fuse_attr *attr,
831 unsigned int blkbits;
832 struct fuse_conn *fc = get_fuse_conn(inode);
834 /* see the comment in fuse_change_attributes() */
835 if (fc->writeback_cache && S_ISREG(inode->i_mode)) {
836 attr->size = i_size_read(inode);
837 attr->mtime = inode->i_mtime.tv_sec;
838 attr->mtimensec = inode->i_mtime.tv_nsec;
839 attr->ctime = inode->i_ctime.tv_sec;
840 attr->ctimensec = inode->i_ctime.tv_nsec;
843 stat->dev = inode->i_sb->s_dev;
844 stat->ino = attr->ino;
845 stat->mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
846 stat->nlink = attr->nlink;
847 stat->uid = make_kuid(&init_user_ns, attr->uid);
848 stat->gid = make_kgid(&init_user_ns, attr->gid);
849 stat->rdev = inode->i_rdev;
850 stat->atime.tv_sec = attr->atime;
851 stat->atime.tv_nsec = attr->atimensec;
852 stat->mtime.tv_sec = attr->mtime;
853 stat->mtime.tv_nsec = attr->mtimensec;
854 stat->ctime.tv_sec = attr->ctime;
855 stat->ctime.tv_nsec = attr->ctimensec;
856 stat->size = attr->size;
857 stat->blocks = attr->blocks;
859 if (attr->blksize != 0)
860 blkbits = ilog2(attr->blksize);
862 blkbits = inode->i_sb->s_blocksize_bits;
864 stat->blksize = 1 << blkbits;
867 static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
871 struct fuse_getattr_in inarg;
872 struct fuse_attr_out outarg;
873 struct fuse_conn *fc = get_fuse_conn(inode);
877 attr_version = fuse_get_attr_version(fc);
879 memset(&inarg, 0, sizeof(inarg));
880 memset(&outarg, 0, sizeof(outarg));
881 /* Directories have separate file-handle space */
882 if (file && S_ISREG(inode->i_mode)) {
883 struct fuse_file *ff = file->private_data;
885 inarg.getattr_flags |= FUSE_GETATTR_FH;
888 args.in.h.opcode = FUSE_GETATTR;
889 args.in.h.nodeid = get_node_id(inode);
891 args.in.args[0].size = sizeof(inarg);
892 args.in.args[0].value = &inarg;
893 args.out.numargs = 1;
894 args.out.args[0].size = sizeof(outarg);
895 args.out.args[0].value = &outarg;
896 err = fuse_simple_request(fc, &args);
898 if ((inode->i_mode ^ outarg.attr.mode) & S_IFMT) {
899 make_bad_inode(inode);
902 fuse_change_attributes(inode, &outarg.attr,
903 attr_timeout(&outarg),
906 fuse_fillattr(inode, &outarg.attr, stat);
912 int fuse_update_attributes(struct inode *inode, struct kstat *stat,
913 struct file *file, bool *refreshed)
915 struct fuse_inode *fi = get_fuse_inode(inode);
919 if (time_before64(fi->i_time, get_jiffies_64())) {
921 err = fuse_do_getattr(inode, stat, file);
926 generic_fillattr(inode, stat);
927 stat->mode = fi->orig_i_mode;
928 stat->ino = fi->orig_ino;
932 if (refreshed != NULL)
938 int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
939 u64 child_nodeid, struct qstr *name)
942 struct inode *parent;
944 struct dentry *entry;
946 parent = ilookup5(sb, parent_nodeid, fuse_inode_eq, &parent_nodeid);
951 if (!S_ISDIR(parent->i_mode))
955 dir = d_find_alias(parent);
959 name->hash = full_name_hash(dir, name->name, name->len);
960 entry = d_lookup(dir, name);
965 fuse_invalidate_attr(parent);
966 fuse_invalidate_entry(entry);
968 if (child_nodeid != 0 && d_really_is_positive(entry)) {
969 inode_lock(d_inode(entry));
970 if (get_node_id(d_inode(entry)) != child_nodeid) {
974 if (d_mountpoint(entry)) {
978 if (d_is_dir(entry)) {
979 shrink_dcache_parent(entry);
980 if (!simple_empty(entry)) {
984 d_inode(entry)->i_flags |= S_DEAD;
987 clear_nlink(d_inode(entry));
990 inode_unlock(d_inode(entry));
999 inode_unlock(parent);
1005 * Calling into a user-controlled filesystem gives the filesystem
1006 * daemon ptrace-like capabilities over the current process. This
1007 * means, that the filesystem daemon is able to record the exact
1008 * filesystem operations performed, and can also control the behavior
1009 * of the requester process in otherwise impossible ways. For example
1010 * it can delay the operation for arbitrary length of time allowing
1011 * DoS against the requester.
1013 * For this reason only those processes can call into the filesystem,
1014 * for which the owner of the mount has ptrace privilege. This
1015 * excludes processes started by other users, suid or sgid processes.
1017 int fuse_allow_current_process(struct fuse_conn *fc)
1019 const struct cred *cred;
1021 if (fc->flags & FUSE_ALLOW_OTHER)
1024 cred = current_cred();
1025 if (uid_eq(cred->euid, fc->user_id) &&
1026 uid_eq(cred->suid, fc->user_id) &&
1027 uid_eq(cred->uid, fc->user_id) &&
1028 gid_eq(cred->egid, fc->group_id) &&
1029 gid_eq(cred->sgid, fc->group_id) &&
1030 gid_eq(cred->gid, fc->group_id))
1036 static int fuse_access(struct inode *inode, int mask)
1038 struct fuse_conn *fc = get_fuse_conn(inode);
1040 struct fuse_access_in inarg;
1043 BUG_ON(mask & MAY_NOT_BLOCK);
1048 memset(&inarg, 0, sizeof(inarg));
1049 inarg.mask = mask & (MAY_READ | MAY_WRITE | MAY_EXEC);
1050 args.in.h.opcode = FUSE_ACCESS;
1051 args.in.h.nodeid = get_node_id(inode);
1052 args.in.numargs = 1;
1053 args.in.args[0].size = sizeof(inarg);
1054 args.in.args[0].value = &inarg;
1055 err = fuse_simple_request(fc, &args);
1056 if (err == -ENOSYS) {
1063 static int fuse_perm_getattr(struct inode *inode, int mask)
1065 if (mask & MAY_NOT_BLOCK)
1068 return fuse_do_getattr(inode, NULL, NULL);
1072 * Check permission. The two basic access models of FUSE are:
1074 * 1) Local access checking ('default_permissions' mount option) based
1075 * on file mode. This is the plain old disk filesystem permission
1078 * 2) "Remote" access checking, where server is responsible for
1079 * checking permission in each inode operation. An exception to this
1080 * is if ->permission() was invoked from sys_access() in which case an
1081 * access request is sent. Execute permission is still checked
1082 * locally based on file mode.
1084 static int fuse_permission(struct inode *inode, int mask)
1086 struct fuse_conn *fc = get_fuse_conn(inode);
1087 bool refreshed = false;
1090 if (!fuse_allow_current_process(fc))
1094 * If attributes are needed, refresh them before proceeding
1096 if ((fc->flags & FUSE_DEFAULT_PERMISSIONS) ||
1097 ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) {
1098 struct fuse_inode *fi = get_fuse_inode(inode);
1100 if (time_before64(fi->i_time, get_jiffies_64())) {
1103 err = fuse_perm_getattr(inode, mask);
1109 if (fc->flags & FUSE_DEFAULT_PERMISSIONS) {
1110 err = generic_permission(inode, mask);
1112 /* If permission is denied, try to refresh file
1113 attributes. This is also needed, because the root
1114 node will at first have no permissions */
1115 if (err == -EACCES && !refreshed) {
1116 err = fuse_perm_getattr(inode, mask);
1118 err = generic_permission(inode, mask);
1121 /* Note: the opposite of the above test does not
1122 exist. So if permissions are revoked this won't be
1123 noticed immediately, only after the attribute
1124 timeout has expired */
1125 } else if (mask & (MAY_ACCESS | MAY_CHDIR)) {
1126 err = fuse_access(inode, mask);
1127 } else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) {
1128 if (!(inode->i_mode & S_IXUGO)) {
1132 err = fuse_perm_getattr(inode, mask);
1133 if (!err && !(inode->i_mode & S_IXUGO))
1140 static int parse_dirfile(char *buf, size_t nbytes, struct file *file,
1141 struct dir_context *ctx)
1143 while (nbytes >= FUSE_NAME_OFFSET) {
1144 struct fuse_dirent *dirent = (struct fuse_dirent *) buf;
1145 size_t reclen = FUSE_DIRENT_SIZE(dirent);
1146 if (!dirent->namelen || dirent->namelen > FUSE_NAME_MAX)
1148 if (reclen > nbytes)
1150 if (memchr(dirent->name, '/', dirent->namelen) != NULL)
1153 if (!dir_emit(ctx, dirent->name, dirent->namelen,
1154 dirent->ino, dirent->type))
1159 ctx->pos = dirent->off;
1165 static int fuse_direntplus_link(struct file *file,
1166 struct fuse_direntplus *direntplus,
1169 struct fuse_entry_out *o = &direntplus->entry_out;
1170 struct fuse_dirent *dirent = &direntplus->dirent;
1171 struct dentry *parent = file->f_path.dentry;
1172 struct qstr name = QSTR_INIT(dirent->name, dirent->namelen);
1173 struct dentry *dentry;
1174 struct dentry *alias;
1175 struct inode *dir = d_inode(parent);
1176 struct fuse_conn *fc;
1177 struct inode *inode;
1178 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
1182 * Unlike in the case of fuse_lookup, zero nodeid does not mean
1183 * ENOENT. Instead, it only means the userspace filesystem did
1184 * not want to return attributes/handle for this entry.
1191 if (name.name[0] == '.') {
1193 * We could potentially refresh the attributes of the directory
1198 if (name.name[1] == '.' && name.len == 2)
1202 if (invalid_nodeid(o->nodeid))
1204 if (!fuse_valid_type(o->attr.mode))
1207 fc = get_fuse_conn(dir);
1209 name.hash = full_name_hash(parent, name.name, name.len);
1210 dentry = d_lookup(parent, &name);
1213 dentry = d_alloc_parallel(parent, &name, &wq);
1215 return PTR_ERR(dentry);
1217 if (!d_in_lookup(dentry)) {
1218 struct fuse_inode *fi;
1219 inode = d_inode(dentry);
1221 get_node_id(inode) != o->nodeid ||
1222 ((o->attr.mode ^ inode->i_mode) & S_IFMT)) {
1223 d_invalidate(dentry);
1227 if (is_bad_inode(inode)) {
1232 fi = get_fuse_inode(inode);
1233 spin_lock(&fc->lock);
1235 spin_unlock(&fc->lock);
1237 fuse_change_attributes(inode, &o->attr,
1238 entry_attr_timeout(o),
1241 * The other branch comes via fuse_iget()
1242 * which bumps nlookup inside
1245 inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
1246 &o->attr, entry_attr_timeout(o),
1249 inode = ERR_PTR(-ENOMEM);
1251 alias = d_splice_alias(inode, dentry);
1252 d_lookup_done(dentry);
1258 return PTR_ERR(dentry);
1260 if (fc->readdirplus_auto)
1261 set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state);
1262 fuse_change_entry_timeout(dentry, o);
1268 static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file,
1269 struct dir_context *ctx, u64 attr_version)
1271 struct fuse_direntplus *direntplus;
1272 struct fuse_dirent *dirent;
1277 while (nbytes >= FUSE_NAME_OFFSET_DIRENTPLUS) {
1278 direntplus = (struct fuse_direntplus *) buf;
1279 dirent = &direntplus->dirent;
1280 reclen = FUSE_DIRENTPLUS_SIZE(direntplus);
1282 if (!dirent->namelen || dirent->namelen > FUSE_NAME_MAX)
1284 if (reclen > nbytes)
1286 if (memchr(dirent->name, '/', dirent->namelen) != NULL)
1290 /* We fill entries into dstbuf only as much as
1291 it can hold. But we still continue iterating
1292 over remaining entries to link them. If not,
1293 we need to send a FORGET for each of those
1294 which we did not link.
1296 over = !dir_emit(ctx, dirent->name, dirent->namelen,
1297 dirent->ino, dirent->type);
1298 ctx->pos = dirent->off;
1304 ret = fuse_direntplus_link(file, direntplus, attr_version);
1306 fuse_force_forget(file, direntplus->entry_out.nodeid);
1312 static int fuse_readdir(struct file *file, struct dir_context *ctx)
1317 struct inode *inode = file_inode(file);
1318 struct fuse_conn *fc = get_fuse_conn(inode);
1319 struct fuse_req *req;
1320 u64 attr_version = 0;
1322 if (is_bad_inode(inode))
1325 req = fuse_get_req(fc, 1);
1327 return PTR_ERR(req);
1329 page = alloc_page(GFP_KERNEL);
1331 fuse_put_request(fc, req);
1335 plus = fuse_use_readdirplus(inode, ctx);
1336 req->out.argpages = 1;
1338 req->pages[0] = page;
1339 req->page_descs[0].length = PAGE_SIZE;
1341 attr_version = fuse_get_attr_version(fc);
1342 fuse_read_fill(req, file, ctx->pos, PAGE_SIZE,
1345 fuse_read_fill(req, file, ctx->pos, PAGE_SIZE,
1348 fuse_lock_inode(inode);
1349 fuse_request_send(fc, req);
1350 fuse_unlock_inode(inode);
1351 nbytes = req->out.args[0].size;
1352 err = req->out.h.error;
1353 fuse_put_request(fc, req);
1356 err = parse_dirplusfile(page_address(page), nbytes,
1360 err = parse_dirfile(page_address(page), nbytes, file,
1366 fuse_invalidate_atime(inode);
1370 static const char *fuse_get_link(struct dentry *dentry,
1371 struct inode *inode,
1372 struct delayed_call *done)
1374 struct fuse_conn *fc = get_fuse_conn(inode);
1380 return ERR_PTR(-ECHILD);
1382 link = kmalloc(PAGE_SIZE, GFP_KERNEL);
1384 return ERR_PTR(-ENOMEM);
1386 args.in.h.opcode = FUSE_READLINK;
1387 args.in.h.nodeid = get_node_id(inode);
1388 args.out.argvar = 1;
1389 args.out.numargs = 1;
1390 args.out.args[0].size = PAGE_SIZE - 1;
1391 args.out.args[0].value = link;
1392 ret = fuse_simple_request(fc, &args);
1395 link = ERR_PTR(ret);
1398 set_delayed_call(done, kfree_link, link);
1400 fuse_invalidate_atime(inode);
1404 static int fuse_dir_open(struct inode *inode, struct file *file)
1406 return fuse_open_common(inode, file, true);
1409 static int fuse_dir_release(struct inode *inode, struct file *file)
1411 fuse_release_common(file, FUSE_RELEASEDIR);
1416 static int fuse_dir_fsync(struct file *file, loff_t start, loff_t end,
1419 return fuse_fsync_common(file, start, end, datasync, 1);
1422 static long fuse_dir_ioctl(struct file *file, unsigned int cmd,
1425 struct fuse_conn *fc = get_fuse_conn(file->f_mapping->host);
1427 /* FUSE_IOCTL_DIR only supported for API version >= 7.18 */
1431 return fuse_ioctl_common(file, cmd, arg, FUSE_IOCTL_DIR);
1434 static long fuse_dir_compat_ioctl(struct file *file, unsigned int cmd,
1437 struct fuse_conn *fc = get_fuse_conn(file->f_mapping->host);
1442 return fuse_ioctl_common(file, cmd, arg,
1443 FUSE_IOCTL_COMPAT | FUSE_IOCTL_DIR);
1446 static bool update_mtime(unsigned ivalid, bool trust_local_mtime)
1448 /* Always update if mtime is explicitly set */
1449 if (ivalid & ATTR_MTIME_SET)
1452 /* Or if kernel i_mtime is the official one */
1453 if (trust_local_mtime)
1456 /* If it's an open(O_TRUNC) or an ftruncate(), don't update */
1457 if ((ivalid & ATTR_SIZE) && (ivalid & (ATTR_OPEN | ATTR_FILE)))
1460 /* In all other cases update */
1464 static void iattr_to_fattr(struct iattr *iattr, struct fuse_setattr_in *arg,
1465 bool trust_local_cmtime)
1467 unsigned ivalid = iattr->ia_valid;
1469 if (ivalid & ATTR_MODE)
1470 arg->valid |= FATTR_MODE, arg->mode = iattr->ia_mode;
1471 if (ivalid & ATTR_UID)
1472 arg->valid |= FATTR_UID, arg->uid = from_kuid(&init_user_ns, iattr->ia_uid);
1473 if (ivalid & ATTR_GID)
1474 arg->valid |= FATTR_GID, arg->gid = from_kgid(&init_user_ns, iattr->ia_gid);
1475 if (ivalid & ATTR_SIZE)
1476 arg->valid |= FATTR_SIZE, arg->size = iattr->ia_size;
1477 if (ivalid & ATTR_ATIME) {
1478 arg->valid |= FATTR_ATIME;
1479 arg->atime = iattr->ia_atime.tv_sec;
1480 arg->atimensec = iattr->ia_atime.tv_nsec;
1481 if (!(ivalid & ATTR_ATIME_SET))
1482 arg->valid |= FATTR_ATIME_NOW;
1484 if ((ivalid & ATTR_MTIME) && update_mtime(ivalid, trust_local_cmtime)) {
1485 arg->valid |= FATTR_MTIME;
1486 arg->mtime = iattr->ia_mtime.tv_sec;
1487 arg->mtimensec = iattr->ia_mtime.tv_nsec;
1488 if (!(ivalid & ATTR_MTIME_SET) && !trust_local_cmtime)
1489 arg->valid |= FATTR_MTIME_NOW;
1491 if ((ivalid & ATTR_CTIME) && trust_local_cmtime) {
1492 arg->valid |= FATTR_CTIME;
1493 arg->ctime = iattr->ia_ctime.tv_sec;
1494 arg->ctimensec = iattr->ia_ctime.tv_nsec;
1499 * Prevent concurrent writepages on inode
1501 * This is done by adding a negative bias to the inode write counter
1502 * and waiting for all pending writes to finish.
1504 void fuse_set_nowrite(struct inode *inode)
1506 struct fuse_conn *fc = get_fuse_conn(inode);
1507 struct fuse_inode *fi = get_fuse_inode(inode);
1509 BUG_ON(!inode_is_locked(inode));
1511 spin_lock(&fc->lock);
1512 BUG_ON(fi->writectr < 0);
1513 fi->writectr += FUSE_NOWRITE;
1514 spin_unlock(&fc->lock);
1515 wait_event(fi->page_waitq, fi->writectr == FUSE_NOWRITE);
1519 * Allow writepages on inode
1521 * Remove the bias from the writecounter and send any queued
1524 static void __fuse_release_nowrite(struct inode *inode)
1526 struct fuse_inode *fi = get_fuse_inode(inode);
1528 BUG_ON(fi->writectr != FUSE_NOWRITE);
1530 fuse_flush_writepages(inode);
1533 void fuse_release_nowrite(struct inode *inode)
1535 struct fuse_conn *fc = get_fuse_conn(inode);
1537 spin_lock(&fc->lock);
1538 __fuse_release_nowrite(inode);
1539 spin_unlock(&fc->lock);
1542 static void fuse_setattr_fill(struct fuse_conn *fc, struct fuse_args *args,
1543 struct inode *inode,
1544 struct fuse_setattr_in *inarg_p,
1545 struct fuse_attr_out *outarg_p)
1547 args->in.h.opcode = FUSE_SETATTR;
1548 args->in.h.nodeid = get_node_id(inode);
1549 args->in.numargs = 1;
1550 args->in.args[0].size = sizeof(*inarg_p);
1551 args->in.args[0].value = inarg_p;
1552 args->out.numargs = 1;
1553 args->out.args[0].size = sizeof(*outarg_p);
1554 args->out.args[0].value = outarg_p;
1558 * Flush inode->i_mtime to the server
1560 int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
1562 struct fuse_conn *fc = get_fuse_conn(inode);
1564 struct fuse_setattr_in inarg;
1565 struct fuse_attr_out outarg;
1567 memset(&inarg, 0, sizeof(inarg));
1568 memset(&outarg, 0, sizeof(outarg));
1570 inarg.valid = FATTR_MTIME;
1571 inarg.mtime = inode->i_mtime.tv_sec;
1572 inarg.mtimensec = inode->i_mtime.tv_nsec;
1573 if (fc->minor >= 23) {
1574 inarg.valid |= FATTR_CTIME;
1575 inarg.ctime = inode->i_ctime.tv_sec;
1576 inarg.ctimensec = inode->i_ctime.tv_nsec;
1579 inarg.valid |= FATTR_FH;
1582 fuse_setattr_fill(fc, &args, inode, &inarg, &outarg);
1584 return fuse_simple_request(fc, &args);
1588 * Set attributes, and at the same time refresh them.
1590 * Truncation is slightly complicated, because the 'truncate' request
1591 * may fail, in which case we don't want to touch the mapping.
1592 * vmtruncate() doesn't allow for this case, so do the rlimit checking
1593 * and the actual truncation by hand.
1595 int fuse_do_setattr(struct inode *inode, struct iattr *attr,
1598 struct fuse_conn *fc = get_fuse_conn(inode);
1599 struct fuse_inode *fi = get_fuse_inode(inode);
1601 struct fuse_setattr_in inarg;
1602 struct fuse_attr_out outarg;
1603 bool is_truncate = false;
1604 bool is_wb = fc->writeback_cache;
1607 bool trust_local_cmtime = is_wb && S_ISREG(inode->i_mode);
1609 if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS))
1610 attr->ia_valid |= ATTR_FORCE;
1612 err = inode_change_ok(inode, attr);
1616 if (attr->ia_valid & ATTR_OPEN) {
1617 if (fc->atomic_o_trunc)
1622 if (attr->ia_valid & ATTR_SIZE)
1626 fuse_set_nowrite(inode);
1627 set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
1628 if (trust_local_cmtime && attr->ia_size != inode->i_size)
1629 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
1632 memset(&inarg, 0, sizeof(inarg));
1633 memset(&outarg, 0, sizeof(outarg));
1634 iattr_to_fattr(attr, &inarg, trust_local_cmtime);
1636 struct fuse_file *ff = file->private_data;
1637 inarg.valid |= FATTR_FH;
1640 if (attr->ia_valid & ATTR_SIZE) {
1641 /* For mandatory locking in truncate */
1642 inarg.valid |= FATTR_LOCKOWNER;
1643 inarg.lock_owner = fuse_lock_owner_id(fc, current->files);
1645 fuse_setattr_fill(fc, &args, inode, &inarg, &outarg);
1646 err = fuse_simple_request(fc, &args);
1649 fuse_invalidate_attr(inode);
1653 if ((inode->i_mode ^ outarg.attr.mode) & S_IFMT) {
1654 make_bad_inode(inode);
1659 spin_lock(&fc->lock);
1660 /* the kernel maintains i_mtime locally */
1661 if (trust_local_cmtime) {
1662 if (attr->ia_valid & ATTR_MTIME)
1663 inode->i_mtime = attr->ia_mtime;
1664 if (attr->ia_valid & ATTR_CTIME)
1665 inode->i_ctime = attr->ia_ctime;
1666 /* FIXME: clear I_DIRTY_SYNC? */
1669 fuse_change_attributes_common(inode, &outarg.attr,
1670 attr_timeout(&outarg));
1671 oldsize = inode->i_size;
1672 /* see the comment in fuse_change_attributes() */
1673 if (!is_wb || is_truncate || !S_ISREG(inode->i_mode))
1674 i_size_write(inode, outarg.attr.size);
1677 /* NOTE: this may release/reacquire fc->lock */
1678 __fuse_release_nowrite(inode);
1680 spin_unlock(&fc->lock);
1683 * Only call invalidate_inode_pages2() after removing
1684 * FUSE_NOWRITE, otherwise fuse_launder_page() would deadlock.
1686 if ((is_truncate || !is_wb) &&
1687 S_ISREG(inode->i_mode) && oldsize != outarg.attr.size) {
1688 truncate_pagecache(inode, outarg.attr.size);
1689 invalidate_inode_pages2(inode->i_mapping);
1692 clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
1697 fuse_release_nowrite(inode);
1699 clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
1703 static int fuse_setattr(struct dentry *entry, struct iattr *attr)
1705 struct inode *inode = d_inode(entry);
1707 if (!fuse_allow_current_process(get_fuse_conn(inode)))
1710 if (attr->ia_valid & ATTR_FILE)
1711 return fuse_do_setattr(inode, attr, attr->ia_file);
1713 return fuse_do_setattr(inode, attr, NULL);
1716 static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
1719 struct inode *inode = d_inode(entry);
1720 struct fuse_conn *fc = get_fuse_conn(inode);
1722 if (!fuse_allow_current_process(fc))
1725 return fuse_update_attributes(inode, stat, NULL, NULL);
1728 static const struct inode_operations fuse_dir_inode_operations = {
1729 .lookup = fuse_lookup,
1730 .mkdir = fuse_mkdir,
1731 .symlink = fuse_symlink,
1732 .unlink = fuse_unlink,
1733 .rmdir = fuse_rmdir,
1734 .rename2 = fuse_rename2,
1736 .setattr = fuse_setattr,
1737 .create = fuse_create,
1738 .atomic_open = fuse_atomic_open,
1739 .mknod = fuse_mknod,
1740 .permission = fuse_permission,
1741 .getattr = fuse_getattr,
1742 .setxattr = generic_setxattr,
1743 .getxattr = generic_getxattr,
1744 .listxattr = fuse_listxattr,
1745 .removexattr = generic_removexattr,
1748 static const struct file_operations fuse_dir_operations = {
1749 .llseek = generic_file_llseek,
1750 .read = generic_read_dir,
1751 .iterate_shared = fuse_readdir,
1752 .open = fuse_dir_open,
1753 .release = fuse_dir_release,
1754 .fsync = fuse_dir_fsync,
1755 .unlocked_ioctl = fuse_dir_ioctl,
1756 .compat_ioctl = fuse_dir_compat_ioctl,
1759 static const struct inode_operations fuse_common_inode_operations = {
1760 .setattr = fuse_setattr,
1761 .permission = fuse_permission,
1762 .getattr = fuse_getattr,
1763 .setxattr = generic_setxattr,
1764 .getxattr = generic_getxattr,
1765 .listxattr = fuse_listxattr,
1766 .removexattr = generic_removexattr,
1769 static const struct inode_operations fuse_symlink_inode_operations = {
1770 .setattr = fuse_setattr,
1771 .get_link = fuse_get_link,
1772 .readlink = generic_readlink,
1773 .getattr = fuse_getattr,
1774 .setxattr = generic_setxattr,
1775 .getxattr = generic_getxattr,
1776 .listxattr = fuse_listxattr,
1777 .removexattr = generic_removexattr,
1780 void fuse_init_common(struct inode *inode)
1782 inode->i_op = &fuse_common_inode_operations;
1785 void fuse_init_dir(struct inode *inode)
1787 inode->i_op = &fuse_dir_inode_operations;
1788 inode->i_fop = &fuse_dir_operations;
1791 void fuse_init_symlink(struct inode *inode)
1793 inode->i_op = &fuse_symlink_inode_operations;