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_release_end(struct fuse_conn
*fc
, struct fuse_req
*req
)
77 mntput(req
->vfsmount
);
78 fuse_put_request(fc
, req
);
81 static void fuse_file_put(struct fuse_file
*ff
)
83 if (atomic_dec_and_test(&ff
->count
)) {
84 struct fuse_req
*req
= ff
->reserved_req
;
85 struct fuse_conn
*fc
= get_fuse_conn(req
->dentry
->d_inode
);
86 req
->end
= fuse_release_end
;
87 request_send_background(fc
, req
);
92 void fuse_finish_open(struct inode
*inode
, struct file
*file
,
93 struct fuse_file
*ff
, struct fuse_open_out
*outarg
)
95 if (outarg
->open_flags
& FOPEN_DIRECT_IO
)
96 file
->f_op
= &fuse_direct_io_file_operations
;
97 if (!(outarg
->open_flags
& FOPEN_KEEP_CACHE
))
98 invalidate_inode_pages2(inode
->i_mapping
);
100 file
->private_data
= fuse_file_get(ff
);
103 int fuse_open_common(struct inode
*inode
, struct file
*file
, int isdir
)
105 struct fuse_open_out outarg
;
106 struct fuse_file
*ff
;
109 /* VFS checks this, but only _after_ ->open() */
110 if (file
->f_flags
& O_DIRECT
)
113 err
= generic_file_open(inode
, file
);
117 ff
= fuse_file_alloc();
121 err
= fuse_send_open(inode
, file
, isdir
, &outarg
);
126 outarg
.open_flags
&= ~FOPEN_DIRECT_IO
;
127 fuse_finish_open(inode
, file
, ff
, &outarg
);
133 void fuse_release_fill(struct fuse_file
*ff
, u64 nodeid
, int flags
, int opcode
)
135 struct fuse_req
*req
= ff
->reserved_req
;
136 struct fuse_release_in
*inarg
= &req
->misc
.release_in
;
139 inarg
->flags
= flags
;
140 req
->in
.h
.opcode
= opcode
;
141 req
->in
.h
.nodeid
= nodeid
;
143 req
->in
.args
[0].size
= sizeof(struct fuse_release_in
);
144 req
->in
.args
[0].value
= inarg
;
147 int fuse_release_common(struct inode
*inode
, struct file
*file
, int isdir
)
149 struct fuse_file
*ff
= file
->private_data
;
151 fuse_release_fill(ff
, get_node_id(inode
), file
->f_flags
,
152 isdir
? FUSE_RELEASEDIR
: FUSE_RELEASE
);
154 /* Hold vfsmount and dentry until release is finished */
155 ff
->reserved_req
->vfsmount
= mntget(file
->f_path
.mnt
);
156 ff
->reserved_req
->dentry
= dget(file
->f_path
.dentry
);
158 * Normally this will send the RELEASE request,
159 * however if some asynchronous READ or WRITE requests
160 * are outstanding, the sending will be delayed
165 /* Return value is ignored by VFS */
169 static int fuse_open(struct inode
*inode
, struct file
*file
)
171 return fuse_open_common(inode
, file
, 0);
174 static int fuse_release(struct inode
*inode
, struct file
*file
)
176 return fuse_release_common(inode
, file
, 0);
180 * Scramble the ID space with XTEA, so that the value of the files_struct
181 * pointer is not exposed to userspace.
183 static u64
fuse_lock_owner_id(struct fuse_conn
*fc
, fl_owner_t id
)
185 u32
*k
= fc
->scramble_key
;
186 u64 v
= (unsigned long) id
;
192 for (i
= 0; i
< 32; i
++) {
193 v0
+= ((v1
<< 4 ^ v1
>> 5) + v1
) ^ (sum
+ k
[sum
& 3]);
195 v1
+= ((v0
<< 4 ^ v0
>> 5) + v0
) ^ (sum
+ k
[sum
>>11 & 3]);
198 return (u64
) v0
+ ((u64
) v1
<< 32);
201 static int fuse_flush(struct file
*file
, fl_owner_t id
)
203 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
204 struct fuse_conn
*fc
= get_fuse_conn(inode
);
205 struct fuse_file
*ff
= file
->private_data
;
206 struct fuse_req
*req
;
207 struct fuse_flush_in inarg
;
210 if (is_bad_inode(inode
))
216 req
= fuse_get_req_nofail(fc
, file
);
217 memset(&inarg
, 0, sizeof(inarg
));
219 inarg
.lock_owner
= fuse_lock_owner_id(fc
, id
);
220 req
->in
.h
.opcode
= FUSE_FLUSH
;
221 req
->in
.h
.nodeid
= get_node_id(inode
);
223 req
->in
.args
[0].size
= sizeof(inarg
);
224 req
->in
.args
[0].value
= &inarg
;
226 request_send(fc
, req
);
227 err
= req
->out
.h
.error
;
228 fuse_put_request(fc
, req
);
229 if (err
== -ENOSYS
) {
236 int fuse_fsync_common(struct file
*file
, struct dentry
*de
, int datasync
,
239 struct inode
*inode
= de
->d_inode
;
240 struct fuse_conn
*fc
= get_fuse_conn(inode
);
241 struct fuse_file
*ff
= file
->private_data
;
242 struct fuse_req
*req
;
243 struct fuse_fsync_in inarg
;
246 if (is_bad_inode(inode
))
249 if ((!isdir
&& fc
->no_fsync
) || (isdir
&& fc
->no_fsyncdir
))
252 req
= fuse_get_req(fc
);
256 memset(&inarg
, 0, sizeof(inarg
));
258 inarg
.fsync_flags
= datasync
? 1 : 0;
259 req
->in
.h
.opcode
= isdir
? FUSE_FSYNCDIR
: FUSE_FSYNC
;
260 req
->in
.h
.nodeid
= get_node_id(inode
);
262 req
->in
.args
[0].size
= sizeof(inarg
);
263 req
->in
.args
[0].value
= &inarg
;
264 request_send(fc
, req
);
265 err
= req
->out
.h
.error
;
266 fuse_put_request(fc
, req
);
267 if (err
== -ENOSYS
) {
277 static int fuse_fsync(struct file
*file
, struct dentry
*de
, int datasync
)
279 return fuse_fsync_common(file
, de
, datasync
, 0);
282 void fuse_read_fill(struct fuse_req
*req
, struct fuse_file
*ff
,
283 struct inode
*inode
, loff_t pos
, size_t count
, int opcode
)
285 struct fuse_read_in
*inarg
= &req
->misc
.read_in
;
290 req
->in
.h
.opcode
= opcode
;
291 req
->in
.h
.nodeid
= get_node_id(inode
);
293 req
->in
.args
[0].size
= sizeof(struct fuse_read_in
);
294 req
->in
.args
[0].value
= inarg
;
295 req
->out
.argpages
= 1;
297 req
->out
.numargs
= 1;
298 req
->out
.args
[0].size
= count
;
301 static size_t fuse_send_read(struct fuse_req
*req
, struct file
*file
,
302 struct inode
*inode
, loff_t pos
, size_t count
)
304 struct fuse_conn
*fc
= get_fuse_conn(inode
);
305 struct fuse_file
*ff
= file
->private_data
;
306 fuse_read_fill(req
, ff
, inode
, pos
, count
, FUSE_READ
);
307 request_send(fc
, req
);
308 return req
->out
.args
[0].size
;
311 static int fuse_readpage(struct file
*file
, struct page
*page
)
313 struct inode
*inode
= page
->mapping
->host
;
314 struct fuse_conn
*fc
= get_fuse_conn(inode
);
315 struct fuse_req
*req
;
319 if (is_bad_inode(inode
))
322 req
= fuse_get_req(fc
);
327 req
->out
.page_zeroing
= 1;
329 req
->pages
[0] = page
;
330 fuse_send_read(req
, file
, inode
, page_offset(page
), PAGE_CACHE_SIZE
);
331 err
= req
->out
.h
.error
;
332 fuse_put_request(fc
, req
);
334 SetPageUptodate(page
);
335 fuse_invalidate_attr(inode
); /* atime changed */
341 static void fuse_readpages_end(struct fuse_conn
*fc
, struct fuse_req
*req
)
345 fuse_invalidate_attr(req
->pages
[0]->mapping
->host
); /* atime changed */
347 for (i
= 0; i
< req
->num_pages
; i
++) {
348 struct page
*page
= req
->pages
[i
];
349 if (!req
->out
.h
.error
)
350 SetPageUptodate(page
);
356 fuse_file_put(req
->ff
);
357 fuse_put_request(fc
, req
);
360 static void fuse_send_readpages(struct fuse_req
*req
, struct fuse_file
*ff
,
363 struct fuse_conn
*fc
= get_fuse_conn(inode
);
364 loff_t pos
= page_offset(req
->pages
[0]);
365 size_t count
= req
->num_pages
<< PAGE_CACHE_SHIFT
;
366 req
->out
.page_zeroing
= 1;
367 fuse_read_fill(req
, ff
, inode
, pos
, count
, FUSE_READ
);
368 if (fc
->async_read
) {
369 req
->ff
= fuse_file_get(ff
);
370 req
->end
= fuse_readpages_end
;
371 request_send_background(fc
, req
);
373 request_send(fc
, req
);
374 fuse_readpages_end(fc
, req
);
378 struct fuse_fill_data
{
379 struct fuse_req
*req
;
380 struct fuse_file
*ff
;
384 static int fuse_readpages_fill(void *_data
, struct page
*page
)
386 struct fuse_fill_data
*data
= _data
;
387 struct fuse_req
*req
= data
->req
;
388 struct inode
*inode
= data
->inode
;
389 struct fuse_conn
*fc
= get_fuse_conn(inode
);
391 if (req
->num_pages
&&
392 (req
->num_pages
== FUSE_MAX_PAGES_PER_REQ
||
393 (req
->num_pages
+ 1) * PAGE_CACHE_SIZE
> fc
->max_read
||
394 req
->pages
[req
->num_pages
- 1]->index
+ 1 != page
->index
)) {
395 fuse_send_readpages(req
, data
->ff
, inode
);
396 data
->req
= req
= fuse_get_req(fc
);
402 req
->pages
[req
->num_pages
] = page
;
407 static int fuse_readpages(struct file
*file
, struct address_space
*mapping
,
408 struct list_head
*pages
, unsigned nr_pages
)
410 struct inode
*inode
= mapping
->host
;
411 struct fuse_conn
*fc
= get_fuse_conn(inode
);
412 struct fuse_fill_data data
;
416 if (is_bad_inode(inode
))
419 data
.ff
= file
->private_data
;
421 data
.req
= fuse_get_req(fc
);
422 err
= PTR_ERR(data
.req
);
423 if (IS_ERR(data
.req
))
426 err
= read_cache_pages(mapping
, pages
, fuse_readpages_fill
, &data
);
428 if (data
.req
->num_pages
)
429 fuse_send_readpages(data
.req
, data
.ff
, inode
);
431 fuse_put_request(fc
, data
.req
);
437 static size_t fuse_send_write(struct fuse_req
*req
, struct file
*file
,
438 struct inode
*inode
, loff_t pos
, size_t count
)
440 struct fuse_conn
*fc
= get_fuse_conn(inode
);
441 struct fuse_file
*ff
= file
->private_data
;
442 struct fuse_write_in inarg
;
443 struct fuse_write_out outarg
;
445 memset(&inarg
, 0, sizeof(struct fuse_write_in
));
449 req
->in
.h
.opcode
= FUSE_WRITE
;
450 req
->in
.h
.nodeid
= get_node_id(inode
);
451 req
->in
.argpages
= 1;
453 req
->in
.args
[0].size
= sizeof(struct fuse_write_in
);
454 req
->in
.args
[0].value
= &inarg
;
455 req
->in
.args
[1].size
= count
;
456 req
->out
.numargs
= 1;
457 req
->out
.args
[0].size
= sizeof(struct fuse_write_out
);
458 req
->out
.args
[0].value
= &outarg
;
459 request_send(fc
, req
);
463 static int fuse_write_begin(struct file
*file
, struct address_space
*mapping
,
464 loff_t pos
, unsigned len
, unsigned flags
,
465 struct page
**pagep
, void **fsdata
)
467 pgoff_t index
= pos
>> PAGE_CACHE_SHIFT
;
469 *pagep
= __grab_cache_page(mapping
, index
);
475 static int fuse_buffered_write(struct file
*file
, struct inode
*inode
,
476 loff_t pos
, unsigned count
, struct page
*page
)
480 struct fuse_conn
*fc
= get_fuse_conn(inode
);
481 struct fuse_inode
*fi
= get_fuse_inode(inode
);
482 unsigned offset
= pos
& (PAGE_CACHE_SIZE
- 1);
483 struct fuse_req
*req
;
485 if (is_bad_inode(inode
))
488 req
= fuse_get_req(fc
);
493 req
->pages
[0] = page
;
494 req
->page_offset
= offset
;
495 nres
= fuse_send_write(req
, file
, inode
, pos
, count
);
496 err
= req
->out
.h
.error
;
497 fuse_put_request(fc
, req
);
502 spin_lock(&fc
->lock
);
503 fi
->attr_version
= ++fc
->attr_version
;
504 if (pos
> inode
->i_size
)
505 i_size_write(inode
, pos
);
506 spin_unlock(&fc
->lock
);
508 if (count
== PAGE_CACHE_SIZE
)
509 SetPageUptodate(page
);
511 fuse_invalidate_attr(inode
);
512 return err
? err
: nres
;
515 static int fuse_write_end(struct file
*file
, struct address_space
*mapping
,
516 loff_t pos
, unsigned len
, unsigned copied
,
517 struct page
*page
, void *fsdata
)
519 struct inode
*inode
= mapping
->host
;
523 res
= fuse_buffered_write(file
, inode
, pos
, copied
, page
);
526 page_cache_release(page
);
530 static void fuse_release_user_pages(struct fuse_req
*req
, int write
)
534 for (i
= 0; i
< req
->num_pages
; i
++) {
535 struct page
*page
= req
->pages
[i
];
537 set_page_dirty_lock(page
);
542 static int fuse_get_user_pages(struct fuse_req
*req
, const char __user
*buf
,
543 unsigned nbytes
, int write
)
545 unsigned long user_addr
= (unsigned long) buf
;
546 unsigned offset
= user_addr
& ~PAGE_MASK
;
549 /* This doesn't work with nfsd */
553 nbytes
= min(nbytes
, (unsigned) FUSE_MAX_PAGES_PER_REQ
<< PAGE_SHIFT
);
554 npages
= (nbytes
+ offset
+ PAGE_SIZE
- 1) >> PAGE_SHIFT
;
555 npages
= min(max(npages
, 1), FUSE_MAX_PAGES_PER_REQ
);
556 down_read(¤t
->mm
->mmap_sem
);
557 npages
= get_user_pages(current
, current
->mm
, user_addr
, npages
, write
,
558 0, req
->pages
, NULL
);
559 up_read(¤t
->mm
->mmap_sem
);
563 req
->num_pages
= npages
;
564 req
->page_offset
= offset
;
568 static ssize_t
fuse_direct_io(struct file
*file
, const char __user
*buf
,
569 size_t count
, loff_t
*ppos
, int write
)
571 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
572 struct fuse_conn
*fc
= get_fuse_conn(inode
);
573 size_t nmax
= write
? fc
->max_write
: fc
->max_read
;
576 struct fuse_req
*req
;
578 if (is_bad_inode(inode
))
581 req
= fuse_get_req(fc
);
587 size_t nbytes
= min(count
, nmax
);
588 int err
= fuse_get_user_pages(req
, buf
, nbytes
, !write
);
593 nbytes
= (req
->num_pages
<< PAGE_SHIFT
) - req
->page_offset
;
594 nbytes
= min(count
, nbytes
);
596 nres
= fuse_send_write(req
, file
, inode
, pos
, nbytes
);
598 nres
= fuse_send_read(req
, file
, inode
, pos
, nbytes
);
599 fuse_release_user_pages(req
, !write
);
600 if (req
->out
.h
.error
) {
602 res
= req
->out
.h
.error
;
604 } else if (nres
> nbytes
) {
615 fuse_put_request(fc
, req
);
616 req
= fuse_get_req(fc
);
621 fuse_put_request(fc
, req
);
624 spin_lock(&fc
->lock
);
625 if (pos
> inode
->i_size
)
626 i_size_write(inode
, pos
);
627 spin_unlock(&fc
->lock
);
631 fuse_invalidate_attr(inode
);
636 static ssize_t
fuse_direct_read(struct file
*file
, char __user
*buf
,
637 size_t count
, loff_t
*ppos
)
639 return fuse_direct_io(file
, buf
, count
, ppos
, 0);
642 static ssize_t
fuse_direct_write(struct file
*file
, const char __user
*buf
,
643 size_t count
, loff_t
*ppos
)
645 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
647 /* Don't allow parallel writes to the same file */
648 mutex_lock(&inode
->i_mutex
);
649 res
= generic_write_checks(file
, ppos
, &count
, 0);
651 res
= fuse_direct_io(file
, buf
, count
, ppos
, 1);
652 mutex_unlock(&inode
->i_mutex
);
656 static int fuse_file_mmap(struct file
*file
, struct vm_area_struct
*vma
)
658 if ((vma
->vm_flags
& VM_SHARED
)) {
659 if ((vma
->vm_flags
& VM_WRITE
))
662 vma
->vm_flags
&= ~VM_MAYWRITE
;
664 return generic_file_mmap(file
, vma
);
667 static int fuse_set_page_dirty(struct page
*page
)
669 printk("fuse_set_page_dirty: should not happen\n");
674 static int convert_fuse_file_lock(const struct fuse_file_lock
*ffl
,
675 struct file_lock
*fl
)
683 if (ffl
->start
> OFFSET_MAX
|| ffl
->end
> OFFSET_MAX
||
684 ffl
->end
< ffl
->start
)
687 fl
->fl_start
= ffl
->start
;
688 fl
->fl_end
= ffl
->end
;
689 fl
->fl_pid
= ffl
->pid
;
695 fl
->fl_type
= ffl
->type
;
699 static void fuse_lk_fill(struct fuse_req
*req
, struct file
*file
,
700 const struct file_lock
*fl
, int opcode
, pid_t pid
)
702 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
703 struct fuse_conn
*fc
= get_fuse_conn(inode
);
704 struct fuse_file
*ff
= file
->private_data
;
705 struct fuse_lk_in
*arg
= &req
->misc
.lk_in
;
708 arg
->owner
= fuse_lock_owner_id(fc
, fl
->fl_owner
);
709 arg
->lk
.start
= fl
->fl_start
;
710 arg
->lk
.end
= fl
->fl_end
;
711 arg
->lk
.type
= fl
->fl_type
;
713 req
->in
.h
.opcode
= opcode
;
714 req
->in
.h
.nodeid
= get_node_id(inode
);
716 req
->in
.args
[0].size
= sizeof(*arg
);
717 req
->in
.args
[0].value
= arg
;
720 static int fuse_getlk(struct file
*file
, struct file_lock
*fl
)
722 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
723 struct fuse_conn
*fc
= get_fuse_conn(inode
);
724 struct fuse_req
*req
;
725 struct fuse_lk_out outarg
;
728 req
= fuse_get_req(fc
);
732 fuse_lk_fill(req
, file
, fl
, FUSE_GETLK
, 0);
733 req
->out
.numargs
= 1;
734 req
->out
.args
[0].size
= sizeof(outarg
);
735 req
->out
.args
[0].value
= &outarg
;
736 request_send(fc
, req
);
737 err
= req
->out
.h
.error
;
738 fuse_put_request(fc
, req
);
740 err
= convert_fuse_file_lock(&outarg
.lk
, fl
);
745 static int fuse_setlk(struct file
*file
, struct file_lock
*fl
)
747 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
748 struct fuse_conn
*fc
= get_fuse_conn(inode
);
749 struct fuse_req
*req
;
750 int opcode
= (fl
->fl_flags
& FL_SLEEP
) ? FUSE_SETLKW
: FUSE_SETLK
;
751 pid_t pid
= fl
->fl_type
!= F_UNLCK
? current
->tgid
: 0;
754 /* Unlock on close is handled by the flush method */
755 if (fl
->fl_flags
& FL_CLOSE
)
758 req
= fuse_get_req(fc
);
762 fuse_lk_fill(req
, file
, fl
, opcode
, pid
);
763 request_send(fc
, req
);
764 err
= req
->out
.h
.error
;
765 /* locking is restartable */
768 fuse_put_request(fc
, req
);
772 static int fuse_file_lock(struct file
*file
, int cmd
, struct file_lock
*fl
)
774 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
775 struct fuse_conn
*fc
= get_fuse_conn(inode
);
778 if (cmd
== F_GETLK
) {
780 posix_test_lock(file
, fl
);
783 err
= fuse_getlk(file
, fl
);
786 err
= posix_lock_file_wait(file
, fl
);
788 err
= fuse_setlk(file
, fl
);
793 static sector_t
fuse_bmap(struct address_space
*mapping
, sector_t block
)
795 struct inode
*inode
= mapping
->host
;
796 struct fuse_conn
*fc
= get_fuse_conn(inode
);
797 struct fuse_req
*req
;
798 struct fuse_bmap_in inarg
;
799 struct fuse_bmap_out outarg
;
802 if (!inode
->i_sb
->s_bdev
|| fc
->no_bmap
)
805 req
= fuse_get_req(fc
);
809 memset(&inarg
, 0, sizeof(inarg
));
811 inarg
.blocksize
= inode
->i_sb
->s_blocksize
;
812 req
->in
.h
.opcode
= FUSE_BMAP
;
813 req
->in
.h
.nodeid
= get_node_id(inode
);
815 req
->in
.args
[0].size
= sizeof(inarg
);
816 req
->in
.args
[0].value
= &inarg
;
817 req
->out
.numargs
= 1;
818 req
->out
.args
[0].size
= sizeof(outarg
);
819 req
->out
.args
[0].value
= &outarg
;
820 request_send(fc
, req
);
821 err
= req
->out
.h
.error
;
822 fuse_put_request(fc
, req
);
826 return err
? 0 : outarg
.block
;
829 static const struct file_operations fuse_file_operations
= {
830 .llseek
= generic_file_llseek
,
831 .read
= do_sync_read
,
832 .aio_read
= generic_file_aio_read
,
833 .write
= do_sync_write
,
834 .aio_write
= generic_file_aio_write
,
835 .mmap
= fuse_file_mmap
,
838 .release
= fuse_release
,
840 .lock
= fuse_file_lock
,
841 .splice_read
= generic_file_splice_read
,
844 static const struct file_operations fuse_direct_io_file_operations
= {
845 .llseek
= generic_file_llseek
,
846 .read
= fuse_direct_read
,
847 .write
= fuse_direct_write
,
850 .release
= fuse_release
,
852 .lock
= fuse_file_lock
,
853 /* no mmap and splice_read */
856 static const struct address_space_operations fuse_file_aops
= {
857 .readpage
= fuse_readpage
,
858 .write_begin
= fuse_write_begin
,
859 .write_end
= fuse_write_end
,
860 .readpages
= fuse_readpages
,
861 .set_page_dirty
= fuse_set_page_dirty
,
865 void fuse_init_file_inode(struct inode
*inode
)
867 inode
->i_fop
= &fuse_file_operations
;
868 inode
->i_data
.a_ops
= &fuse_file_aops
;