[file_utils] Use aligned memory in zero_superblock
This commit is contained in:
parent
abb32897e2
commit
58048dc178
@ -144,10 +144,14 @@ file_utils::get_file_length(string const &file) {
|
|||||||
void
|
void
|
||||||
file_utils::zero_superblock(std::string const &path)
|
file_utils::zero_superblock(std::string const &path)
|
||||||
{
|
{
|
||||||
|
char *buffer;
|
||||||
unsigned const SUPERBLOCK_SIZE = 4096;
|
unsigned const SUPERBLOCK_SIZE = 4096;
|
||||||
char buffer[SUPERBLOCK_SIZE];
|
|
||||||
int fd = open_block_file(path, SUPERBLOCK_SIZE, true, true);
|
int fd = open_block_file(path, SUPERBLOCK_SIZE, true, true);
|
||||||
|
|
||||||
|
buffer = reinterpret_cast<char *>(aligned_alloc(SUPERBLOCK_SIZE, SUPERBLOCK_SIZE));
|
||||||
|
if (!buffer)
|
||||||
|
throw runtime_error("out of memory");
|
||||||
|
|
||||||
memset(buffer, 0, SUPERBLOCK_SIZE);
|
memset(buffer, 0, SUPERBLOCK_SIZE);
|
||||||
if (::write(fd, buffer, SUPERBLOCK_SIZE) != SUPERBLOCK_SIZE)
|
if (::write(fd, buffer, SUPERBLOCK_SIZE) != SUPERBLOCK_SIZE)
|
||||||
throw runtime_error("couldn't zero superblock");
|
throw runtime_error("couldn't zero superblock");
|
||||||
|
Loading…
Reference in New Issue
Block a user