Flushes buffered data and attributes written to the file to permanent storage
| 619 | |
| 620 | //! Flushes buffered data and attributes written to the file to permanent storage |
| 621 | inline int full_sync(int fd) |
| 622 | { |
| 623 | while (true) |
| 624 | { |
| 625 | #if defined(__APPLE__) && defined(__MACH__) && defined(F_FULLFSYNC) |
| 626 | // Mac OS does not flush data to physical storage with fsync() |
| 627 | int err = ::fcntl(fd, F_FULLFSYNC); |
| 628 | #else |
| 629 | int err = ::fsync(fd); |
| 630 | #endif |
| 631 | if (BOOST_UNLIKELY(err < 0)) |
| 632 | { |
| 633 | err = errno; |
| 634 | // POSIX says fsync can return EINTR (https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html). |
| 635 | // fcntl(F_FULLFSYNC) isn't documented to return EINTR, but it doesn't hurt to check. |
| 636 | if (err == EINTR) |
| 637 | continue; |
| 638 | |
| 639 | return err; |
| 640 | } |
| 641 | |
| 642 | break; |
| 643 | } |
| 644 | |
| 645 | return 0; |
| 646 | } |
| 647 | |
| 648 | //! Flushes buffered data written to the file to permanent storage |
| 649 | inline int data_sync(int fd) |