static void process_chunk(byte[] data) throws Exception
	{
		PackedTags2 pt = StructHandler.read(PackedTags2.class, ByteBuffer.wrap(data, CHUNK_SIZE, data.length-CHUNK_SIZE).order(ByteOrder.LITTLE_ENDIAN));
		if (pt.t.byteCount != 0xffff)
			return;
		ObjectHeader oh = StructHandler.read(ObjectHeader.class,  ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN));
		String full_path_name = obj_list[oh.parentObjectId]+ "/" + StructHandler.getString(oh.name);
		obj_list[pt.t.objectId] = full_path_name;

		switch(oh.type) {
			case YAFFS_OBJECT_TYPE_FILE:
				System.out.println("Extracting file "+full_path_name+" (size "+oh.fileSize+")");
				// open with oh.yst_mode ?
				File outFile = new File(full_path_name);
				FileOutputStream out_file = new FileOutputStream(outFile);
				long remain = ((long)oh.fileSize);
				//System.out.println("remain "+remain);
				while(remain > 0) {
					byte[] chunk_data = new byte[CHUNK_SIZE + SPARE_SIZE];
					int nb_read = img_file.read(chunk_data);
					if(nb_read <= -1)
						break;
					pt = StructHandler.read(PackedTags2.class, ByteBuffer.wrap(chunk_data, CHUNK_SIZE, chunk_data.length-CHUNK_SIZE).order(ByteOrder.LITTLE_ENDIAN));
					//System.out.println("nb_read "+nb_read);
					//System.out.println("chuck bytecount "+pt.t.byteCount);
					if(pt.t.byteCount > CHUNK_SIZE)
						pt.t.byteCount = CHUNK_SIZE;
					int s = (remain < pt.t.byteCount) ? (int)remain : pt.t.byteCount;	
					//System.out.println("s "+s);
					out_file.write(chunk_data, 0, s);
					remain -= s;
				}
				//close(out_file);
				break;
			case YAFFS_OBJECT_TYPE_SYMLINK:
				//symlink(oh->alias, full_path_name);
				break;
			case YAFFS_OBJECT_TYPE_DIRECTORY:
				//mkdir(full_path_name, 0777);
				new File(full_path_name).mkdir();
				break;
			case YAFFS_OBJECT_TYPE_HARDLINK:
				//link(obj_list[oh->equivalentObjectId], full_path_name);
				break;
		}
	}