public String computeDataSizeAndType(RandomAccessFile fin) throws IOException { SinAddr a = map.get(0); byte[] res = new byte[(int) a.getDataLength()]; fin.seek(getDataHeaderSize() + map.getSize() + a.getSrcOffset()); fin.read(res); byte[] magic = new byte[4]; int pos = 0; while (res[pos] == 0) pos++; int startpos = pos; pos = 0; System.arraycopy(res, startpos + pos, magic, 0, magic.length); if (new String(magic).contains("ELF")) return "elf"; while (!HexDump.toHex(magic).startsWith("[FF, FF, 53, EF")) { pos++; try { System.arraycopy(res, startpos + pos, magic, 0, magic.length); } catch (Exception e) { return "unknown"; } if (new String(magic).contains("ELF")) return "elf"; } // if (pos>=500) return "unknown"; pos = pos - 54; byte[] header = new byte[58]; System.arraycopy(res, startpos + pos, header, 0, header.length); byte[] bcount = new byte[4]; System.arraycopy(header, 4, bcount, 0, bcount.length); BytesUtil.revert(bcount); long blockcount = BytesUtil.getInt(bcount); outputsize = blockcount * 4L * 1024L; return "ext4"; }