summaryrefslogtreecommitdiff
path: root/e2fsck/unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsck/unix.c')
-rw-r--r--e2fsck/unix.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 882e5800..fbe59804 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -547,8 +547,8 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
!cflag && !swapfs)
ctx->options |= E2F_OPT_READONLY;
ctx->filesystem_name = argv[optind];
- if (flush) {
#ifdef BLKFLSBUF
+ if (flush) {
int fd = open(ctx->filesystem_name, O_RDONLY, 0);
if (fd < 0) {
@@ -557,6 +557,12 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
ctx->filesystem_name);
exit(FSCK_ERROR);
}
+ if (fsync(fd) < 0) {
+ com_err("fsync", errno,
+ _("while trying to flush %s"),
+ ctx->filesystem_name);
+ exit(FSCK_ERROR);
+ }
if (ioctl(fd, BLKFLSBUF, 0) < 0) {
com_err("BLKFLSBUF", errno,
_("while trying to flush %s"),
@@ -564,10 +570,8 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
exit(FSCK_ERROR);
}
close(fd);
-#else
- fatal_error(ctx, _("BLKFLSBUF not supported"));
-#endif /* BLKFLSBUF */
}
+#endif /* BLKFLSBUF */
if (swapfs) {
if (cflag || bad_blocks_file) {
fprintf(stderr, _("Incompatible options not "