// Path: src/jext2/exceptions/JExt2Exception.java
// public class JExt2Exception extends Exception {
// 	protected static final int ERRNO = -1;
// 
// 	private static final long serialVersionUID = -7429088074385678308L;
// 
// 	Logger logger = Filesystem.getLogger();
// 
// 	public JExt2Exception() {
// 		log("");
// 	}
// 
// 	public JExt2Exception(String msg) {
// 		log(msg);
// 	}
// 
// 	private void log(String msg) {
// 		if (logger.isLoggable(Level.FINE)) {
// 			StackTraceElement[] stack = getStackTrace();
// 
// 			StringBuilder log = new StringBuilder();
// 			log.append("JEXT2 exception was raised: ");
// 			log.append(this.getClass().getSimpleName());
// 			log.append(" source=");
// 			log.append(stack[0].getClassName());
// 			log.append("->");
// 			log.append(stack[0].getMethodName());
// 			log.append(" msg=");
// 			log.append(msg);
// 			log.append(" errno=");
// 			log.append(getErrno());
// 
// 			logger.fine(log.toString());
// 		}
// 	}
// 
// 	public int getErrno() {
// 		throw new RuntimeException("This method should not be executed. " +
// 				"- The errno value defined here is meaningless");
// 	}
// }
// 
// Path: src/jext2/exceptions/NoSpaceLeftOnDevice.java
// public class NoSpaceLeftOnDevice extends JExt2Exception {
// 	static final long serialVersionUID = 42;
// 	protected final static int ERRNO = Errno.ENOSPC;
// 
// 	public int getErrno() {
// 		return ERRNO;
// 	}
// }


import jext2.exceptions.JExt2Exception;
import jext2.exceptions.NoSpaceLeftOnDevice;
import java.util.logging.Level;
import java.util.logging.Logger;
		if (ino < superblock.getFirstIno() ||
				ino > superblock.getInodesCount()) {
			throw new RuntimeException("reserved or nonexistent inode " + ino);
		}

		BlockGroupDescriptor groupDescr =
				blockGroups.getGroupDescriptor(Calculations.groupOfIno(ino));
		Bitmap bitmap = bitmaps.openInodeBitmap(groupDescr);
		int bit = Calculations.localInodeIndex(ino);

		if (!bitmap.isSet(bit)) {
			throw new RuntimeException("Bit allready cleared for inode " + ino);
		} else {
			bitmap.setBit(bit, false);
			bitmap.write();
		}

		bitmaps.closeBitmap(bitmap);

		groupDescr.setFreeBlocksCount(groupDescr.getFreeInodesCount() + 1);

		if (inode.isDirectory()) {
			groupDescr.setUsedDirsCount(groupDescr.getUsedDirsCount() - 1);
			superblock.setDirsCount(superblock.getDirsCount() - 1);
		}

		if (logger.isLoggable(Level.FINE)) {
			String s = new StringBuilder()
				.append("Freed Inode #")
				.append(ino)
// Path: src/jext2/exceptions/JExt2Exception.java
// public class JExt2Exception extends Exception {
// 	protected static final int ERRNO = -1;
// 
// 	private static final long serialVersionUID = -7429088074385678308L;
// 
// 	Logger logger = Filesystem.getLogger();
// 
// 	public JExt2Exception() {
// 		log("");
// 	}
// 
// 	public JExt2Exception(String msg) {
// 		log(msg);
// 	}
// 
// 	private void log(String msg) {
// 		if (logger.isLoggable(Level.FINE)) {
// 			StackTraceElement[] stack = getStackTrace();
// 
// 			StringBuilder log = new StringBuilder();
// 			log.append("JEXT2 exception was raised: ");
// 			log.append(this.getClass().getSimpleName());
// 			log.append(" source=");
// 			log.append(stack[0].getClassName());
// 			log.append("->");
// 			log.append(stack[0].getMethodName());
// 			log.append(" msg=");
// 			log.append(msg);
// 			log.append(" errno=");
// 			log.append(getErrno());
// 
// 			logger.fine(log.toString());
// 		}
// 	}
// 
// 	public int getErrno() {
// 		throw new RuntimeException("This method should not be executed. " +
// 				"- The errno value defined here is meaningless");
// 	}
// }
// 
// Path: src/jext2/exceptions/NoSpaceLeftOnDevice.java
// public class NoSpaceLeftOnDevice extends JExt2Exception {
// 	static final long serialVersionUID = 42;
// 	protected final static int ERRNO = Errno.ENOSPC;
// 
// 	public int getErrno() {
// 		return ERRNO;
// 	}
// }


// Path: src/jext2/InodeAlloc.java
import jext2.exceptions.JExt2Exception;
import jext2.exceptions.NoSpaceLeftOnDevice;
import java.util.logging.Level;
import java.util.logging.Logger;

		if (ino < superblock.getFirstIno() ||
				ino > superblock.getInodesCount()) {
			throw new RuntimeException("reserved or nonexistent inode " + ino);
		}

		BlockGroupDescriptor groupDescr =
				blockGroups.getGroupDescriptor(Calculations.groupOfIno(ino));
		Bitmap bitmap = bitmaps.openInodeBitmap(groupDescr);
		int bit = Calculations.localInodeIndex(ino);

		if (!bitmap.isSet(bit)) {
			throw new RuntimeException("Bit allready cleared for inode " + ino);
		} else {
			bitmap.setBit(bit, false);
			bitmap.write();
		}

		bitmaps.closeBitmap(bitmap);

		groupDescr.setFreeBlocksCount(groupDescr.getFreeInodesCount() + 1);

		if (inode.isDirectory()) {
			groupDescr.setUsedDirsCount(groupDescr.getUsedDirsCount() - 1);
			superblock.setDirsCount(superblock.getDirsCount() - 1);
		}

		if (logger.isLoggable(Level.FINE)) {
			String s = new StringBuilder()
				.append("Freed Inode #")
				.append(ino)
				.append(" in block group ")