file.c (2106cb18930312af9325d3418e138569c5b903cc) | file.c (c7b7143c6342b8751d47b03a025ac5c0ac1ae809) |
---|---|
1/* 2 FUSE: Filesystem in Userspace 3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> 4 5 This program can be distributed under the terms of the GNU GPL. 6 See the file COPYING. 7*/ 8 --- 65 unchanged lines hidden (view full) --- 74} 75 76void fuse_file_free(struct fuse_file *ff) 77{ 78 fuse_request_free(ff->reserved_req); 79 kfree(ff); 80} 81 | 1/* 2 FUSE: Filesystem in Userspace 3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> 4 5 This program can be distributed under the terms of the GNU GPL. 6 See the file COPYING. 7*/ 8 --- 65 unchanged lines hidden (view full) --- 74} 75 76void fuse_file_free(struct fuse_file *ff) 77{ 78 fuse_request_free(ff->reserved_req); 79 kfree(ff); 80} 81 |
82static struct fuse_file *fuse_file_get(struct fuse_file *ff) | 82struct fuse_file *fuse_file_get(struct fuse_file *ff) |
83{ 84 atomic_inc(&ff->count); 85 return ff; 86} 87 88static void fuse_release_end(struct fuse_conn *fc, struct fuse_req *req) 89{ 90 path_put(&req->misc.release.path); --- 6 unchanged lines hidden (view full) --- 97 struct inode *inode = req->misc.release.path.dentry->d_inode; 98 struct fuse_conn *fc = get_fuse_conn(inode); 99 req->end = fuse_release_end; 100 fuse_request_send_background(fc, req); 101 kfree(ff); 102 } 103} 104 | 83{ 84 atomic_inc(&ff->count); 85 return ff; 86} 87 88static void fuse_release_end(struct fuse_conn *fc, struct fuse_req *req) 89{ 90 path_put(&req->misc.release.path); --- 6 unchanged lines hidden (view full) --- 97 struct inode *inode = req->misc.release.path.dentry->d_inode; 98 struct fuse_conn *fc = get_fuse_conn(inode); 99 req->end = fuse_release_end; 100 fuse_request_send_background(fc, req); 101 kfree(ff); 102 } 103} 104 |
105void fuse_finish_open(struct inode *inode, struct file *file, 106 struct fuse_file *ff, struct fuse_open_out *outarg) | 105void fuse_finish_open(struct inode *inode, struct file *file) |
107{ | 106{ |
108 if (outarg->open_flags & FOPEN_DIRECT_IO) | 107 struct fuse_file *ff = file->private_data; 108 109 if (ff->open_flags & FOPEN_DIRECT_IO) |
109 file->f_op = &fuse_direct_io_file_operations; | 110 file->f_op = &fuse_direct_io_file_operations; |
110 if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) | 111 if (!(ff->open_flags & FOPEN_KEEP_CACHE)) |
111 invalidate_inode_pages2(inode->i_mapping); | 112 invalidate_inode_pages2(inode->i_mapping); |
112 if (outarg->open_flags & FOPEN_NONSEEKABLE) | 113 if (ff->open_flags & FOPEN_NONSEEKABLE) |
113 nonseekable_open(inode, file); | 114 nonseekable_open(inode, file); |
114 ff->fh = outarg->fh; 115 ff->nodeid = get_node_id(inode); 116 file->private_data = fuse_file_get(ff); | |
117} 118 119int fuse_open_common(struct inode *inode, struct file *file, int isdir) 120{ 121 struct fuse_conn *fc = get_fuse_conn(inode); 122 struct fuse_open_out outarg; 123 struct fuse_file *ff; 124 int err; --- 11 unchanged lines hidden (view full) --- 136 return -ENOMEM; 137 138 err = fuse_send_open(inode, file, isdir, &outarg); 139 if (err) 140 fuse_file_free(ff); 141 else { 142 if (isdir) 143 outarg.open_flags &= ~FOPEN_DIRECT_IO; | 115} 116 117int fuse_open_common(struct inode *inode, struct file *file, int isdir) 118{ 119 struct fuse_conn *fc = get_fuse_conn(inode); 120 struct fuse_open_out outarg; 121 struct fuse_file *ff; 122 int err; --- 11 unchanged lines hidden (view full) --- 134 return -ENOMEM; 135 136 err = fuse_send_open(inode, file, isdir, &outarg); 137 if (err) 138 fuse_file_free(ff); 139 else { 140 if (isdir) 141 outarg.open_flags &= ~FOPEN_DIRECT_IO; |
144 fuse_finish_open(inode, file, ff, &outarg); | 142 ff->fh = outarg.fh; 143 ff->nodeid = get_node_id(inode); 144 ff->open_flags = outarg.open_flags; 145 file->private_data = fuse_file_get(ff); 146 fuse_finish_open(inode, file); |
145 } 146 147 return err; 148} 149 | 147 } 148 149 return err; 150} 151 |
150void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode) | 152void fuse_release_fill(struct fuse_file *ff, int flags, int opcode) |
151{ 152 struct fuse_req *req = ff->reserved_req; 153 struct fuse_release_in *inarg = &req->misc.release.in; 154 155 inarg->fh = ff->fh; 156 inarg->flags = flags; 157 req->in.h.opcode = opcode; | 153{ 154 struct fuse_req *req = ff->reserved_req; 155 struct fuse_release_in *inarg = &req->misc.release.in; 156 157 inarg->fh = ff->fh; 158 inarg->flags = flags; 159 req->in.h.opcode = opcode; |
158 req->in.h.nodeid = nodeid; | 160 req->in.h.nodeid = ff->nodeid; |
159 req->in.numargs = 1; 160 req->in.args[0].size = sizeof(struct fuse_release_in); 161 req->in.args[0].value = inarg; 162} 163 164int fuse_release_common(struct inode *inode, struct file *file, int isdir) 165{ 166 struct fuse_conn *fc; 167 struct fuse_file *ff; 168 struct fuse_req *req; 169 170 ff = file->private_data; 171 if (unlikely(!ff)) 172 return 0; /* return value is ignored by VFS */ 173 174 fc = get_fuse_conn(inode); 175 req = ff->reserved_req; 176 | 161 req->in.numargs = 1; 162 req->in.args[0].size = sizeof(struct fuse_release_in); 163 req->in.args[0].value = inarg; 164} 165 166int fuse_release_common(struct inode *inode, struct file *file, int isdir) 167{ 168 struct fuse_conn *fc; 169 struct fuse_file *ff; 170 struct fuse_req *req; 171 172 ff = file->private_data; 173 if (unlikely(!ff)) 174 return 0; /* return value is ignored by VFS */ 175 176 fc = get_fuse_conn(inode); 177 req = ff->reserved_req; 178 |
177 fuse_release_fill(ff, get_node_id(inode), file->f_flags, | 179 fuse_release_fill(ff, file->f_flags, |
178 isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); 179 180 /* Hold vfsmount and dentry until release is finished */ 181 path_get(&file->f_path); 182 req->misc.release.path = file->f_path; 183 184 spin_lock(&fc->lock); 185 list_del(&ff->write_entry); --- 1801 unchanged lines hidden --- | 180 isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); 181 182 /* Hold vfsmount and dentry until release is finished */ 183 path_get(&file->f_path); 184 req->misc.release.path = file->f_path; 185 186 spin_lock(&fc->lock); 187 list_del(&ff->write_entry); --- 1801 unchanged lines hidden --- |