[haiku-commits] Change in haiku[master]: ext2: accept block count until the disk size plus one

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 25 Jun 2022 07:50:08 +0000

From Jérôme Duval <jerome.duval@xxxxxxxxx>:

Jérôme Duval has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/5399 ;)


Change subject: ext2: accept block count until the disk size plus one
......................................................................

ext2: accept block count until the disk size plus one

my understanding is that it's possible that the last block (for instance of 
size 4KB)
is too large for the last few partition sectors, if the partition size isn't a 
multiple
of the block size.
---
M src/add-ons/kernel/file_systems/ext2/Volume.cpp
1 file changed, 3 insertions(+), 1 deletion(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/99/5399/1

diff --git a/src/add-ons/kernel/file_systems/ext2/Volume.cpp 
b/src/add-ons/kernel/file_systems/ext2/Volume.cpp
index 7727c1f..dff0520 100644
--- a/src/add-ons/kernel/file_systems/ext2/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/ext2/Volume.cpp
@@ -233,8 +233,10 @@
        status = opener.GetSize(&diskSize);
        if (status != B_OK)
                return status;
-       if (diskSize < ((off_t)NumBlocks() << BlockShift()))
+       if ((diskSize + fBlockSize) <= ((off_t)NumBlocks() << BlockShift())) {
+               FATAL("diskSize is too small for the number of blocks!\n");
                return B_BAD_VALUE;
+       }

        fBlockCache = opener.InitCache(NumBlocks(), fBlockSize);
        if (fBlockCache == NULL)

--
To view, visit https://review.haiku-os.org/c/haiku/+/5399
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I88c709d6e449aa52358fd9343c9f68f7ac1c01fe
Gerrit-Change-Number: 5399
Gerrit-PatchSet: 1
Gerrit-Owner: Jérôme Duval <jerome.duval@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: ext2: accept block count until the disk size plus one - Gerrit