// 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 there are block groups with both free inodes and free blocks counts
	 * not worse than average we return one with smallest directory count.
	 * Otherwise we simply return a random group.
	 *
	 * For the rest rules look so:
	 *
	 * It's OK to put directory into a group unless
	 * it has too many directories already (max_dirs) or
	 * it has too few free inodes left (min_inodes) or
	 * it has too few free blocks left (min_blocks) or
	 * it's already running too large debt (max_debt).
	 * Parent's group is preferred, if it doesn't satisfy these
	 * conditions we search cyclically through the rest. If none
	 * of the groups look good we just look for a group with more
	 * free inodes than average (starting at parent's group).
	 *
	 * Debt is incremented each time we allocate a directory and decremented
	 * when we allocate an inode, within 0--255.
	 */

	public static int findGroupOrlov(Inode parent) {
		// TODO implement me
		return -1;
	}

	/**
	 * Free Inode: Remove data blocks and set bit to 0
	 * @throws JExt2Exception
	 */
// 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 there are block groups with both free inodes and free blocks counts
	 * not worse than average we return one with smallest directory count.
	 * Otherwise we simply return a random group.
	 *
	 * For the rest rules look so:
	 *
	 * It's OK to put directory into a group unless
	 * it has too many directories already (max_dirs) or
	 * it has too few free inodes left (min_inodes) or
	 * it has too few free blocks left (min_blocks) or
	 * it's already running too large debt (max_debt).
	 * Parent's group is preferred, if it doesn't satisfy these
	 * conditions we search cyclically through the rest. If none
	 * of the groups look good we just look for a group with more
	 * free inodes than average (starting at parent's group).
	 *
	 * Debt is incremented each time we allocate a directory and decremented
	 * when we allocate an inode, within 0--255.
	 */

	public static int findGroupOrlov(Inode parent) {
		// TODO implement me
		return -1;
	}

	/**
	 * Free Inode: Remove data blocks and set bit to 0
	 * @throws JExt2Exception
	 */
	static void freeInode(Inode inode) throws JExt2Exception {