hrev48308 adds 1 changeset to branch 'master' old head: a9327b111058afdb622bd9a1fddbf9e3273c453b new head: cce8cb8ca3418fd4f5840ceda0cce90ee14e09d5 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=cce8cb8+%5Ea9327b1 ---------------------------------------------------------------------------- cce8cb8: bfs: only erase first sector when initializing f9ac1e93fb1ba12163bff4128efb54d8e548e4a8 didn't take into account that the superblock gets written back from places other than Initialize(), resulting in unbootable volumes. Now the first sector will only be erased if the volume is being initialized. [ Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev48308 Commit: cce8cb8ca3418fd4f5840ceda0cce90ee14e09d5 URL: http://cgit.haiku-os.org/haiku/commit/?id=cce8cb8 Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> Date: Sat Nov 15 19:12:43 2014 UTC ---------------------------------------------------------------------------- 2 files changed, 11 insertions(+), 9 deletions(-) src/add-ons/kernel/file_systems/bfs/Volume.cpp | 18 ++++++++++-------- src/add-ons/kernel/file_systems/bfs/Volume.h | 2 +- ---------------------------------------------------------------------------- diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.cpp b/src/add-ons/kernel/file_systems/bfs/Volume.cpp index 80eecc2..7b5043a 100644 --- a/src/add-ons/kernel/file_systems/bfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Volume.cpp @@ -546,13 +546,15 @@ Volume::AllocateForInode(Transaction& transaction, const Inode* parent, status_t -Volume::WriteSuperBlock() -{ - const char emptySector[512] = { 0 }; - // also erase the first block, otherwise we risk mis-identifying the - // file system later (e.g. NTFS is identified by sector 0). - if (write_pos(fDevice, 0, emptySector, 512) != 512) - return B_IO_ERROR; +Volume::WriteSuperBlock(bool initializing) +{ + if (initializing) { + const char emptySector[512] = { 0 }; + // also erase the first block, otherwise we risk mis-identifying + // the file system later (e.g. NTFS is identified by sector 0). + if (write_pos(fDevice, 0, emptySector, 512) != 512) + return B_IO_ERROR; + } if (write_pos(fDevice, 512, &fSuperBlock, sizeof(disk_super_block)) != sizeof(disk_super_block)) @@ -775,7 +777,7 @@ Volume::Initialize(int fd, const char* name, uint32 blockSize, CreateVolumeID(transaction); - WriteSuperBlock(); + WriteSuperBlock(true); transaction.Done(); Sync(); diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.h b/src/add-ons/kernel/file_systems/bfs/Volume.h index 6d87a0f..9a77c4f 100644 --- a/src/add-ons/kernel/file_systems/bfs/Volume.h +++ b/src/add-ons/kernel/file_systems/bfs/Volume.h @@ -116,7 +116,7 @@ public: { return find_thread(NULL) == fCheckingThread; } // cache access - status_t WriteSuperBlock(); + status_t WriteSuperBlock(bool initializing = false); status_t FlushDevice(); // queries