Пример #1
0
 public void xdrDecode(XdrDecodingStream xdr)
 {
     nfl_util = new nfl_util4(xdr);
     nfl_first_stripe_index = xdr.xdrDecodeInt();
     nfl_pattern_offset     = new offset4(xdr);
     { int _size = xdr.xdrDecodeInt(); nfl_fh_list = new nfs_fh4[_size]; for (int _idx = 0; _idx < _size; ++_idx)
       {
           nfl_fh_list[_idx] = new nfs_fh4(xdr);
       }
     }
 }
Пример #2
0
 public void xdrDecode(XdrDecodingStream xdr)
 {
     object1 = new nfs_fh4(xdr);
 }
Пример #3
0
 public void xdrDecode(XdrDecodingStream xdr) {
     value = new nfs_fh4(xdr);
 }
Пример #4
0
 public fattr4_filehandle(nfs_fh4 value) {
     this.value = value;
 }
Пример #5
0
 public void xdrDecode(XdrDecodingStream xdr) {
     nfl_util = new nfl_util4(xdr);
     nfl_first_stripe_index = xdr.xdrDecodeInt();
     nfl_pattern_offset = new offset4(xdr);
     { int _size = xdr.xdrDecodeInt(); nfl_fh_list = new nfs_fh4[_size]; for ( int _idx = 0; _idx < _size; ++_idx ) { nfl_fh_list[_idx] = new nfs_fh4(xdr); } }
 }
Пример #6
0
 public void xdrDecode(XdrDecodingStream xdr)
  {
     object1 = new nfs_fh4(xdr);
 }
Пример #7
0
        private void getRootFh()
        {
            List<int> attrs = new List<int>(1);
            attrs.Add(NFSv4Protocol.FATTR4_LEASE_TIME);
            List<nfs_argop4> ops = new List<nfs_argop4>();

            ops.Add(SequenceStub.generateRequest(false, _sessionid.value,
                    _sequenceID.value.value, 0, 0));
            ops.Add(PutrootfhStub.generateRequest());
            ops.Add(GetfhStub.generateRequest());
            ops.Add(GetattrStub.generateRequest(attrs));

            COMPOUND4res compound4res = sendCompound(ops, "");

            if (compound4res.status == nfsstat4.NFS4_OK)
            {

                _rootFH = compound4res.resarray[2].opgetfh.resok4.object1;

            }
            else
            {
                throw new NFSConnectionException(nfsstat4.getErrorString(compound4res.status));
            }

        }
Пример #8
0
        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 Connect(IPAddress Address, int UserID, int GroupID, int ClientTimeout, System.Text.Encoding characterEncoding, bool useSecurePort,bool useCache)
        {
            if (ClientTimeout == 0)
            { ClientTimeout = 60000; }

            if (characterEncoding == null)
            { characterEncoding = System.Text.Encoding.ASCII; }

            _CurrentItem = String.Empty;

            useFHCache = useCache;
            

            if(useFHCache)
            cached_attrs = new Hashtable();//new Dictionary<string, NFSAttributes>();
            
            _rootFH = null;

            //_cwd = null;

            _cwf = null;

            //_cwhTree = new List<nfs_fh4>();
            //treePosition = 0;

            _GroupID = GroupID;
            _UserID = UserID;

            _ProtocolV4 = new NFSv4ProtocolClient(Address, OncRpcProtocols.ONCRPC_TCP, useSecurePort);

            OncRpcClientAuthUnix authUnix = new OncRpcClientAuthUnix(Address.ToString(), UserID, GroupID);

            _ProtocolV4.GetClient().setAuth(authUnix);
            _ProtocolV4.GetClient().setTimeout(ClientTimeout);
            _ProtocolV4.GetClient().setCharacterEncoding(characterEncoding.WebName);

            //send null dummy procedure to see if server is responding
            sendNullPRocedure();

        }
Пример #10
0
        public void CompleteIO()
        {
            if (_cwf != null || _CurrentItem != string.Empty)
            {
                closeFile(_cwf, currentState);
                _CurrentItem = string.Empty;
                _cwf = null;
            }

        }
Пример #11
0
        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
        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));
        }
        }
Пример #13
0
        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;
        }
Пример #14
0
 public fattr4_filehandle(nfs_fh4 value)
 {
     this.value = value;
 }
Пример #15
0
        public int get_fh_acess(nfs_fh4 file_handle)
        {
            uint32_t access = new uint32_t(0);

            //all acsses possible
            access.value = access.value +
            NFSv4Protocol.ACCESS4_READ +
            NFSv4Protocol.ACCESS4_LOOKUP +
            NFSv4Protocol.ACCESS4_MODIFY +
            NFSv4Protocol.ACCESS4_EXTEND +
            NFSv4Protocol.ACCESS4_DELETE; //+
            //NFSv4Protocol.ACCESS4_EXECUTE; 

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


            ops.Add(SequenceStub.generateRequest(false, _sessionid.value,
                    _sequenceID.value.value, 12, 0));
            ops.Add(PutfhStub.generateRequest(file_handle));
            ops.Add(AcessStub.generateRequest(access));


            COMPOUND4res compound4res = sendCompound(ops, "");

            if (compound4res.status == nfsstat4.NFS4_OK)
            {

                return compound4res.resarray[2].opaccess.resok4.access.value;
            }
            else
            {
                throw new NFSConnectionException(nfsstat4.getErrorString(compound4res.status));
            }
        }
Пример #16
0
 public void xdrDecode(XdrDecodingStream xdr)
 {
     value = new nfs_fh4(xdr);
 }
Пример #17
0
        public List<String> GetItemListByFH(nfs_fh4 dir_fh)
        {

            //should return result
            int acess = get_fh_acess(dir_fh);


            List<string> ItemsList = new List<string>();

            //has read acess
            if (acess % 2 == 1)
            {

                bool done = false;
                long cookie = 0;

                verifier4 verifier = new verifier4(0);

                do
                {

                    List<nfs_argop4> ops = new List<nfs_argop4>();
                    ops.Add(SequenceStub.generateRequest(false, _sessionid.value,
                            _sequenceID.value.value, 12, 0));
                    ops.Add(PutfhStub.generateRequest(dir_fh));
                    ops.Add(ReadDirStub.generateRequest(cookie, verifier));

                    COMPOUND4res compound4res = sendCompound(ops, "");

                    if (compound4res.status == nfsstat4.NFS4_OK)
                    {
                        verifier = compound4res.resarray[2].opreaddir.resok4.cookieverf;
                        done = compound4res.resarray[2].opreaddir.resok4.reply.eof;

                        entry4 dirEntry = compound4res.resarray[2].opreaddir.resok4.reply.entries;
                        while (dirEntry != null)
                        {
                            cookie = dirEntry.cookie.value.value;
                            string name = System.Text.Encoding.UTF8.GetString(dirEntry.name.value.value.value);
                            ItemsList.Add(name);
                            dirEntry = dirEntry.nextentry;
                        }

                    }
                    else
                    {
                        throw new NFSGeneralException(nfsstat4.getErrorString(compound4res.status));

                    }

                } while (!done);
                //now do the lookups (maintained by the nfsclient)
            }
            else
                throw new NFSGeneralException(nfsstat4.getErrorString(nfsstat4.NFS4ERR_ACCESS));


            return ItemsList;
        }