Skip to content

Commit

Permalink
main: Align STUB_SIZE to 16K boundary
Browse files Browse the repository at this point in the history
Blocks are 4K, but let's do 16K for good measure.

Signed-off-by: Hector Martin <marcan@marcan.st>
  • Loading branch information
marcan committed Feb 22, 2022
1 parent b9ab887 commit e11101d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import system, osenum, stub, diskutil
from util import *

STUB_SIZE = 2500 * 1000 * 1000
STUB_SIZE = align_up(2500 * 1000 * 1000)

@dataclass
class IPSW:
Expand Down Expand Up @@ -354,7 +354,7 @@ def main(self):
continue
if p.free:
p.desc = f"(free space: {ssize(p.size)})"
if p.size > STUB_SIZE:
if p.size >= STUB_SIZE:
parts_free.append(p)
elif p.type.startswith("Apple_APFS"):
p.desc = "APFS"
Expand Down
8 changes: 8 additions & 0 deletions src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ def split_ver(s):
parts2[-3] -= 1
parts2[-2] = 99
return tuple(parts2)

def align_up(v, a=16384):
return (v + a - 1) & ~(a - 1)

align = align_up

def align_down(v, a=16384):
return v & ~(a - 1)

0 comments on commit e11101d

Please sign in to comment.