Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | FUSE: Filesystem in Userspace |
Miklos Szeredi | 56cf34f | 2006-04-11 21:16:51 +0200 | [diff] [blame] | 3 | Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu> |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 4 | |
| 5 | This program can be distributed under the terms of the GNU GPL. |
| 6 | See the file COPYING. |
| 7 | */ |
| 8 | |
| 9 | #include "fuse_i.h" |
| 10 | |
| 11 | #include <linux/pagemap.h> |
| 12 | #include <linux/slab.h> |
| 13 | #include <linux/kernel.h> |
| 14 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 15 | static const struct file_operations fuse_direct_io_file_operations; |
Miklos Szeredi | 45323fb | 2005-09-09 13:10:37 -0700 | [diff] [blame] | 16 | |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 17 | static int fuse_send_open(struct inode *inode, struct file *file, int isdir, |
| 18 | struct fuse_open_out *outargp) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 19 | { |
| 20 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 21 | struct fuse_open_in inarg; |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 22 | struct fuse_req *req; |
| 23 | int err; |
| 24 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 25 | req = fuse_get_req(fc); |
| 26 | if (IS_ERR(req)) |
| 27 | return PTR_ERR(req); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 28 | |
| 29 | memset(&inarg, 0, sizeof(inarg)); |
| 30 | inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); |
| 31 | req->in.h.opcode = isdir ? FUSE_OPENDIR : FUSE_OPEN; |
| 32 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 33 | req->in.numargs = 1; |
| 34 | req->in.args[0].size = sizeof(inarg); |
| 35 | req->in.args[0].value = &inarg; |
| 36 | req->out.numargs = 1; |
| 37 | req->out.args[0].size = sizeof(*outargp); |
| 38 | req->out.args[0].value = outargp; |
| 39 | request_send(fc, req); |
| 40 | err = req->out.h.error; |
| 41 | fuse_put_request(fc, req); |
| 42 | |
| 43 | return err; |
| 44 | } |
| 45 | |
| 46 | struct fuse_file *fuse_file_alloc(void) |
| 47 | { |
| 48 | struct fuse_file *ff; |
| 49 | ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL); |
| 50 | if (ff) { |
| 51 | ff->release_req = fuse_request_alloc(); |
| 52 | if (!ff->release_req) { |
| 53 | kfree(ff); |
| 54 | ff = NULL; |
| 55 | } |
| 56 | } |
| 57 | return ff; |
| 58 | } |
| 59 | |
| 60 | void fuse_file_free(struct fuse_file *ff) |
| 61 | { |
| 62 | fuse_request_free(ff->release_req); |
| 63 | kfree(ff); |
| 64 | } |
| 65 | |
| 66 | void fuse_finish_open(struct inode *inode, struct file *file, |
| 67 | struct fuse_file *ff, struct fuse_open_out *outarg) |
| 68 | { |
| 69 | if (outarg->open_flags & FOPEN_DIRECT_IO) |
| 70 | file->f_op = &fuse_direct_io_file_operations; |
| 71 | if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) |
| 72 | invalidate_inode_pages(inode->i_mapping); |
| 73 | ff->fh = outarg->fh; |
| 74 | file->private_data = ff; |
| 75 | } |
| 76 | |
| 77 | int fuse_open_common(struct inode *inode, struct file *file, int isdir) |
| 78 | { |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 79 | struct fuse_open_out outarg; |
| 80 | struct fuse_file *ff; |
| 81 | int err; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 82 | |
Miklos Szeredi | dd190d0 | 2005-09-30 11:59:02 -0700 | [diff] [blame] | 83 | /* VFS checks this, but only _after_ ->open() */ |
| 84 | if (file->f_flags & O_DIRECT) |
| 85 | return -EINVAL; |
| 86 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 87 | err = generic_file_open(inode, file); |
| 88 | if (err) |
| 89 | return err; |
| 90 | |
| 91 | /* If opening the root node, no lookup has been performed on |
| 92 | it, so the attributes must be refreshed */ |
| 93 | if (get_node_id(inode) == FUSE_ROOT_ID) { |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 94 | err = fuse_do_getattr(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 95 | if (err) |
| 96 | return err; |
| 97 | } |
| 98 | |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 99 | ff = fuse_file_alloc(); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 100 | if (!ff) |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 101 | return -ENOMEM; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 102 | |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 103 | err = fuse_send_open(inode, file, isdir, &outarg); |
| 104 | if (err) |
| 105 | fuse_file_free(ff); |
| 106 | else { |
| 107 | if (isdir) |
| 108 | outarg.open_flags &= ~FOPEN_DIRECT_IO; |
| 109 | fuse_finish_open(inode, file, ff, &outarg); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 112 | return err; |
| 113 | } |
| 114 | |
Miklos Szeredi | 51eb01e | 2006-06-25 05:48:50 -0700 | [diff] [blame] | 115 | struct fuse_req *fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, |
| 116 | int opcode) |
Miklos Szeredi | 64c6d8e | 2006-01-16 22:14:42 -0800 | [diff] [blame] | 117 | { |
Miklos Szeredi | 51eb01e | 2006-06-25 05:48:50 -0700 | [diff] [blame] | 118 | struct fuse_req *req = ff->release_req; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 119 | struct fuse_release_in *inarg = &req->misc.release_in; |
| 120 | |
| 121 | inarg->fh = ff->fh; |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 122 | inarg->flags = flags; |
Miklos Szeredi | 51eb01e | 2006-06-25 05:48:50 -0700 | [diff] [blame] | 123 | req->in.h.opcode = opcode; |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 124 | req->in.h.nodeid = nodeid; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 125 | req->in.numargs = 1; |
| 126 | req->in.args[0].size = sizeof(struct fuse_release_in); |
| 127 | req->in.args[0].value = inarg; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 128 | kfree(ff); |
Miklos Szeredi | 51eb01e | 2006-06-25 05:48:50 -0700 | [diff] [blame] | 129 | |
| 130 | return req; |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | int fuse_release_common(struct inode *inode, struct file *file, int isdir) |
| 134 | { |
| 135 | struct fuse_file *ff = file->private_data; |
| 136 | if (ff) { |
| 137 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | 51eb01e | 2006-06-25 05:48:50 -0700 | [diff] [blame] | 138 | struct fuse_req *req; |
| 139 | |
| 140 | req = fuse_release_fill(ff, get_node_id(inode), file->f_flags, |
| 141 | isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); |
| 142 | |
| 143 | /* Hold vfsmount and dentry until release is finished */ |
| 144 | req->vfsmount = mntget(file->f_vfsmnt); |
| 145 | req->dentry = dget(file->f_dentry); |
| 146 | request_send_background(fc, req); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 147 | } |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 148 | |
| 149 | /* Return value is ignored by VFS */ |
| 150 | return 0; |
| 151 | } |
| 152 | |
Miklos Szeredi | 04730fe | 2005-09-09 13:10:36 -0700 | [diff] [blame] | 153 | static int fuse_open(struct inode *inode, struct file *file) |
| 154 | { |
| 155 | return fuse_open_common(inode, file, 0); |
| 156 | } |
| 157 | |
| 158 | static int fuse_release(struct inode *inode, struct file *file) |
| 159 | { |
| 160 | return fuse_release_common(inode, file, 0); |
| 161 | } |
| 162 | |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame^] | 163 | /* |
| 164 | * It would be nice to scramble the ID space, so that the value of the |
| 165 | * files_struct pointer is not exposed to userspace. Symmetric crypto |
| 166 | * functions are overkill, since the inverse function doesn't need to |
| 167 | * be implemented (though it does have to exist). Is there something |
| 168 | * simpler? |
| 169 | */ |
| 170 | static inline u64 fuse_lock_owner_id(fl_owner_t id) |
| 171 | { |
| 172 | return (unsigned long) id; |
| 173 | } |
| 174 | |
Miklos Szeredi | 75e1fcc | 2006-06-23 02:05:12 -0700 | [diff] [blame] | 175 | static int fuse_flush(struct file *file, fl_owner_t id) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 176 | { |
| 177 | struct inode *inode = file->f_dentry->d_inode; |
| 178 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 179 | struct fuse_file *ff = file->private_data; |
| 180 | struct fuse_req *req; |
| 181 | struct fuse_flush_in inarg; |
| 182 | int err; |
| 183 | |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 184 | if (is_bad_inode(inode)) |
| 185 | return -EIO; |
| 186 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 187 | if (fc->no_flush) |
| 188 | return 0; |
| 189 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 190 | req = fuse_get_req(fc); |
| 191 | if (IS_ERR(req)) |
| 192 | return PTR_ERR(req); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 193 | |
| 194 | memset(&inarg, 0, sizeof(inarg)); |
| 195 | inarg.fh = ff->fh; |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame^] | 196 | inarg.lock_owner = fuse_lock_owner_id(id); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 197 | req->in.h.opcode = FUSE_FLUSH; |
| 198 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 199 | req->in.numargs = 1; |
| 200 | req->in.args[0].size = sizeof(inarg); |
| 201 | req->in.args[0].value = &inarg; |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame^] | 202 | req->force = 1; |
Miklos Szeredi | 7c352bd | 2005-09-09 13:10:39 -0700 | [diff] [blame] | 203 | request_send(fc, req); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 204 | err = req->out.h.error; |
| 205 | fuse_put_request(fc, req); |
| 206 | if (err == -ENOSYS) { |
| 207 | fc->no_flush = 1; |
| 208 | err = 0; |
| 209 | } |
| 210 | return err; |
| 211 | } |
| 212 | |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 213 | int fuse_fsync_common(struct file *file, struct dentry *de, int datasync, |
| 214 | int isdir) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 215 | { |
| 216 | struct inode *inode = de->d_inode; |
| 217 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 218 | struct fuse_file *ff = file->private_data; |
| 219 | struct fuse_req *req; |
| 220 | struct fuse_fsync_in inarg; |
| 221 | int err; |
| 222 | |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 223 | if (is_bad_inode(inode)) |
| 224 | return -EIO; |
| 225 | |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 226 | if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir)) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 227 | return 0; |
| 228 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 229 | req = fuse_get_req(fc); |
| 230 | if (IS_ERR(req)) |
| 231 | return PTR_ERR(req); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 232 | |
| 233 | memset(&inarg, 0, sizeof(inarg)); |
| 234 | inarg.fh = ff->fh; |
| 235 | inarg.fsync_flags = datasync ? 1 : 0; |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 236 | req->in.h.opcode = isdir ? FUSE_FSYNCDIR : FUSE_FSYNC; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 237 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 238 | req->in.numargs = 1; |
| 239 | req->in.args[0].size = sizeof(inarg); |
| 240 | req->in.args[0].value = &inarg; |
| 241 | request_send(fc, req); |
| 242 | err = req->out.h.error; |
| 243 | fuse_put_request(fc, req); |
| 244 | if (err == -ENOSYS) { |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 245 | if (isdir) |
| 246 | fc->no_fsyncdir = 1; |
| 247 | else |
| 248 | fc->no_fsync = 1; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 249 | err = 0; |
| 250 | } |
| 251 | return err; |
| 252 | } |
| 253 | |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 254 | static int fuse_fsync(struct file *file, struct dentry *de, int datasync) |
| 255 | { |
| 256 | return fuse_fsync_common(file, de, datasync, 0); |
| 257 | } |
| 258 | |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 259 | void fuse_read_fill(struct fuse_req *req, struct file *file, |
| 260 | struct inode *inode, loff_t pos, size_t count, int opcode) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 261 | { |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 262 | struct fuse_file *ff = file->private_data; |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 263 | struct fuse_read_in *inarg = &req->misc.read_in; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 264 | |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 265 | inarg->fh = ff->fh; |
| 266 | inarg->offset = pos; |
| 267 | inarg->size = count; |
| 268 | req->in.h.opcode = opcode; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 269 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 270 | req->in.numargs = 1; |
| 271 | req->in.args[0].size = sizeof(struct fuse_read_in); |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 272 | req->in.args[0].value = inarg; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 273 | req->out.argpages = 1; |
| 274 | req->out.argvar = 1; |
| 275 | req->out.numargs = 1; |
| 276 | req->out.args[0].size = count; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 277 | } |
| 278 | |
Miklos Szeredi | 8bfc016 | 2006-01-16 22:14:28 -0800 | [diff] [blame] | 279 | static size_t fuse_send_read(struct fuse_req *req, struct file *file, |
| 280 | struct inode *inode, loff_t pos, size_t count) |
Miklos Szeredi | 04730fe | 2005-09-09 13:10:36 -0700 | [diff] [blame] | 281 | { |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 282 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 283 | fuse_read_fill(req, file, inode, pos, count, FUSE_READ); |
| 284 | request_send(fc, req); |
| 285 | return req->out.args[0].size; |
Miklos Szeredi | 04730fe | 2005-09-09 13:10:36 -0700 | [diff] [blame] | 286 | } |
| 287 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 288 | static int fuse_readpage(struct file *file, struct page *page) |
| 289 | { |
| 290 | struct inode *inode = page->mapping->host; |
| 291 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 292 | struct fuse_req *req; |
| 293 | int err; |
| 294 | |
| 295 | err = -EIO; |
| 296 | if (is_bad_inode(inode)) |
| 297 | goto out; |
| 298 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 299 | req = fuse_get_req(fc); |
| 300 | err = PTR_ERR(req); |
| 301 | if (IS_ERR(req)) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 302 | goto out; |
| 303 | |
| 304 | req->out.page_zeroing = 1; |
| 305 | req->num_pages = 1; |
| 306 | req->pages[0] = page; |
Miklos Szeredi | 4633a22 | 2006-01-06 00:19:36 -0800 | [diff] [blame] | 307 | fuse_send_read(req, file, inode, page_offset(page), PAGE_CACHE_SIZE); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 308 | err = req->out.h.error; |
| 309 | fuse_put_request(fc, req); |
| 310 | if (!err) |
| 311 | SetPageUptodate(page); |
Miklos Szeredi | b36c31b | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 312 | fuse_invalidate_attr(inode); /* atime changed */ |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 313 | out: |
| 314 | unlock_page(page); |
| 315 | return err; |
| 316 | } |
| 317 | |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 318 | static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req) |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 319 | { |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 320 | int i; |
| 321 | |
| 322 | fuse_invalidate_attr(req->pages[0]->mapping->host); /* atime changed */ |
| 323 | |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 324 | for (i = 0; i < req->num_pages; i++) { |
| 325 | struct page *page = req->pages[i]; |
| 326 | if (!req->out.h.error) |
| 327 | SetPageUptodate(page); |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 328 | else |
| 329 | SetPageError(page); |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 330 | unlock_page(page); |
| 331 | } |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 332 | fuse_put_request(fc, req); |
| 333 | } |
| 334 | |
| 335 | static void fuse_send_readpages(struct fuse_req *req, struct file *file, |
| 336 | struct inode *inode) |
| 337 | { |
| 338 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 339 | loff_t pos = page_offset(req->pages[0]); |
| 340 | size_t count = req->num_pages << PAGE_CACHE_SHIFT; |
| 341 | req->out.page_zeroing = 1; |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 342 | fuse_read_fill(req, file, inode, pos, count, FUSE_READ); |
Miklos Szeredi | 9cd6845 | 2006-02-01 03:04:40 -0800 | [diff] [blame] | 343 | if (fc->async_read) { |
Miklos Szeredi | 51eb01e | 2006-06-25 05:48:50 -0700 | [diff] [blame] | 344 | get_file(file); |
| 345 | req->file = file; |
Miklos Szeredi | 9cd6845 | 2006-02-01 03:04:40 -0800 | [diff] [blame] | 346 | req->end = fuse_readpages_end; |
| 347 | request_send_background(fc, req); |
| 348 | } else { |
| 349 | request_send(fc, req); |
| 350 | fuse_readpages_end(fc, req); |
| 351 | } |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | struct fuse_readpages_data { |
| 355 | struct fuse_req *req; |
| 356 | struct file *file; |
| 357 | struct inode *inode; |
| 358 | }; |
| 359 | |
| 360 | static int fuse_readpages_fill(void *_data, struct page *page) |
| 361 | { |
| 362 | struct fuse_readpages_data *data = _data; |
| 363 | struct fuse_req *req = data->req; |
| 364 | struct inode *inode = data->inode; |
| 365 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 366 | |
| 367 | if (req->num_pages && |
| 368 | (req->num_pages == FUSE_MAX_PAGES_PER_REQ || |
| 369 | (req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read || |
| 370 | req->pages[req->num_pages - 1]->index + 1 != page->index)) { |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 371 | fuse_send_readpages(req, data->file, inode); |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 372 | data->req = req = fuse_get_req(fc); |
| 373 | if (IS_ERR(req)) { |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 374 | unlock_page(page); |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 375 | return PTR_ERR(req); |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 376 | } |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 377 | } |
| 378 | req->pages[req->num_pages] = page; |
| 379 | req->num_pages ++; |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | static int fuse_readpages(struct file *file, struct address_space *mapping, |
| 384 | struct list_head *pages, unsigned nr_pages) |
| 385 | { |
| 386 | struct inode *inode = mapping->host; |
| 387 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 388 | struct fuse_readpages_data data; |
| 389 | int err; |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 390 | |
| 391 | if (is_bad_inode(inode)) |
| 392 | return -EIO; |
| 393 | |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 394 | data.file = file; |
| 395 | data.inode = inode; |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 396 | data.req = fuse_get_req(fc); |
| 397 | if (IS_ERR(data.req)) |
| 398 | return PTR_ERR(data.req); |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 399 | |
| 400 | err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data); |
Miklos Szeredi | d3406ff | 2006-04-10 22:54:49 -0700 | [diff] [blame] | 401 | if (!err) { |
| 402 | if (data.req->num_pages) |
| 403 | fuse_send_readpages(data.req, file, inode); |
| 404 | else |
| 405 | fuse_put_request(fc, data.req); |
| 406 | } |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 407 | return err; |
| 408 | } |
| 409 | |
Miklos Szeredi | 04730fe | 2005-09-09 13:10:36 -0700 | [diff] [blame] | 410 | static size_t fuse_send_write(struct fuse_req *req, struct file *file, |
| 411 | struct inode *inode, loff_t pos, size_t count) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 412 | { |
| 413 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 414 | struct fuse_file *ff = file->private_data; |
| 415 | struct fuse_write_in inarg; |
| 416 | struct fuse_write_out outarg; |
| 417 | |
| 418 | memset(&inarg, 0, sizeof(struct fuse_write_in)); |
| 419 | inarg.fh = ff->fh; |
| 420 | inarg.offset = pos; |
| 421 | inarg.size = count; |
| 422 | req->in.h.opcode = FUSE_WRITE; |
| 423 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 424 | req->in.argpages = 1; |
| 425 | req->in.numargs = 2; |
| 426 | req->in.args[0].size = sizeof(struct fuse_write_in); |
| 427 | req->in.args[0].value = &inarg; |
| 428 | req->in.args[1].size = count; |
| 429 | req->out.numargs = 1; |
| 430 | req->out.args[0].size = sizeof(struct fuse_write_out); |
| 431 | req->out.args[0].value = &outarg; |
Miklos Szeredi | 7c352bd | 2005-09-09 13:10:39 -0700 | [diff] [blame] | 432 | request_send(fc, req); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 433 | return outarg.size; |
| 434 | } |
| 435 | |
| 436 | static int fuse_prepare_write(struct file *file, struct page *page, |
| 437 | unsigned offset, unsigned to) |
| 438 | { |
| 439 | /* No op */ |
| 440 | return 0; |
| 441 | } |
| 442 | |
| 443 | static int fuse_commit_write(struct file *file, struct page *page, |
| 444 | unsigned offset, unsigned to) |
| 445 | { |
| 446 | int err; |
Miklos Szeredi | 04730fe | 2005-09-09 13:10:36 -0700 | [diff] [blame] | 447 | size_t nres; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 448 | unsigned count = to - offset; |
| 449 | struct inode *inode = page->mapping->host; |
| 450 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | 4633a22 | 2006-01-06 00:19:36 -0800 | [diff] [blame] | 451 | loff_t pos = page_offset(page) + offset; |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 452 | struct fuse_req *req; |
| 453 | |
| 454 | if (is_bad_inode(inode)) |
| 455 | return -EIO; |
| 456 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 457 | req = fuse_get_req(fc); |
| 458 | if (IS_ERR(req)) |
| 459 | return PTR_ERR(req); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 460 | |
| 461 | req->num_pages = 1; |
| 462 | req->pages[0] = page; |
| 463 | req->page_offset = offset; |
| 464 | nres = fuse_send_write(req, file, inode, pos, count); |
| 465 | err = req->out.h.error; |
| 466 | fuse_put_request(fc, req); |
| 467 | if (!err && nres != count) |
| 468 | err = -EIO; |
| 469 | if (!err) { |
| 470 | pos += count; |
| 471 | if (pos > i_size_read(inode)) |
| 472 | i_size_write(inode, pos); |
| 473 | |
| 474 | if (offset == 0 && to == PAGE_CACHE_SIZE) { |
| 475 | clear_page_dirty(page); |
| 476 | SetPageUptodate(page); |
| 477 | } |
Miklos Szeredi | b36c31b | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 478 | } |
| 479 | fuse_invalidate_attr(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 480 | return err; |
| 481 | } |
| 482 | |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 483 | static void fuse_release_user_pages(struct fuse_req *req, int write) |
| 484 | { |
| 485 | unsigned i; |
| 486 | |
| 487 | for (i = 0; i < req->num_pages; i++) { |
| 488 | struct page *page = req->pages[i]; |
| 489 | if (write) |
| 490 | set_page_dirty_lock(page); |
| 491 | put_page(page); |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | static int fuse_get_user_pages(struct fuse_req *req, const char __user *buf, |
| 496 | unsigned nbytes, int write) |
| 497 | { |
| 498 | unsigned long user_addr = (unsigned long) buf; |
| 499 | unsigned offset = user_addr & ~PAGE_MASK; |
| 500 | int npages; |
| 501 | |
| 502 | /* This doesn't work with nfsd */ |
| 503 | if (!current->mm) |
| 504 | return -EPERM; |
| 505 | |
| 506 | nbytes = min(nbytes, (unsigned) FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT); |
| 507 | npages = (nbytes + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; |
Miklos Szeredi | 6ad84ac | 2006-01-06 00:19:42 -0800 | [diff] [blame] | 508 | npages = min(max(npages, 1), FUSE_MAX_PAGES_PER_REQ); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 509 | down_read(¤t->mm->mmap_sem); |
| 510 | npages = get_user_pages(current, current->mm, user_addr, npages, write, |
| 511 | 0, req->pages, NULL); |
| 512 | up_read(¤t->mm->mmap_sem); |
| 513 | if (npages < 0) |
| 514 | return npages; |
| 515 | |
| 516 | req->num_pages = npages; |
| 517 | req->page_offset = offset; |
| 518 | return 0; |
| 519 | } |
| 520 | |
| 521 | static ssize_t fuse_direct_io(struct file *file, const char __user *buf, |
| 522 | size_t count, loff_t *ppos, int write) |
| 523 | { |
| 524 | struct inode *inode = file->f_dentry->d_inode; |
| 525 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 526 | size_t nmax = write ? fc->max_write : fc->max_read; |
| 527 | loff_t pos = *ppos; |
| 528 | ssize_t res = 0; |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 529 | struct fuse_req *req; |
| 530 | |
| 531 | if (is_bad_inode(inode)) |
| 532 | return -EIO; |
| 533 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 534 | req = fuse_get_req(fc); |
| 535 | if (IS_ERR(req)) |
| 536 | return PTR_ERR(req); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 537 | |
| 538 | while (count) { |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 539 | size_t nres; |
| 540 | size_t nbytes = min(count, nmax); |
| 541 | int err = fuse_get_user_pages(req, buf, nbytes, !write); |
| 542 | if (err) { |
| 543 | res = err; |
| 544 | break; |
| 545 | } |
Miklos Szeredi | 6ad84ac | 2006-01-06 00:19:42 -0800 | [diff] [blame] | 546 | nbytes = (req->num_pages << PAGE_SHIFT) - req->page_offset; |
| 547 | nbytes = min(count, nbytes); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 548 | if (write) |
| 549 | nres = fuse_send_write(req, file, inode, pos, nbytes); |
| 550 | else |
| 551 | nres = fuse_send_read(req, file, inode, pos, nbytes); |
| 552 | fuse_release_user_pages(req, !write); |
| 553 | if (req->out.h.error) { |
| 554 | if (!res) |
| 555 | res = req->out.h.error; |
| 556 | break; |
| 557 | } else if (nres > nbytes) { |
| 558 | res = -EIO; |
| 559 | break; |
| 560 | } |
| 561 | count -= nres; |
| 562 | res += nres; |
| 563 | pos += nres; |
| 564 | buf += nres; |
| 565 | if (nres != nbytes) |
| 566 | break; |
Miklos Szeredi | 56cf34f | 2006-04-11 21:16:51 +0200 | [diff] [blame] | 567 | if (count) { |
| 568 | fuse_put_request(fc, req); |
| 569 | req = fuse_get_req(fc); |
| 570 | if (IS_ERR(req)) |
| 571 | break; |
| 572 | } |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 573 | } |
| 574 | fuse_put_request(fc, req); |
| 575 | if (res > 0) { |
| 576 | if (write && pos > i_size_read(inode)) |
| 577 | i_size_write(inode, pos); |
| 578 | *ppos = pos; |
Miklos Szeredi | b36c31b | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 579 | } |
| 580 | fuse_invalidate_attr(inode); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 581 | |
| 582 | return res; |
| 583 | } |
| 584 | |
| 585 | static ssize_t fuse_direct_read(struct file *file, char __user *buf, |
| 586 | size_t count, loff_t *ppos) |
| 587 | { |
| 588 | return fuse_direct_io(file, buf, count, ppos, 0); |
| 589 | } |
| 590 | |
| 591 | static ssize_t fuse_direct_write(struct file *file, const char __user *buf, |
| 592 | size_t count, loff_t *ppos) |
| 593 | { |
| 594 | struct inode *inode = file->f_dentry->d_inode; |
| 595 | ssize_t res; |
| 596 | /* Don't allow parallel writes to the same file */ |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 597 | mutex_lock(&inode->i_mutex); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 598 | res = fuse_direct_io(file, buf, count, ppos, 1); |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 599 | mutex_unlock(&inode->i_mutex); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 600 | return res; |
| 601 | } |
| 602 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 603 | static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma) |
| 604 | { |
| 605 | if ((vma->vm_flags & VM_SHARED)) { |
| 606 | if ((vma->vm_flags & VM_WRITE)) |
| 607 | return -ENODEV; |
| 608 | else |
| 609 | vma->vm_flags &= ~VM_MAYWRITE; |
| 610 | } |
| 611 | return generic_file_mmap(file, vma); |
| 612 | } |
| 613 | |
| 614 | static int fuse_set_page_dirty(struct page *page) |
| 615 | { |
| 616 | printk("fuse_set_page_dirty: should not happen\n"); |
| 617 | dump_stack(); |
| 618 | return 0; |
| 619 | } |
| 620 | |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame^] | 621 | static int convert_fuse_file_lock(const struct fuse_file_lock *ffl, |
| 622 | struct file_lock *fl) |
| 623 | { |
| 624 | switch (ffl->type) { |
| 625 | case F_UNLCK: |
| 626 | break; |
| 627 | |
| 628 | case F_RDLCK: |
| 629 | case F_WRLCK: |
| 630 | if (ffl->start > OFFSET_MAX || ffl->end > OFFSET_MAX || |
| 631 | ffl->end < ffl->start) |
| 632 | return -EIO; |
| 633 | |
| 634 | fl->fl_start = ffl->start; |
| 635 | fl->fl_end = ffl->end; |
| 636 | fl->fl_pid = ffl->pid; |
| 637 | break; |
| 638 | |
| 639 | default: |
| 640 | return -EIO; |
| 641 | } |
| 642 | fl->fl_type = ffl->type; |
| 643 | return 0; |
| 644 | } |
| 645 | |
| 646 | static void fuse_lk_fill(struct fuse_req *req, struct file *file, |
| 647 | const struct file_lock *fl, int opcode, pid_t pid) |
| 648 | { |
| 649 | struct inode *inode = file->f_dentry->d_inode; |
| 650 | struct fuse_file *ff = file->private_data; |
| 651 | struct fuse_lk_in *arg = &req->misc.lk_in; |
| 652 | |
| 653 | arg->fh = ff->fh; |
| 654 | arg->owner = fuse_lock_owner_id(fl->fl_owner); |
| 655 | arg->lk.start = fl->fl_start; |
| 656 | arg->lk.end = fl->fl_end; |
| 657 | arg->lk.type = fl->fl_type; |
| 658 | arg->lk.pid = pid; |
| 659 | req->in.h.opcode = opcode; |
| 660 | req->in.h.nodeid = get_node_id(inode); |
| 661 | req->in.numargs = 1; |
| 662 | req->in.args[0].size = sizeof(*arg); |
| 663 | req->in.args[0].value = arg; |
| 664 | } |
| 665 | |
| 666 | static int fuse_getlk(struct file *file, struct file_lock *fl) |
| 667 | { |
| 668 | struct inode *inode = file->f_dentry->d_inode; |
| 669 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 670 | struct fuse_req *req; |
| 671 | struct fuse_lk_out outarg; |
| 672 | int err; |
| 673 | |
| 674 | req = fuse_get_req(fc); |
| 675 | if (IS_ERR(req)) |
| 676 | return PTR_ERR(req); |
| 677 | |
| 678 | fuse_lk_fill(req, file, fl, FUSE_GETLK, 0); |
| 679 | req->out.numargs = 1; |
| 680 | req->out.args[0].size = sizeof(outarg); |
| 681 | req->out.args[0].value = &outarg; |
| 682 | request_send(fc, req); |
| 683 | err = req->out.h.error; |
| 684 | fuse_put_request(fc, req); |
| 685 | if (!err) |
| 686 | err = convert_fuse_file_lock(&outarg.lk, fl); |
| 687 | |
| 688 | return err; |
| 689 | } |
| 690 | |
| 691 | static int fuse_setlk(struct file *file, struct file_lock *fl) |
| 692 | { |
| 693 | struct inode *inode = file->f_dentry->d_inode; |
| 694 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 695 | struct fuse_req *req; |
| 696 | int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; |
| 697 | pid_t pid = fl->fl_type != F_UNLCK ? current->tgid : 0; |
| 698 | int err; |
| 699 | |
| 700 | /* Unlock on close is handled by the flush method */ |
| 701 | if (fl->fl_flags & FL_CLOSE) |
| 702 | return 0; |
| 703 | |
| 704 | req = fuse_get_req(fc); |
| 705 | if (IS_ERR(req)) |
| 706 | return PTR_ERR(req); |
| 707 | |
| 708 | fuse_lk_fill(req, file, fl, opcode, pid); |
| 709 | request_send(fc, req); |
| 710 | err = req->out.h.error; |
| 711 | fuse_put_request(fc, req); |
| 712 | return err; |
| 713 | } |
| 714 | |
| 715 | static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) |
| 716 | { |
| 717 | struct inode *inode = file->f_dentry->d_inode; |
| 718 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 719 | int err; |
| 720 | |
| 721 | if (cmd == F_GETLK) { |
| 722 | if (fc->no_lock) { |
| 723 | if (!posix_test_lock(file, fl, fl)) |
| 724 | fl->fl_type = F_UNLCK; |
| 725 | err = 0; |
| 726 | } else |
| 727 | err = fuse_getlk(file, fl); |
| 728 | } else { |
| 729 | if (fc->no_lock) |
| 730 | err = posix_lock_file_wait(file, fl); |
| 731 | else |
| 732 | err = fuse_setlk(file, fl); |
| 733 | } |
| 734 | return err; |
| 735 | } |
| 736 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 737 | static const struct file_operations fuse_file_operations = { |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 738 | .llseek = generic_file_llseek, |
| 739 | .read = generic_file_read, |
| 740 | .write = generic_file_write, |
| 741 | .mmap = fuse_file_mmap, |
| 742 | .open = fuse_open, |
| 743 | .flush = fuse_flush, |
| 744 | .release = fuse_release, |
| 745 | .fsync = fuse_fsync, |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame^] | 746 | .lock = fuse_file_lock, |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 747 | .sendfile = generic_file_sendfile, |
| 748 | }; |
| 749 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 750 | static const struct file_operations fuse_direct_io_file_operations = { |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 751 | .llseek = generic_file_llseek, |
| 752 | .read = fuse_direct_read, |
| 753 | .write = fuse_direct_write, |
| 754 | .open = fuse_open, |
| 755 | .flush = fuse_flush, |
| 756 | .release = fuse_release, |
| 757 | .fsync = fuse_fsync, |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame^] | 758 | .lock = fuse_file_lock, |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 759 | /* no mmap and sendfile */ |
| 760 | }; |
| 761 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 762 | static struct address_space_operations fuse_file_aops = { |
| 763 | .readpage = fuse_readpage, |
| 764 | .prepare_write = fuse_prepare_write, |
| 765 | .commit_write = fuse_commit_write, |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 766 | .readpages = fuse_readpages, |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 767 | .set_page_dirty = fuse_set_page_dirty, |
| 768 | }; |
| 769 | |
| 770 | void fuse_init_file_inode(struct inode *inode) |
| 771 | { |
Miklos Szeredi | 45323fb | 2005-09-09 13:10:37 -0700 | [diff] [blame] | 772 | inode->i_fop = &fuse_file_operations; |
| 773 | inode->i_data.a_ops = &fuse_file_aops; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 774 | } |