synchronized(parentINode) { parentINode.setLinksCount( parentINode.getLinksCount()+1 ); }
parentINode.setLinksCount( parentINode.getLinksCount()+1 );
	public FSEntry addDirectory(String name) throws IOException {		if(isReadOnly())			throw new IOException("Filesystem or directory is mounted read-only!");			 		//create a new iNode for the file		//TODO: access rights, file type, UID and GID should be passed through the FSDirectory interface		INode newINode;		Ext2DirectoryRecord dr;		Ext2Entry newEntry;		try{			int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO);			newINode = fs.createINode((int)iNode.getGroup(), Ext2Constants.EXT2_S_IFDIR, rights, 0, 0);						dr = new Ext2DirectoryRecord(fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_DIR, name);			addDirectoryRecord(dr);						//TODO: add synchronization			newINode.setLinksCount( newINode.getLinksCount()+1 );			newEntry = new Ext2Entry(newINode, name, Ext2Constants.EXT2_FT_DIR, fs, this.entry);						//add "."						Ext2Directory newDir = new Ext2Directory(newINode, fs, newEntry);			Ext2DirectoryRecord drThis = new Ext2DirectoryRecord( fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_DIR, "." );			newDir.addDirectoryRecord( drThis );			newINode.setLinksCount( 2 );									//add ".."			long parentINodeNr = ((Ext2Directory)entry.getDirectory()).getINode().getINodeNr();			Ext2DirectoryRecord drParent=new Ext2DirectoryRecord( fs, parentINodeNr, Ext2Constants.EXT2_FT_DIR, ".." );			newDir.addDirectoryRecord( drParent );						//increase the reference count for the parent directory			INode parentINode = fs.getINode((int)parentINodeNr);			//to be able to synchronize to the inode object requires that an inode cache is used and			//it contains only one copy of any inode			synchronized(parentINode) {				parentINode.setLinksCount( parentINode.getLinksCount()+1 ); 			}						//update the number of used directories in the block group			int group = (int)( (newINode.getINodeNr()-1) / fs.getSuperblock().getINodesPerGroup()) ;			fs.modifyUsedDirsCount(group, 1);						//update both affected directory inodes			iNode.update();			newINode.update();		}catch(FileSystemException fse) {			throw new IOException(fse);		}				return newEntry; 	}