fsync.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * fsync.c
  3. *
  4. * PURPOSE
  5. * Fsync handling routines for the OSTA-UDF(tm) filesystem.
  6. *
  7. * COPYRIGHT
  8. * This file is distributed under the terms of the GNU General Public
  9. * License (GPL). Copies of the GPL can be obtained from:
  10. * ftp://prep.ai.mit.edu/pub/gnu/GPL
  11. * Each contributing author retains all rights to their own work.
  12. *
  13. * (C) 1999-2001 Ben Fennema
  14. * (C) 1999-2000 Stelias Computing Inc
  15. *
  16. * HISTORY
  17. *
  18. * 05/22/99 blf Created.
  19. */
  20. #include "udfdecl.h"
  21. #include <linux/fs.h>
  22. #include <linux/smp_lock.h>
  23. static int udf_fsync_inode(struct inode *, int);
  24. /*
  25. * File may be NULL when we are called. Perhaps we shouldn't
  26. * even pass file to fsync ?
  27. */
  28. int udf_fsync_file(struct file * file, struct dentry *dentry, int datasync)
  29. {
  30. struct inode *inode = dentry->d_inode;
  31. return udf_fsync_inode(inode, datasync);
  32. }
  33. static int udf_fsync_inode(struct inode *inode, int datasync)
  34. {
  35. int err;
  36. err = sync_mapping_buffers(inode->i_mapping);
  37. if (!(inode->i_state & I_DIRTY))
  38. return err;
  39. if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
  40. return err;
  41. err |= udf_sync_inode (inode);
  42. return err ? -EIO : 0;
  43. }