diff --git a/core/java/src/net/metanotion/io/block/BlockFile.java b/core/java/src/net/metanotion/io/block/BlockFile.java index d9613653f66c7c8fedb37eab8e7dd88ba35c2bb9..f6ea7d63409ff7ef76129f4df03564ab00632d25 100644 --- a/core/java/src/net/metanotion/io/block/BlockFile.java +++ b/core/java/src/net/metanotion/io/block/BlockFile.java @@ -57,6 +57,7 @@ import net.i2p.util.Log; * free list start (unsigned int) * is mounted (unsigned short) 0 = no, 1 = yes * span size (unsigned short) + * block size (unsigned int) * * Metaindex skiplist is on page 2 * @@ -71,7 +72,9 @@ public class BlockFile { public final RandomAccessInterface file; private static final int MAJOR = 0x01; - private static final int MINOR = 0x01; + private static final int MINOR = 0x02; + private static final int MIN_MAJOR = 0x01; + private static final int MIN_MINOR = 0x01; // I2P changed magic number, format changed, magic numbers now on all pages private static final long MAGIC_BASE = 0x3141de4932500000L; // 0x3141de I 2 P 00 00 private static final long MAGIC = MAGIC_BASE | (MAJOR << 8) | MINOR; @@ -109,6 +112,8 @@ public class BlockFile { file.writeInt( freeListStart); file.writeShort(mounted); file.writeShort(spanSize); + // added in version 1.2 + file.writeInt(PAGESIZE); } private void readSuperBlock() throws IOException { @@ -118,6 +123,7 @@ public class BlockFile { freeListStart = file.readUnsignedInt(); mounted = file.readUnsignedShort(); spanSize = file.readUnsignedShort(); + // assume 1024 page size } /** @@ -293,9 +299,13 @@ public class BlockFile { readSuperBlock(); if(magicBytes != MAGIC) { - if((magicBytes & MAGIC_BASE) == MAGIC_BASE) { - throw new IOException("Expected " + MAJOR + '.' + MINOR + - " but got " + (magicBytes >> 8 & 0xff) + '.' + (magicBytes & 0xff)); + if ((magicBytes & MAGIC_BASE) == MAGIC_BASE) { + long major = (magicBytes >> 8) & 0xff; + long minor = magicBytes & 0xff; + if (major < MIN_MAJOR || + (major == MIN_MAJOR && minor < MIN_MINOR)) + throw new IOException("Expected " + MAJOR + '.' + MINOR + + " but got " + major + '.' + minor); } else { throw new IOException("Bad magic number"); } diff --git a/core/java/src/net/metanotion/io/block/index/BSkipList.java b/core/java/src/net/metanotion/io/block/index/BSkipList.java index 9ecb11d973d32eb0354ff32885ba35d65240d8e8..3dbae72681798115c610292f56b13967c57a4832 100644 --- a/core/java/src/net/metanotion/io/block/index/BSkipList.java +++ b/core/java/src/net/metanotion/io/block/index/BSkipList.java @@ -82,6 +82,8 @@ public class BSkipList extends SkipList { size = bf.file.readUnsignedInt(); int spans = bf.file.readInt(); int levelCount = bf.file.readInt(); + // two byte spansize as of version 1.2, ignore for now + // int ss = bf.file.readUnsignedShort(); if (ss > 0) ... //System.out.println(size + " " + spans); this.fileOnly = fileOnly; @@ -171,6 +173,8 @@ public class BSkipList extends SkipList { bf.file.writeInt(0); bf.file.writeInt(1); bf.file.writeInt(1); + // added in version 1.2 + bf.file.writeShort(spanSize); BSkipSpan.init(bf, firstSpan, spanSize); BSkipLevels.init(bf, firstLevel, firstSpan, 4); }