mmap.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * fs/sdcardfs/mmap.c
  3. *
  4. * Copyright (c) 2013 Samsung Electronics Co. Ltd
  5. * Authors: Daeho Jeong, Woojoong Lee, Seunghwan Hyun,
  6. * Sunghwan Yun, Sungjong Seo
  7. *
  8. * This program has been developed as a stackable file system based on
  9. * the WrapFS which written by
  10. *
  11. * Copyright (c) 1998-2011 Erez Zadok
  12. * Copyright (c) 2009 Shrikar Archak
  13. * Copyright (c) 2003-2011 Stony Brook University
  14. * Copyright (c) 2003-2011 The Research Foundation of SUNY
  15. *
  16. * This file is dual licensed. It may be redistributed and/or modified
  17. * under the terms of the Apache 2.0 License OR version 2 of the GNU
  18. * General Public License.
  19. */
  20. #include "sdcardfs.h"
  21. static int sdcardfs_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  22. {
  23. int err;
  24. struct file *file;
  25. const struct vm_operations_struct *lower_vm_ops;
  26. file = (struct file *)vma->vm_private_data;
  27. lower_vm_ops = SDCARDFS_F(file)->lower_vm_ops;
  28. BUG_ON(!lower_vm_ops);
  29. err = lower_vm_ops->fault(vma, vmf);
  30. return err;
  31. }
  32. static void sdcardfs_vm_open(struct vm_area_struct *vma)
  33. {
  34. struct file *file = (struct file *)vma->vm_private_data;
  35. get_file(file);
  36. }
  37. static void sdcardfs_vm_close(struct vm_area_struct *vma)
  38. {
  39. struct file *file = (struct file *)vma->vm_private_data;
  40. fput(file);
  41. }
  42. static int sdcardfs_page_mkwrite(struct vm_area_struct *vma,
  43. struct vm_fault *vmf)
  44. {
  45. int err = 0;
  46. struct file *file;
  47. const struct vm_operations_struct *lower_vm_ops;
  48. file = (struct file *)vma->vm_private_data;
  49. lower_vm_ops = SDCARDFS_F(file)->lower_vm_ops;
  50. BUG_ON(!lower_vm_ops);
  51. if (!lower_vm_ops->page_mkwrite)
  52. goto out;
  53. err = lower_vm_ops->page_mkwrite(vma, vmf);
  54. out:
  55. return err;
  56. }
  57. static ssize_t sdcardfs_direct_IO(int rw, struct kiocb *iocb,
  58. const struct iovec *iov, loff_t offset,
  59. unsigned long nr_segs)
  60. {
  61. /*
  62. * This function should never be called directly. We need it
  63. * to exist, to get past a check in open_check_o_direct(),
  64. * which is called from do_last().
  65. */
  66. return -EINVAL;
  67. }
  68. const struct address_space_operations sdcardfs_aops = {
  69. .direct_IO = sdcardfs_direct_IO,
  70. };
  71. const struct vm_operations_struct sdcardfs_vm_ops = {
  72. .fault = sdcardfs_fault,
  73. .page_mkwrite = sdcardfs_page_mkwrite,
  74. .remap_pages = generic_file_remap_pages,
  75. .open = sdcardfs_vm_open,
  76. .close = sdcardfs_vm_close,
  77. };