Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inline int sync_filesystem(int fd)
- {
- /* On Linux, newer versions of glibc have a function called syncfs that
- * performs a sync on only one filesystem. If we don't have this call, we
- * have to fall back on sync(), which synchronizes every filesystem on the
- * computer. */
- #ifdef HAVE_SYS_SYNCFS
- if (syncfs(fd) == 0)
- return 0;
- #elif defined(SYS_syncfs)
- if (syscall(SYS_syncfs, fd) == 0)
- return 0;
- #elif defined(__NR_syncfs)
- if (syscall(__NR_syncfs, fd) == 0)
- return 0;
- #endif
- #ifdef BTRFS_IOC_SYNC
- if (::ioctl(fd, BTRFS_IOC_SYNC) == 0)
- return 0;
- #endif
- sync();
- return 0;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement