	public void sync() throws IOException {
		int blocks = 0;
		for (DirectoryEntry dir : entries.values()) {
			Dirent ent = (Dirent) dir;
			log.debug("ent size", ent.getSize());
			int n = ent.numberHeaderBlocks();
			blocks += n;
		}
		long dirPosition = chan.position();
		int blockSize = headerBlockManager.getBlockSize();
		int forHeader = (blocks + DirectoryEntry.SLOTS_PER_ENTRY - 1)/DirectoryEntry.SLOTS_PER_ENTRY;
		log.debug("header blocks needed", forHeader);
		chan.position(dirPosition + (long) forHeader * Dirent.ENTRY_SIZE);
		for (DirectoryEntry dir : entries.values()) {
			Dirent ent = (Dirent) dir;
			if (!ent.isSpecial()) {
				log.debug("wrting ", dir.getFullName(), " at ", chan.position());
				log.debug("ent size", ent.getSize());
				ent.sync(chan);
			}
		}
		long end = (long) blockSize * headerBlockManager.getMaxBlock();
		ByteBuffer buf = ByteBuffer.allocate((int) (end - chan.position()));
		for (int i = 0; i < buf.capacity(); i++)
			buf.put((byte) 0);
		buf.flip();
		chan.write(buf);
		chan.position(dirPosition);
		Dirent ent = (Dirent) entries.values().iterator().next();
		log.debug("ent header size", ent.getSize());
		ent.sync(chan);
	}

	public void sync() throws IOException {
		int blocks = 0;
		for (DirectoryEntry dir : entries.values()) {
			Dirent ent = (Dirent) dir;
			log.debug("ent size", ent.getSize());
			int n = ent.numberHeaderBlocks();
			blocks += n;
		}
		long dirPosition = chan.position();
		int blockSize = headerBlockManager.getBlockSize();
		int forHeader = (blocks + Dirent.ENTRY_SIZE - 1)/Dirent.ENTRY_SIZE;
		log.debug("header blocks needed", forHeader);
		assert forHeader == 1;
		chan.position(dirPosition + (long) forHeader * Dirent.ENTRY_SIZE);
		for (DirectoryEntry dir : entries.values()) {
			Dirent ent = (Dirent) dir;
			if (!ent.isSpecial()) {
				log.debug("wrting ", dir.getFullName(), " at ", chan.position());
				log.debug("ent size", ent.getSize());
				ent.sync(chan);
			}
		}
		long end = (long) blockSize * headerBlockManager.getMaxBlock();
		ByteBuffer buf = ByteBuffer.allocate((int) (end - chan.position()));
		for (int i = 0; i < buf.capacity(); i++)
			buf.put((byte) 0);
		buf.flip();
		chan.write(buf);
		chan.position(dirPosition);
		Dirent ent = (Dirent) entries.values().iterator().next();
		log.debug("ent header size", ent.getSize());
		ent.sync(chan);
	}
