Rewrite upgrade-simple to C++

This commit is contained in:
Vitaliy Filippov
2022-08-18 01:31:31 +03:00
parent a16263e88c
commit 40d8d65188
10 changed files with 217 additions and 147 deletions
+6
View File
@@ -1,6 +1,7 @@
// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details)
#include <sys/file.h>
#include <dirent.h>
#include "disk_tool.h"
@@ -109,6 +110,11 @@ uint32_t disk_tool_t::write_osd_superblock(std::string device, json11::Json para
free(buf);
return 0;
}
// Lock the file
if (flock(fd, LOCK_EX|LOCK_NB) < 0)
{
fprintf(stderr, "Warning: Failed to lock %s with flock - udev autodetection may fail. Error: %s\n", device.c_str(), strerror(errno));
}
int r = write_blocking(fd, buf, buf_len);
if (r < 0)
{