[haiku-commits] haiku: hrev53429 - in src/add-ons/kernel/file_systems: ext2 bfs

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 30 Aug 2019 15:18:23 -0400 (EDT)

hrev53429 adds 3 changesets to branch 'master'
old head: 1f52c921e27aa442370e1bd4adc021acf2b78b64
new head: e8f5d1ca66d8e190d2ba1669b9f01c2c58f32e5b
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=e8f5d1ca66d8+%5E1f52c921e27a

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

b684f018357f: ext2: fix panic mounting ext2-overwritten-with-BFS volumes
  
  I have two partitions which used to be ext2, but have long since been
  reinitialized as BFS. However, the ext2 superblock is still here, and
  the ext2 filesystem will detect it. It crashes later on trying to access
  an Inode at block -1, so just add a check for that to avoid the crash.
  
  Change-Id: Ie2ed6a969ea3ffd343dedfe45a15dfc37af05804
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/1800
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

354311b57bc3: filesystems: bump priority of BFS over others
  
  If multipole filesystems think they can handle a volume, it makes sense
  to assume the native one is to be used.
  
  Makes my partitions with a BFS superblock and a leftover ext2 superblock
  on them mountable again without manually specifying the filesystem type.
  
  Fixes #15045.
  
  Change-Id: Icb694472aa3de0a79e5f7d3c54976038e1e2590a
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/1801
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

e8f5d1ca66d8: 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@xxxxxxxxx>

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

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

3 files changed, 11 insertions(+), 2 deletions(-)
src/add-ons/kernel/file_systems/bfs/Volume.cpp           | 4 ++++
src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp | 2 +-
src/add-ons/kernel/file_systems/ext2/Volume.cpp          | 7 ++++++-

############################################################################

Commit:      b684f018357f942f051ab172d882d97c7dec64bf
URL:         https://git.haiku-os.org/haiku/commit/?id=b684f018357f
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri Aug 30 18:39:05 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Fri Aug 30 19:18:20 2019 UTC

ext2: fix panic mounting ext2-overwritten-with-BFS volumes

I have two partitions which used to be ext2, but have long since been
reinitialized as BFS. However, the ext2 superblock is still here, and
the ext2 filesystem will detect it. It crashes later on trying to access
an Inode at block -1, so just add a check for that to avoid the crash.

Change-Id: Ie2ed6a969ea3ffd343dedfe45a15dfc37af05804
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1800
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

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

diff --git a/src/add-ons/kernel/file_systems/ext2/Volume.cpp 
b/src/add-ons/kernel/file_systems/ext2/Volume.cpp
index 91bddff28d..cf9bff9347 100644
--- a/src/add-ons/kernel/file_systems/ext2/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/ext2/Volume.cpp
@@ -207,7 +207,10 @@ ext2_super_block::IsValid()
                        || BlocksPerGroup() != (1UL << BlockShift()) * 8
                        || InodeSize() > (1UL << BlockShift())
                        || RevisionLevel() > EXT2_MAX_REVISION
-                       || ReservedGDTBlocks() > (1UL << BlockShift()) / 4) {
+                       || ReservedGDTBlocks() > (1UL << BlockShift()) / 4
+                       || NumInodes() == 0
+                       || InodeSize() == 0
+                       || FreeInodes() > NumInodes()) {
                return false;
        }
 
@@ -536,6 +539,8 @@ Volume::GetInodeBlock(ino_t id, off_t& block)
 
        block = group->InodeTable(Has64bitFeature())
                + ((id - 1) % fSuperBlock.InodesPerGroup()) / fInodesPerBlock;
+       if (block < 0)
+               return B_BAD_DATA;
        return B_OK;
 }
 

############################################################################

Commit:      354311b57bc367a32132b174b67d9af1ec1cd7de
URL:         https://git.haiku-os.org/haiku/commit/?id=354311b57bc3
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri Aug 30 18:42:30 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Fri Aug 30 19:18:20 2019 UTC

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

filesystems: bump priority of BFS over others

If multipole filesystems think they can handle a volume, it makes sense
to assume the native one is to be used.

Makes my partitions with a BFS superblock and a leftover ext2 superblock
on them mountable again without manually specifying the filesystem type.

Fixes #15045.

Change-Id: Icb694472aa3de0a79e5f7d3c54976038e1e2590a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1801
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

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

diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 
b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp
index 12ae4cfa17..98cafcb01c 100644
--- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp
@@ -134,7 +134,7 @@ bfs_identify_partition(int fd, partition_data* partition, 
void** _cookie)
        memcpy(&cookie->super_block, &superBlock, sizeof(disk_super_block));
 
        *_cookie = cookie;
-       return 0.8f;
+       return 0.85f;
 }
 
 

############################################################################

Revision:    hrev53429
Commit:      e8f5d1ca66d8e190d2ba1669b9f01c2c58f32e5b
URL:         https://git.haiku-os.org/haiku/commit/?id=e8f5d1ca66d8
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri Aug 30 18:48:24 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Fri Aug 30 19:18:20 2019 UTC

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@xxxxxxxxx>

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

diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.cpp 
b/src/add-ons/kernel/file_systems/bfs/Volume.cpp
index ca3241fd24..2b06068c3f 100644
--- a/src/add-ons/kernel/file_systems/bfs/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/Volume.cpp
@@ -828,8 +828,12 @@ Volume::_EraseUnusedBootBlock()
 {
        const int32 blockSize = 512;
        const char emptySector[blockSize] = { 0 };
+       // Erase boot block if any
        if (write_pos(fDevice, 0, emptySector, blockSize) != blockSize)
                return B_IO_ERROR;
+       // Erase ext2 superblock if any
+       if (write_pos(fDevice, 1024, emptySector, blockSize) != blockSize)
+               return B_IO_ERROR;
 
        return B_OK;
 }


Other related posts: