Skip to content

Commit

Permalink
udflabel: Call first fdatasync() only when write operation happened
Browse files Browse the repository at this point in the history
  • Loading branch information
pali committed Dec 29, 2017
1 parent b6d2153 commit 36fd4f6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions udflabel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,16 @@ int main(int argc, char *argv[])
write_desc(fd, &disc, MVDS, TAG_IDENT_IUVD, disc.udf_iuvd[0]);
}

printf("Synchronizing...\n");
if (!(disc.flags & FLAG_NO_WRITE))
if (update_pvd || update_lvd || update_iuvd)
{
if (fdatasync(fd) != 0)
printf("Synchronizing...\n");
if (!(disc.flags & FLAG_NO_WRITE))
{
fprintf(stderr, "%s: Synchronization failed: %s\n", appname, strerror(errno));
exit(1);
if (fdatasync(fd) != 0)
{
fprintf(stderr, "%s: Synchronization failed: %s\n", appname, strerror(errno));
exit(1);
}
}
}

Expand Down

0 comments on commit 36fd4f6

Please sign in to comment.