bfs: erase ext2 superblock when initializing

Having valid superblocks from multiple filesystems on the same disk is
confusing, let's try to avoid that.

Change-Id: I1a58843d45ea52193a77faaf8dcc3ca6a049406e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1802
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Adrien Destugues 2019-08-30 20:48:24 +02:00 committed by waddlesplash
parent 354311b57b
commit e8f5d1ca66
1 changed files with 4 additions and 0 deletions

View File

@ -828,8 +828,12 @@ Volume::_EraseUnusedBootBlock()
{ {
const int32 blockSize = 512; const int32 blockSize = 512;
const char emptySector[blockSize] = { 0 }; const char emptySector[blockSize] = { 0 };
// Erase boot block if any
if (write_pos(fDevice, 0, emptySector, blockSize) != blockSize) if (write_pos(fDevice, 0, emptySector, blockSize) != blockSize)
return B_IO_ERROR; return B_IO_ERROR;
// Erase ext2 superblock if any
if (write_pos(fDevice, 1024, emptySector, blockSize) != blockSize)
return B_IO_ERROR;
return B_OK; return B_OK;
} }