I have another patch. It may not fix your problem (although it does,
at least, fix a different problem - one however that I don't believe
has ever been reported).
And here it is attached...
..Steve
Index: src/uk/me/parabola/imgfmt/sys/Directory.java
===================================================================
--- src/uk/me/parabola/imgfmt/sys/Directory.java (revision 1922)
+++ src/uk/me/parabola/imgfmt/sys/Directory.java (working copy)
@@ -147,12 +147,14 @@
int n = ent.numberHeaderBlocks();
blocks += n;
}
+ System.out.println("dir: header blocks(slots) " + blocks);
// Save the current position
long dirPosition = chan.position();
int blockSize = headerBlockManager.getBlockSize();
int forHeader = (blocks + Dirent.ENTRY_SIZE - 1)/Dirent.ENTRY_SIZE;
+ System.out.println("header blocks needed " + forHeader);
log.debug("header blocks needed", forHeader);
// There is nothing really wrong with larger values (perhaps, I don't
@@ -173,6 +175,7 @@
}
long end = (long) blockSize * headerBlockManager.getMaxBlock();
+ System.out.println("dir: end slot " + end/512);
ByteBuffer buf = ByteBuffer.allocate((int) (end - chan.position()));
for (int i = 0; i < buf.capacity(); i++)
buf.put((byte) 0);
Index: src/uk/me/parabola/imgfmt/sys/ImgFS.java
===================================================================
--- src/uk/me/parabola/imgfmt/sys/ImgFS.java (revision 1922)
+++ src/uk/me/parabola/imgfmt/sys/ImgFS.java (working copy)
@@ -242,6 +242,8 @@
log.debug("could not sync filesystem");
} finally {
try {
+ if (fileBlockManager != null)
+ System.out.println("file size in blocks " + file.size()/fileBlockManager.getBlockSize());
file.close();
} catch (IOException e) {
log.warn("Could not close file");
Index: src/uk/me/parabola/imgfmt/sys/ImgHeader.java
===================================================================
--- src/uk/me/parabola/imgfmt/sys/ImgHeader.java (revision 1922)
+++ src/uk/me/parabola/imgfmt/sys/ImgHeader.java (working copy)
@@ -114,6 +114,7 @@
* @param params File system parameters.
*/
void createHeader(FileSystemParam params) {
+ System.out.println("create header " + params.getBlockSize());
this.fsParams = params;
header.put(OFF_XOR, (byte) 0);
Index: src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java
===================================================================
--- src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java (revision 1922)
+++ src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java (working copy)
@@ -353,10 +353,13 @@
params.setDirectoryStartBlock(DIRECTORY_OFFSET_BLOCK);
int reserved = DIRECTORY_OFFSET_BLOCK + bi.reserveBlocks + bi.headerSlots;
+ System.out.println("reserve=" + bi.reserveBlocks + ", headerslots=" + bi.headerSlots);
+ System.out.println("bs =" + blockSize + ", reserving " + reserved);
log.info("bs of", blockSize, "reserving", reserved);
int reserve = (int) Math.ceil(reserved * 512.0 / blockSize);
- params.setReservedDirectoryBlocks(reserve);
+ System.out.println("real reserve " + reserve + ", but using " + bi.reserveBlocks);
+ params.setReservedDirectoryBlocks(bi.reserveBlocks);
log.info("reserved", reserve);
FileSystem outfs = ImgFS.createFs(Utils.joinPath(outputDir, GMAPSUPP), params);
@@ -442,15 +445,24 @@
totHeaderSlots += slots;
}
+ // Estimate the number of blocks needed for the MPS file
+ int mpsSize = files.size() * 80 + 100;
+ int mpsBlocks = (mpsSize + (bs - 1)) / bs;
+ int mpsSlots = (mpsBlocks + ENTRY_SIZE-1) / ENTRY_SIZE;
+
+ totBlocks += mpsBlocks;
+ totHeaderSlots += mpsSlots;
+
totHeaderSlots += 2;
int totHeaderBlocks = totHeaderSlots * 512 / bs;
log.info("total blocks for", bs, "is", totHeaderBlocks, "based on slots=", totHeaderSlots);
- if (totBlocks < 0xfffe && totHeaderBlocks <= ENTRY_SIZE) {
- // Add one for the MPS file
- totHeaderSlots += 1;
- return new BlockInfo(bs, totHeaderSlots, totHeaderSlots / bs + 1);
+ System.out.printf("bs %d: tot blocks %d, tot header blocks %d\n", bs, totBlocks, totHeaderBlocks);
+ int reserved = DIRECTORY_OFFSET_BLOCK + 1 + totHeaderSlots;
+ if (totBlocks + reserved < 0xfffe && totHeaderBlocks <= ENTRY_SIZE) {
+ int reserve = (int) Math.ceil(reserved * 512.0 / bs);
+ return new BlockInfo(bs, totHeaderSlots, reserve);
}
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev