file.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * linux/fs/ext2/file.c
  3. *
  4. * Copyright (C) 1992, 1993, 1994, 1995
  5. * Remy Card (card@masi.ibp.fr)
  6. * Laboratoire MASI - Institut Blaise Pascal
  7. * Universite Pierre et Marie Curie (Paris VI)
  8. *
  9. * from
  10. *
  11. * linux/fs/minix/file.c
  12. *
  13. * Copyright (C) 1991, 1992 Linus Torvalds
  14. *
  15. * ext2 fs regular file handling primitives
  16. *
  17. * 64-bit file support on 64-bit platforms by Jakub Jelinek
  18. * (jj@sunsite.ms.mff.cuni.cz)
  19. */
  20. #include <linux/time.h>
  21. #include "ext2.h"
  22. #include "xattr.h"
  23. #include "acl.h"
  24. /*
  25. * Called when filp is released. This happens when all file descriptors
  26. * for a single struct file are closed. Note that different open() calls
  27. * for the same file yield different struct file structures.
  28. */
  29. static int ext2_release_file (struct inode * inode, struct file * filp)
  30. {
  31. if (filp->f_mode & FMODE_WRITE)
  32. ext2_discard_prealloc (inode);
  33. return 0;
  34. }
  35. /*
  36. * We have mostly NULL's here: the current defaults are ok for
  37. * the ext2 filesystem.
  38. */
  39. const struct file_operations ext2_file_operations = {
  40. .llseek = generic_file_llseek,
  41. .read = do_sync_read,
  42. .write = do_sync_write,
  43. .aio_read = generic_file_aio_read,
  44. .aio_write = generic_file_aio_write,
  45. .ioctl = ext2_ioctl,
  46. #ifdef CONFIG_COMPAT
  47. .compat_ioctl = ext2_compat_ioctl,
  48. #endif
  49. .mmap = generic_file_mmap,
  50. .open = generic_file_open,
  51. .release = ext2_release_file,
  52. .fsync = ext2_sync_file,
  53. .splice_read = generic_file_splice_read,
  54. .splice_write = generic_file_splice_write,
  55. };
  56. #ifdef CONFIG_EXT2_FS_XIP
  57. const struct file_operations ext2_xip_file_operations = {
  58. .llseek = generic_file_llseek,
  59. .read = xip_file_read,
  60. .write = xip_file_write,
  61. .ioctl = ext2_ioctl,
  62. #ifdef CONFIG_COMPAT
  63. .compat_ioctl = ext2_compat_ioctl,
  64. #endif
  65. .mmap = xip_file_mmap,
  66. .open = generic_file_open,
  67. .release = ext2_release_file,
  68. .fsync = ext2_sync_file,
  69. };
  70. #endif
  71. const struct inode_operations ext2_file_inode_operations = {
  72. .truncate = ext2_truncate,
  73. #ifdef CONFIG_EXT2_FS_XATTR
  74. .setxattr = generic_setxattr,
  75. .getxattr = generic_getxattr,
  76. .listxattr = ext2_listxattr,
  77. .removexattr = generic_removexattr,
  78. #endif
  79. .setattr = ext2_setattr,
  80. .permission = ext2_permission,
  81. };