long byteIndex;
blockCache = new BlockCache(50,(float)0.75); inodeCache = new INodeCache(50,(float)0.75);  groupDescriptorLock = new Object(); superblockLock = new Object();
	public Ext2FileSystem(Device device) throws FileSystemException {		if (device == null) {			throw new FileSystemException("null device!");		}		this.device = device;		try {			this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class);		} catch (ApiNotFoundException ex) {			throw new FileSystemException("Device is not a partition", ex);		}		closed = false;		byte data[];		//points to the byte where the fs metadata parsing has reached		long byteIndex;		cache = new BlockCache(50, (float) 0.75);		try {			data = new byte[Superblock.SUPERBLOCK_LENGTH];			//skip the first 1024 bytes (bootsector) and read the superblock			byteIndex = 1024;			api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH);			byteIndex += Superblock.SUPERBLOCK_LENGTH;			superblock = new Superblock(data);			//read the group descriptors			groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup());			groupDescriptors = new GroupDescriptor[groupCount];			for (int i = 0; i < groupCount; i++) {				data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH];				api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH);				groupDescriptors[i] = new GroupDescriptor(data);			}			byteIndex += superblock.getBlockSize();			/*			 * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0,			 * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize();			 * 			 * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap			 * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize();			 * 			 * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ];			 */		} catch (FileSystemException e) {			throw e;		} catch (Exception e) {			throw new FileSystemException(e);		}		log.debug("Ext2fs filesystem constructed sucessfully");		log.debug(			"	superblock:	#blocks:		"				+ superblock.getBlocksCount()				+ "\n"				+ "				#blocks/group:	"				+ superblock.getBlocksPerGroup()				+ "\n"				+ "				#block groups:	"				+ groupCount				+ "\n"				+ "				block size:		"				+ superblock.getBlockSize()				+ "\n"				+ "				#inodes:		"				+ superblock.getINodesCount()				+ "\n"				+ "				#inodes/group:	"				+ superblock.getINodesPerGroup());	}