/** * Process a filesystem I/O control request * * @param sess Server session * @param tree Tree connection. * @param ctrlCode I/O control code * @param fid File id * @param dataBuf I/O control specific input data * @param isFSCtrl true if this is a filesystem control, or false for a device control * @param filter if bit0 is set indicates that the control applies to the share root handle * @return DataBuffer * @exception IOControlNotImplementedException * @exception SMBException */ public DataBuffer processIOControl( SrvSession sess, TreeConnection tree, int ctrlCode, int fid, DataBuffer dataBuf, boolean isFSCtrl, int filter) throws IOControlNotImplementedException, SMBException { // Validate the file id NetworkFile netFile = tree.findFile(fid); if (netFile == null || netFile.isDirectory() == false) throw new SMBException(SMBStatus.NTErr, SMBStatus.NTInvalidParameter); // Check if the I/O control handler is enabled if (tree.getContext() instanceof ContentContext) { ContentContext ctx = (ContentContext) tree.getContext(); if (ioControlHandler != null) { return ioControlHandler.processIOControl( sess, tree, ctrlCode, fid, dataBuf, isFSCtrl, filter, this, ctx); } else { throw new IOControlNotImplementedException(); } } return null; }
@Override public NetworkFile createFile(SrvSession sess, TreeConnection tree, FileOpenParams params) throws IOException { ContentContext tctx = (ContentContext) tree.getContext(); FileAccessToken token = null; if (tctx.hasStateCache()) { FileStateCache cache = tctx.getStateCache(); FileState fstate = tctx.getStateCache().findFileState(params.getPath(), true); token = cache.grantFileAccess(params, fstate, FileStatus.NotExist); if (logger.isDebugEnabled()) { logger.debug("create file created lock token:" + token); } } try { NetworkFile newFile = diskInterface.createFile(sess, tree, params); if (tctx.hasStateCache()) { FileState fstate = tctx.getStateCache().findFileState(params.getPath(), true); fstate.setProcessId(params.getProcessId()); fstate.setSharedAccess(params.getSharedAccess()); // Indicate that the file is open fstate.setFileStatus( newFile.isDirectory() ? FileStatus.DirectoryExists : FileStatus.FileExists); fstate.setAllocationSize(params.getAllocationSize()); if (newFile instanceof NodeRefNetworkFile) { NodeRefNetworkFile x = (NodeRefNetworkFile) newFile; x.setFileState(fstate); } if (newFile instanceof TempNetworkFile) { TempNetworkFile x = (TempNetworkFile) newFile; x.setFileState(fstate); } } if (newFile instanceof NodeRefNetworkFile) { NodeRefNetworkFile x = (NodeRefNetworkFile) newFile; x.setProcessId(params.getProcessId()); x.setAccessToken(token); } if (newFile instanceof TempNetworkFile) { TempNetworkFile x = (TempNetworkFile) newFile; x.setAccessToken(token); } return newFile; } catch (IOException ie) { if (logger.isDebugEnabled()) { logger.debug("create file exception caught", ie); } if (tctx.hasStateCache() && token != null) { FileStateCache cache = tctx.getStateCache(); FileState fstate = tctx.getStateCache().findFileState(params.getPath(), false); if (fstate != null && token != null) { if (logger.isDebugEnabled()) { logger.debug("create file release lock token:" + token); } cache.releaseFileAccess(fstate, token); } } throw ie; } }