2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2006 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/slab.h>
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
16 static const struct file_operations fuse_direct_io_file_operations
;
18 static int fuse_send_open(struct inode
*inode
, struct file
*file
, int isdir
,
19 struct fuse_open_out
*outargp
)
21 struct fuse_conn
*fc
= get_fuse_conn(inode
);
22 struct fuse_open_in inarg
;
26 req
= fuse_get_req(fc
);
30 memset(&inarg
, 0, sizeof(inarg
));
31 inarg
.flags
= file
->f_flags
& ~(O_CREAT
| O_EXCL
| O_NOCTTY
| O_TRUNC
);
32 req
->in
.h
.opcode
= isdir
? FUSE_OPENDIR
: FUSE_OPEN
;
33 req
->in
.h
.nodeid
= get_node_id(inode
);
35 req
->in
.args
[0].size
= sizeof(inarg
);
36 req
->in
.args
[0].value
= &inarg
;
38 req
->out
.args
[0].size
= sizeof(*outargp
);
39 req
->out
.args
[0].value
= outargp
;
40 request_send(fc
, req
);
41 err
= req
->out
.h
.error
;
42 fuse_put_request(fc
, req
);
47 struct fuse_file
*fuse_file_alloc(void)
50 ff
= kmalloc(sizeof(struct fuse_file
), GFP_KERNEL
);
52 ff
->reserved_req
= fuse_request_alloc();
53 if (!ff
->reserved_req
) {
57 atomic_set(&ff
->count
, 0);
62 void fuse_file_free(struct fuse_file
*ff
)
64 fuse_request_free(ff
->reserved_req
);
68 static struct fuse_file
*fuse_file_get(struct fuse_file
*ff
)
70 atomic_inc(&ff
->count
);
74 static void fuse_file_put(struct fuse_file
*ff
)
76 if (atomic_dec_and_test(&ff
->count
)) {
77 struct fuse_req
*req
= ff
->reserved_req
;
78 struct fuse_conn
*fc
= get_fuse_conn(req
->dentry
->d_inode
);
79 request_send_background(fc
, req
);
84 void fuse_finish_open(struct inode
*inode
, struct file
*file
,
85 struct fuse_file
*ff
, struct fuse_open_out
*outarg
)
87 if (outarg
->open_flags
& FOPEN_DIRECT_IO
)
88 file
->f_op
= &fuse_direct_io_file_operations
;
89 if (!(outarg
->open_flags
& FOPEN_KEEP_CACHE
))
90 invalidate_inode_pages2(inode
->i_mapping
);
92 file
->private_data
= fuse_file_get(ff
);
95 int fuse_open_common(struct inode
*inode
, struct file
*file
, int isdir
)
97 struct fuse_open_out outarg
;
101 /* VFS checks this, but only _after_ ->open() */
102 if (file
->f_flags
& O_DIRECT
)
105 err
= generic_file_open(inode
, file
);
109 ff
= fuse_file_alloc();
113 err
= fuse_send_open(inode
, file
, isdir
, &outarg
);
118 outarg
.open_flags
&= ~FOPEN_DIRECT_IO
;
119 fuse_finish_open(inode
, file
, ff
, &outarg
);
125 void fuse_release_fill(struct fuse_file
*ff
, u64 nodeid
, int flags
, int opcode
)
127 struct fuse_req
*req
= ff
->reserved_req
;
128 struct fuse_release_in
*inarg
= &req
->misc
.release_in
;
131 inarg
->flags
= flags
;
132 req
->in
.h
.opcode
= opcode
;
133 req
->in
.h
.nodeid
= nodeid
;
135 req
->in
.args
[0].size
= sizeof(struct fuse_release_in
);
136 req
->in
.args
[0].value
= inarg
;
139 int fuse_release_common(struct inode
*inode
, struct file
*file
, int isdir
)
141 struct fuse_file
*ff
= file
->private_data
;
143 fuse_release_fill(ff
, get_node_id(inode
), file
->f_flags
,
144 isdir
? FUSE_RELEASEDIR
: FUSE_RELEASE
);
146 /* Hold vfsmount and dentry until release is finished */
147 ff
->reserved_req
->vfsmount
= mntget(file
->f_path
.mnt
);
148 ff
->reserved_req
->dentry
= dget(file
->f_path
.dentry
);
150 * Normally this will send the RELEASE request,
151 * however if some asynchronous READ or WRITE requests
152 * are outstanding, the sending will be delayed
157 /* Return value is ignored by VFS */
161 static int fuse_open(struct inode
*inode
, struct file
*file
)
163 return fuse_open_common(inode
, file
, 0);
166 static int fuse_release(struct inode
*inode
, struct file
*file
)
168 return fuse_release_common(inode
, file
, 0);
172 * Scramble the ID space with XTEA, so that the value of the files_struct
173 * pointer is not exposed to userspace.
175 static u64
fuse_lock_owner_id(struct fuse_conn
*fc
, fl_owner_t id
)
177 u32
*k
= fc
->scramble_key
;
178 u64 v
= (unsigned long) id
;
184 for (i
= 0; i
< 32; i
++) {
185 v0
+= ((v1
<< 4 ^ v1
>> 5) + v1
) ^ (sum
+ k
[sum
& 3]);
187 v1
+= ((v0
<< 4 ^ v0
>> 5) + v0
) ^ (sum
+ k
[sum
>>11 & 3]);
190 return (u64
) v0
+ ((u64
) v1
<< 32);
193 static int fuse_flush(struct file
*file
, fl_owner_t id
)
195 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
196 struct fuse_conn
*fc
= get_fuse_conn(inode
);
197 struct fuse_file
*ff
= file
->private_data
;
198 struct fuse_req
*req
;
199 struct fuse_flush_in inarg
;
202 if (is_bad_inode(inode
))
208 req
= fuse_get_req_nofail(fc
, file
);
209 memset(&inarg
, 0, sizeof(inarg
));
211 inarg
.lock_owner
= fuse_lock_owner_id(fc
, id
);
212 req
->in
.h
.opcode
= FUSE_FLUSH
;
213 req
->in
.h
.nodeid
= get_node_id(inode
);
215 req
->in
.args
[0].size
= sizeof(inarg
);
216 req
->in
.args
[0].value
= &inarg
;
218 request_send(fc
, req
);
219 err
= req
->out
.h
.error
;
220 fuse_put_request(fc
, req
);
221 if (err
== -ENOSYS
) {
228 int fuse_fsync_common(struct file
*file
, struct dentry
*de
, int datasync
,
231 struct inode
*inode
= de
->d_inode
;
232 struct fuse_conn
*fc
= get_fuse_conn(inode
);
233 struct fuse_file
*ff
= file
->private_data
;
234 struct fuse_req
*req
;
235 struct fuse_fsync_in inarg
;
238 if (is_bad_inode(inode
))
241 if ((!isdir
&& fc
->no_fsync
) || (isdir
&& fc
->no_fsyncdir
))
244 req
= fuse_get_req(fc
);
248 memset(&inarg
, 0, sizeof(inarg
));
250 inarg
.fsync_flags
= datasync
? 1 : 0;
251 req
->in
.h
.opcode
= isdir
? FUSE_FSYNCDIR
: FUSE_FSYNC
;
252 req
->in
.h
.nodeid
= get_node_id(inode
);
254 req
->in
.args
[0].size
= sizeof(inarg
);
255 req
->in
.args
[0].value
= &inarg
;
256 request_send(fc
, req
);
257 err
= req
->out
.h
.error
;
258 fuse_put_request(fc
, req
);
259 if (err
== -ENOSYS
) {
269 static int fuse_fsync(struct file
*file
, struct dentry
*de
, int datasync
)
271 return fuse_fsync_common(file
, de
, datasync
, 0);
274 void fuse_read_fill(struct fuse_req
*req
, struct fuse_file
*ff
,
275 struct inode
*inode
, loff_t pos
, size_t count
, int opcode
)
277 struct fuse_read_in
*inarg
= &req
->misc
.read_in
;
282 req
->in
.h
.opcode
= opcode
;
283 req
->in
.h
.nodeid
= get_node_id(inode
);
285 req
->in
.args
[0].size
= sizeof(struct fuse_read_in
);
286 req
->in
.args
[0].value
= inarg
;
287 req
->out
.argpages
= 1;
289 req
->out
.numargs
= 1;
290 req
->out
.args
[0].size
= count
;
293 static size_t fuse_send_read(struct fuse_req
*req
, struct file
*file
,
294 struct inode
*inode
, loff_t pos
, size_t count
)
296 struct fuse_conn
*fc
= get_fuse_conn(inode
);
297 struct fuse_file
*ff
= file
->private_data
;
298 fuse_read_fill(req
, ff
, inode
, pos
, count
, FUSE_READ
);
299 request_send(fc
, req
);
300 return req
->out
.args
[0].size
;
303 static int fuse_readpage(struct file
*file
, struct page
*page
)
305 struct inode
*inode
= page
->mapping
->host
;
306 struct fuse_conn
*fc
= get_fuse_conn(inode
);
307 struct fuse_req
*req
;
311 if (is_bad_inode(inode
))
314 req
= fuse_get_req(fc
);
319 req
->out
.page_zeroing
= 1;
321 req
->pages
[0] = page
;
322 fuse_send_read(req
, file
, inode
, page_offset(page
), PAGE_CACHE_SIZE
);
323 err
= req
->out
.h
.error
;
324 fuse_put_request(fc
, req
);
326 SetPageUptodate(page
);
327 fuse_invalidate_attr(inode
); /* atime changed */
333 static void fuse_readpages_end(struct fuse_conn
*fc
, struct fuse_req
*req
)
337 fuse_invalidate_attr(req
->pages
[0]->mapping
->host
); /* atime changed */
339 for (i
= 0; i
< req
->num_pages
; i
++) {
340 struct page
*page
= req
->pages
[i
];
341 if (!req
->out
.h
.error
)
342 SetPageUptodate(page
);
348 fuse_file_put(req
->ff
);
349 fuse_put_request(fc
, req
);
352 static void fuse_send_readpages(struct fuse_req
*req
, struct fuse_file
*ff
,
355 struct fuse_conn
*fc
= get_fuse_conn(inode
);
356 loff_t pos
= page_offset(req
->pages
[0]);
357 size_t count
= req
->num_pages
<< PAGE_CACHE_SHIFT
;
358 req
->out
.page_zeroing
= 1;
359 fuse_read_fill(req
, ff
, inode
, pos
, count
, FUSE_READ
);
360 if (fc
->async_read
) {
361 req
->ff
= fuse_file_get(ff
);
362 req
->end
= fuse_readpages_end
;
363 request_send_background(fc
, req
);
365 request_send(fc
, req
);
366 fuse_readpages_end(fc
, req
);
370 struct fuse_fill_data
{
371 struct fuse_req
*req
;
372 struct fuse_file
*ff
;
376 static int fuse_readpages_fill(void *_data
, struct page
*page
)
378 struct fuse_fill_data
*data
= _data
;
379 struct fuse_req
*req
= data
->req
;
380 struct inode
*inode
= data
->inode
;
381 struct fuse_conn
*fc
= get_fuse_conn(inode
);
383 if (req
->num_pages
&&
384 (req
->num_pages
== FUSE_MAX_PAGES_PER_REQ
||
385 (req
->num_pages
+ 1) * PAGE_CACHE_SIZE
> fc
->max_read
||
386 req
->pages
[req
->num_pages
- 1]->index
+ 1 != page
->index
)) {
387 fuse_send_readpages(req
, data
->ff
, inode
);
388 data
->req
= req
= fuse_get_req(fc
);
394 req
->pages
[req
->num_pages
] = page
;
399 static int fuse_readpages(struct file
*file
, struct address_space
*mapping
,
400 struct list_head
*pages
, unsigned nr_pages
)
402 struct inode
*inode
= mapping
->host
;
403 struct fuse_conn
*fc
= get_fuse_conn(inode
);
404 struct fuse_fill_data data
;
408 if (is_bad_inode(inode
))
411 data
.ff
= file
->private_data
;
413 data
.req
= fuse_get_req(fc
);
414 err
= PTR_ERR(data
.req
);
415 if (IS_ERR(data
.req
))
418 err
= read_cache_pages(mapping
, pages
, fuse_readpages_fill
, &data
);
420 if (data
.req
->num_pages
)
421 fuse_send_readpages(data
.req
, data
.ff
, inode
);
423 fuse_put_request(fc
, data
.req
);
429 static size_t fuse_send_write(struct fuse_req
*req
, struct file
*file
,
430 struct inode
*inode
, loff_t pos
, size_t count
)
432 struct fuse_conn
*fc
= get_fuse_conn(inode
);
433 struct fuse_file
*ff
= file
->private_data
;
434 struct fuse_write_in inarg
;
435 struct fuse_write_out outarg
;
437 memset(&inarg
, 0, sizeof(struct fuse_write_in
));
441 req
->in
.h
.opcode
= FUSE_WRITE
;
442 req
->in
.h
.nodeid
= get_node_id(inode
);
443 req
->in
.argpages
= 1;
445 req
->in
.args
[0].size
= sizeof(struct fuse_write_in
);
446 req
->in
.args
[0].value
= &inarg
;
447 req
->in
.args
[1].size
= count
;
448 req
->out
.numargs
= 1;
449 req
->out
.args
[0].size
= sizeof(struct fuse_write_out
);
450 req
->out
.args
[0].value
= &outarg
;
451 request_send(fc
, req
);
455 static int fuse_write_begin(struct file
*file
, struct address_space
*mapping
,
456 loff_t pos
, unsigned len
, unsigned flags
,
457 struct page
**pagep
, void **fsdata
)
459 pgoff_t index
= pos
>> PAGE_CACHE_SHIFT
;
461 *pagep
= __grab_cache_page(mapping
, index
);
467 static int fuse_buffered_write(struct file
*file
, struct inode
*inode
,
468 loff_t pos
, unsigned count
, struct page
*page
)
472 struct fuse_conn
*fc
= get_fuse_conn(inode
);
473 unsigned offset
= pos
& (PAGE_CACHE_SIZE
- 1);
474 struct fuse_req
*req
;
476 if (is_bad_inode(inode
))
479 req
= fuse_get_req(fc
);
484 req
->pages
[0] = page
;
485 req
->page_offset
= offset
;
486 nres
= fuse_send_write(req
, file
, inode
, pos
, count
);
487 err
= req
->out
.h
.error
;
488 fuse_put_request(fc
, req
);
493 spin_lock(&fc
->lock
);
494 if (pos
> inode
->i_size
)
495 i_size_write(inode
, pos
);
496 spin_unlock(&fc
->lock
);
498 if (count
== PAGE_CACHE_SIZE
)
499 SetPageUptodate(page
);
501 fuse_invalidate_attr(inode
);
502 return err
? err
: nres
;
505 static int fuse_write_end(struct file
*file
, struct address_space
*mapping
,
506 loff_t pos
, unsigned len
, unsigned copied
,
507 struct page
*page
, void *fsdata
)
509 struct inode
*inode
= mapping
->host
;
513 res
= fuse_buffered_write(file
, inode
, pos
, copied
, page
);
516 page_cache_release(page
);
520 static void fuse_release_user_pages(struct fuse_req
*req
, int write
)
524 for (i
= 0; i
< req
->num_pages
; i
++) {
525 struct page
*page
= req
->pages
[i
];
527 set_page_dirty_lock(page
);
532 static int fuse_get_user_pages(struct fuse_req
*req
, const char __user
*buf
,
533 unsigned nbytes
, int write
)
535 unsigned long user_addr
= (unsigned long) buf
;
536 unsigned offset
= user_addr
& ~PAGE_MASK
;
539 /* This doesn't work with nfsd */
543 nbytes
= min(nbytes
, (unsigned) FUSE_MAX_PAGES_PER_REQ
<< PAGE_SHIFT
);
544 npages
= (nbytes
+ offset
+ PAGE_SIZE
- 1) >> PAGE_SHIFT
;
545 npages
= min(max(npages
, 1), FUSE_MAX_PAGES_PER_REQ
);
546 down_read(¤t
->mm
->mmap_sem
);
547 npages
= get_user_pages(current
, current
->mm
, user_addr
, npages
, write
,
548 0, req
->pages
, NULL
);
549 up_read(¤t
->mm
->mmap_sem
);
553 req
->num_pages
= npages
;
554 req
->page_offset
= offset
;
558 static ssize_t
fuse_direct_io(struct file
*file
, const char __user
*buf
,
559 size_t count
, loff_t
*ppos
, int write
)
561 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
562 struct fuse_conn
*fc
= get_fuse_conn(inode
);
563 size_t nmax
= write
? fc
->max_write
: fc
->max_read
;
566 struct fuse_req
*req
;
568 if (is_bad_inode(inode
))
571 req
= fuse_get_req(fc
);
577 size_t nbytes
= min(count
, nmax
);
578 int err
= fuse_get_user_pages(req
, buf
, nbytes
, !write
);
583 nbytes
= (req
->num_pages
<< PAGE_SHIFT
) - req
->page_offset
;
584 nbytes
= min(count
, nbytes
);
586 nres
= fuse_send_write(req
, file
, inode
, pos
, nbytes
);
588 nres
= fuse_send_read(req
, file
, inode
, pos
, nbytes
);
589 fuse_release_user_pages(req
, !write
);
590 if (req
->out
.h
.error
) {
592 res
= req
->out
.h
.error
;
594 } else if (nres
> nbytes
) {
605 fuse_put_request(fc
, req
);
606 req
= fuse_get_req(fc
);
611 fuse_put_request(fc
, req
);
614 spin_lock(&fc
->lock
);
615 if (pos
> inode
->i_size
)
616 i_size_write(inode
, pos
);
617 spin_unlock(&fc
->lock
);
621 fuse_invalidate_attr(inode
);
626 static ssize_t
fuse_direct_read(struct file
*file
, char __user
*buf
,
627 size_t count
, loff_t
*ppos
)
629 return fuse_direct_io(file
, buf
, count
, ppos
, 0);
632 static ssize_t
fuse_direct_write(struct file
*file
, const char __user
*buf
,
633 size_t count
, loff_t
*ppos
)
635 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
637 /* Don't allow parallel writes to the same file */
638 mutex_lock(&inode
->i_mutex
);
639 res
= generic_write_checks(file
, ppos
, &count
, 0);
641 res
= fuse_direct_io(file
, buf
, count
, ppos
, 1);
642 mutex_unlock(&inode
->i_mutex
);
646 static int fuse_file_mmap(struct file
*file
, struct vm_area_struct
*vma
)
648 if ((vma
->vm_flags
& VM_SHARED
)) {
649 if ((vma
->vm_flags
& VM_WRITE
))
652 vma
->vm_flags
&= ~VM_MAYWRITE
;
654 return generic_file_mmap(file
, vma
);
657 static int fuse_set_page_dirty(struct page
*page
)
659 printk("fuse_set_page_dirty: should not happen\n");
664 static int convert_fuse_file_lock(const struct fuse_file_lock
*ffl
,
665 struct file_lock
*fl
)
673 if (ffl
->start
> OFFSET_MAX
|| ffl
->end
> OFFSET_MAX
||
674 ffl
->end
< ffl
->start
)
677 fl
->fl_start
= ffl
->start
;
678 fl
->fl_end
= ffl
->end
;
679 fl
->fl_pid
= ffl
->pid
;
685 fl
->fl_type
= ffl
->type
;
689 static void fuse_lk_fill(struct fuse_req
*req
, struct file
*file
,
690 const struct file_lock
*fl
, int opcode
, pid_t pid
)
692 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
693 struct fuse_conn
*fc
= get_fuse_conn(inode
);
694 struct fuse_file
*ff
= file
->private_data
;
695 struct fuse_lk_in
*arg
= &req
->misc
.lk_in
;
698 arg
->owner
= fuse_lock_owner_id(fc
, fl
->fl_owner
);
699 arg
->lk
.start
= fl
->fl_start
;
700 arg
->lk
.end
= fl
->fl_end
;
701 arg
->lk
.type
= fl
->fl_type
;
703 req
->in
.h
.opcode
= opcode
;
704 req
->in
.h
.nodeid
= get_node_id(inode
);
706 req
->in
.args
[0].size
= sizeof(*arg
);
707 req
->in
.args
[0].value
= arg
;
710 static int fuse_getlk(struct file
*file
, struct file_lock
*fl
)
712 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
713 struct fuse_conn
*fc
= get_fuse_conn(inode
);
714 struct fuse_req
*req
;
715 struct fuse_lk_out outarg
;
718 req
= fuse_get_req(fc
);
722 fuse_lk_fill(req
, file
, fl
, FUSE_GETLK
, 0);
723 req
->out
.numargs
= 1;
724 req
->out
.args
[0].size
= sizeof(outarg
);
725 req
->out
.args
[0].value
= &outarg
;
726 request_send(fc
, req
);
727 err
= req
->out
.h
.error
;
728 fuse_put_request(fc
, req
);
730 err
= convert_fuse_file_lock(&outarg
.lk
, fl
);
735 static int fuse_setlk(struct file
*file
, struct file_lock
*fl
)
737 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
738 struct fuse_conn
*fc
= get_fuse_conn(inode
);
739 struct fuse_req
*req
;
740 int opcode
= (fl
->fl_flags
& FL_SLEEP
) ? FUSE_SETLKW
: FUSE_SETLK
;
741 pid_t pid
= fl
->fl_type
!= F_UNLCK
? current
->tgid
: 0;
744 /* Unlock on close is handled by the flush method */
745 if (fl
->fl_flags
& FL_CLOSE
)
748 req
= fuse_get_req(fc
);
752 fuse_lk_fill(req
, file
, fl
, opcode
, pid
);
753 request_send(fc
, req
);
754 err
= req
->out
.h
.error
;
755 /* locking is restartable */
758 fuse_put_request(fc
, req
);
762 static int fuse_file_lock(struct file
*file
, int cmd
, struct file_lock
*fl
)
764 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
765 struct fuse_conn
*fc
= get_fuse_conn(inode
);
768 if (cmd
== F_GETLK
) {
770 posix_test_lock(file
, fl
);
773 err
= fuse_getlk(file
, fl
);
776 err
= posix_lock_file_wait(file
, fl
);
778 err
= fuse_setlk(file
, fl
);
783 static sector_t
fuse_bmap(struct address_space
*mapping
, sector_t block
)
785 struct inode
*inode
= mapping
->host
;
786 struct fuse_conn
*fc
= get_fuse_conn(inode
);
787 struct fuse_req
*req
;
788 struct fuse_bmap_in inarg
;
789 struct fuse_bmap_out outarg
;
792 if (!inode
->i_sb
->s_bdev
|| fc
->no_bmap
)
795 req
= fuse_get_req(fc
);
799 memset(&inarg
, 0, sizeof(inarg
));
801 inarg
.blocksize
= inode
->i_sb
->s_blocksize
;
802 req
->in
.h
.opcode
= FUSE_BMAP
;
803 req
->in
.h
.nodeid
= get_node_id(inode
);
805 req
->in
.args
[0].size
= sizeof(inarg
);
806 req
->in
.args
[0].value
= &inarg
;
807 req
->out
.numargs
= 1;
808 req
->out
.args
[0].size
= sizeof(outarg
);
809 req
->out
.args
[0].value
= &outarg
;
810 request_send(fc
, req
);
811 err
= req
->out
.h
.error
;
812 fuse_put_request(fc
, req
);
816 return err
? 0 : outarg
.block
;
819 static const struct file_operations fuse_file_operations
= {
820 .llseek
= generic_file_llseek
,
821 .read
= do_sync_read
,
822 .aio_read
= generic_file_aio_read
,
823 .write
= do_sync_write
,
824 .aio_write
= generic_file_aio_write
,
825 .mmap
= fuse_file_mmap
,
828 .release
= fuse_release
,
830 .lock
= fuse_file_lock
,
831 .splice_read
= generic_file_splice_read
,
834 static const struct file_operations fuse_direct_io_file_operations
= {
835 .llseek
= generic_file_llseek
,
836 .read
= fuse_direct_read
,
837 .write
= fuse_direct_write
,
840 .release
= fuse_release
,
842 .lock
= fuse_file_lock
,
843 /* no mmap and splice_read */
846 static const struct address_space_operations fuse_file_aops
= {
847 .readpage
= fuse_readpage
,
848 .write_begin
= fuse_write_begin
,
849 .write_end
= fuse_write_end
,
850 .readpages
= fuse_readpages
,
851 .set_page_dirty
= fuse_set_page_dirty
,
855 void fuse_init_file_inode(struct inode
*inode
)
857 inode
->i_fop
= &fuse_file_operations
;
858 inode
->i_data
.a_ops
= &fuse_file_aops
;