Esempio n. 1
0
        public FSInfoReply FSINFO(FSInfoCall fsInfoCall)
        {
            RootShareDirectory rootShareDirectory;

            Nfs3Procedure.Status status = sharedFileSystem.TryGetRootSharedDirectory(fsInfoCall.handle, out rootShareDirectory);
            if (status != Nfs3Procedure.Status.Ok)
            {
                return(new FSInfoReply(status, OptionalFileAttributes.None));
            }

            return(new FSInfoReply(
                       OptionalFileAttributes.None,
                       (UInt32)fileContents.array.Length, (UInt32)fileContents.array.Length, suggestedReadSizeMultiple,
                       0x10000, 0x10000, 0x1000,
                       0x1000,
#if WindowsCE
                       0x100000000, // 4 Gigabytes
#else
                       UInt64.MaxValue,
#endif
                       1,
                       0,
                       FileProperties.Fsf3Link | FileProperties.Fsf3SymLink | FileProperties.Fsf3Homogeneous | FileProperties.Fsf3CanSetTime
                       ));
        }
Esempio n. 2
0
        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));
        }