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/gfp.h>
14 #include <linux/sched.h>
15 #include <linux/namei.h>
17 #if BITS_PER_LONG >= 64
18 static inline void fuse_dentry_settime(struct dentry
*entry
, u64 time
)
23 static inline u64
fuse_dentry_time(struct dentry
*entry
)
29 * On 32 bit archs store the high 32 bits of time in d_fsdata
31 static void fuse_dentry_settime(struct dentry
*entry
, u64 time
)
34 entry
->d_fsdata
= (void *) (unsigned long) (time
>> 32);
37 static u64
fuse_dentry_time(struct dentry
*entry
)
39 return (u64
) entry
->d_time
+
40 ((u64
) (unsigned long) entry
->d_fsdata
<< 32);
45 * FUSE caches dentries and attributes with separate timeout. The
46 * time in jiffies until the dentry/attributes are valid is stored in
47 * dentry->d_time and fuse_inode->i_time respectively.
51 * Calculate the time in jiffies until a dentry/attributes are valid
53 static u64
time_to_jiffies(unsigned long sec
, unsigned long nsec
)
56 struct timespec ts
= {sec
, nsec
};
57 return get_jiffies_64() + timespec_to_jiffies(&ts
);
63 * Set dentry and possibly attribute timeouts from the lookup/mk*
66 static void fuse_change_entry_timeout(struct dentry
*entry
,
67 struct fuse_entry_out
*o
)
69 fuse_dentry_settime(entry
,
70 time_to_jiffies(o
->entry_valid
, o
->entry_valid_nsec
));
73 static u64
attr_timeout(struct fuse_attr_out
*o
)
75 return time_to_jiffies(o
->attr_valid
, o
->attr_valid_nsec
);
78 static u64
entry_attr_timeout(struct fuse_entry_out
*o
)
80 return time_to_jiffies(o
->attr_valid
, o
->attr_valid_nsec
);
84 * Mark the attributes as stale, so that at the next call to
85 * ->getattr() they will be fetched from userspace
87 void fuse_invalidate_attr(struct inode
*inode
)
89 get_fuse_inode(inode
)->i_time
= 0;
93 * Just mark the entry as stale, so that a next attempt to look it up
94 * will result in a new lookup call to userspace
96 * This is called when a dentry is about to become negative and the
97 * timeout is unknown (unlink, rmdir, rename and in some cases
100 void fuse_invalidate_entry_cache(struct dentry
*entry
)
102 fuse_dentry_settime(entry
, 0);
106 * Same as fuse_invalidate_entry_cache(), but also try to remove the
107 * dentry from the hash
109 static void fuse_invalidate_entry(struct dentry
*entry
)
112 fuse_invalidate_entry_cache(entry
);
115 static void fuse_lookup_init(struct fuse_conn
*fc
, struct fuse_req
*req
,
116 u64 nodeid
, struct qstr
*name
,
117 struct fuse_entry_out
*outarg
)
119 memset(outarg
, 0, sizeof(struct fuse_entry_out
));
120 req
->in
.h
.opcode
= FUSE_LOOKUP
;
121 req
->in
.h
.nodeid
= nodeid
;
123 req
->in
.args
[0].size
= name
->len
+ 1;
124 req
->in
.args
[0].value
= name
->name
;
125 req
->out
.numargs
= 1;
127 req
->out
.args
[0].size
= FUSE_COMPAT_ENTRY_OUT_SIZE
;
129 req
->out
.args
[0].size
= sizeof(struct fuse_entry_out
);
130 req
->out
.args
[0].value
= outarg
;
133 u64
fuse_get_attr_version(struct fuse_conn
*fc
)
138 * The spin lock isn't actually needed on 64bit archs, but we
139 * don't yet care too much about such optimizations.
141 spin_lock(&fc
->lock
);
142 curr_version
= fc
->attr_version
;
143 spin_unlock(&fc
->lock
);
149 * Check whether the dentry is still valid
151 * If the entry validity timeout has expired and the dentry is
152 * positive, try to redo the lookup. If the lookup results in a
153 * different inode, then let the VFS invalidate the dentry and redo
154 * the lookup once more. If the lookup results in the same inode,
155 * then refresh the attributes, timeouts and mark the dentry valid.
157 static int fuse_dentry_revalidate(struct dentry
*entry
, struct nameidata
*nd
)
159 struct inode
*inode
= entry
->d_inode
;
161 if (inode
&& is_bad_inode(inode
))
163 else if (fuse_dentry_time(entry
) < get_jiffies_64()) {
165 struct fuse_entry_out outarg
;
166 struct fuse_conn
*fc
;
167 struct fuse_req
*req
;
168 struct fuse_req
*forget_req
;
169 struct dentry
*parent
;
172 /* For negative dentries, always do a fresh lookup */
176 fc
= get_fuse_conn(inode
);
177 req
= fuse_get_req(fc
);
181 forget_req
= fuse_get_req(fc
);
182 if (IS_ERR(forget_req
)) {
183 fuse_put_request(fc
, req
);
187 attr_version
= fuse_get_attr_version(fc
);
189 parent
= dget_parent(entry
);
190 fuse_lookup_init(fc
, req
, get_node_id(parent
->d_inode
),
191 &entry
->d_name
, &outarg
);
192 fuse_request_send(fc
, req
);
194 err
= req
->out
.h
.error
;
195 fuse_put_request(fc
, req
);
196 /* Zero nodeid is same as -ENOENT */
197 if (!err
&& !outarg
.nodeid
)
200 struct fuse_inode
*fi
= get_fuse_inode(inode
);
201 if (outarg
.nodeid
!= get_node_id(inode
)) {
202 fuse_send_forget(fc
, forget_req
,
206 spin_lock(&fc
->lock
);
208 spin_unlock(&fc
->lock
);
210 fuse_put_request(fc
, forget_req
);
211 if (err
|| (outarg
.attr
.mode
^ inode
->i_mode
) & S_IFMT
)
214 fuse_change_attributes(inode
, &outarg
.attr
,
215 entry_attr_timeout(&outarg
),
217 fuse_change_entry_timeout(entry
, &outarg
);
222 static int invalid_nodeid(u64 nodeid
)
224 return !nodeid
|| nodeid
== FUSE_ROOT_ID
;
227 const struct dentry_operations fuse_dentry_operations
= {
228 .d_revalidate
= fuse_dentry_revalidate
,
231 int fuse_valid_type(int m
)
233 return S_ISREG(m
) || S_ISDIR(m
) || S_ISLNK(m
) || S_ISCHR(m
) ||
234 S_ISBLK(m
) || S_ISFIFO(m
) || S_ISSOCK(m
);
238 * Add a directory inode to a dentry, ensuring that no other dentry
239 * refers to this inode. Called with fc->inst_mutex.
241 static struct dentry
*fuse_d_add_directory(struct dentry
*entry
,
244 struct dentry
*alias
= d_find_alias(inode
);
245 if (alias
&& !(alias
->d_flags
& DCACHE_DISCONNECTED
)) {
246 /* This tries to shrink the subtree below alias */
247 fuse_invalidate_entry(alias
);
249 if (!list_empty(&inode
->i_dentry
))
250 return ERR_PTR(-EBUSY
);
254 return d_splice_alias(inode
, entry
);
257 int fuse_lookup_name(struct super_block
*sb
, u64 nodeid
, struct qstr
*name
,
258 struct fuse_entry_out
*outarg
, struct inode
**inode
)
260 struct fuse_conn
*fc
= get_fuse_conn_super(sb
);
261 struct fuse_req
*req
;
262 struct fuse_req
*forget_req
;
268 if (name
->len
> FUSE_NAME_MAX
)
271 req
= fuse_get_req(fc
);
276 forget_req
= fuse_get_req(fc
);
277 err
= PTR_ERR(forget_req
);
278 if (IS_ERR(forget_req
)) {
279 fuse_put_request(fc
, req
);
283 attr_version
= fuse_get_attr_version(fc
);
285 fuse_lookup_init(fc
, req
, nodeid
, name
, outarg
);
286 fuse_request_send(fc
, req
);
287 err
= req
->out
.h
.error
;
288 fuse_put_request(fc
, req
);
289 /* Zero nodeid is same as -ENOENT, but with valid timeout */
290 if (err
|| !outarg
->nodeid
)
296 if (!fuse_valid_type(outarg
->attr
.mode
))
299 *inode
= fuse_iget(sb
, outarg
->nodeid
, outarg
->generation
,
300 &outarg
->attr
, entry_attr_timeout(outarg
),
304 fuse_send_forget(fc
, forget_req
, outarg
->nodeid
, 1);
310 fuse_put_request(fc
, forget_req
);
315 static struct dentry
*fuse_lookup(struct inode
*dir
, struct dentry
*entry
,
316 struct nameidata
*nd
)
319 struct fuse_entry_out outarg
;
321 struct dentry
*newent
;
322 struct fuse_conn
*fc
= get_fuse_conn(dir
);
323 bool outarg_valid
= true;
325 err
= fuse_lookup_name(dir
->i_sb
, get_node_id(dir
), &entry
->d_name
,
327 if (err
== -ENOENT
) {
328 outarg_valid
= false;
335 if (inode
&& get_node_id(inode
) == FUSE_ROOT_ID
)
338 if (inode
&& S_ISDIR(inode
->i_mode
)) {
339 mutex_lock(&fc
->inst_mutex
);
340 newent
= fuse_d_add_directory(entry
, inode
);
341 mutex_unlock(&fc
->inst_mutex
);
342 err
= PTR_ERR(newent
);
346 newent
= d_splice_alias(inode
, entry
);
349 entry
= newent
? newent
: entry
;
350 entry
->d_op
= &fuse_dentry_operations
;
352 fuse_change_entry_timeout(entry
, &outarg
);
354 fuse_invalidate_entry_cache(entry
);
365 * Atomic create+open operation
367 * If the filesystem doesn't support this, then fall back to separate
368 * 'mknod' + 'open' requests.
370 static int fuse_create_open(struct inode
*dir
, struct dentry
*entry
, int mode
,
371 struct nameidata
*nd
)
375 struct fuse_conn
*fc
= get_fuse_conn(dir
);
376 struct fuse_req
*req
;
377 struct fuse_req
*forget_req
;
378 struct fuse_create_in inarg
;
379 struct fuse_open_out outopen
;
380 struct fuse_entry_out outentry
;
381 struct fuse_file
*ff
;
383 int flags
= nd
->intent
.open
.flags
- 1;
388 forget_req
= fuse_get_req(fc
);
389 if (IS_ERR(forget_req
))
390 return PTR_ERR(forget_req
);
392 req
= fuse_get_req(fc
);
395 goto out_put_forget_req
;
398 ff
= fuse_file_alloc(fc
);
400 goto out_put_request
;
403 mode
&= ~current_umask();
406 memset(&inarg
, 0, sizeof(inarg
));
407 memset(&outentry
, 0, sizeof(outentry
));
410 inarg
.umask
= current_umask();
411 req
->in
.h
.opcode
= FUSE_CREATE
;
412 req
->in
.h
.nodeid
= get_node_id(dir
);
414 req
->in
.args
[0].size
= fc
->minor
< 12 ? sizeof(struct fuse_open_in
) :
416 req
->in
.args
[0].value
= &inarg
;
417 req
->in
.args
[1].size
= entry
->d_name
.len
+ 1;
418 req
->in
.args
[1].value
= entry
->d_name
.name
;
419 req
->out
.numargs
= 2;
421 req
->out
.args
[0].size
= FUSE_COMPAT_ENTRY_OUT_SIZE
;
423 req
->out
.args
[0].size
= sizeof(outentry
);
424 req
->out
.args
[0].value
= &outentry
;
425 req
->out
.args
[1].size
= sizeof(outopen
);
426 req
->out
.args
[1].value
= &outopen
;
427 fuse_request_send(fc
, req
);
428 err
= req
->out
.h
.error
;
436 if (!S_ISREG(outentry
.attr
.mode
) || invalid_nodeid(outentry
.nodeid
))
439 fuse_put_request(fc
, req
);
441 ff
->nodeid
= outentry
.nodeid
;
442 ff
->open_flags
= outopen
.open_flags
;
443 inode
= fuse_iget(dir
->i_sb
, outentry
.nodeid
, outentry
.generation
,
444 &outentry
.attr
, entry_attr_timeout(&outentry
), 0);
446 flags
&= ~(O_CREAT
| O_EXCL
| O_TRUNC
);
447 fuse_sync_release(ff
, flags
);
448 fuse_send_forget(fc
, forget_req
, outentry
.nodeid
, 1);
451 fuse_put_request(fc
, forget_req
);
452 d_instantiate(entry
, inode
);
453 fuse_change_entry_timeout(entry
, &outentry
);
454 fuse_invalidate_attr(dir
);
455 file
= lookup_instantiate_filp(nd
, entry
, generic_file_open
);
457 fuse_sync_release(ff
, flags
);
458 return PTR_ERR(file
);
460 file
->private_data
= fuse_file_get(ff
);
461 fuse_finish_open(inode
, file
);
467 fuse_put_request(fc
, req
);
469 fuse_put_request(fc
, forget_req
);
474 * Code shared between mknod, mkdir, symlink and link
476 static int create_new_entry(struct fuse_conn
*fc
, struct fuse_req
*req
,
477 struct inode
*dir
, struct dentry
*entry
,
480 struct fuse_entry_out outarg
;
483 struct fuse_req
*forget_req
;
485 forget_req
= fuse_get_req(fc
);
486 if (IS_ERR(forget_req
)) {
487 fuse_put_request(fc
, req
);
488 return PTR_ERR(forget_req
);
491 memset(&outarg
, 0, sizeof(outarg
));
492 req
->in
.h
.nodeid
= get_node_id(dir
);
493 req
->out
.numargs
= 1;
495 req
->out
.args
[0].size
= FUSE_COMPAT_ENTRY_OUT_SIZE
;
497 req
->out
.args
[0].size
= sizeof(outarg
);
498 req
->out
.args
[0].value
= &outarg
;
499 fuse_request_send(fc
, req
);
500 err
= req
->out
.h
.error
;
501 fuse_put_request(fc
, req
);
503 goto out_put_forget_req
;
506 if (invalid_nodeid(outarg
.nodeid
))
507 goto out_put_forget_req
;
509 if ((outarg
.attr
.mode
^ mode
) & S_IFMT
)
510 goto out_put_forget_req
;
512 inode
= fuse_iget(dir
->i_sb
, outarg
.nodeid
, outarg
.generation
,
513 &outarg
.attr
, entry_attr_timeout(&outarg
), 0);
515 fuse_send_forget(fc
, forget_req
, outarg
.nodeid
, 1);
518 fuse_put_request(fc
, forget_req
);
520 if (S_ISDIR(inode
->i_mode
)) {
521 struct dentry
*alias
;
522 mutex_lock(&fc
->inst_mutex
);
523 alias
= d_find_alias(inode
);
525 /* New directory must have moved since mkdir */
526 mutex_unlock(&fc
->inst_mutex
);
531 d_instantiate(entry
, inode
);
532 mutex_unlock(&fc
->inst_mutex
);
534 d_instantiate(entry
, inode
);
536 fuse_change_entry_timeout(entry
, &outarg
);
537 fuse_invalidate_attr(dir
);
541 fuse_put_request(fc
, forget_req
);
545 static int fuse_mknod(struct inode
*dir
, struct dentry
*entry
, int mode
,
548 struct fuse_mknod_in inarg
;
549 struct fuse_conn
*fc
= get_fuse_conn(dir
);
550 struct fuse_req
*req
= fuse_get_req(fc
);
555 mode
&= ~current_umask();
557 memset(&inarg
, 0, sizeof(inarg
));
559 inarg
.rdev
= new_encode_dev(rdev
);
560 inarg
.umask
= current_umask();
561 req
->in
.h
.opcode
= FUSE_MKNOD
;
563 req
->in
.args
[0].size
= fc
->minor
< 12 ? FUSE_COMPAT_MKNOD_IN_SIZE
:
565 req
->in
.args
[0].value
= &inarg
;
566 req
->in
.args
[1].size
= entry
->d_name
.len
+ 1;
567 req
->in
.args
[1].value
= entry
->d_name
.name
;
568 return create_new_entry(fc
, req
, dir
, entry
, mode
);
571 static int fuse_create(struct inode
*dir
, struct dentry
*entry
, int mode
,
572 struct nameidata
*nd
)
574 if (nd
&& (nd
->flags
& LOOKUP_OPEN
)) {
575 int err
= fuse_create_open(dir
, entry
, mode
, nd
);
578 /* Fall back on mknod */
580 return fuse_mknod(dir
, entry
, mode
, 0);
583 static int fuse_mkdir(struct inode
*dir
, struct dentry
*entry
, int mode
)
585 struct fuse_mkdir_in inarg
;
586 struct fuse_conn
*fc
= get_fuse_conn(dir
);
587 struct fuse_req
*req
= fuse_get_req(fc
);
592 mode
&= ~current_umask();
594 memset(&inarg
, 0, sizeof(inarg
));
596 inarg
.umask
= current_umask();
597 req
->in
.h
.opcode
= FUSE_MKDIR
;
599 req
->in
.args
[0].size
= sizeof(inarg
);
600 req
->in
.args
[0].value
= &inarg
;
601 req
->in
.args
[1].size
= entry
->d_name
.len
+ 1;
602 req
->in
.args
[1].value
= entry
->d_name
.name
;
603 return create_new_entry(fc
, req
, dir
, entry
, S_IFDIR
);
606 static int fuse_symlink(struct inode
*dir
, struct dentry
*entry
,
609 struct fuse_conn
*fc
= get_fuse_conn(dir
);
610 unsigned len
= strlen(link
) + 1;
611 struct fuse_req
*req
= fuse_get_req(fc
);
615 req
->in
.h
.opcode
= FUSE_SYMLINK
;
617 req
->in
.args
[0].size
= entry
->d_name
.len
+ 1;
618 req
->in
.args
[0].value
= entry
->d_name
.name
;
619 req
->in
.args
[1].size
= len
;
620 req
->in
.args
[1].value
= link
;
621 return create_new_entry(fc
, req
, dir
, entry
, S_IFLNK
);
624 static int fuse_unlink(struct inode
*dir
, struct dentry
*entry
)
627 struct fuse_conn
*fc
= get_fuse_conn(dir
);
628 struct fuse_req
*req
= fuse_get_req(fc
);
632 req
->in
.h
.opcode
= FUSE_UNLINK
;
633 req
->in
.h
.nodeid
= get_node_id(dir
);
635 req
->in
.args
[0].size
= entry
->d_name
.len
+ 1;
636 req
->in
.args
[0].value
= entry
->d_name
.name
;
637 fuse_request_send(fc
, req
);
638 err
= req
->out
.h
.error
;
639 fuse_put_request(fc
, req
);
641 struct inode
*inode
= entry
->d_inode
;
644 * Set nlink to zero so the inode can be cleared, if the inode
645 * does have more links this will be discovered at the next
649 fuse_invalidate_attr(inode
);
650 fuse_invalidate_attr(dir
);
651 fuse_invalidate_entry_cache(entry
);
652 } else if (err
== -EINTR
)
653 fuse_invalidate_entry(entry
);
657 static int fuse_rmdir(struct inode
*dir
, struct dentry
*entry
)
660 struct fuse_conn
*fc
= get_fuse_conn(dir
);
661 struct fuse_req
*req
= fuse_get_req(fc
);
665 req
->in
.h
.opcode
= FUSE_RMDIR
;
666 req
->in
.h
.nodeid
= get_node_id(dir
);
668 req
->in
.args
[0].size
= entry
->d_name
.len
+ 1;
669 req
->in
.args
[0].value
= entry
->d_name
.name
;
670 fuse_request_send(fc
, req
);
671 err
= req
->out
.h
.error
;
672 fuse_put_request(fc
, req
);
674 clear_nlink(entry
->d_inode
);
675 fuse_invalidate_attr(dir
);
676 fuse_invalidate_entry_cache(entry
);
677 } else if (err
== -EINTR
)
678 fuse_invalidate_entry(entry
);
682 static int fuse_rename(struct inode
*olddir
, struct dentry
*oldent
,
683 struct inode
*newdir
, struct dentry
*newent
)
686 struct fuse_rename_in inarg
;
687 struct fuse_conn
*fc
= get_fuse_conn(olddir
);
688 struct fuse_req
*req
= fuse_get_req(fc
);
692 memset(&inarg
, 0, sizeof(inarg
));
693 inarg
.newdir
= get_node_id(newdir
);
694 req
->in
.h
.opcode
= FUSE_RENAME
;
695 req
->in
.h
.nodeid
= get_node_id(olddir
);
697 req
->in
.args
[0].size
= sizeof(inarg
);
698 req
->in
.args
[0].value
= &inarg
;
699 req
->in
.args
[1].size
= oldent
->d_name
.len
+ 1;
700 req
->in
.args
[1].value
= oldent
->d_name
.name
;
701 req
->in
.args
[2].size
= newent
->d_name
.len
+ 1;
702 req
->in
.args
[2].value
= newent
->d_name
.name
;
703 fuse_request_send(fc
, req
);
704 err
= req
->out
.h
.error
;
705 fuse_put_request(fc
, req
);
708 fuse_invalidate_attr(oldent
->d_inode
);
710 fuse_invalidate_attr(olddir
);
711 if (olddir
!= newdir
)
712 fuse_invalidate_attr(newdir
);
714 /* newent will end up negative */
715 if (newent
->d_inode
) {
716 fuse_invalidate_attr(newent
->d_inode
);
717 fuse_invalidate_entry_cache(newent
);
719 } else if (err
== -EINTR
) {
720 /* If request was interrupted, DEITY only knows if the
721 rename actually took place. If the invalidation
722 fails (e.g. some process has CWD under the renamed
723 directory), then there can be inconsistency between
724 the dcache and the real filesystem. Tough luck. */
725 fuse_invalidate_entry(oldent
);
727 fuse_invalidate_entry(newent
);
733 static int fuse_link(struct dentry
*entry
, struct inode
*newdir
,
734 struct dentry
*newent
)
737 struct fuse_link_in inarg
;
738 struct inode
*inode
= entry
->d_inode
;
739 struct fuse_conn
*fc
= get_fuse_conn(inode
);
740 struct fuse_req
*req
= fuse_get_req(fc
);
744 memset(&inarg
, 0, sizeof(inarg
));
745 inarg
.oldnodeid
= get_node_id(inode
);
746 req
->in
.h
.opcode
= FUSE_LINK
;
748 req
->in
.args
[0].size
= sizeof(inarg
);
749 req
->in
.args
[0].value
= &inarg
;
750 req
->in
.args
[1].size
= newent
->d_name
.len
+ 1;
751 req
->in
.args
[1].value
= newent
->d_name
.name
;
752 err
= create_new_entry(fc
, req
, newdir
, newent
, inode
->i_mode
);
753 /* Contrary to "normal" filesystems it can happen that link
754 makes two "logical" inodes point to the same "physical"
755 inode. We invalidate the attributes of the old one, so it
756 will reflect changes in the backing inode (link count,
759 if (!err
|| err
== -EINTR
)
760 fuse_invalidate_attr(inode
);
764 static void fuse_fillattr(struct inode
*inode
, struct fuse_attr
*attr
,
767 stat
->dev
= inode
->i_sb
->s_dev
;
768 stat
->ino
= attr
->ino
;
769 stat
->mode
= (inode
->i_mode
& S_IFMT
) | (attr
->mode
& 07777);
770 stat
->nlink
= attr
->nlink
;
771 stat
->uid
= attr
->uid
;
772 stat
->gid
= attr
->gid
;
773 stat
->rdev
= inode
->i_rdev
;
774 stat
->atime
.tv_sec
= attr
->atime
;
775 stat
->atime
.tv_nsec
= attr
->atimensec
;
776 stat
->mtime
.tv_sec
= attr
->mtime
;
777 stat
->mtime
.tv_nsec
= attr
->mtimensec
;
778 stat
->ctime
.tv_sec
= attr
->ctime
;
779 stat
->ctime
.tv_nsec
= attr
->ctimensec
;
780 stat
->size
= attr
->size
;
781 stat
->blocks
= attr
->blocks
;
782 stat
->blksize
= (1 << inode
->i_blkbits
);
785 static int fuse_do_getattr(struct inode
*inode
, struct kstat
*stat
,
789 struct fuse_getattr_in inarg
;
790 struct fuse_attr_out outarg
;
791 struct fuse_conn
*fc
= get_fuse_conn(inode
);
792 struct fuse_req
*req
;
795 req
= fuse_get_req(fc
);
799 attr_version
= fuse_get_attr_version(fc
);
801 memset(&inarg
, 0, sizeof(inarg
));
802 memset(&outarg
, 0, sizeof(outarg
));
803 /* Directories have separate file-handle space */
804 if (file
&& S_ISREG(inode
->i_mode
)) {
805 struct fuse_file
*ff
= file
->private_data
;
807 inarg
.getattr_flags
|= FUSE_GETATTR_FH
;
810 req
->in
.h
.opcode
= FUSE_GETATTR
;
811 req
->in
.h
.nodeid
= get_node_id(inode
);
813 req
->in
.args
[0].size
= sizeof(inarg
);
814 req
->in
.args
[0].value
= &inarg
;
815 req
->out
.numargs
= 1;
817 req
->out
.args
[0].size
= FUSE_COMPAT_ATTR_OUT_SIZE
;
819 req
->out
.args
[0].size
= sizeof(outarg
);
820 req
->out
.args
[0].value
= &outarg
;
821 fuse_request_send(fc
, req
);
822 err
= req
->out
.h
.error
;
823 fuse_put_request(fc
, req
);
825 if ((inode
->i_mode
^ outarg
.attr
.mode
) & S_IFMT
) {
826 make_bad_inode(inode
);
829 fuse_change_attributes(inode
, &outarg
.attr
,
830 attr_timeout(&outarg
),
833 fuse_fillattr(inode
, &outarg
.attr
, stat
);
839 int fuse_update_attributes(struct inode
*inode
, struct kstat
*stat
,
840 struct file
*file
, bool *refreshed
)
842 struct fuse_inode
*fi
= get_fuse_inode(inode
);
846 if (fi
->i_time
< get_jiffies_64()) {
848 err
= fuse_do_getattr(inode
, stat
, file
);
853 generic_fillattr(inode
, stat
);
854 stat
->mode
= fi
->orig_i_mode
;
858 if (refreshed
!= NULL
)
864 int fuse_reverse_inval_entry(struct super_block
*sb
, u64 parent_nodeid
,
868 struct inode
*parent
;
870 struct dentry
*entry
;
872 parent
= ilookup5(sb
, parent_nodeid
, fuse_inode_eq
, &parent_nodeid
);
876 mutex_lock(&parent
->i_mutex
);
877 if (!S_ISDIR(parent
->i_mode
))
881 dir
= d_find_alias(parent
);
885 entry
= d_lookup(dir
, name
);
890 fuse_invalidate_attr(parent
);
891 fuse_invalidate_entry(entry
);
896 mutex_unlock(&parent
->i_mutex
);
902 * Calling into a user-controlled filesystem gives the filesystem
903 * daemon ptrace-like capabilities over the requester process. This
904 * means, that the filesystem daemon is able to record the exact
905 * filesystem operations performed, and can also control the behavior
906 * of the requester process in otherwise impossible ways. For example
907 * it can delay the operation for arbitrary length of time allowing
908 * DoS against the requester.
910 * For this reason only those processes can call into the filesystem,
911 * for which the owner of the mount has ptrace privilege. This
912 * excludes processes started by other users, suid or sgid processes.
914 int fuse_allow_task(struct fuse_conn
*fc
, struct task_struct
*task
)
916 const struct cred
*cred
;
919 if (fc
->flags
& FUSE_ALLOW_OTHER
)
924 cred
= __task_cred(task
);
925 if (cred
->euid
== fc
->user_id
&&
926 cred
->suid
== fc
->user_id
&&
927 cred
->uid
== fc
->user_id
&&
928 cred
->egid
== fc
->group_id
&&
929 cred
->sgid
== fc
->group_id
&&
930 cred
->gid
== fc
->group_id
)
937 static int fuse_access(struct inode
*inode
, int mask
)
939 struct fuse_conn
*fc
= get_fuse_conn(inode
);
940 struct fuse_req
*req
;
941 struct fuse_access_in inarg
;
947 req
= fuse_get_req(fc
);
951 memset(&inarg
, 0, sizeof(inarg
));
952 inarg
.mask
= mask
& (MAY_READ
| MAY_WRITE
| MAY_EXEC
);
953 req
->in
.h
.opcode
= FUSE_ACCESS
;
954 req
->in
.h
.nodeid
= get_node_id(inode
);
956 req
->in
.args
[0].size
= sizeof(inarg
);
957 req
->in
.args
[0].value
= &inarg
;
958 fuse_request_send(fc
, req
);
959 err
= req
->out
.h
.error
;
960 fuse_put_request(fc
, req
);
961 if (err
== -ENOSYS
) {
969 * Check permission. The two basic access models of FUSE are:
971 * 1) Local access checking ('default_permissions' mount option) based
972 * on file mode. This is the plain old disk filesystem permission
975 * 2) "Remote" access checking, where server is responsible for
976 * checking permission in each inode operation. An exception to this
977 * is if ->permission() was invoked from sys_access() in which case an
978 * access request is sent. Execute permission is still checked
979 * locally based on file mode.
981 static int fuse_permission(struct inode
*inode
, int mask
)
983 struct fuse_conn
*fc
= get_fuse_conn(inode
);
984 bool refreshed
= false;
987 if (!fuse_allow_task(fc
, current
))
991 * If attributes are needed, refresh them before proceeding
993 if ((fc
->flags
& FUSE_DEFAULT_PERMISSIONS
) ||
994 ((mask
& MAY_EXEC
) && S_ISREG(inode
->i_mode
))) {
995 err
= fuse_update_attributes(inode
, NULL
, NULL
, &refreshed
);
1000 if (fc
->flags
& FUSE_DEFAULT_PERMISSIONS
) {
1001 err
= generic_permission(inode
, mask
, NULL
);
1003 /* If permission is denied, try to refresh file
1004 attributes. This is also needed, because the root
1005 node will at first have no permissions */
1006 if (err
== -EACCES
&& !refreshed
) {
1007 err
= fuse_do_getattr(inode
, NULL
, NULL
);
1009 err
= generic_permission(inode
, mask
, NULL
);
1012 /* Note: the opposite of the above test does not
1013 exist. So if permissions are revoked this won't be
1014 noticed immediately, only after the attribute
1015 timeout has expired */
1016 } else if (mask
& MAY_ACCESS
) {
1017 err
= fuse_access(inode
, mask
);
1018 } else if ((mask
& MAY_EXEC
) && S_ISREG(inode
->i_mode
)) {
1019 if (!(inode
->i_mode
& S_IXUGO
)) {
1023 err
= fuse_do_getattr(inode
, NULL
, NULL
);
1024 if (!err
&& !(inode
->i_mode
& S_IXUGO
))
1031 static int parse_dirfile(char *buf
, size_t nbytes
, struct file
*file
,
1032 void *dstbuf
, filldir_t filldir
)
1034 while (nbytes
>= FUSE_NAME_OFFSET
) {
1035 struct fuse_dirent
*dirent
= (struct fuse_dirent
*) buf
;
1036 size_t reclen
= FUSE_DIRENT_SIZE(dirent
);
1038 if (!dirent
->namelen
|| dirent
->namelen
> FUSE_NAME_MAX
)
1040 if (reclen
> nbytes
)
1043 over
= filldir(dstbuf
, dirent
->name
, dirent
->namelen
,
1044 file
->f_pos
, dirent
->ino
, dirent
->type
);
1050 file
->f_pos
= dirent
->off
;
1056 static int fuse_readdir(struct file
*file
, void *dstbuf
, filldir_t filldir
)
1061 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
1062 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1063 struct fuse_req
*req
;
1065 if (is_bad_inode(inode
))
1068 req
= fuse_get_req(fc
);
1070 return PTR_ERR(req
);
1072 page
= alloc_page(GFP_KERNEL
);
1074 fuse_put_request(fc
, req
);
1077 req
->out
.argpages
= 1;
1079 req
->pages
[0] = page
;
1080 fuse_read_fill(req
, file
, file
->f_pos
, PAGE_SIZE
, FUSE_READDIR
);
1081 fuse_request_send(fc
, req
);
1082 nbytes
= req
->out
.args
[0].size
;
1083 err
= req
->out
.h
.error
;
1084 fuse_put_request(fc
, req
);
1086 err
= parse_dirfile(page_address(page
), nbytes
, file
, dstbuf
,
1090 fuse_invalidate_attr(inode
); /* atime changed */
1094 static char *read_link(struct dentry
*dentry
)
1096 struct inode
*inode
= dentry
->d_inode
;
1097 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1098 struct fuse_req
*req
= fuse_get_req(fc
);
1102 return ERR_CAST(req
);
1104 link
= (char *) __get_free_page(GFP_KERNEL
);
1106 link
= ERR_PTR(-ENOMEM
);
1109 req
->in
.h
.opcode
= FUSE_READLINK
;
1110 req
->in
.h
.nodeid
= get_node_id(inode
);
1111 req
->out
.argvar
= 1;
1112 req
->out
.numargs
= 1;
1113 req
->out
.args
[0].size
= PAGE_SIZE
- 1;
1114 req
->out
.args
[0].value
= link
;
1115 fuse_request_send(fc
, req
);
1116 if (req
->out
.h
.error
) {
1117 free_page((unsigned long) link
);
1118 link
= ERR_PTR(req
->out
.h
.error
);
1120 link
[req
->out
.args
[0].size
] = '\0';
1122 fuse_put_request(fc
, req
);
1123 fuse_invalidate_attr(inode
); /* atime changed */
1127 static void free_link(char *link
)
1130 free_page((unsigned long) link
);
1133 static void *fuse_follow_link(struct dentry
*dentry
, struct nameidata
*nd
)
1135 nd_set_link(nd
, read_link(dentry
));
1139 static void fuse_put_link(struct dentry
*dentry
, struct nameidata
*nd
, void *c
)
1141 free_link(nd_get_link(nd
));
1144 static int fuse_dir_open(struct inode
*inode
, struct file
*file
)
1146 return fuse_open_common(inode
, file
, true);
1149 static int fuse_dir_release(struct inode
*inode
, struct file
*file
)
1151 fuse_release_common(file
, FUSE_RELEASEDIR
);
1156 static int fuse_dir_fsync(struct file
*file
, struct dentry
*de
, int datasync
)
1158 /* nfsd can call this with no file */
1159 return file
? fuse_fsync_common(file
, de
, datasync
, 1) : 0;
1162 static bool update_mtime(unsigned ivalid
)
1164 /* Always update if mtime is explicitly set */
1165 if (ivalid
& ATTR_MTIME_SET
)
1168 /* If it's an open(O_TRUNC) or an ftruncate(), don't update */
1169 if ((ivalid
& ATTR_SIZE
) && (ivalid
& (ATTR_OPEN
| ATTR_FILE
)))
1172 /* In all other cases update */
1176 static void iattr_to_fattr(struct iattr
*iattr
, struct fuse_setattr_in
*arg
)
1178 unsigned ivalid
= iattr
->ia_valid
;
1180 if (ivalid
& ATTR_MODE
)
1181 arg
->valid
|= FATTR_MODE
, arg
->mode
= iattr
->ia_mode
;
1182 if (ivalid
& ATTR_UID
)
1183 arg
->valid
|= FATTR_UID
, arg
->uid
= iattr
->ia_uid
;
1184 if (ivalid
& ATTR_GID
)
1185 arg
->valid
|= FATTR_GID
, arg
->gid
= iattr
->ia_gid
;
1186 if (ivalid
& ATTR_SIZE
)
1187 arg
->valid
|= FATTR_SIZE
, arg
->size
= iattr
->ia_size
;
1188 if (ivalid
& ATTR_ATIME
) {
1189 arg
->valid
|= FATTR_ATIME
;
1190 arg
->atime
= iattr
->ia_atime
.tv_sec
;
1191 arg
->atimensec
= iattr
->ia_atime
.tv_nsec
;
1192 if (!(ivalid
& ATTR_ATIME_SET
))
1193 arg
->valid
|= FATTR_ATIME_NOW
;
1195 if ((ivalid
& ATTR_MTIME
) && update_mtime(ivalid
)) {
1196 arg
->valid
|= FATTR_MTIME
;
1197 arg
->mtime
= iattr
->ia_mtime
.tv_sec
;
1198 arg
->mtimensec
= iattr
->ia_mtime
.tv_nsec
;
1199 if (!(ivalid
& ATTR_MTIME_SET
))
1200 arg
->valid
|= FATTR_MTIME_NOW
;
1205 * Prevent concurrent writepages on inode
1207 * This is done by adding a negative bias to the inode write counter
1208 * and waiting for all pending writes to finish.
1210 void fuse_set_nowrite(struct inode
*inode
)
1212 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1213 struct fuse_inode
*fi
= get_fuse_inode(inode
);
1215 BUG_ON(!mutex_is_locked(&inode
->i_mutex
));
1217 spin_lock(&fc
->lock
);
1218 BUG_ON(fi
->writectr
< 0);
1219 fi
->writectr
+= FUSE_NOWRITE
;
1220 spin_unlock(&fc
->lock
);
1221 wait_event(fi
->page_waitq
, fi
->writectr
== FUSE_NOWRITE
);
1225 * Allow writepages on inode
1227 * Remove the bias from the writecounter and send any queued
1230 static void __fuse_release_nowrite(struct inode
*inode
)
1232 struct fuse_inode
*fi
= get_fuse_inode(inode
);
1234 BUG_ON(fi
->writectr
!= FUSE_NOWRITE
);
1236 fuse_flush_writepages(inode
);
1239 void fuse_release_nowrite(struct inode
*inode
)
1241 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1243 spin_lock(&fc
->lock
);
1244 __fuse_release_nowrite(inode
);
1245 spin_unlock(&fc
->lock
);
1249 * Set attributes, and at the same time refresh them.
1251 * Truncation is slightly complicated, because the 'truncate' request
1252 * may fail, in which case we don't want to touch the mapping.
1253 * vmtruncate() doesn't allow for this case, so do the rlimit checking
1254 * and the actual truncation by hand.
1256 static int fuse_do_setattr(struct dentry
*entry
, struct iattr
*attr
,
1259 struct inode
*inode
= entry
->d_inode
;
1260 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1261 struct fuse_req
*req
;
1262 struct fuse_setattr_in inarg
;
1263 struct fuse_attr_out outarg
;
1264 bool is_truncate
= false;
1268 if (!fuse_allow_task(fc
, current
))
1271 if (fc
->flags
& FUSE_DEFAULT_PERMISSIONS
) {
1272 err
= inode_change_ok(inode
, attr
);
1277 if ((attr
->ia_valid
& ATTR_OPEN
) && fc
->atomic_o_trunc
)
1280 if (attr
->ia_valid
& ATTR_SIZE
) {
1281 err
= inode_newsize_ok(inode
, attr
->ia_size
);
1287 req
= fuse_get_req(fc
);
1289 return PTR_ERR(req
);
1292 fuse_set_nowrite(inode
);
1294 memset(&inarg
, 0, sizeof(inarg
));
1295 memset(&outarg
, 0, sizeof(outarg
));
1296 iattr_to_fattr(attr
, &inarg
);
1298 struct fuse_file
*ff
= file
->private_data
;
1299 inarg
.valid
|= FATTR_FH
;
1302 if (attr
->ia_valid
& ATTR_SIZE
) {
1303 /* For mandatory locking in truncate */
1304 inarg
.valid
|= FATTR_LOCKOWNER
;
1305 inarg
.lock_owner
= fuse_lock_owner_id(fc
, current
->files
);
1307 req
->in
.h
.opcode
= FUSE_SETATTR
;
1308 req
->in
.h
.nodeid
= get_node_id(inode
);
1309 req
->in
.numargs
= 1;
1310 req
->in
.args
[0].size
= sizeof(inarg
);
1311 req
->in
.args
[0].value
= &inarg
;
1312 req
->out
.numargs
= 1;
1314 req
->out
.args
[0].size
= FUSE_COMPAT_ATTR_OUT_SIZE
;
1316 req
->out
.args
[0].size
= sizeof(outarg
);
1317 req
->out
.args
[0].value
= &outarg
;
1318 fuse_request_send(fc
, req
);
1319 err
= req
->out
.h
.error
;
1320 fuse_put_request(fc
, req
);
1323 fuse_invalidate_attr(inode
);
1327 if ((inode
->i_mode
^ outarg
.attr
.mode
) & S_IFMT
) {
1328 make_bad_inode(inode
);
1333 spin_lock(&fc
->lock
);
1334 fuse_change_attributes_common(inode
, &outarg
.attr
,
1335 attr_timeout(&outarg
));
1336 oldsize
= inode
->i_size
;
1337 i_size_write(inode
, outarg
.attr
.size
);
1340 /* NOTE: this may release/reacquire fc->lock */
1341 __fuse_release_nowrite(inode
);
1343 spin_unlock(&fc
->lock
);
1346 * Only call invalidate_inode_pages2() after removing
1347 * FUSE_NOWRITE, otherwise fuse_launder_page() would deadlock.
1349 if (S_ISREG(inode
->i_mode
) && oldsize
!= outarg
.attr
.size
) {
1350 truncate_pagecache(inode
, oldsize
, outarg
.attr
.size
);
1351 invalidate_inode_pages2(inode
->i_mapping
);
1358 fuse_release_nowrite(inode
);
1363 static int fuse_setattr(struct dentry
*entry
, struct iattr
*attr
)
1365 if (attr
->ia_valid
& ATTR_FILE
)
1366 return fuse_do_setattr(entry
, attr
, attr
->ia_file
);
1368 return fuse_do_setattr(entry
, attr
, NULL
);
1371 static int fuse_getattr(struct vfsmount
*mnt
, struct dentry
*entry
,
1374 struct inode
*inode
= entry
->d_inode
;
1375 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1377 if (!fuse_allow_task(fc
, current
))
1380 return fuse_update_attributes(inode
, stat
, NULL
, NULL
);
1383 static int fuse_setxattr(struct dentry
*entry
, const char *name
,
1384 const void *value
, size_t size
, int flags
)
1386 struct inode
*inode
= entry
->d_inode
;
1387 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1388 struct fuse_req
*req
;
1389 struct fuse_setxattr_in inarg
;
1392 if (fc
->no_setxattr
)
1395 req
= fuse_get_req(fc
);
1397 return PTR_ERR(req
);
1399 memset(&inarg
, 0, sizeof(inarg
));
1401 inarg
.flags
= flags
;
1402 req
->in
.h
.opcode
= FUSE_SETXATTR
;
1403 req
->in
.h
.nodeid
= get_node_id(inode
);
1404 req
->in
.numargs
= 3;
1405 req
->in
.args
[0].size
= sizeof(inarg
);
1406 req
->in
.args
[0].value
= &inarg
;
1407 req
->in
.args
[1].size
= strlen(name
) + 1;
1408 req
->in
.args
[1].value
= name
;
1409 req
->in
.args
[2].size
= size
;
1410 req
->in
.args
[2].value
= value
;
1411 fuse_request_send(fc
, req
);
1412 err
= req
->out
.h
.error
;
1413 fuse_put_request(fc
, req
);
1414 if (err
== -ENOSYS
) {
1415 fc
->no_setxattr
= 1;
1421 static ssize_t
fuse_getxattr(struct dentry
*entry
, const char *name
,
1422 void *value
, size_t size
)
1424 struct inode
*inode
= entry
->d_inode
;
1425 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1426 struct fuse_req
*req
;
1427 struct fuse_getxattr_in inarg
;
1428 struct fuse_getxattr_out outarg
;
1431 if (fc
->no_getxattr
)
1434 req
= fuse_get_req(fc
);
1436 return PTR_ERR(req
);
1438 memset(&inarg
, 0, sizeof(inarg
));
1440 req
->in
.h
.opcode
= FUSE_GETXATTR
;
1441 req
->in
.h
.nodeid
= get_node_id(inode
);
1442 req
->in
.numargs
= 2;
1443 req
->in
.args
[0].size
= sizeof(inarg
);
1444 req
->in
.args
[0].value
= &inarg
;
1445 req
->in
.args
[1].size
= strlen(name
) + 1;
1446 req
->in
.args
[1].value
= name
;
1447 /* This is really two different operations rolled into one */
1448 req
->out
.numargs
= 1;
1450 req
->out
.argvar
= 1;
1451 req
->out
.args
[0].size
= size
;
1452 req
->out
.args
[0].value
= value
;
1454 req
->out
.args
[0].size
= sizeof(outarg
);
1455 req
->out
.args
[0].value
= &outarg
;
1457 fuse_request_send(fc
, req
);
1458 ret
= req
->out
.h
.error
;
1460 ret
= size
? req
->out
.args
[0].size
: outarg
.size
;
1462 if (ret
== -ENOSYS
) {
1463 fc
->no_getxattr
= 1;
1467 fuse_put_request(fc
, req
);
1471 static ssize_t
fuse_listxattr(struct dentry
*entry
, char *list
, size_t size
)
1473 struct inode
*inode
= entry
->d_inode
;
1474 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1475 struct fuse_req
*req
;
1476 struct fuse_getxattr_in inarg
;
1477 struct fuse_getxattr_out outarg
;
1480 if (!fuse_allow_task(fc
, current
))
1483 if (fc
->no_listxattr
)
1486 req
= fuse_get_req(fc
);
1488 return PTR_ERR(req
);
1490 memset(&inarg
, 0, sizeof(inarg
));
1492 req
->in
.h
.opcode
= FUSE_LISTXATTR
;
1493 req
->in
.h
.nodeid
= get_node_id(inode
);
1494 req
->in
.numargs
= 1;
1495 req
->in
.args
[0].size
= sizeof(inarg
);
1496 req
->in
.args
[0].value
= &inarg
;
1497 /* This is really two different operations rolled into one */
1498 req
->out
.numargs
= 1;
1500 req
->out
.argvar
= 1;
1501 req
->out
.args
[0].size
= size
;
1502 req
->out
.args
[0].value
= list
;
1504 req
->out
.args
[0].size
= sizeof(outarg
);
1505 req
->out
.args
[0].value
= &outarg
;
1507 fuse_request_send(fc
, req
);
1508 ret
= req
->out
.h
.error
;
1510 ret
= size
? req
->out
.args
[0].size
: outarg
.size
;
1512 if (ret
== -ENOSYS
) {
1513 fc
->no_listxattr
= 1;
1517 fuse_put_request(fc
, req
);
1521 static int fuse_removexattr(struct dentry
*entry
, const char *name
)
1523 struct inode
*inode
= entry
->d_inode
;
1524 struct fuse_conn
*fc
= get_fuse_conn(inode
);
1525 struct fuse_req
*req
;
1528 if (fc
->no_removexattr
)
1531 req
= fuse_get_req(fc
);
1533 return PTR_ERR(req
);
1535 req
->in
.h
.opcode
= FUSE_REMOVEXATTR
;
1536 req
->in
.h
.nodeid
= get_node_id(inode
);
1537 req
->in
.numargs
= 1;
1538 req
->in
.args
[0].size
= strlen(name
) + 1;
1539 req
->in
.args
[0].value
= name
;
1540 fuse_request_send(fc
, req
);
1541 err
= req
->out
.h
.error
;
1542 fuse_put_request(fc
, req
);
1543 if (err
== -ENOSYS
) {
1544 fc
->no_removexattr
= 1;
1550 static const struct inode_operations fuse_dir_inode_operations
= {
1551 .lookup
= fuse_lookup
,
1552 .mkdir
= fuse_mkdir
,
1553 .symlink
= fuse_symlink
,
1554 .unlink
= fuse_unlink
,
1555 .rmdir
= fuse_rmdir
,
1556 .rename
= fuse_rename
,
1558 .setattr
= fuse_setattr
,
1559 .create
= fuse_create
,
1560 .mknod
= fuse_mknod
,
1561 .permission
= fuse_permission
,
1562 .getattr
= fuse_getattr
,
1563 .setxattr
= fuse_setxattr
,
1564 .getxattr
= fuse_getxattr
,
1565 .listxattr
= fuse_listxattr
,
1566 .removexattr
= fuse_removexattr
,
1569 static const struct file_operations fuse_dir_operations
= {
1570 .llseek
= generic_file_llseek
,
1571 .read
= generic_read_dir
,
1572 .readdir
= fuse_readdir
,
1573 .open
= fuse_dir_open
,
1574 .release
= fuse_dir_release
,
1575 .fsync
= fuse_dir_fsync
,
1578 static const struct inode_operations fuse_common_inode_operations
= {
1579 .setattr
= fuse_setattr
,
1580 .permission
= fuse_permission
,
1581 .getattr
= fuse_getattr
,
1582 .setxattr
= fuse_setxattr
,
1583 .getxattr
= fuse_getxattr
,
1584 .listxattr
= fuse_listxattr
,
1585 .removexattr
= fuse_removexattr
,
1588 static const struct inode_operations fuse_symlink_inode_operations
= {
1589 .setattr
= fuse_setattr
,
1590 .follow_link
= fuse_follow_link
,
1591 .put_link
= fuse_put_link
,
1592 .readlink
= generic_readlink
,
1593 .getattr
= fuse_getattr
,
1594 .setxattr
= fuse_setxattr
,
1595 .getxattr
= fuse_getxattr
,
1596 .listxattr
= fuse_listxattr
,
1597 .removexattr
= fuse_removexattr
,
1600 void fuse_init_common(struct inode
*inode
)
1602 inode
->i_op
= &fuse_common_inode_operations
;
1605 void fuse_init_dir(struct inode
*inode
)
1607 inode
->i_op
= &fuse_dir_inode_operations
;
1608 inode
->i_fop
= &fuse_dir_operations
;
1611 void fuse_init_symlink(struct inode
*inode
)
1613 inode
->i_op
= &fuse_symlink_inode_operations
;