コード例 #1
0
ファイル: CloseStub.cs プロジェクト: SonnyX/NFS-Client
        public static nfs_argop4 generateRequest(stateid4 stateid)
        {
            CLOSE4args args = new CLOSE4args();

            args.seqid        = new seqid4(new uint32_t(0));
            args.open_stateid = stateid;

            nfs_argop4 op = new nfs_argop4();

            op.argop   = nfs_opnum4.OP_CLOSE;
            op.opclose = args;

            return(op);
        }
コード例 #2
0
ファイル: ReadStub.cs プロジェクト: SonnyX/NFS-Client
        public static nfs_argop4 generateRequest(int count, long offset, stateid4 stateid)
        {
            READ4args args = new READ4args();

            args.count  = new count4(new uint32_t(count));
            args.offset = new offset4(new uint64_t(offset));

            args.stateid = stateid;

            nfs_argop4 op = new nfs_argop4();

            op.argop  = nfs_opnum4.OP_READ;
            op.opread = args;

            return(op);
        }
コード例 #3
0
ファイル: ReadStub.cs プロジェクト: zjianliu/NFSClient
        public static nfs_argop4 generateRequest(int count, long offset, stateid4 stateid)
        {

            READ4args args = new READ4args();
            args.count = new count4(new uint32_t(count));
            args.offset = new offset4(new uint64_t(offset));

            args.stateid = stateid;

            nfs_argop4 op = new nfs_argop4();
            op.argop = nfs_opnum4.OP_READ;
            op.opread = args;

            return op;

        }
コード例 #4
0
ファイル: CloseStub.cs プロジェクト: zjianliu/NFSClient
        public static nfs_argop4 generateRequest(stateid4 stateid)
        {


            CLOSE4args args = new CLOSE4args();

            args.seqid = new seqid4(new uint32_t(0));
            args.open_stateid = stateid;


            nfs_argop4 op = new nfs_argop4();

            op.argop = nfs_opnum4.OP_CLOSE;
            op.opclose = args;

            return op;

        }
コード例 #5
0
ファイル: NFSv4.1.cs プロジェクト: zousenming/NFSClient
        private void closeFile(nfs_fh4 fh, stateid4 stateid)
        {
            List <nfs_argop4> ops = new List <nfs_argop4>();

            ops.Add(SequenceStub.generateRequest(false, _sessionid.value,
                                                 _sequenceID.value.value, 12, 0));

            ops.Add(PutfhStub.generateRequest(fh));
            ops.Add(CloseStub.generateRequest(stateid));

            COMPOUND4res compound4res = sendCompound(ops, "");

            if (compound4res.status == nfsstat4.NFS4_OK)
            {
                //close file ok
            }
            else
            {
                throw new NFSConnectionException(nfsstat4.getErrorString(compound4res.status));
            }
        }
コード例 #6
0
ファイル: WriteStub.cs プロジェクト: SonnyX/NFS-Client
        public static nfs_argop4 generateRequest(long offset, byte[] data, stateid4 stateid)
        {
            WRITE4args args = new WRITE4args();

            //enable this for sycronized stable writes
            //args.stable = stable_how4.FILE_SYNC4;

            args.stable = stable_how4.UNSTABLE4;

            args.offset = new offset4(new uint64_t(offset));

            args.stateid = stateid;

            args.data = data;

            nfs_argop4 op = new nfs_argop4();

            op.argop   = nfs_opnum4.OP_WRITE;
            op.opwrite = args;

            return(op);
        }
コード例 #7
0
ファイル: WriteStub.cs プロジェクト: zjianliu/NFSClient
        public static nfs_argop4 generateRequest(long offset, byte[] data, stateid4 stateid)
        {

            WRITE4args args = new WRITE4args();

            //enable this for sycronized stable writes
            //args.stable = stable_how4.FILE_SYNC4;

            args.stable = stable_how4.UNSTABLE4;

            args.offset = new offset4(new uint64_t(offset));

            args.stateid = stateid;

            args.data = data;

            nfs_argop4 op = new nfs_argop4();
            op.argop = nfs_opnum4.OP_WRITE;
            op.opwrite = args;

            return op;
        }
コード例 #8
0
ファイル: NFSv4.1.cs プロジェクト: zousenming/NFSClient
        public void CreateFile(string FileFullName, NFSPermission Mode)
        {
            if (_CurrentItem != FileFullName)
            {
                _CurrentItem = FileFullName;


                String[] PathTree = FileFullName.Split(@"\".ToCharArray());

                string        ParentDirectory  = System.IO.Path.GetDirectoryName(FileFullName);
                NFSAttributes ParentAttributes = GetItemAttributes(ParentDirectory);



                //make open here
                List <nfs_argop4> ops = new List <nfs_argop4>();
                ops.Add(SequenceStub.generateRequest(false, _sessionid.value,
                                                     _sequenceID.value.value, 12, 0));
                //dir  herez
                ops.Add(PutfhStub.generateRequest(new nfs_fh4(ParentAttributes.Handle)));
                //let's try with sequence 0
                ops.Add(OpenStub.normalCREATE(PathTree[PathTree.Length - 1], _sequenceID.value.value, _clientIdByServer, NFSv4Protocol.OPEN4_SHARE_ACCESS_WRITE));
                ops.Add(GetfhStub.generateRequest());


                COMPOUND4res compound4res = sendCompound(ops, "");
                if (compound4res.status == nfsstat4.NFS4_OK)
                {
                    //open ok
                    currentState = compound4res.resarray[2].opopen.resok4.stateid;

                    _cwf = compound4res.resarray[3].opgetfh.resok4.object1;
                }
                else
                {
                    throw new NFSConnectionException(nfsstat4.getErrorString(compound4res.status));
                }
            }
        }
コード例 #9
0
 public void xdrDecode(XdrDecodingStream xdr)
 {
     lor_offset = new offset4(xdr);
     lor_length = new length4(xdr);
     lor_stateid = new stateid4(xdr);
 }
コード例 #10
0
 public void xdrDecode(XdrDecodingStream xdr) {
     lor_offset = new offset4(xdr);
     lor_length = new length4(xdr);
     lor_stateid = new stateid4(xdr);
 }
コード例 #11
0
ファイル: NFSv4.1.cs プロジェクト: zousenming/NFSClient
        public int Write(String FileFullName, long Offset, int Count, Byte[] Buffer)
        {
            if (_ProtocolV4 == null)
            {
                throw new NFSConnectionException("NFS Client not connected!");
            }


            int rCount = 0;

            //nfs_fh4 current = _cwd;



            if (_CurrentItem != FileFullName)
            {
                _CurrentItem = FileFullName;


                String[] PathTree = FileFullName.Split(@"\".ToCharArray());

                string        ParentDirectory  = System.IO.Path.GetDirectoryName(FileFullName);
                NFSAttributes ParentAttributes = GetItemAttributes(ParentDirectory);


                //make open here
                List <nfs_argop4> ops = new List <nfs_argop4>();
                ops.Add(SequenceStub.generateRequest(false, _sessionid.value,
                                                     _sequenceID.value.value, 12, 0));
                //dir  herez
                ops.Add(PutfhStub.generateRequest(new nfs_fh4(ParentAttributes.Handle)));
                //let's try with sequence 0
                ops.Add(OpenStub.normalOPENonly(PathTree[PathTree.Length - 1], _sequenceID.value.value, _clientIdByServer, NFSv4Protocol.OPEN4_SHARE_ACCESS_WRITE));
                ops.Add(GetfhStub.generateRequest());


                COMPOUND4res compound4res = sendCompound(ops, "");
                if (compound4res.status == nfsstat4.NFS4_OK)
                {
                    //open ok
                    currentState = compound4res.resarray[2].opopen.resok4.stateid;

                    _cwf = compound4res.resarray[3].opgetfh.resok4.object1;
                }
                else
                {
                    throw new NFSConnectionException(nfsstat4.getErrorString(compound4res.status));
                }
            }

            List <nfs_argop4> ops2 = new List <nfs_argop4>();

            ops2.Add(SequenceStub.generateRequest(false, _sessionid.value,
                                                  _sequenceID.value.value, 12, 0));
            ops2.Add(PutfhStub.generateRequest(_cwf));

            //make better buffer
            Byte[] Buffer2 = new Byte[Count];
            Array.Copy(Buffer, Buffer2, Count);
            ops2.Add(WriteStub.generateRequest(Offset, Buffer2, currentState));



            COMPOUND4res compound4res2 = sendCompound(ops2, "");

            if (compound4res2.status == nfsstat4.NFS4_OK)
            {
                //write of offset complete
                rCount = compound4res2.resarray[2].opwrite.resok4.count.value.value;
            }
            else
            {
                throw new NFSConnectionException(nfsstat4.getErrorString(compound4res2.status));
            }

            return(rCount);
        }
コード例 #12
0
ファイル: NFSv4.1.cs プロジェクト: zousenming/NFSClient
        public int Read(String FileFullName, long Offset, int Count, ref Byte[] Buffer)
        {
            if (_ProtocolV4 == null)
            {
                throw new NFSConnectionException("NFS Client not connected!");
            }

            int rCount = 0;

            if (Count == 0)
            {
                return(0);
            }


            if (_CurrentItem != FileFullName)
            {
                NFSAttributes Attributes = GetItemAttributes(FileFullName);
                _cwf         = new nfs_fh4(Attributes.Handle);
                _CurrentItem = FileFullName;

                string        ParentDirectory  = System.IO.Path.GetDirectoryName(FileFullName);
                NFSAttributes ParentAttributes = GetItemAttributes(ParentDirectory);

                String[] PathTree = FileFullName.Split(@"\".ToCharArray());


                //make open here
                List <nfs_argop4> ops = new List <nfs_argop4>();
                ops.Add(SequenceStub.generateRequest(false, _sessionid.value,
                                                     _sequenceID.value.value, 12, 0));
                //dir  herez
                //ops.Add(PutfhStub.generateRequest(_cwd));
                ops.Add(PutfhStub.generateRequest(new nfs_fh4(ParentAttributes.Handle)));
                //let's try with sequence 0
                ops.Add(OpenStub.normalREAD(PathTree[PathTree.Length - 1], 0, _clientIdByServer, NFSv4Protocol.OPEN4_SHARE_ACCESS_READ));


                COMPOUND4res compound4res = sendCompound(ops, "");
                if (compound4res.status == nfsstat4.NFS4_OK)
                {
                    //open ok
                    currentState = compound4res.resarray[2].opopen.resok4.stateid;
                }
                else
                {
                    throw new NFSConnectionException(nfsstat4.getErrorString(compound4res.status));
                }



                //check the acess also
                if (get_fh_acess(_cwf) % 2 != 1)
                {
                    //we don't have read acess give error
                    throw new NFSConnectionException("Sorry no file READ acess !!!");
                }
            }

            List <nfs_argop4> ops2 = new List <nfs_argop4>();

            ops2.Add(SequenceStub.generateRequest(false, _sessionid.value,
                                                  _sequenceID.value.value, 12, 0));
            ops2.Add(PutfhStub.generateRequest(_cwf));
            ops2.Add(ReadStub.generateRequest(Count, Offset, currentState));



            COMPOUND4res compound4res2 = sendCompound(ops2, "");

            if (compound4res2.status == nfsstat4.NFS4_OK)
            {
                //read of offset complete
                rCount = compound4res2.resarray[2].opread.resok4.data.Length;

                ///copy the data to the output
                Array.Copy(compound4res2.resarray[2].opread.resok4.data, Buffer, rCount);
            }
            else
            {
                throw new NFSConnectionException(nfsstat4.getErrorString(compound4res2.status));
            }

            return(rCount);
        }