Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * file.c |
| 3 | * |
| 4 | * Copyright (C) 1995, 1996, 1997 by Paal-Kr. Engstad and Volker Lendecke |
| 5 | * Copyright (C) 1997 by Volker Lendecke |
| 6 | * |
| 7 | * Please add a note about your changes to smbfs in the ChangeLog file. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/time.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/errno.h> |
| 13 | #include <linux/fcntl.h> |
| 14 | #include <linux/stat.h> |
| 15 | #include <linux/mm.h> |
| 16 | #include <linux/slab.h> |
| 17 | #include <linux/pagemap.h> |
| 18 | #include <linux/smp_lock.h> |
| 19 | #include <linux/net.h> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 20 | #include <linux/aio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | #include <asm/uaccess.h> |
| 23 | #include <asm/system.h> |
| 24 | |
| 25 | #include <linux/smbno.h> |
| 26 | #include <linux/smb_fs.h> |
| 27 | |
| 28 | #include "smb_debug.h" |
| 29 | #include "proto.h" |
| 30 | |
| 31 | static int |
| 32 | smb_fsync(struct file *file, struct dentry * dentry, int datasync) |
| 33 | { |
| 34 | struct smb_sb_info *server = server_from_dentry(dentry); |
| 35 | int result; |
| 36 | |
| 37 | VERBOSE("sync file %s/%s\n", DENTRY_PATH(dentry)); |
| 38 | |
| 39 | /* |
| 40 | * The VFS will writepage() all dirty pages for us, but we |
| 41 | * should send a SMBflush to the server, letting it know that |
| 42 | * we want things synchronized with actual storage. |
| 43 | * |
| 44 | * Note: this function requires all pages to have been written already |
| 45 | * (should be ok with writepage_sync) |
| 46 | */ |
| 47 | result = smb_proc_flush(server, SMB_I(dentry->d_inode)->fileid); |
| 48 | return result; |
| 49 | } |
| 50 | |
| 51 | /* |
| 52 | * Read a page synchronously. |
| 53 | */ |
| 54 | static int |
| 55 | smb_readpage_sync(struct dentry *dentry, struct page *page) |
| 56 | { |
| 57 | char *buffer = kmap(page); |
| 58 | loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT; |
| 59 | struct smb_sb_info *server = server_from_dentry(dentry); |
| 60 | unsigned int rsize = smb_get_rsize(server); |
| 61 | int count = PAGE_SIZE; |
| 62 | int result; |
| 63 | |
| 64 | VERBOSE("file %s/%s, count=%d@%Ld, rsize=%d\n", |
| 65 | DENTRY_PATH(dentry), count, offset, rsize); |
| 66 | |
| 67 | result = smb_open(dentry, SMB_O_RDONLY); |
| 68 | if (result < 0) |
| 69 | goto io_error; |
| 70 | |
| 71 | do { |
| 72 | if (count < rsize) |
| 73 | rsize = count; |
| 74 | |
| 75 | result = server->ops->read(dentry->d_inode,offset,rsize,buffer); |
| 76 | if (result < 0) |
| 77 | goto io_error; |
| 78 | |
| 79 | count -= result; |
| 80 | offset += result; |
| 81 | buffer += result; |
| 82 | dentry->d_inode->i_atime = |
| 83 | current_fs_time(dentry->d_inode->i_sb); |
| 84 | if (result < rsize) |
| 85 | break; |
| 86 | } while (count); |
| 87 | |
| 88 | memset(buffer, 0, count); |
| 89 | flush_dcache_page(page); |
| 90 | SetPageUptodate(page); |
| 91 | result = 0; |
| 92 | |
| 93 | io_error: |
| 94 | kunmap(page); |
| 95 | unlock_page(page); |
| 96 | return result; |
| 97 | } |
| 98 | |
| 99 | /* |
| 100 | * We are called with the page locked and we unlock it when done. |
| 101 | */ |
| 102 | static int |
| 103 | smb_readpage(struct file *file, struct page *page) |
| 104 | { |
| 105 | int error; |
Josef Sipek | 17b75e6 | 2006-12-08 02:37:39 -0800 | [diff] [blame] | 106 | struct dentry *dentry = file->f_path.dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
| 108 | page_cache_get(page); |
| 109 | error = smb_readpage_sync(dentry, page); |
| 110 | page_cache_release(page); |
| 111 | return error; |
| 112 | } |
| 113 | |
| 114 | /* |
| 115 | * Write a page synchronously. |
| 116 | * Offset is the data offset within the page. |
| 117 | */ |
| 118 | static int |
| 119 | smb_writepage_sync(struct inode *inode, struct page *page, |
| 120 | unsigned long pageoffset, unsigned int count) |
| 121 | { |
| 122 | loff_t offset; |
| 123 | char *buffer = kmap(page) + pageoffset; |
| 124 | struct smb_sb_info *server = server_from_inode(inode); |
| 125 | unsigned int wsize = smb_get_wsize(server); |
| 126 | int ret = 0; |
| 127 | |
| 128 | offset = ((loff_t)page->index << PAGE_CACHE_SHIFT) + pageoffset; |
| 129 | VERBOSE("file ino=%ld, fileid=%d, count=%d@%Ld, wsize=%d\n", |
| 130 | inode->i_ino, SMB_I(inode)->fileid, count, offset, wsize); |
| 131 | |
| 132 | do { |
| 133 | int write_ret; |
| 134 | |
| 135 | if (count < wsize) |
| 136 | wsize = count; |
| 137 | |
| 138 | write_ret = server->ops->write(inode, offset, wsize, buffer); |
| 139 | if (write_ret < 0) { |
| 140 | PARANOIA("failed write, wsize=%d, write_ret=%d\n", |
| 141 | wsize, write_ret); |
| 142 | ret = write_ret; |
| 143 | break; |
| 144 | } |
| 145 | /* N.B. what if result < wsize?? */ |
| 146 | #ifdef SMBFS_PARANOIA |
| 147 | if (write_ret < wsize) |
| 148 | PARANOIA("short write, wsize=%d, write_ret=%d\n", |
| 149 | wsize, write_ret); |
| 150 | #endif |
| 151 | buffer += wsize; |
| 152 | offset += wsize; |
| 153 | count -= wsize; |
| 154 | /* |
| 155 | * Update the inode now rather than waiting for a refresh. |
| 156 | */ |
| 157 | inode->i_mtime = inode->i_atime = current_fs_time(inode->i_sb); |
| 158 | SMB_I(inode)->flags |= SMB_F_LOCALWRITE; |
| 159 | if (offset > inode->i_size) |
| 160 | inode->i_size = offset; |
| 161 | } while (count); |
| 162 | |
| 163 | kunmap(page); |
| 164 | return ret; |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | * Write a page to the server. This will be used for NFS swapping only |
| 169 | * (for now), and we currently do this synchronously only. |
| 170 | * |
| 171 | * We are called with the page locked and we unlock it when done. |
| 172 | */ |
| 173 | static int |
| 174 | smb_writepage(struct page *page, struct writeback_control *wbc) |
| 175 | { |
| 176 | struct address_space *mapping = page->mapping; |
| 177 | struct inode *inode; |
| 178 | unsigned long end_index; |
| 179 | unsigned offset = PAGE_CACHE_SIZE; |
| 180 | int err; |
| 181 | |
Eric Sesterhenn | 5df0d31 | 2006-04-01 01:16:26 +0200 | [diff] [blame] | 182 | BUG_ON(!mapping); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | inode = mapping->host; |
Eric Sesterhenn | 5df0d31 | 2006-04-01 01:16:26 +0200 | [diff] [blame] | 184 | BUG_ON(!inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
| 186 | end_index = inode->i_size >> PAGE_CACHE_SHIFT; |
| 187 | |
| 188 | /* easy case */ |
| 189 | if (page->index < end_index) |
| 190 | goto do_it; |
| 191 | /* things got complicated... */ |
| 192 | offset = inode->i_size & (PAGE_CACHE_SIZE-1); |
| 193 | /* OK, are we completely out? */ |
| 194 | if (page->index >= end_index+1 || !offset) |
| 195 | return 0; /* truncated - don't care */ |
| 196 | do_it: |
| 197 | page_cache_get(page); |
| 198 | err = smb_writepage_sync(inode, page, 0, offset); |
| 199 | SetPageUptodate(page); |
| 200 | unlock_page(page); |
| 201 | page_cache_release(page); |
| 202 | return err; |
| 203 | } |
| 204 | |
| 205 | static int |
| 206 | smb_updatepage(struct file *file, struct page *page, unsigned long offset, |
| 207 | unsigned int count) |
| 208 | { |
Josef Sipek | 17b75e6 | 2006-12-08 02:37:39 -0800 | [diff] [blame] | 209 | struct dentry *dentry = file->f_path.dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | |
Andrew Morton | 54b21a7 | 2006-01-08 01:03:05 -0800 | [diff] [blame] | 211 | DEBUG1("(%s/%s %d@%lld)\n", DENTRY_PATH(dentry), count, |
| 212 | ((unsigned long long)page->index << PAGE_CACHE_SHIFT) + offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
| 214 | return smb_writepage_sync(dentry->d_inode, page, offset, count); |
| 215 | } |
| 216 | |
| 217 | static ssize_t |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 218 | smb_file_aio_read(struct kiocb *iocb, const struct iovec *iov, |
| 219 | unsigned long nr_segs, loff_t pos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | { |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 221 | struct file * file = iocb->ki_filp; |
Josef Sipek | 17b75e6 | 2006-12-08 02:37:39 -0800 | [diff] [blame] | 222 | struct dentry * dentry = file->f_path.dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | ssize_t status; |
| 224 | |
| 225 | VERBOSE("file %s/%s, count=%lu@%lu\n", DENTRY_PATH(dentry), |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 226 | (unsigned long) iocb->ki_left, (unsigned long) pos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
| 228 | status = smb_revalidate_inode(dentry); |
| 229 | if (status) { |
| 230 | PARANOIA("%s/%s validation failed, error=%Zd\n", |
| 231 | DENTRY_PATH(dentry), status); |
| 232 | goto out; |
| 233 | } |
| 234 | |
| 235 | VERBOSE("before read, size=%ld, flags=%x, atime=%ld\n", |
| 236 | (long)dentry->d_inode->i_size, |
Jeff Layton | dbaf4c0 | 2007-11-14 17:00:18 -0800 | [diff] [blame] | 237 | dentry->d_inode->i_flags, dentry->d_inode->i_atime.tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 239 | status = generic_file_aio_read(iocb, iov, nr_segs, pos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | out: |
| 241 | return status; |
| 242 | } |
| 243 | |
| 244 | static int |
| 245 | smb_file_mmap(struct file * file, struct vm_area_struct * vma) |
| 246 | { |
Josef Sipek | 17b75e6 | 2006-12-08 02:37:39 -0800 | [diff] [blame] | 247 | struct dentry * dentry = file->f_path.dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | int status; |
| 249 | |
| 250 | VERBOSE("file %s/%s, address %lu - %lu\n", |
| 251 | DENTRY_PATH(dentry), vma->vm_start, vma->vm_end); |
| 252 | |
| 253 | status = smb_revalidate_inode(dentry); |
| 254 | if (status) { |
| 255 | PARANOIA("%s/%s validation failed, error=%d\n", |
| 256 | DENTRY_PATH(dentry), status); |
| 257 | goto out; |
| 258 | } |
| 259 | status = generic_file_mmap(file, vma); |
| 260 | out: |
| 261 | return status; |
| 262 | } |
| 263 | |
| 264 | static ssize_t |
Jens Axboe | 5ffc4ef | 2007-06-01 11:49:19 +0200 | [diff] [blame] | 265 | smb_file_splice_read(struct file *file, loff_t *ppos, |
| 266 | struct pipe_inode_info *pipe, size_t count, |
| 267 | unsigned int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | { |
Josef Sipek | 17b75e6 | 2006-12-08 02:37:39 -0800 | [diff] [blame] | 269 | struct dentry *dentry = file->f_path.dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | ssize_t status; |
| 271 | |
Jeff Layton | dbaf4c0 | 2007-11-14 17:00:18 -0800 | [diff] [blame] | 272 | VERBOSE("file %s/%s, pos=%Ld, count=%lu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | DENTRY_PATH(dentry), *ppos, count); |
| 274 | |
| 275 | status = smb_revalidate_inode(dentry); |
| 276 | if (status) { |
| 277 | PARANOIA("%s/%s validation failed, error=%Zd\n", |
| 278 | DENTRY_PATH(dentry), status); |
| 279 | goto out; |
| 280 | } |
Jens Axboe | 5ffc4ef | 2007-06-01 11:49:19 +0200 | [diff] [blame] | 281 | status = generic_file_splice_read(file, ppos, pipe, count, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | out: |
| 283 | return status; |
| 284 | } |
| 285 | |
| 286 | /* |
| 287 | * This does the "real" work of the write. The generic routine has |
| 288 | * allocated the page, locked it, done all the page alignment stuff |
| 289 | * calculations etc. Now we should just copy the data from user |
| 290 | * space and write it back to the real medium.. |
| 291 | * |
| 292 | * If the writer ends up delaying the write, the writer needs to |
| 293 | * increment the page use counts until he is done with the page. |
| 294 | */ |
Nick Piggin | fb53b30 | 2007-10-16 01:25:16 -0700 | [diff] [blame] | 295 | static int smb_write_begin(struct file *file, struct address_space *mapping, |
| 296 | loff_t pos, unsigned len, unsigned flags, |
| 297 | struct page **pagep, void **fsdata) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | { |
Nick Piggin | fb53b30 | 2007-10-16 01:25:16 -0700 | [diff] [blame] | 299 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; |
| 300 | *pagep = __grab_cache_page(mapping, index); |
| 301 | if (!*pagep) |
| 302 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | return 0; |
| 304 | } |
| 305 | |
Nick Piggin | fb53b30 | 2007-10-16 01:25:16 -0700 | [diff] [blame] | 306 | static int smb_write_end(struct file *file, struct address_space *mapping, |
| 307 | loff_t pos, unsigned len, unsigned copied, |
| 308 | struct page *page, void *fsdata) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | { |
| 310 | int status; |
Nick Piggin | fb53b30 | 2007-10-16 01:25:16 -0700 | [diff] [blame] | 311 | unsigned offset = pos & (PAGE_CACHE_SIZE - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | lock_kernel(); |
Nick Piggin | fb53b30 | 2007-10-16 01:25:16 -0700 | [diff] [blame] | 314 | status = smb_updatepage(file, page, offset, copied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | unlock_kernel(); |
Nick Piggin | fb53b30 | 2007-10-16 01:25:16 -0700 | [diff] [blame] | 316 | |
| 317 | if (!status) { |
| 318 | if (!PageUptodate(page) && copied == PAGE_CACHE_SIZE) |
| 319 | SetPageUptodate(page); |
| 320 | status = copied; |
| 321 | } |
| 322 | |
| 323 | unlock_page(page); |
| 324 | page_cache_release(page); |
| 325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | return status; |
| 327 | } |
| 328 | |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 329 | const struct address_space_operations smb_file_aops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | .readpage = smb_readpage, |
| 331 | .writepage = smb_writepage, |
Nick Piggin | fb53b30 | 2007-10-16 01:25:16 -0700 | [diff] [blame] | 332 | .write_begin = smb_write_begin, |
| 333 | .write_end = smb_write_end, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | }; |
| 335 | |
| 336 | /* |
| 337 | * Write to a file (through the page cache). |
| 338 | */ |
| 339 | static ssize_t |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 340 | smb_file_aio_write(struct kiocb *iocb, const struct iovec *iov, |
| 341 | unsigned long nr_segs, loff_t pos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | { |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 343 | struct file * file = iocb->ki_filp; |
Josef Sipek | 17b75e6 | 2006-12-08 02:37:39 -0800 | [diff] [blame] | 344 | struct dentry * dentry = file->f_path.dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | ssize_t result; |
| 346 | |
| 347 | VERBOSE("file %s/%s, count=%lu@%lu\n", |
| 348 | DENTRY_PATH(dentry), |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 349 | (unsigned long) iocb->ki_left, (unsigned long) pos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | |
| 351 | result = smb_revalidate_inode(dentry); |
| 352 | if (result) { |
| 353 | PARANOIA("%s/%s validation failed, error=%Zd\n", |
| 354 | DENTRY_PATH(dentry), result); |
| 355 | goto out; |
| 356 | } |
| 357 | |
| 358 | result = smb_open(dentry, SMB_O_WRONLY); |
| 359 | if (result) |
| 360 | goto out; |
| 361 | |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 362 | if (iocb->ki_left > 0) { |
| 363 | result = generic_file_aio_write(iocb, iov, nr_segs, pos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | VERBOSE("pos=%ld, size=%ld, mtime=%ld, atime=%ld\n", |
| 365 | (long) file->f_pos, (long) dentry->d_inode->i_size, |
Jeff Layton | dbaf4c0 | 2007-11-14 17:00:18 -0800 | [diff] [blame] | 366 | dentry->d_inode->i_mtime.tv_sec, |
| 367 | dentry->d_inode->i_atime.tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | } |
| 369 | out: |
| 370 | return result; |
| 371 | } |
| 372 | |
| 373 | static int |
| 374 | smb_file_open(struct inode *inode, struct file * file) |
| 375 | { |
| 376 | int result; |
Josef Sipek | 17b75e6 | 2006-12-08 02:37:39 -0800 | [diff] [blame] | 377 | struct dentry *dentry = file->f_path.dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | int smb_mode = (file->f_mode & O_ACCMODE) - 1; |
| 379 | |
| 380 | lock_kernel(); |
| 381 | result = smb_open(dentry, smb_mode); |
| 382 | if (result) |
| 383 | goto out; |
| 384 | SMB_I(inode)->openers++; |
| 385 | out: |
| 386 | unlock_kernel(); |
| 387 | return result; |
| 388 | } |
| 389 | |
| 390 | static int |
| 391 | smb_file_release(struct inode *inode, struct file * file) |
| 392 | { |
| 393 | lock_kernel(); |
| 394 | if (!--SMB_I(inode)->openers) { |
| 395 | /* We must flush any dirty pages now as we won't be able to |
| 396 | write anything after close. mmap can trigger this. |
| 397 | "openers" should perhaps include mmap'ers ... */ |
OGAWA Hirofumi | 28fd129 | 2006-01-08 01:02:14 -0800 | [diff] [blame] | 398 | filemap_write_and_wait(inode->i_mapping); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | smb_close(inode); |
| 400 | } |
| 401 | unlock_kernel(); |
| 402 | return 0; |
| 403 | } |
| 404 | |
| 405 | /* |
| 406 | * Check whether the required access is compatible with |
| 407 | * an inode's permission. SMB doesn't recognize superuser |
| 408 | * privileges, so we need our own check for this. |
| 409 | */ |
| 410 | static int |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 411 | smb_file_permission(struct inode *inode, int mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | { |
| 413 | int mode = inode->i_mode; |
| 414 | int error = 0; |
| 415 | |
| 416 | VERBOSE("mode=%x, mask=%x\n", mode, mask); |
| 417 | |
| 418 | /* Look at user permissions */ |
| 419 | mode >>= 6; |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 420 | if (mask & ~mode & (MAY_READ | MAY_WRITE | MAY_EXEC)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | error = -EACCES; |
| 422 | return error; |
| 423 | } |
| 424 | |
Andi Kleen | 9465efc | 2008-06-27 11:05:24 +0200 | [diff] [blame] | 425 | static loff_t smb_remote_llseek(struct file *file, loff_t offset, int origin) |
| 426 | { |
| 427 | loff_t ret; |
| 428 | lock_kernel(); |
| 429 | ret = generic_file_llseek_unlocked(file, offset, origin); |
| 430 | unlock_kernel(); |
| 431 | return ret; |
| 432 | } |
| 433 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 434 | const struct file_operations smb_file_operations = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | { |
Andi Kleen | 9465efc | 2008-06-27 11:05:24 +0200 | [diff] [blame] | 436 | .llseek = smb_remote_llseek, |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 437 | .read = do_sync_read, |
| 438 | .aio_read = smb_file_aio_read, |
| 439 | .write = do_sync_write, |
| 440 | .aio_write = smb_file_aio_write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | .ioctl = smb_ioctl, |
| 442 | .mmap = smb_file_mmap, |
| 443 | .open = smb_file_open, |
| 444 | .release = smb_file_release, |
| 445 | .fsync = smb_fsync, |
Jens Axboe | 5ffc4ef | 2007-06-01 11:49:19 +0200 | [diff] [blame] | 446 | .splice_read = smb_file_splice_read, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | }; |
| 448 | |
Arjan van de Ven | c5ef1c4 | 2007-02-12 00:55:40 -0800 | [diff] [blame] | 449 | const struct inode_operations smb_file_inode_operations = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | { |
| 451 | .permission = smb_file_permission, |
| 452 | .getattr = smb_getattr, |
| 453 | .setattr = smb_notify_change, |
| 454 | }; |