[haiku-commits] haiku: hrev48305 - src/add-ons/kernel/file_systems/bfs

  • From: jessica.l.hamilton@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 15 Nov 2014 10:50:09 +0100 (CET)

hrev48305 adds 1 changeset to branch 'master'
old head: 9bce27d261d37fd986b9143f72a248fcdaabdd2d
new head: f9ac1e93fb1ba12163bff4128efb54d8e548e4a8
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=f9ac1e9+%5E9bce27d

----------------------------------------------------------------------------

f9ac1e9: bfs: erase first sector when initialising new partition
  
  * When writing the superblock, because it's at sector 1,
    sector 0 doesn't get erased. As a result, if an
    existing file system was present, identifying details
    in sector 0 could cause the partition identifying code
    to detect an old file system instead.
  
  Fixes #11136.

                         [ Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48305
Commit:      f9ac1e93fb1ba12163bff4128efb54d8e548e4a8
URL:         http://cgit.haiku-os.org/haiku/commit/?id=f9ac1e9
Author:      Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date:        Sat Nov 15 08:42:34 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/11136

----------------------------------------------------------------------------

1 file changed, 6 insertions(+)
src/add-ons/kernel/file_systems/bfs/Volume.cpp | 6 ++++++

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.cpp 
b/src/add-ons/kernel/file_systems/bfs/Volume.cpp
index 2ce9f5f..80eecc2 100644
--- a/src/add-ons/kernel/file_systems/bfs/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/Volume.cpp
@@ -548,6 +548,12 @@ 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;
+        
        if (write_pos(fDevice, 512, &fSuperBlock, sizeof(disk_super_block))
                        != sizeof(disk_super_block))
                return B_IO_ERROR;


Other related posts: