// Path: src/jext2/exceptions/FileTooLarge.java
// public class FileTooLarge extends JExt2Exception {
// 	static final long serialVersionUID = 42;
// 	protected final static int ERRNO = Errno.EFBIG;
// 
// 	public int getErrno() {
// 		return ERRNO;
// 	}
// }
// 
// Path: src/jext2/exceptions/IoError.java
// public class IoError extends JExt2Exception {
// 	static final long serialVersionUID = 42;
// 	protected static final int ERRNO=Errno.EIO;
// 	public IoError(String msg) {
// 		super(msg);
// 	}
// 	public IoError() {
// 		super();
// 	}
// 	public int getErrno() {
// 		return ERRNO;
// 	}
// }
// 
// 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.annotations.MustReturnLock;
import jext2.annotations.NotThreadSafe;
import jext2.exceptions.FileTooLarge;
import jext2.exceptions.IoError;
import jext2.exceptions.JExt2Exception;
import jext2.exceptions.NoSpaceLeftOnDevice;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Logger;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
			throw new RuntimeException("blockToPath: file block number < 0");
		} else if (fileBlockNr < Constants.EXT2_NDIR_BLOCKS) {
			return new int[] { (int)fileBlockNr };
		} else if ((fileBlockNr -= directBlocks) < indirectBlocks) {
			return new int[] { Constants.EXT2_IND_BLOCK,
					(int)fileBlockNr };
		} else if ((fileBlockNr -= indirectBlocks) < doubleBlocks) {
			return new int[] { Constants.EXT2_DIND_BLOCK,
					(int)fileBlockNr / ptrs,
					(int)fileBlockNr % ptrs };
		} else if ((fileBlockNr -= doubleBlocks)  < trippleBlocks) {
			return new int[] { Constants.EXT2_TIND_BLOCK,
					(int)fileBlockNr / (ptrs*ptrs),
					((int)fileBlockNr / ptrs) % ptrs ,
					(int)fileBlockNr % ptrs };
		} else {
			throw new FileTooLarge();
		}
	}

	/**
	 * Read the chain of indirect blocks leading to data
	 * @param inode 	Inode in question
	 * @param offsets	offsets of pointers in inode/indirect blocks
	 * @return	array of length depth with block numbers on the path.
	 * 	  array[depth-1] is data block number rest is the indirection on the path.
	 *
	 * If the chain is incomplete return.length < offsets.length
	 */
	@NotThreadSafe(useLock=true)
// Path: src/jext2/exceptions/FileTooLarge.java
// public class FileTooLarge extends JExt2Exception {
// 	static final long serialVersionUID = 42;
// 	protected final static int ERRNO = Errno.EFBIG;
// 
// 	public int getErrno() {
// 		return ERRNO;
// 	}
// }
// 
// Path: src/jext2/exceptions/IoError.java
// public class IoError extends JExt2Exception {
// 	static final long serialVersionUID = 42;
// 	protected static final int ERRNO=Errno.EIO;
// 	public IoError(String msg) {
// 		super(msg);
// 	}
// 	public IoError() {
// 		super();
// 	}
// 	public int getErrno() {
// 		return ERRNO;
// 	}
// }
// 
// 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/DataBlockAccess.java
import jext2.annotations.MustReturnLock;
import jext2.annotations.NotThreadSafe;
import jext2.exceptions.FileTooLarge;
import jext2.exceptions.IoError;
import jext2.exceptions.JExt2Exception;
import jext2.exceptions.NoSpaceLeftOnDevice;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Logger;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

			throw new RuntimeException("blockToPath: file block number < 0");
		} else if (fileBlockNr < Constants.EXT2_NDIR_BLOCKS) {
			return new int[] { (int)fileBlockNr };
		} else if ((fileBlockNr -= directBlocks) < indirectBlocks) {
			return new int[] { Constants.EXT2_IND_BLOCK,
					(int)fileBlockNr };
		} else if ((fileBlockNr -= indirectBlocks) < doubleBlocks) {
			return new int[] { Constants.EXT2_DIND_BLOCK,
					(int)fileBlockNr / ptrs,
					(int)fileBlockNr % ptrs };
		} else if ((fileBlockNr -= doubleBlocks)  < trippleBlocks) {
			return new int[] { Constants.EXT2_TIND_BLOCK,
					(int)fileBlockNr / (ptrs*ptrs),
					((int)fileBlockNr / ptrs) % ptrs ,
					(int)fileBlockNr % ptrs };
		} else {
			throw new FileTooLarge();
		}
	}

	/**
	 * Read the chain of indirect blocks leading to data
	 * @param inode 	Inode in question
	 * @param offsets	offsets of pointers in inode/indirect blocks
	 * @return	array of length depth with block numbers on the path.
	 * 	  array[depth-1] is data block number rest is the indirection on the path.
	 *
	 * If the chain is incomplete return.length < offsets.length
	 */
	@NotThreadSafe(useLock=true)
	private long[] getBranch(int[] offsets) throws IoError {