Advertisement
Guest User

Untitled

a guest
May 14th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. inline int sync_filesystem(int fd)
  2. {
  3. /* On Linux, newer versions of glibc have a function called syncfs that
  4. * performs a sync on only one filesystem. If we don't have this call, we
  5. * have to fall back on sync(), which synchronizes every filesystem on the
  6. * computer. */
  7. #ifdef HAVE_SYS_SYNCFS
  8. if (syncfs(fd) == 0)
  9. return 0;
  10. #elif defined(SYS_syncfs)
  11. if (syscall(SYS_syncfs, fd) == 0)
  12. return 0;
  13. #elif defined(__NR_syncfs)
  14. if (syscall(__NR_syncfs, fd) == 0)
  15. return 0;
  16. #endif
  17.  
  18. #ifdef BTRFS_IOC_SYNC
  19. if (::ioctl(fd, BTRFS_IOC_SYNC) == 0)
  20. return 0;
  21. #endif
  22.  
  23. sync();
  24. return 0;
  25. }
  26.  
  27. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement