Implement CLI "dd" command - copy data between Vitastor images, files and pipes

This commit is contained in:
Vitaliy Filippov
2024-08-30 02:31:06 +03:00
parent b804051eaf
commit 986cd11705
11 changed files with 1053 additions and 14 deletions
+18
View File
@@ -485,3 +485,21 @@ std::string format_datetime(uint64_t unixtime)
int len = strftime(buf, 128, "%Y-%m-%d %H:%M:%S", &lt);
return std::string(buf, len);
}
bool is_zero(void *buf, size_t size)
{
size_t i = 0;
while (i <= size-8)
{
if (*(uint64_t*)((uint8_t*)buf + i))
return false;
i += 8;
}
while (i < size)
{
if (*((uint8_t*)buf + i))
return false;
i++;
}
return true;
}
+1
View File
@@ -31,3 +31,4 @@ std::string auto_addslashes(const std::string & str, const char *toescape = "\\\
std::string addslashes(const std::string & str, const char *toescape = "\\\"");
std::string realpath_str(std::string path, bool nofail = true);
std::string format_datetime(uint64_t unixtime);
bool is_zero(void *buf, size_t size);