This is for filesystems that do not put an implicit write barrier when renaming files. That way we ensure that we'll never have empty files.
@@ -5,6 +5,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low
due to this.
* Improved description of --search in dpkg-query(1). Closes: #621066
Thanks to Lars Buitinck <larsmans@gmail.com> for the patch.
+ * Let update-alternatives fsync() its administrative files before
+ moving them in place to avoid empty files with some filesystems.
+ LP: #344019
[ Guillem Jover ]
* Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520
@@ -1360,6 +1360,8 @@ alternative_save(struct alternative *a)
altdb_print_line(&ctx, "");
/* Close database file */
+ if (fsync(fileno(ctx.fh)))
+ syserr(_("unable to sync file '%s'"), ctx.filename);
if (fclose(ctx.fh))
syserr(_("unable to close file '%s'"), ctx.filename);