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> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 14 | #include <linux/sched.h> |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 15 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 16 | static const struct file_operations fuse_direct_io_file_operations; |
Miklos Szeredi | 45323fb | 2005-09-09 13:10:37 -0700 | [diff] [blame] | 17 | |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 18 | static int fuse_send_open(struct inode *inode, struct file *file, int isdir, |
| 19 | struct fuse_open_out *outargp) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 20 | { |
| 21 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 22 | struct fuse_open_in inarg; |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 23 | struct fuse_req *req; |
| 24 | int err; |
| 25 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 26 | req = fuse_get_req(fc); |
| 27 | if (IS_ERR(req)) |
| 28 | return PTR_ERR(req); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 29 | |
| 30 | memset(&inarg, 0, sizeof(inarg)); |
Miklos Szeredi | 6ff958e | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 31 | inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY); |
| 32 | if (!fc->atomic_o_trunc) |
| 33 | inarg.flags &= ~O_TRUNC; |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 34 | req->in.h.opcode = isdir ? FUSE_OPENDIR : FUSE_OPEN; |
| 35 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 36 | req->in.numargs = 1; |
| 37 | req->in.args[0].size = sizeof(inarg); |
| 38 | req->in.args[0].value = &inarg; |
| 39 | req->out.numargs = 1; |
| 40 | req->out.args[0].size = sizeof(*outargp); |
| 41 | req->out.args[0].value = outargp; |
| 42 | request_send(fc, req); |
| 43 | err = req->out.h.error; |
| 44 | fuse_put_request(fc, req); |
| 45 | |
| 46 | return err; |
| 47 | } |
| 48 | |
| 49 | struct fuse_file *fuse_file_alloc(void) |
| 50 | { |
| 51 | struct fuse_file *ff; |
| 52 | ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL); |
| 53 | if (ff) { |
Miklos Szeredi | 33649c9 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 54 | ff->reserved_req = fuse_request_alloc(); |
| 55 | if (!ff->reserved_req) { |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 56 | kfree(ff); |
| 57 | ff = NULL; |
Adrian Bunk | 8744969 | 2007-11-14 17:00:02 -0800 | [diff] [blame] | 58 | } else { |
| 59 | INIT_LIST_HEAD(&ff->write_entry); |
| 60 | atomic_set(&ff->count, 0); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 61 | } |
| 62 | } |
| 63 | return ff; |
| 64 | } |
| 65 | |
| 66 | void fuse_file_free(struct fuse_file *ff) |
| 67 | { |
Miklos Szeredi | 33649c9 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 68 | fuse_request_free(ff->reserved_req); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 69 | kfree(ff); |
| 70 | } |
| 71 | |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 72 | static struct fuse_file *fuse_file_get(struct fuse_file *ff) |
| 73 | { |
| 74 | atomic_inc(&ff->count); |
| 75 | return ff; |
| 76 | } |
| 77 | |
Miklos Szeredi | 819c4b3 | 2007-10-16 23:31:04 -0700 | [diff] [blame] | 78 | static void fuse_release_end(struct fuse_conn *fc, struct fuse_req *req) |
| 79 | { |
| 80 | dput(req->dentry); |
| 81 | mntput(req->vfsmount); |
| 82 | fuse_put_request(fc, req); |
| 83 | } |
| 84 | |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 85 | static void fuse_file_put(struct fuse_file *ff) |
| 86 | { |
| 87 | if (atomic_dec_and_test(&ff->count)) { |
| 88 | struct fuse_req *req = ff->reserved_req; |
| 89 | struct fuse_conn *fc = get_fuse_conn(req->dentry->d_inode); |
Miklos Szeredi | 819c4b3 | 2007-10-16 23:31:04 -0700 | [diff] [blame] | 90 | req->end = fuse_release_end; |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 91 | request_send_background(fc, req); |
| 92 | kfree(ff); |
| 93 | } |
| 94 | } |
| 95 | |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 96 | void fuse_finish_open(struct inode *inode, struct file *file, |
| 97 | struct fuse_file *ff, struct fuse_open_out *outarg) |
| 98 | { |
| 99 | if (outarg->open_flags & FOPEN_DIRECT_IO) |
| 100 | file->f_op = &fuse_direct_io_file_operations; |
| 101 | if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) |
Miklos Szeredi | b100997 | 2007-10-16 23:31:01 -0700 | [diff] [blame] | 102 | invalidate_inode_pages2(inode->i_mapping); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 103 | ff->fh = outarg->fh; |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 104 | file->private_data = fuse_file_get(ff); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | int fuse_open_common(struct inode *inode, struct file *file, int isdir) |
| 108 | { |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 109 | struct fuse_open_out outarg; |
| 110 | struct fuse_file *ff; |
| 111 | int err; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 112 | |
Miklos Szeredi | dd190d0 | 2005-09-30 11:59:02 -0700 | [diff] [blame] | 113 | /* VFS checks this, but only _after_ ->open() */ |
| 114 | if (file->f_flags & O_DIRECT) |
| 115 | return -EINVAL; |
| 116 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 117 | err = generic_file_open(inode, file); |
| 118 | if (err) |
| 119 | return err; |
| 120 | |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 121 | ff = fuse_file_alloc(); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 122 | if (!ff) |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 123 | return -ENOMEM; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 124 | |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 125 | err = fuse_send_open(inode, file, isdir, &outarg); |
| 126 | if (err) |
| 127 | fuse_file_free(ff); |
| 128 | else { |
| 129 | if (isdir) |
| 130 | outarg.open_flags &= ~FOPEN_DIRECT_IO; |
| 131 | fuse_finish_open(inode, file, ff, &outarg); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 134 | return err; |
| 135 | } |
| 136 | |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 137 | void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode) |
Miklos Szeredi | 64c6d8e | 2006-01-16 22:14:42 -0800 | [diff] [blame] | 138 | { |
Miklos Szeredi | 33649c9 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 139 | struct fuse_req *req = ff->reserved_req; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 140 | struct fuse_release_in *inarg = &req->misc.release_in; |
| 141 | |
| 142 | inarg->fh = ff->fh; |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 143 | inarg->flags = flags; |
Miklos Szeredi | 51eb01e | 2006-06-25 05:48:50 -0700 | [diff] [blame] | 144 | req->in.h.opcode = opcode; |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 145 | req->in.h.nodeid = nodeid; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 146 | req->in.numargs = 1; |
| 147 | req->in.args[0].size = sizeof(struct fuse_release_in); |
| 148 | req->in.args[0].value = inarg; |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | int fuse_release_common(struct inode *inode, struct file *file, int isdir) |
| 152 | { |
| 153 | struct fuse_file *ff = file->private_data; |
| 154 | if (ff) { |
Miklos Szeredi | 93a8c3c | 2007-10-18 03:07:03 -0700 | [diff] [blame] | 155 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 156 | |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 157 | fuse_release_fill(ff, get_node_id(inode), file->f_flags, |
| 158 | isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); |
Miklos Szeredi | 51eb01e | 2006-06-25 05:48:50 -0700 | [diff] [blame] | 159 | |
| 160 | /* Hold vfsmount and dentry until release is finished */ |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 161 | ff->reserved_req->vfsmount = mntget(file->f_path.mnt); |
| 162 | ff->reserved_req->dentry = dget(file->f_path.dentry); |
Miklos Szeredi | 93a8c3c | 2007-10-18 03:07:03 -0700 | [diff] [blame] | 163 | |
| 164 | spin_lock(&fc->lock); |
| 165 | list_del(&ff->write_entry); |
| 166 | spin_unlock(&fc->lock); |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 167 | /* |
| 168 | * Normally this will send the RELEASE request, |
| 169 | * however if some asynchronous READ or WRITE requests |
| 170 | * are outstanding, the sending will be delayed |
| 171 | */ |
| 172 | fuse_file_put(ff); |
Miklos Szeredi | fd72faa | 2005-11-07 00:59:51 -0800 | [diff] [blame] | 173 | } |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 174 | |
| 175 | /* Return value is ignored by VFS */ |
| 176 | return 0; |
| 177 | } |
| 178 | |
Miklos Szeredi | 04730fe | 2005-09-09 13:10:36 -0700 | [diff] [blame] | 179 | static int fuse_open(struct inode *inode, struct file *file) |
| 180 | { |
| 181 | return fuse_open_common(inode, file, 0); |
| 182 | } |
| 183 | |
| 184 | static int fuse_release(struct inode *inode, struct file *file) |
| 185 | { |
| 186 | return fuse_release_common(inode, file, 0); |
| 187 | } |
| 188 | |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 189 | /* |
Miklos Szeredi | 9c8ef56 | 2006-06-25 05:48:55 -0700 | [diff] [blame] | 190 | * Scramble the ID space with XTEA, so that the value of the files_struct |
| 191 | * pointer is not exposed to userspace. |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 192 | */ |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 193 | u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id) |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 194 | { |
Miklos Szeredi | 9c8ef56 | 2006-06-25 05:48:55 -0700 | [diff] [blame] | 195 | u32 *k = fc->scramble_key; |
| 196 | u64 v = (unsigned long) id; |
| 197 | u32 v0 = v; |
| 198 | u32 v1 = v >> 32; |
| 199 | u32 sum = 0; |
| 200 | int i; |
| 201 | |
| 202 | for (i = 0; i < 32; i++) { |
| 203 | v0 += ((v1 << 4 ^ v1 >> 5) + v1) ^ (sum + k[sum & 3]); |
| 204 | sum += 0x9E3779B9; |
| 205 | v1 += ((v0 << 4 ^ v0 >> 5) + v0) ^ (sum + k[sum>>11 & 3]); |
| 206 | } |
| 207 | |
| 208 | return (u64) v0 + ((u64) v1 << 32); |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Miklos Szeredi | 75e1fcc | 2006-06-23 02:05:12 -0700 | [diff] [blame] | 211 | static int fuse_flush(struct file *file, fl_owner_t id) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 212 | { |
Josef Sipek | 7706a9d | 2006-12-08 02:37:02 -0800 | [diff] [blame] | 213 | struct inode *inode = file->f_path.dentry->d_inode; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 214 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 215 | struct fuse_file *ff = file->private_data; |
| 216 | struct fuse_req *req; |
| 217 | struct fuse_flush_in inarg; |
| 218 | int err; |
| 219 | |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 220 | if (is_bad_inode(inode)) |
| 221 | return -EIO; |
| 222 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 223 | if (fc->no_flush) |
| 224 | return 0; |
| 225 | |
Miklos Szeredi | 33649c9 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 226 | req = fuse_get_req_nofail(fc, file); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 227 | memset(&inarg, 0, sizeof(inarg)); |
| 228 | inarg.fh = ff->fh; |
Miklos Szeredi | 9c8ef56 | 2006-06-25 05:48:55 -0700 | [diff] [blame] | 229 | inarg.lock_owner = fuse_lock_owner_id(fc, id); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 230 | req->in.h.opcode = FUSE_FLUSH; |
| 231 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 232 | req->in.numargs = 1; |
| 233 | req->in.args[0].size = sizeof(inarg); |
| 234 | req->in.args[0].value = &inarg; |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 235 | req->force = 1; |
Miklos Szeredi | 7c352bd | 2005-09-09 13:10:39 -0700 | [diff] [blame] | 236 | request_send(fc, req); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 237 | err = req->out.h.error; |
| 238 | fuse_put_request(fc, req); |
| 239 | if (err == -ENOSYS) { |
| 240 | fc->no_flush = 1; |
| 241 | err = 0; |
| 242 | } |
| 243 | return err; |
| 244 | } |
| 245 | |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 246 | int fuse_fsync_common(struct file *file, struct dentry *de, int datasync, |
| 247 | int isdir) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 248 | { |
| 249 | struct inode *inode = de->d_inode; |
| 250 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 251 | struct fuse_file *ff = file->private_data; |
| 252 | struct fuse_req *req; |
| 253 | struct fuse_fsync_in inarg; |
| 254 | int err; |
| 255 | |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 256 | if (is_bad_inode(inode)) |
| 257 | return -EIO; |
| 258 | |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 259 | if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir)) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 260 | return 0; |
| 261 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 262 | req = fuse_get_req(fc); |
| 263 | if (IS_ERR(req)) |
| 264 | return PTR_ERR(req); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 265 | |
| 266 | memset(&inarg, 0, sizeof(inarg)); |
| 267 | inarg.fh = ff->fh; |
| 268 | inarg.fsync_flags = datasync ? 1 : 0; |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 269 | req->in.h.opcode = isdir ? FUSE_FSYNCDIR : FUSE_FSYNC; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 270 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 271 | req->in.numargs = 1; |
| 272 | req->in.args[0].size = sizeof(inarg); |
| 273 | req->in.args[0].value = &inarg; |
| 274 | request_send(fc, req); |
| 275 | err = req->out.h.error; |
| 276 | fuse_put_request(fc, req); |
| 277 | if (err == -ENOSYS) { |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 278 | if (isdir) |
| 279 | fc->no_fsyncdir = 1; |
| 280 | else |
| 281 | fc->no_fsync = 1; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 282 | err = 0; |
| 283 | } |
| 284 | return err; |
| 285 | } |
| 286 | |
Miklos Szeredi | 8254798 | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 287 | static int fuse_fsync(struct file *file, struct dentry *de, int datasync) |
| 288 | { |
| 289 | return fuse_fsync_common(file, de, datasync, 0); |
| 290 | } |
| 291 | |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 292 | void fuse_read_fill(struct fuse_req *req, struct file *file, |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 293 | struct inode *inode, loff_t pos, size_t count, int opcode) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 294 | { |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 295 | struct fuse_read_in *inarg = &req->misc.read_in; |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 296 | struct fuse_file *ff = file->private_data; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 297 | |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 298 | inarg->fh = ff->fh; |
| 299 | inarg->offset = pos; |
| 300 | inarg->size = count; |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 301 | inarg->flags = file->f_flags; |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 302 | req->in.h.opcode = opcode; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 303 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 304 | req->in.numargs = 1; |
| 305 | req->in.args[0].size = sizeof(struct fuse_read_in); |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 306 | req->in.args[0].value = inarg; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 307 | req->out.argpages = 1; |
| 308 | req->out.argvar = 1; |
| 309 | req->out.numargs = 1; |
| 310 | req->out.args[0].size = count; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 311 | } |
| 312 | |
Miklos Szeredi | 8bfc016 | 2006-01-16 22:14:28 -0800 | [diff] [blame] | 313 | static size_t fuse_send_read(struct fuse_req *req, struct file *file, |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 314 | struct inode *inode, loff_t pos, size_t count, |
| 315 | fl_owner_t owner) |
Miklos Szeredi | 04730fe | 2005-09-09 13:10:36 -0700 | [diff] [blame] | 316 | { |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 317 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 318 | |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 319 | fuse_read_fill(req, file, inode, pos, count, FUSE_READ); |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 320 | if (owner != NULL) { |
| 321 | struct fuse_read_in *inarg = &req->misc.read_in; |
| 322 | |
| 323 | inarg->read_flags |= FUSE_READ_LOCKOWNER; |
| 324 | inarg->lock_owner = fuse_lock_owner_id(fc, owner); |
| 325 | } |
Miklos Szeredi | 361b1eb5 | 2006-01-16 22:14:45 -0800 | [diff] [blame] | 326 | request_send(fc, req); |
| 327 | return req->out.args[0].size; |
Miklos Szeredi | 04730fe | 2005-09-09 13:10:36 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 330 | static int fuse_readpage(struct file *file, struct page *page) |
| 331 | { |
| 332 | struct inode *inode = page->mapping->host; |
| 333 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 334 | struct fuse_req *req; |
| 335 | int err; |
| 336 | |
| 337 | err = -EIO; |
| 338 | if (is_bad_inode(inode)) |
| 339 | goto out; |
| 340 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 341 | req = fuse_get_req(fc); |
| 342 | err = PTR_ERR(req); |
| 343 | if (IS_ERR(req)) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 344 | goto out; |
| 345 | |
| 346 | req->out.page_zeroing = 1; |
| 347 | req->num_pages = 1; |
| 348 | req->pages[0] = page; |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 349 | fuse_send_read(req, file, inode, page_offset(page), PAGE_CACHE_SIZE, |
| 350 | NULL); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 351 | err = req->out.h.error; |
| 352 | fuse_put_request(fc, req); |
| 353 | if (!err) |
| 354 | SetPageUptodate(page); |
Miklos Szeredi | b36c31b | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 355 | fuse_invalidate_attr(inode); /* atime changed */ |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 356 | out: |
| 357 | unlock_page(page); |
| 358 | return err; |
| 359 | } |
| 360 | |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 361 | 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] | 362 | { |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 363 | int i; |
| 364 | |
| 365 | fuse_invalidate_attr(req->pages[0]->mapping->host); /* atime changed */ |
| 366 | |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 367 | for (i = 0; i < req->num_pages; i++) { |
| 368 | struct page *page = req->pages[i]; |
| 369 | if (!req->out.h.error) |
| 370 | SetPageUptodate(page); |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 371 | else |
| 372 | SetPageError(page); |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 373 | unlock_page(page); |
| 374 | } |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 375 | if (req->ff) |
| 376 | fuse_file_put(req->ff); |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 377 | fuse_put_request(fc, req); |
| 378 | } |
| 379 | |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 380 | static void fuse_send_readpages(struct fuse_req *req, struct file *file, |
Miklos Szeredi | c1aa96a | 2006-01-16 22:14:46 -0800 | [diff] [blame] | 381 | struct inode *inode) |
| 382 | { |
| 383 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 384 | loff_t pos = page_offset(req->pages[0]); |
| 385 | size_t count = req->num_pages << PAGE_CACHE_SHIFT; |
| 386 | req->out.page_zeroing = 1; |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 387 | fuse_read_fill(req, file, inode, pos, count, FUSE_READ); |
Miklos Szeredi | 9cd6845 | 2006-02-01 03:04:40 -0800 | [diff] [blame] | 388 | if (fc->async_read) { |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 389 | struct fuse_file *ff = file->private_data; |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 390 | req->ff = fuse_file_get(ff); |
Miklos Szeredi | 9cd6845 | 2006-02-01 03:04:40 -0800 | [diff] [blame] | 391 | req->end = fuse_readpages_end; |
| 392 | request_send_background(fc, req); |
| 393 | } else { |
| 394 | request_send(fc, req); |
| 395 | fuse_readpages_end(fc, req); |
| 396 | } |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 397 | } |
| 398 | |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 399 | struct fuse_fill_data { |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 400 | struct fuse_req *req; |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 401 | struct file *file; |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 402 | struct inode *inode; |
| 403 | }; |
| 404 | |
| 405 | static int fuse_readpages_fill(void *_data, struct page *page) |
| 406 | { |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 407 | struct fuse_fill_data *data = _data; |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 408 | struct fuse_req *req = data->req; |
| 409 | struct inode *inode = data->inode; |
| 410 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 411 | |
| 412 | if (req->num_pages && |
| 413 | (req->num_pages == FUSE_MAX_PAGES_PER_REQ || |
| 414 | (req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read || |
| 415 | req->pages[req->num_pages - 1]->index + 1 != page->index)) { |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 416 | fuse_send_readpages(req, data->file, inode); |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 417 | data->req = req = fuse_get_req(fc); |
| 418 | if (IS_ERR(req)) { |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 419 | unlock_page(page); |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 420 | return PTR_ERR(req); |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 421 | } |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 422 | } |
| 423 | req->pages[req->num_pages] = page; |
| 424 | req->num_pages ++; |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | static int fuse_readpages(struct file *file, struct address_space *mapping, |
| 429 | struct list_head *pages, unsigned nr_pages) |
| 430 | { |
| 431 | struct inode *inode = mapping->host; |
| 432 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | c756e0a | 2007-10-16 23:31:00 -0700 | [diff] [blame] | 433 | struct fuse_fill_data data; |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 434 | int err; |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 435 | |
Alexander Zarochentsev | 1d7ea73 | 2006-08-13 23:24:27 -0700 | [diff] [blame] | 436 | err = -EIO; |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 437 | if (is_bad_inode(inode)) |
OGAWA Hirofumi | 2e99002 | 2006-11-02 22:07:09 -0800 | [diff] [blame] | 438 | goto out; |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 439 | |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 440 | data.file = file; |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 441 | data.inode = inode; |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 442 | data.req = fuse_get_req(fc); |
Alexander Zarochentsev | 1d7ea73 | 2006-08-13 23:24:27 -0700 | [diff] [blame] | 443 | err = PTR_ERR(data.req); |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 444 | if (IS_ERR(data.req)) |
OGAWA Hirofumi | 2e99002 | 2006-11-02 22:07:09 -0800 | [diff] [blame] | 445 | goto out; |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 446 | |
| 447 | err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data); |
Miklos Szeredi | d3406ff | 2006-04-10 22:54:49 -0700 | [diff] [blame] | 448 | if (!err) { |
| 449 | if (data.req->num_pages) |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 450 | fuse_send_readpages(data.req, file, inode); |
Miklos Szeredi | d3406ff | 2006-04-10 22:54:49 -0700 | [diff] [blame] | 451 | else |
| 452 | fuse_put_request(fc, data.req); |
| 453 | } |
OGAWA Hirofumi | 2e99002 | 2006-11-02 22:07:09 -0800 | [diff] [blame] | 454 | out: |
Alexander Zarochentsev | 1d7ea73 | 2006-08-13 23:24:27 -0700 | [diff] [blame] | 455 | return err; |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 456 | } |
| 457 | |
Miklos Szeredi | bcb4be8 | 2007-11-28 16:21:59 -0800 | [diff] [blame] | 458 | static ssize_t fuse_file_aio_read(struct kiocb *iocb, const struct iovec *iov, |
| 459 | unsigned long nr_segs, loff_t pos) |
| 460 | { |
| 461 | struct inode *inode = iocb->ki_filp->f_mapping->host; |
| 462 | |
| 463 | if (pos + iov_length(iov, nr_segs) > i_size_read(inode)) { |
| 464 | int err; |
| 465 | /* |
| 466 | * If trying to read past EOF, make sure the i_size |
| 467 | * attribute is up-to-date. |
| 468 | */ |
| 469 | err = fuse_update_attributes(inode, NULL, iocb->ki_filp, NULL); |
| 470 | if (err) |
| 471 | return err; |
| 472 | } |
| 473 | |
| 474 | return generic_file_aio_read(iocb, iov, nr_segs, pos); |
| 475 | } |
| 476 | |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 477 | static void fuse_write_fill(struct fuse_req *req, struct file *file, |
Miklos Szeredi | b25e82e | 2007-10-18 03:07:03 -0700 | [diff] [blame] | 478 | struct inode *inode, loff_t pos, size_t count, |
| 479 | int writepage) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 480 | { |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 481 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 482 | struct fuse_file *ff = file->private_data; |
Miklos Szeredi | b25e82e | 2007-10-18 03:07:03 -0700 | [diff] [blame] | 483 | struct fuse_write_in *inarg = &req->misc.write.in; |
| 484 | struct fuse_write_out *outarg = &req->misc.write.out; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 485 | |
Miklos Szeredi | b25e82e | 2007-10-18 03:07:03 -0700 | [diff] [blame] | 486 | memset(inarg, 0, sizeof(struct fuse_write_in)); |
| 487 | inarg->fh = ff->fh; |
| 488 | inarg->offset = pos; |
| 489 | inarg->size = count; |
| 490 | inarg->write_flags = writepage ? FUSE_WRITE_CACHE : 0; |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 491 | inarg->flags = file->f_flags; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 492 | req->in.h.opcode = FUSE_WRITE; |
| 493 | req->in.h.nodeid = get_node_id(inode); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 494 | req->in.argpages = 1; |
| 495 | req->in.numargs = 2; |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 496 | if (fc->minor < 9) |
| 497 | req->in.args[0].size = FUSE_COMPAT_WRITE_IN_SIZE; |
| 498 | else |
| 499 | req->in.args[0].size = sizeof(struct fuse_write_in); |
Miklos Szeredi | b25e82e | 2007-10-18 03:07:03 -0700 | [diff] [blame] | 500 | req->in.args[0].value = inarg; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 501 | req->in.args[1].size = count; |
| 502 | req->out.numargs = 1; |
| 503 | req->out.args[0].size = sizeof(struct fuse_write_out); |
Miklos Szeredi | b25e82e | 2007-10-18 03:07:03 -0700 | [diff] [blame] | 504 | req->out.args[0].value = outarg; |
| 505 | } |
| 506 | |
| 507 | static size_t fuse_send_write(struct fuse_req *req, struct file *file, |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 508 | struct inode *inode, loff_t pos, size_t count, |
| 509 | fl_owner_t owner) |
Miklos Szeredi | b25e82e | 2007-10-18 03:07:03 -0700 | [diff] [blame] | 510 | { |
| 511 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | a664309 | 2007-11-28 16:22:00 -0800 | [diff] [blame] | 512 | fuse_write_fill(req, file, inode, pos, count, 0); |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 513 | if (owner != NULL) { |
| 514 | struct fuse_write_in *inarg = &req->misc.write.in; |
| 515 | inarg->write_flags |= FUSE_WRITE_LOCKOWNER; |
| 516 | inarg->lock_owner = fuse_lock_owner_id(fc, owner); |
| 517 | } |
Miklos Szeredi | 7c352bd | 2005-09-09 13:10:39 -0700 | [diff] [blame] | 518 | request_send(fc, req); |
Miklos Szeredi | b25e82e | 2007-10-18 03:07:03 -0700 | [diff] [blame] | 519 | return req->misc.write.out.size; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 520 | } |
| 521 | |
Nick Piggin | 5e6f58a | 2007-10-16 01:25:17 -0700 | [diff] [blame] | 522 | static int fuse_write_begin(struct file *file, struct address_space *mapping, |
| 523 | loff_t pos, unsigned len, unsigned flags, |
| 524 | struct page **pagep, void **fsdata) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 525 | { |
Nick Piggin | 5e6f58a | 2007-10-16 01:25:17 -0700 | [diff] [blame] | 526 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; |
| 527 | |
| 528 | *pagep = __grab_cache_page(mapping, index); |
| 529 | if (!*pagep) |
| 530 | return -ENOMEM; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 531 | return 0; |
| 532 | } |
| 533 | |
Nick Piggin | 5e6f58a | 2007-10-16 01:25:17 -0700 | [diff] [blame] | 534 | static int fuse_buffered_write(struct file *file, struct inode *inode, |
| 535 | loff_t pos, unsigned count, struct page *page) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 536 | { |
| 537 | int err; |
Miklos Szeredi | 04730fe | 2005-09-09 13:10:36 -0700 | [diff] [blame] | 538 | size_t nres; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 539 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | 1fb69e7 | 2007-10-18 03:06:58 -0700 | [diff] [blame] | 540 | struct fuse_inode *fi = get_fuse_inode(inode); |
Nick Piggin | 5e6f58a | 2007-10-16 01:25:17 -0700 | [diff] [blame] | 541 | unsigned offset = pos & (PAGE_CACHE_SIZE - 1); |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 542 | struct fuse_req *req; |
| 543 | |
| 544 | if (is_bad_inode(inode)) |
| 545 | return -EIO; |
| 546 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 547 | req = fuse_get_req(fc); |
| 548 | if (IS_ERR(req)) |
| 549 | return PTR_ERR(req); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 550 | |
| 551 | req->num_pages = 1; |
| 552 | req->pages[0] = page; |
| 553 | req->page_offset = offset; |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 554 | nres = fuse_send_write(req, file, inode, pos, count, NULL); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 555 | err = req->out.h.error; |
| 556 | fuse_put_request(fc, req); |
Nick Piggin | 5e6f58a | 2007-10-16 01:25:17 -0700 | [diff] [blame] | 557 | if (!err && !nres) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 558 | err = -EIO; |
| 559 | if (!err) { |
Nick Piggin | 5e6f58a | 2007-10-16 01:25:17 -0700 | [diff] [blame] | 560 | pos += nres; |
Miklos Szeredi | 9ffbb91 | 2006-10-17 00:10:06 -0700 | [diff] [blame] | 561 | spin_lock(&fc->lock); |
Miklos Szeredi | 1fb69e7 | 2007-10-18 03:06:58 -0700 | [diff] [blame] | 562 | fi->attr_version = ++fc->attr_version; |
Miklos Szeredi | 9ffbb91 | 2006-10-17 00:10:06 -0700 | [diff] [blame] | 563 | if (pos > inode->i_size) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 564 | i_size_write(inode, pos); |
Miklos Szeredi | 9ffbb91 | 2006-10-17 00:10:06 -0700 | [diff] [blame] | 565 | spin_unlock(&fc->lock); |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 566 | |
Nick Piggin | 5e6f58a | 2007-10-16 01:25:17 -0700 | [diff] [blame] | 567 | if (count == PAGE_CACHE_SIZE) |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 568 | SetPageUptodate(page); |
Miklos Szeredi | b36c31b | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 569 | } |
| 570 | fuse_invalidate_attr(inode); |
Nick Piggin | 5e6f58a | 2007-10-16 01:25:17 -0700 | [diff] [blame] | 571 | return err ? err : nres; |
| 572 | } |
| 573 | |
| 574 | static int fuse_write_end(struct file *file, struct address_space *mapping, |
| 575 | loff_t pos, unsigned len, unsigned copied, |
| 576 | struct page *page, void *fsdata) |
| 577 | { |
| 578 | struct inode *inode = mapping->host; |
| 579 | int res = 0; |
| 580 | |
| 581 | if (copied) |
| 582 | res = fuse_buffered_write(file, inode, pos, copied, page); |
| 583 | |
| 584 | unlock_page(page); |
| 585 | page_cache_release(page); |
| 586 | return res; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 587 | } |
| 588 | |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 589 | static void fuse_release_user_pages(struct fuse_req *req, int write) |
| 590 | { |
| 591 | unsigned i; |
| 592 | |
| 593 | for (i = 0; i < req->num_pages; i++) { |
| 594 | struct page *page = req->pages[i]; |
| 595 | if (write) |
| 596 | set_page_dirty_lock(page); |
| 597 | put_page(page); |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | static int fuse_get_user_pages(struct fuse_req *req, const char __user *buf, |
| 602 | unsigned nbytes, int write) |
| 603 | { |
| 604 | unsigned long user_addr = (unsigned long) buf; |
| 605 | unsigned offset = user_addr & ~PAGE_MASK; |
| 606 | int npages; |
| 607 | |
| 608 | /* This doesn't work with nfsd */ |
| 609 | if (!current->mm) |
| 610 | return -EPERM; |
| 611 | |
| 612 | nbytes = min(nbytes, (unsigned) FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT); |
| 613 | npages = (nbytes + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; |
Miklos Szeredi | 6ad84ac | 2006-01-06 00:19:42 -0800 | [diff] [blame] | 614 | npages = min(max(npages, 1), FUSE_MAX_PAGES_PER_REQ); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 615 | down_read(¤t->mm->mmap_sem); |
| 616 | npages = get_user_pages(current, current->mm, user_addr, npages, write, |
| 617 | 0, req->pages, NULL); |
| 618 | up_read(¤t->mm->mmap_sem); |
| 619 | if (npages < 0) |
| 620 | return npages; |
| 621 | |
| 622 | req->num_pages = npages; |
| 623 | req->page_offset = offset; |
| 624 | return 0; |
| 625 | } |
| 626 | |
| 627 | static ssize_t fuse_direct_io(struct file *file, const char __user *buf, |
| 628 | size_t count, loff_t *ppos, int write) |
| 629 | { |
Josef Sipek | 7706a9d | 2006-12-08 02:37:02 -0800 | [diff] [blame] | 630 | struct inode *inode = file->f_path.dentry->d_inode; |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 631 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 632 | size_t nmax = write ? fc->max_write : fc->max_read; |
| 633 | loff_t pos = *ppos; |
| 634 | ssize_t res = 0; |
Miklos Szeredi | 248d86e | 2006-01-06 00:19:39 -0800 | [diff] [blame] | 635 | struct fuse_req *req; |
| 636 | |
| 637 | if (is_bad_inode(inode)) |
| 638 | return -EIO; |
| 639 | |
Miklos Szeredi | ce1d5a4 | 2006-04-10 22:54:58 -0700 | [diff] [blame] | 640 | req = fuse_get_req(fc); |
| 641 | if (IS_ERR(req)) |
| 642 | return PTR_ERR(req); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 643 | |
| 644 | while (count) { |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 645 | size_t nres; |
| 646 | size_t nbytes = min(count, nmax); |
| 647 | int err = fuse_get_user_pages(req, buf, nbytes, !write); |
| 648 | if (err) { |
| 649 | res = err; |
| 650 | break; |
| 651 | } |
Miklos Szeredi | 6ad84ac | 2006-01-06 00:19:42 -0800 | [diff] [blame] | 652 | nbytes = (req->num_pages << PAGE_SHIFT) - req->page_offset; |
| 653 | nbytes = min(count, nbytes); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 654 | if (write) |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 655 | nres = fuse_send_write(req, file, inode, pos, nbytes, |
| 656 | current->files); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 657 | else |
Miklos Szeredi | f333211 | 2007-10-18 03:07:04 -0700 | [diff] [blame] | 658 | nres = fuse_send_read(req, file, inode, pos, nbytes, |
| 659 | current->files); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 660 | fuse_release_user_pages(req, !write); |
| 661 | if (req->out.h.error) { |
| 662 | if (!res) |
| 663 | res = req->out.h.error; |
| 664 | break; |
| 665 | } else if (nres > nbytes) { |
| 666 | res = -EIO; |
| 667 | break; |
| 668 | } |
| 669 | count -= nres; |
| 670 | res += nres; |
| 671 | pos += nres; |
| 672 | buf += nres; |
| 673 | if (nres != nbytes) |
| 674 | break; |
Miklos Szeredi | 56cf34f | 2006-04-11 21:16:51 +0200 | [diff] [blame] | 675 | if (count) { |
| 676 | fuse_put_request(fc, req); |
| 677 | req = fuse_get_req(fc); |
| 678 | if (IS_ERR(req)) |
| 679 | break; |
| 680 | } |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 681 | } |
| 682 | fuse_put_request(fc, req); |
| 683 | if (res > 0) { |
Miklos Szeredi | 9ffbb91 | 2006-10-17 00:10:06 -0700 | [diff] [blame] | 684 | if (write) { |
| 685 | spin_lock(&fc->lock); |
| 686 | if (pos > inode->i_size) |
| 687 | i_size_write(inode, pos); |
| 688 | spin_unlock(&fc->lock); |
| 689 | } |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 690 | *ppos = pos; |
Miklos Szeredi | b36c31b | 2005-09-09 13:10:38 -0700 | [diff] [blame] | 691 | } |
| 692 | fuse_invalidate_attr(inode); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 693 | |
| 694 | return res; |
| 695 | } |
| 696 | |
| 697 | static ssize_t fuse_direct_read(struct file *file, char __user *buf, |
| 698 | size_t count, loff_t *ppos) |
| 699 | { |
| 700 | return fuse_direct_io(file, buf, count, ppos, 0); |
| 701 | } |
| 702 | |
| 703 | static ssize_t fuse_direct_write(struct file *file, const char __user *buf, |
| 704 | size_t count, loff_t *ppos) |
| 705 | { |
Josef Sipek | 7706a9d | 2006-12-08 02:37:02 -0800 | [diff] [blame] | 706 | struct inode *inode = file->f_path.dentry->d_inode; |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 707 | ssize_t res; |
| 708 | /* Don't allow parallel writes to the same file */ |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 709 | mutex_lock(&inode->i_mutex); |
Miklos Szeredi | 889f784 | 2007-05-23 13:57:54 -0700 | [diff] [blame] | 710 | res = generic_write_checks(file, ppos, &count, 0); |
| 711 | if (!res) |
| 712 | res = fuse_direct_io(file, buf, count, ppos, 1); |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 713 | mutex_unlock(&inode->i_mutex); |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 714 | return res; |
| 715 | } |
| 716 | |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 717 | static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma) |
| 718 | { |
| 719 | if ((vma->vm_flags & VM_SHARED)) { |
| 720 | if ((vma->vm_flags & VM_WRITE)) |
| 721 | return -ENODEV; |
| 722 | else |
| 723 | vma->vm_flags &= ~VM_MAYWRITE; |
| 724 | } |
| 725 | return generic_file_mmap(file, vma); |
| 726 | } |
| 727 | |
| 728 | static int fuse_set_page_dirty(struct page *page) |
| 729 | { |
| 730 | printk("fuse_set_page_dirty: should not happen\n"); |
| 731 | dump_stack(); |
| 732 | return 0; |
| 733 | } |
| 734 | |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 735 | static int convert_fuse_file_lock(const struct fuse_file_lock *ffl, |
| 736 | struct file_lock *fl) |
| 737 | { |
| 738 | switch (ffl->type) { |
| 739 | case F_UNLCK: |
| 740 | break; |
| 741 | |
| 742 | case F_RDLCK: |
| 743 | case F_WRLCK: |
| 744 | if (ffl->start > OFFSET_MAX || ffl->end > OFFSET_MAX || |
| 745 | ffl->end < ffl->start) |
| 746 | return -EIO; |
| 747 | |
| 748 | fl->fl_start = ffl->start; |
| 749 | fl->fl_end = ffl->end; |
| 750 | fl->fl_pid = ffl->pid; |
| 751 | break; |
| 752 | |
| 753 | default: |
| 754 | return -EIO; |
| 755 | } |
| 756 | fl->fl_type = ffl->type; |
| 757 | return 0; |
| 758 | } |
| 759 | |
| 760 | static void fuse_lk_fill(struct fuse_req *req, struct file *file, |
Miklos Szeredi | a9ff4f8 | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 761 | const struct file_lock *fl, int opcode, pid_t pid, |
| 762 | int flock) |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 763 | { |
Josef Sipek | 7706a9d | 2006-12-08 02:37:02 -0800 | [diff] [blame] | 764 | struct inode *inode = file->f_path.dentry->d_inode; |
Miklos Szeredi | 9c8ef56 | 2006-06-25 05:48:55 -0700 | [diff] [blame] | 765 | struct fuse_conn *fc = get_fuse_conn(inode); |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 766 | struct fuse_file *ff = file->private_data; |
| 767 | struct fuse_lk_in *arg = &req->misc.lk_in; |
| 768 | |
| 769 | arg->fh = ff->fh; |
Miklos Szeredi | 9c8ef56 | 2006-06-25 05:48:55 -0700 | [diff] [blame] | 770 | arg->owner = fuse_lock_owner_id(fc, fl->fl_owner); |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 771 | arg->lk.start = fl->fl_start; |
| 772 | arg->lk.end = fl->fl_end; |
| 773 | arg->lk.type = fl->fl_type; |
| 774 | arg->lk.pid = pid; |
Miklos Szeredi | a9ff4f8 | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 775 | if (flock) |
| 776 | arg->lk_flags |= FUSE_LK_FLOCK; |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 777 | req->in.h.opcode = opcode; |
| 778 | req->in.h.nodeid = get_node_id(inode); |
| 779 | req->in.numargs = 1; |
| 780 | req->in.args[0].size = sizeof(*arg); |
| 781 | req->in.args[0].value = arg; |
| 782 | } |
| 783 | |
| 784 | static int fuse_getlk(struct file *file, struct file_lock *fl) |
| 785 | { |
Josef Sipek | 7706a9d | 2006-12-08 02:37:02 -0800 | [diff] [blame] | 786 | struct inode *inode = file->f_path.dentry->d_inode; |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 787 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 788 | struct fuse_req *req; |
| 789 | struct fuse_lk_out outarg; |
| 790 | int err; |
| 791 | |
| 792 | req = fuse_get_req(fc); |
| 793 | if (IS_ERR(req)) |
| 794 | return PTR_ERR(req); |
| 795 | |
Miklos Szeredi | a9ff4f8 | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 796 | fuse_lk_fill(req, file, fl, FUSE_GETLK, 0, 0); |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 797 | req->out.numargs = 1; |
| 798 | req->out.args[0].size = sizeof(outarg); |
| 799 | req->out.args[0].value = &outarg; |
| 800 | request_send(fc, req); |
| 801 | err = req->out.h.error; |
| 802 | fuse_put_request(fc, req); |
| 803 | if (!err) |
| 804 | err = convert_fuse_file_lock(&outarg.lk, fl); |
| 805 | |
| 806 | return err; |
| 807 | } |
| 808 | |
Miklos Szeredi | a9ff4f8 | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 809 | static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 810 | { |
Josef Sipek | 7706a9d | 2006-12-08 02:37:02 -0800 | [diff] [blame] | 811 | struct inode *inode = file->f_path.dentry->d_inode; |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 812 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 813 | struct fuse_req *req; |
| 814 | int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; |
| 815 | pid_t pid = fl->fl_type != F_UNLCK ? current->tgid : 0; |
| 816 | int err; |
| 817 | |
| 818 | /* Unlock on close is handled by the flush method */ |
| 819 | if (fl->fl_flags & FL_CLOSE) |
| 820 | return 0; |
| 821 | |
| 822 | req = fuse_get_req(fc); |
| 823 | if (IS_ERR(req)) |
| 824 | return PTR_ERR(req); |
| 825 | |
Miklos Szeredi | a9ff4f8 | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 826 | fuse_lk_fill(req, file, fl, opcode, pid, flock); |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 827 | request_send(fc, req); |
| 828 | err = req->out.h.error; |
Miklos Szeredi | a4d27e7 | 2006-06-25 05:48:54 -0700 | [diff] [blame] | 829 | /* locking is restartable */ |
| 830 | if (err == -EINTR) |
| 831 | err = -ERESTARTSYS; |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 832 | fuse_put_request(fc, req); |
| 833 | return err; |
| 834 | } |
| 835 | |
| 836 | static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) |
| 837 | { |
Josef Sipek | 7706a9d | 2006-12-08 02:37:02 -0800 | [diff] [blame] | 838 | struct inode *inode = file->f_path.dentry->d_inode; |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 839 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 840 | int err; |
| 841 | |
| 842 | if (cmd == F_GETLK) { |
| 843 | if (fc->no_lock) { |
Marc Eshel | 9d6a8c5 | 2007-02-21 00:55:18 -0500 | [diff] [blame] | 844 | posix_test_lock(file, fl); |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 845 | err = 0; |
| 846 | } else |
| 847 | err = fuse_getlk(file, fl); |
| 848 | } else { |
| 849 | if (fc->no_lock) |
| 850 | err = posix_lock_file_wait(file, fl); |
| 851 | else |
Miklos Szeredi | a9ff4f8 | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 852 | err = fuse_setlk(file, fl, 0); |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 853 | } |
| 854 | return err; |
| 855 | } |
| 856 | |
Miklos Szeredi | a9ff4f8 | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 857 | static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl) |
| 858 | { |
| 859 | struct inode *inode = file->f_path.dentry->d_inode; |
| 860 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 861 | int err; |
| 862 | |
| 863 | if (fc->no_lock) { |
| 864 | err = flock_lock_file_wait(file, fl); |
| 865 | } else { |
| 866 | /* emulate flock with POSIX locks */ |
| 867 | fl->fl_owner = (fl_owner_t) file; |
| 868 | err = fuse_setlk(file, fl, 1); |
| 869 | } |
| 870 | |
| 871 | return err; |
| 872 | } |
| 873 | |
Miklos Szeredi | b2d2272 | 2006-12-06 20:35:51 -0800 | [diff] [blame] | 874 | static sector_t fuse_bmap(struct address_space *mapping, sector_t block) |
| 875 | { |
| 876 | struct inode *inode = mapping->host; |
| 877 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 878 | struct fuse_req *req; |
| 879 | struct fuse_bmap_in inarg; |
| 880 | struct fuse_bmap_out outarg; |
| 881 | int err; |
| 882 | |
| 883 | if (!inode->i_sb->s_bdev || fc->no_bmap) |
| 884 | return 0; |
| 885 | |
| 886 | req = fuse_get_req(fc); |
| 887 | if (IS_ERR(req)) |
| 888 | return 0; |
| 889 | |
| 890 | memset(&inarg, 0, sizeof(inarg)); |
| 891 | inarg.block = block; |
| 892 | inarg.blocksize = inode->i_sb->s_blocksize; |
| 893 | req->in.h.opcode = FUSE_BMAP; |
| 894 | req->in.h.nodeid = get_node_id(inode); |
| 895 | req->in.numargs = 1; |
| 896 | req->in.args[0].size = sizeof(inarg); |
| 897 | req->in.args[0].value = &inarg; |
| 898 | req->out.numargs = 1; |
| 899 | req->out.args[0].size = sizeof(outarg); |
| 900 | req->out.args[0].value = &outarg; |
| 901 | request_send(fc, req); |
| 902 | err = req->out.h.error; |
| 903 | fuse_put_request(fc, req); |
| 904 | if (err == -ENOSYS) |
| 905 | fc->no_bmap = 1; |
| 906 | |
| 907 | return err ? 0 : outarg.block; |
| 908 | } |
| 909 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 910 | static const struct file_operations fuse_file_operations = { |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 911 | .llseek = generic_file_llseek, |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 912 | .read = do_sync_read, |
Miklos Szeredi | bcb4be8 | 2007-11-28 16:21:59 -0800 | [diff] [blame] | 913 | .aio_read = fuse_file_aio_read, |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 914 | .write = do_sync_write, |
| 915 | .aio_write = generic_file_aio_write, |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 916 | .mmap = fuse_file_mmap, |
| 917 | .open = fuse_open, |
| 918 | .flush = fuse_flush, |
| 919 | .release = fuse_release, |
| 920 | .fsync = fuse_fsync, |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 921 | .lock = fuse_file_lock, |
Miklos Szeredi | a9ff4f8 | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 922 | .flock = fuse_file_flock, |
Jens Axboe | 5ffc4ef | 2007-06-01 11:49:19 +0200 | [diff] [blame] | 923 | .splice_read = generic_file_splice_read, |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 924 | }; |
| 925 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 926 | static const struct file_operations fuse_direct_io_file_operations = { |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 927 | .llseek = generic_file_llseek, |
| 928 | .read = fuse_direct_read, |
| 929 | .write = fuse_direct_write, |
| 930 | .open = fuse_open, |
| 931 | .flush = fuse_flush, |
| 932 | .release = fuse_release, |
| 933 | .fsync = fuse_fsync, |
Miklos Szeredi | 7142125 | 2006-06-25 05:48:52 -0700 | [diff] [blame] | 934 | .lock = fuse_file_lock, |
Miklos Szeredi | a9ff4f8 | 2007-10-18 03:07:02 -0700 | [diff] [blame] | 935 | .flock = fuse_file_flock, |
Jens Axboe | 5ffc4ef | 2007-06-01 11:49:19 +0200 | [diff] [blame] | 936 | /* no mmap and splice_read */ |
Miklos Szeredi | 413ef8c | 2005-09-09 13:10:35 -0700 | [diff] [blame] | 937 | }; |
| 938 | |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 939 | static const struct address_space_operations fuse_file_aops = { |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 940 | .readpage = fuse_readpage, |
Nick Piggin | 5e6f58a | 2007-10-16 01:25:17 -0700 | [diff] [blame] | 941 | .write_begin = fuse_write_begin, |
| 942 | .write_end = fuse_write_end, |
Miklos Szeredi | db50b96 | 2005-09-09 13:10:33 -0700 | [diff] [blame] | 943 | .readpages = fuse_readpages, |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 944 | .set_page_dirty = fuse_set_page_dirty, |
Miklos Szeredi | b2d2272 | 2006-12-06 20:35:51 -0800 | [diff] [blame] | 945 | .bmap = fuse_bmap, |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 946 | }; |
| 947 | |
| 948 | void fuse_init_file_inode(struct inode *inode) |
| 949 | { |
Miklos Szeredi | 45323fb | 2005-09-09 13:10:37 -0700 | [diff] [blame] | 950 | inode->i_fop = &fuse_file_operations; |
| 951 | inode->i_data.a_ops = &fuse_file_aops; |
Miklos Szeredi | b6aeade | 2005-09-09 13:10:30 -0700 | [diff] [blame] | 952 | } |