public RenameReply RENAME(RenameCall renameCall) { ShareObject oldParentDirectoryShareObject; ShareObject newParentDirectoryShareObject; Status status = sharedFileSystem.TryGetSharedObject(renameCall.oldDirectoryHandle, out oldParentDirectoryShareObject); if (status != Status.Ok) { return(new RenameReply(status, BeforeAndAfterAttributes.None, BeforeAndAfterAttributes.None)); } status = sharedFileSystem.TryGetSharedObject(renameCall.newDirectoryHandle, out newParentDirectoryShareObject); if (status != Status.Ok) { return(new RenameReply(status, BeforeAndAfterAttributes.None, BeforeAndAfterAttributes.None)); } oldParentDirectoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); SizeAndTimes oldDirectorySizeAndTimesBeforeCreate = AutoExtensions.CreateSizeAndTimes(oldParentDirectoryShareObject.fileAttributes); newParentDirectoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); SizeAndTimes newDirectorySizeAndTimesBeforeCreate = AutoExtensions.CreateSizeAndTimes(newParentDirectoryShareObject.fileAttributes); status = sharedFileSystem.Move(oldParentDirectoryShareObject, renameCall.oldName, newParentDirectoryShareObject, renameCall.newName); if (status != Status.Ok) { return(new RenameReply(status, BeforeAndAfterAttributes.None, BeforeAndAfterAttributes.None)); } oldParentDirectoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); newParentDirectoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); return(new RenameReply(Status.Ok, new BeforeAndAfterAttributes(oldDirectorySizeAndTimesBeforeCreate, oldParentDirectoryShareObject.fileAttributes), new BeforeAndAfterAttributes(newDirectorySizeAndTimesBeforeCreate, newParentDirectoryShareObject.fileAttributes))); }
public override RpcReply Call(String clientString, RpcCall call, byte[] callParameters, UInt32 callOffset, UInt32 callMaxOffset, out ISerializer replyParameters) { String nfsMethodName; ISerializer callData; Int32 extraPerfoamanceData = -1; Int64 beforeCall = Stopwatch.GetTimestamp(); Boolean printCall = true, printReply = true; switch (call.procedure) { case (UInt32)Nfs3Command.NULL: nfsMethodName = "NULL"; callData = VoidSerializer.Instance; replyParameters = VoidSerializer.Instance; break; case (UInt32)Nfs3Command.GETATTR: nfsMethodName = "GETATTR"; GetFileAttributesCall getFileAttributesCall = new GetFileAttributesCall(callParameters, callOffset, callMaxOffset); callData = getFileAttributesCall.CreateSerializer(); replyParameters = GETATTR(getFileAttributesCall).CreateSerializer(); break; case (UInt32)Nfs3Command.SETATTR: nfsMethodName = "SETATTR"; SetFileAttributesCall setFileAttributesCall = new SetFileAttributesCall(callParameters, callOffset, callMaxOffset); callData = setFileAttributesCall.CreateSerializer(); replyParameters = SETATTR(setFileAttributesCall).CreateSerializer(); break; case (UInt32)Nfs3Command.LOOKUP: nfsMethodName = "LOOKUP"; printReply = false; LookupCall lookupCall = new LookupCall(callParameters, callOffset, callMaxOffset); callData = lookupCall.CreateSerializer(); replyParameters = LOOKUP(lookupCall).CreateSerializer(); break; case (UInt32)Nfs3Command.ACCESS: nfsMethodName = "ACCESS"; AccessCall accessCall = new AccessCall(callParameters, callOffset, callMaxOffset); callData = accessCall.CreateSerializer(); replyParameters = ACCESS(accessCall).CreateSerializer(); break; case (UInt32)Nfs3Command.READ: nfsMethodName = "READ"; printReply = false; ReadCall readCall = new ReadCall(callParameters, callOffset, callMaxOffset); callData = readCall.CreateSerializer(); replyParameters = READ(readCall).CreateSerializer(); extraPerfoamanceData = (Int32)readCall.count; break; case (UInt32)Nfs3Command.WRITE: nfsMethodName = "WRITE"; printCall = false; WriteCall writeCall = new WriteCall(callParameters, callOffset, callMaxOffset); callData = writeCall.CreateSerializer(); replyParameters = WRITE(writeCall).CreateSerializer(); extraPerfoamanceData = (Int32)writeCall.count; break; case (UInt32)Nfs3Command.CREATE: nfsMethodName = "CREATE"; CreateCall createCall = new CreateCall(callParameters, callOffset, callMaxOffset); callData = createCall.CreateSerializer(); replyParameters = CREATE(createCall).CreateSerializer(); break; case (UInt32)Nfs3Command.MKDIR: nfsMethodName = "MKDIR"; MkdirCall mkdirCall = new MkdirCall(callParameters, callOffset, callMaxOffset); callData = mkdirCall.CreateSerializer(); replyParameters = MKDIR(mkdirCall).CreateSerializer(); break; case (UInt32)Nfs3Command.SYMLINK: nfsMethodName = "SYMLINK"; SymLinkCall symLinkCall = new SymLinkCall(callParameters, callOffset, callMaxOffset); callData = symLinkCall.CreateSerializer(); replyParameters = SYMLINK(symLinkCall).CreateSerializer(); break; case (UInt32)Nfs3Command.REMOVE: case (UInt32)Nfs3Command.RMDIR: nfsMethodName = "REMOVE/RMDIR"; RemoveCall removeCall = new RemoveCall(callParameters, callOffset, callMaxOffset); callData = removeCall.CreateSerializer(); replyParameters = REMOVE(removeCall).CreateSerializer(); break; case (UInt32)Nfs3Command.RENAME: nfsMethodName = "RENAME"; RenameCall renameCall = new RenameCall(callParameters, callOffset, callMaxOffset); callData = renameCall.CreateSerializer(); replyParameters = RENAME(renameCall).CreateSerializer(); break; case (UInt32)Nfs3Command.READDIRPLUS: nfsMethodName = "READDIRPLUS"; printReply = false; ReadDirPlusCall readDirPlusCall = new ReadDirPlusCall(callParameters, callOffset, callMaxOffset); callData = readDirPlusCall.CreateSerializer(); replyParameters = READDIRPLUS(readDirPlusCall).CreateSerializer(); break; case (UInt32)Nfs3Command.FSSTAT: nfsMethodName = "FSSTAT"; FileSystemStatusCall fileSystemInfoCall = new FileSystemStatusCall(callParameters, callOffset, callMaxOffset); callData = fileSystemInfoCall.CreateSerializer(); replyParameters = FSSTAT(fileSystemInfoCall).CreateSerializer(); break; case (UInt32)Nfs3Command.FSINFO: nfsMethodName = "FSINFO"; // // Deserialize // FSInfoCall fsInfoCall = new FSInfoCall(callParameters, callOffset, callMaxOffset); callData = fsInfoCall.CreateSerializer(); replyParameters = FSINFO(fsInfoCall).CreateSerializer(); break; case (UInt32)Nfs3Command.COMMIT: nfsMethodName = "COMMIT"; // Since this server does not perform unstable writes at the moment, this function is unnecessary CommitCall commitCall = new CommitCall(callParameters, callOffset, callMaxOffset); callData = commitCall.CreateSerializer(); //replyParameters = Handle(commitCall).CreateSerializer(); CommitReply commitReply = new CommitReply(BeforeAndAfterAttributes.None, null); replyParameters = commitReply.CreateSerializer(); break; default: if (NfsServerLog.warningLogger != null) { NfsServerLog.warningLogger.WriteLine("[{0}] [Warning] client '{1}' sent unknown procedure number {2}", serviceName, clientString, call.procedure); } replyParameters = VoidSerializer.Instance; return(new RpcReply(RpcVerifier.None, RpcAcceptStatus.ProcedureUnavailable)); } Int64 afterCall = Stopwatch.GetTimestamp(); Int64 callStopwatchTicks = afterCall - beforeCall; if (NfsServerLog.rpcCallLogger != null) { NfsServerLog.rpcCallLogger.WriteLine( #if WindowsCE JediTimer.JediTimerPrefix() + #endif "[{0}] {1} {2} => {3} {4:0.00} milliseconds", serviceName, nfsMethodName, printCall ? DataStringBuilder.DataSmallString(callData, NfsServerLog.sharedDataStringBuilder) : "[Call Ommited From Log]", printReply ? DataStringBuilder.DataSmallString(replyParameters, NfsServerLog.sharedDataStringBuilder) : "[Reply Ommited From Log]", callStopwatchTicks.StopwatchTicksAsDoubleMilliseconds()); } else if (NfsServerLog.warningLogger != null) { Double callMilliseconds = callStopwatchTicks.StopwatchTicksAsDoubleMilliseconds(); if (callMilliseconds >= 40) { NfsServerLog.warningLogger.WriteLine( #if WindowsCE JediTimer.JediTimerPrefix() + #endif "[{0}] [Warning] {1} {2} => {3} {4:0.00} milliseconds", serviceName, nfsMethodName, printCall ? DataStringBuilder.DataSmallString(callData, NfsServerLog.sharedDataStringBuilder) : "[Call Ommited From Log]", printReply ? DataStringBuilder.DataSmallString(replyParameters, NfsServerLog.sharedDataStringBuilder) : "[Reply Ommited From Log]", callMilliseconds); } } if (NfsServerLog.performanceLog != null) { NfsServerLog.performanceLog.Log((Nfs3Command)call.procedure, (UInt32)callStopwatchTicks.StopwatchTicksAsMicroseconds(), extraPerfoamanceData); } //servicesManager.PrintPerformance(); return(new RpcReply(RpcVerifier.None)); }