iNode.setSize(length);  iNode.setMtime(System.currentTimeMillis()/1000);  return; }     if(length>getLength()) { long len = length - getLength(); long blocksAllocated = getLengthInBlocks(); long bytesAllocated  = getLength(); long bytesCovered=0; while( bytesCovered < len ) { long blockIndex = 	(bytesAllocated+bytesCovered) / blockSize; long blockOffset = 	(bytesAllocated+bytesCovered) % blockSize; long newSection = Math.min(len-bytesCovered, blockSize - blockOffset);   if(blockIndex >= blocksAllocated) { try{ iNode.allocateDataBlock(blockIndex); }catch(FileSystemException fe) { throw new IOException("Internal filesystem exception",fe); } blocksAllocated++; }  bytesCovered += newSection; } iNode.setSize(length);  iNode.setMtime(System.currentTimeMillis()/1000);  return; }
}
	public void setLength(long length) throws IOException {		if(!canWrite())			throw new ReadOnlyFileSystemException("FileSystem or File is readonly");				long blockSize = iNode.getExt2FileSystem().getBlockSize();				//if length<getLength(), then the file is truncated		if(length<getLength()) {			long blockNr 	 = length / blockSize;			long blockOffset = length % blockSize;			long nextBlock;			if(blockOffset==0)				nextBlock=blockNr;			else				nextBlock=blockNr+1;							for(long i=iNode.getAllocatedBlockCount()-1; i>=nextBlock; i--)  {				log.debug("setLength(): freeing up block "+i+" of inode");				try{					iNode.freeDataBlock(i);				}catch(FileSystemException fse) {					throw new IOException(fse);				}							}			iNode.setSize(length);			iNode.setMtime(System.currentTimeMillis()/1000);			return;		}				//if length>getLength(), then new blocks are allocated for the file		//The content of the new blocks is undefined (see the setLength(long i) 		//method of java.io.RandomAccessFile		if(length>getLength()) {			long len = length - getLength();			long blocksAllocated = getLengthInBlocks();			long bytesAllocated  = getLength();			long bytesCovered=0;			while( bytesCovered < len ) {				long blockIndex = 	(bytesAllocated+bytesCovered) / blockSize;				long blockOffset = 	(bytesAllocated+bytesCovered) % blockSize;				long newSection = Math.min(len-bytesCovered, blockSize - blockOffset);							//allocate a new block if needed				if(blockIndex >= blocksAllocated) {					try{						iNode.allocateDataBlock(blockIndex);					}catch(FileSystemException fe) {						throw new IOException("Internal filesystem exception",fe);					}					blocksAllocated++;				}								bytesCovered += newSection;			}		iNode.setSize(length);		iNode.setMtime(System.currentTimeMillis()/1000);				return;		}			}