vfs_addr.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * linux/fs/9p/vfs_addr.c
  3. *
  4. * This file contians vfs address (mmap) ops for 9P2000.
  5. *
  6. * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com>
  7. * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to:
  20. * Free Software Foundation
  21. * 51 Franklin Street, Fifth Floor
  22. * Boston, MA 02111-1301 USA
  23. *
  24. */
  25. #include <linux/module.h>
  26. #include <linux/errno.h>
  27. #include <linux/fs.h>
  28. #include <linux/file.h>
  29. #include <linux/stat.h>
  30. #include <linux/string.h>
  31. #include <linux/inet.h>
  32. #include <linux/pagemap.h>
  33. #include <linux/idr.h>
  34. #include <linux/sched.h>
  35. #include <net/9p/9p.h>
  36. #include <net/9p/client.h>
  37. #include "v9fs.h"
  38. #include "v9fs_vfs.h"
  39. #include "fid.h"
  40. /**
  41. * v9fs_vfs_readpage - read an entire page in from 9P
  42. *
  43. * @file: file being read
  44. * @page: structure to page
  45. *
  46. */
  47. static int v9fs_vfs_readpage(struct file *filp, struct page *page)
  48. {
  49. int retval;
  50. loff_t offset;
  51. char *buffer;
  52. struct p9_fid *fid;
  53. P9_DPRINTK(P9_DEBUG_VFS, "\n");
  54. fid = filp->private_data;
  55. buffer = kmap(page);
  56. offset = page_offset(page);
  57. retval = p9_client_readn(fid, buffer, offset, PAGE_CACHE_SIZE);
  58. if (retval < 0)
  59. goto done;
  60. memset(buffer + retval, 0, PAGE_CACHE_SIZE - retval);
  61. flush_dcache_page(page);
  62. SetPageUptodate(page);
  63. retval = 0;
  64. done:
  65. kunmap(page);
  66. unlock_page(page);
  67. return retval;
  68. }
  69. const struct address_space_operations v9fs_addr_operations = {
  70. .readpage = v9fs_vfs_readpage,
  71. };