Procházet zdrojové kódy

u-a: Flush the alternatives database file stream before fsync()ing it

For stream I/O the buffers have to be flushed before they are fsync()ed
to guarantee the data has been written, and as such fsync() can do its
job.

Missed in commit 0e0e26cb8e9e3b8e3a60c329d8ea0c6e5445742c.
Guillem Jover před 15 roky
rodič
revize
9ccc961518
1 změnil soubory, kde provedl 2 přidání a 0 odebrání
  1. 2 0
      utils/update-alternatives.c

+ 2 - 0
utils/update-alternatives.c

@@ -1360,6 +1360,8 @@ alternative_save(struct alternative *a)
 	altdb_print_line(&ctx, "");
 
 	/* Close database file */
+	if (fflush(ctx.fh))
+		syserr(_("unable to flush file '%s'"), ctx.filename);
 	if (fsync(fileno(ctx.fh)))
 		syserr(_("unable to sync file '%s'"), ctx.filename);
 	if (fclose(ctx.fh))