Skip to content

Commit e11101d

Browse files
committed
main: Align STUB_SIZE to 16K boundary
Blocks are 4K, but let's do 16K for good measure. Signed-off-by: Hector Martin <[email protected]>
1 parent b9ab887 commit e11101d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import system, osenum, stub, diskutil
77
from util import *
88

9-
STUB_SIZE = 2500 * 1000 * 1000
9+
STUB_SIZE = align_up(2500 * 1000 * 1000)
1010

1111
@dataclass
1212
class IPSW:
@@ -354,7 +354,7 @@ def main(self):
354354
continue
355355
if p.free:
356356
p.desc = f"(free space: {ssize(p.size)})"
357-
if p.size > STUB_SIZE:
357+
if p.size >= STUB_SIZE:
358358
parts_free.append(p)
359359
elif p.type.startswith("Apple_APFS"):
360360
p.desc = "APFS"

src/util.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ def split_ver(s):
2323
parts2[-3] -= 1
2424
parts2[-2] = 99
2525
return tuple(parts2)
26+
27+
def align_up(v, a=16384):
28+
return (v + a - 1) & ~(a - 1)
29+
30+
align = align_up
31+
32+
def align_down(v, a=16384):
33+
return v & ~(a - 1)

0 commit comments

Comments
 (0)