public Handle open (Credential cr, int mode) {
		
		// try to open entry.
		Handle hdl = super.open (cr, mode);
		if (hdl.rc != Handle.RC_OK)
			// open failed on basic level
			return hdl;

		// determine access mode
		String fMode = "r";
		if (hdl.forWrite) fMode = "rw";
		
		// check access to open physical file
		java.io.File f = new java.io.File (fileName);
		if ((hdl.forRead && !f.canRead()) || (hdl.forWrite && !f.canWrite())) {
			// overwrite permission if the server
			// can't access the file. 
			inUse--;
			hdl.rc = Handle.RC_NO_PERMISSION;
			return hdl;
		}
		
		// create our own handle.
		DiskHandle dHdl = new DiskHandle ();
		dHdl.forRead = hdl.forRead;
		dHdl.forWrite = hdl.forWrite;
		try {
			dHdl.rc = Handle.RC_OK;
			dHdl.file = new RandomAccessFile (f, fMode);
			// truncate file on request
			if ((mode & Permissions.OTRUNC) != 0)
				dHdl.file.setLength (0);
			fileSize = dHdl.file.length();
		}
		catch (Exception e) {
			hdl.rc = Handle.RC_NO_SUCH_FILE;
			inUse--;
			return hdl;
		}
		return dHdl;
	}