private void addDirectoryRecord(Ext2DirectoryRecord dr) throws IOException, FileSystemException{
private synchronized void addDirectoryRecord(Ext2DirectoryRecord dr) throws IOException, FileSystemException{
	private void addDirectoryRecord(Ext2DirectoryRecord dr) throws IOException, FileSystemException{		Ext2File dir = new Ext2File(iNode);		//read itself as a file		//find the last directory record (if any)		Ext2FSEntryIterator iterator = (Ext2FSEntryIterator)iterator();		Ext2DirectoryRecord rec=null;		while(iterator.hasNext()) {			rec = iterator.nextDirectoryRecord();		}				if(rec!=null) {			long lastPos = rec.getFileOffset(); 			long lastLen = rec.getRecLen();			//truncate the last record to its minimal size (cut the padding from the end)			rec.truncateRecord();						//directoryRecords may not extend over block boundaries:			//	see if the new record fits in the same block after truncating the last record			long remainingLength = fs.getBlockSize() - (lastPos%fs.getBlockSize()) - rec.getRecLen();			log.debug("LAST-1 record: begins at: "+lastPos+", length: "+lastLen);			log.debug("LAST-1 truncated length: "+rec.getRecLen());			log.debug("Remaining length: "+remainingLength);			if(remainingLength >= dr.getRecLen()) {							//write back the last record truncated				dir.write( lastPos, rec.getData(), rec.getOffset(), rec.getRecLen() );					//pad the end of the new record with zeroes				dr.expandRecord(lastPos+rec.getRecLen(), lastPos+rec.getRecLen()+remainingLength);				//append the new record at the end of the list				dir.write( lastPos+rec.getRecLen(), dr.getData(), dr.getOffset(), dr.getRecLen() );				log.debug("addDirectoryRecord(): LAST   record: begins at: "+						 (rec.getFileOffset()+rec.getRecLen())+", length: "+dr.getRecLen());			} else {				//the new record must go to the next block				//(the previously last record (rec) stays padded to the end of the block, so we can 				// append after that)				dr.expandRecord(lastPos+lastLen, lastPos+lastLen+fs.getBlockSize());								dir.write( lastPos+lastLen, dr.getData(), dr.getOffset(), dr.getRecLen() );				log.debug("addDirectoryRecord(): LAST   record: begins at: "+(lastPos+lastLen)+", length: "+dr.getRecLen());				}		} else {	//rec==null, ie. this is the first record in the directory			dr.expandRecord(0, fs.getBlockSize());			dir.write(0, dr.getData(), dr.getOffset(), dr.getRecLen());			log.debug("addDirectoryRecord(): LAST   record: begins at: 0, length: "+dr.getRecLen());						}				iNode.setMtime(System.currentTimeMillis()/1000);	}