Skip to content

Commit

Permalink
Open target device with O_SYNC
Browse files Browse the repository at this point in the history
Open the target device with the O_SYNC flag; in this way, the data for
each range will be flushed to the device before starting processing the
next one.

As a side effect, the application will return immediately after an error
instead of waiting for all the previous cached writes to be sync'ed to
the target device.

Signed-off-by: Francesco Valla <[email protected]>
  • Loading branch information
WallaceIT committed Dec 15, 2024
1 parent e1737e1 commit 22229e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bmap-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int BmapWriteImage(const std::string &imageFile, const bmap_t &bmap, const std::
int ret = 0;

try {
dev_fd = open(device.c_str(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
dev_fd = open(device.c_str(), O_WRONLY | O_CREAT | O_SYNC, S_IRUSR | S_IWUSR);
if (dev_fd < 0) {
throw std::string("Unable to open or create target device");
}
Expand Down

0 comments on commit 22229e4

Please sign in to comment.