Example #1
0
        public Nfs3ReadResult Read(Nfs3FileHandle handle, long position, int count)
        {
            MemoryStream  ms     = new MemoryStream();
            XdrDataWriter writer = StartCallMessage(ms, _client.Credentials, 6);

            handle.Write(writer);
            writer.Write(position);
            writer.Write(count);

            RpcReply reply = DoSend(ms);

            if (reply.Header.IsSuccess)
            {
                return(new Nfs3ReadResult(reply.BodyReader));
            }
            else
            {
                throw new RpcException(reply.Header.ReplyHeader);
            }
        }
Example #2
0
        public Nfs3CreateResult MakeDirectory(Nfs3FileHandle dirHandle, string name, Nfs3SetAttributes attributes)
        {
            MemoryStream  ms     = new MemoryStream();
            XdrDataWriter writer = StartCallMessage(ms, _client.Credentials, 9);

            dirHandle.Write(writer);
            writer.Write(name);
            attributes.Write(writer);

            RpcReply reply = DoSend(ms);

            if (reply.Header.IsSuccess)
            {
                return(new Nfs3CreateResult(reply.BodyReader));
            }
            else
            {
                throw new RpcException(reply.Header.ReplyHeader);
            }
        }
Example #3
0
        public Nfs3ModifyResult SetAttributes(Nfs3FileHandle handle, Nfs3SetAttributes newAttributes)
        {
            MemoryStream  ms     = new MemoryStream();
            XdrDataWriter writer = StartCallMessage(ms, _client.Credentials, 2);

            handle.Write(writer);
            newAttributes.Write(writer);
            writer.Write(false);

            RpcReply reply = DoSend(ms);

            if (reply.Header.IsSuccess)
            {
                return(new Nfs3ModifyResult(reply.BodyReader));
            }
            else
            {
                throw new RpcException(reply.Header.ReplyHeader);
            }
        }
Example #4
0
        public Nfs3RenameResult Rename(Nfs3FileHandle fromDirHandle, string fromName, Nfs3FileHandle toDirHandle, string toName)
        {
            MemoryStream  ms     = new MemoryStream();
            XdrDataWriter writer = StartCallMessage(ms, _client.Credentials, 14);

            fromDirHandle.Write(writer);
            writer.Write(fromName);
            toDirHandle.Write(writer);
            writer.Write(toName);

            RpcReply reply = DoSend(ms);

            if (reply.Header.IsSuccess)
            {
                return(new Nfs3RenameResult(reply.BodyReader));
            }
            else
            {
                throw new RpcException(reply.Header.ReplyHeader);
            }
        }
Example #5
0
        public int GetPort(int program, int version, PortMapperProtocol protocol)
        {
            MemoryStream  ms     = new MemoryStream();
            XdrDataWriter writer = StartCallMessage(ms, null, 3);

            writer.Write(program);
            writer.Write(version);
            writer.Write((uint)protocol);
            writer.Write((uint)0);

            RpcReply reply = DoSend(ms);

            if (reply.Header.IsSuccess)
            {
                return((int)reply.BodyReader.ReadUInt32());
            }
            else
            {
                throw new RpcException(reply.Header.ReplyHeader);
            }
        }
Example #6
0
        public Nfs3ReadDirPlusResult ReadDirPlus(Nfs3FileHandle dir, ulong cookie, byte[] cookieVerifier, uint dirCount, uint maxCount)
        {
            MemoryStream  ms     = new MemoryStream();
            XdrDataWriter writer = StartCallMessage(ms, _client.Credentials, 17);

            dir.Write(writer);
            writer.Write(cookie);
            writer.WriteBytes(cookieVerifier ?? new byte[Nfs3.CookieVerifierSize]);
            writer.Write(dirCount);
            writer.Write(maxCount);

            RpcReply reply = DoSend(ms);

            if (reply.Header.IsSuccess)
            {
                return(new Nfs3ReadDirPlusResult(reply.BodyReader));
            }
            else
            {
                throw new RpcException(reply.Header.ReplyHeader);
            }
        }
Example #7
0
        public Nfs3WriteResult Write(Nfs3FileHandle handle, long position, byte[] buffer, int bufferOffset, int count)
        {
            MemoryStream  ms     = new MemoryStream();
            XdrDataWriter writer = StartCallMessage(ms, _client.Credentials, 7);

            handle.Write(writer);
            writer.Write(position);
            writer.Write(count);
            writer.Write((int)0); // UNSTABLE
            writer.WriteBuffer(buffer, bufferOffset, count);

            RpcReply reply = DoSend(ms);

            if (reply.Header.IsSuccess)
            {
                return(new Nfs3WriteResult(reply.BodyReader));
            }
            else
            {
                throw new RpcException(reply.Header.ReplyHeader);
            }
        }
Example #8
0
        public List <Nfs3Export> Exports()
        {
            MemoryStream  ms     = new MemoryStream();
            XdrDataWriter writer = StartCallMessage(ms, null, 5);

            RpcReply reply = DoSend(ms);

            if (reply.Header.IsSuccess)
            {
                List <Nfs3Export> exports = new List <Nfs3Export>();
                while (reply.BodyReader.ReadBool())
                {
                    exports.Add(new Nfs3Export(reply.BodyReader));
                }

                return(exports);
            }
            else
            {
                throw new RpcException(reply.Header.ReplyHeader);
            }
        }
Example #9
0
        public Nfs3MountResult Mount(string dirPath)
        {
            MemoryStream  ms     = new MemoryStream();
            XdrDataWriter writer = StartCallMessage(ms, _client.Credentials, 1);

            writer.Write(dirPath);

            RpcReply reply = DoSend(ms);

            if (reply.Header.IsSuccess)
            {
                Nfs3Status status = (Nfs3Status)reply.BodyReader.ReadInt32();
                if (status == Nfs3Status.Ok)
                {
                    return(new Nfs3MountResult(reply.BodyReader));
                }

                throw new Nfs3Exception(status);
            }
            else
            {
                throw new RpcException(reply.Header.ReplyHeader);
            }
        }