/* public static List<Integer> supportedAttrs(bitmap4 bitmap) { * * List<Integer> supported = new ArrayList<Integer>(); * * // TODO: * * return supported; * * }*/ public static Dictionary <int, Object> decodeType(fattr4 attributes) { Dictionary <int, Object> attr = new Dictionary <int, Object>(); int[] mask = new int[attributes.attrmask.value.Length]; for (int i = 0; i < mask.Length; i++) { mask[i] = attributes.attrmask.value[i].value; } XdrDecodingStream xdr = new XdrBufferDecodingStream(attributes.attr_vals.value); xdr.beginDecoding(); if (mask.Length != 0) { int maxAttr = 32 * mask.Length; for (int i = 0; i < maxAttr; i++) { int newmask = (mask[i / 32] >> (i - (32 * (i / 32)))); if ((newmask & 1L) != 0) { xdr2fattr(attr, i, xdr); } } } xdr.endDecoding(); return(attr); }
/* public static List<Integer> supportedAttrs(bitmap4 bitmap) { List<Integer> supported = new ArrayList<Integer>(); // TODO: return supported; }*/ public static Dictionary<int, Object> decodeType(fattr4 attributes) { Dictionary<int,Object> attr = new Dictionary<int, Object>(); int[] mask = new int[attributes.attrmask.value.Length]; for( int i = 0; i < mask.Length; i++) { mask[i] = attributes.attrmask.value[i].value; } XdrDecodingStream xdr = new XdrBufferDecodingStream(attributes.attr_vals.value); xdr.beginDecoding(); if( mask.Length != 0 ) { int maxAttr = 32*mask.Length; for( int i = 0; i < maxAttr; i++) { int newmask = (mask[i/32] >> (i-(32*(i/32))) ); if( (newmask & 1L) != 0 ) { xdr2fattr(attr, i, xdr); } } } xdr.endDecoding(); return attr; }
public void CreateDirectory(string DirectoryFullName, NFSPermission Mode) { if (_ProtocolV4 == null) { throw new NFSConnectionException("NFS Client not connected!"); } int user = 7; int group = 7; int other = 7; if (Mode != null) { user = Mode.UserAccess; group = Mode.GroupAccess; other = Mode.OtherAccess; } string ParentDirectory = System.IO.Path.GetDirectoryName(DirectoryFullName); string fileName = System.IO.Path.GetFileName(DirectoryFullName); NFSAttributes ParentItemAttributes = GetItemAttributes(ParentDirectory); //create item attributes now fattr4 attr = new fattr4(); attr.attrmask = OpenStub.openFattrBitmap(); attr.attr_vals = new attrlist4(); attr.attr_vals.value = OpenStub.openAttrs(user, group, other, 4096); List <nfs_argop4> ops = new List <nfs_argop4>(); ops.Add(SequenceStub.generateRequest(false, _sessionid.value, _sequenceID.value.value, 12, 0)); ops.Add(PutfhStub.generateRequest(new nfs_fh4(ParentItemAttributes.Handle))); ops.Add(CreateStub.generateRequest(fileName, attr)); COMPOUND4res compound4res = sendCompound(ops, ""); if (compound4res.status == nfsstat4.NFS4_OK) { //create directory ok } else { throw new NFSConnectionException(nfsstat4.getErrorString(compound4res.status)); } }
public static nfs_argop4 generateRequest(String name,fattr4 attribs) { nfs_argop4 op = new nfs_argop4(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); op.argop = nfs_opnum4.OP_CREATE; op.opcreate = new CREATE4args(); op.opcreate.objname = new component4(); op.opcreate.objname.value = new utf8str_cs(new utf8string(encoding.GetBytes(name))); op.opcreate.createattrs = attribs; op.opcreate.objtype = new createtype4(); //we will create only directories op.opcreate.objtype.type = nfs_ftype4.NF4DIR; return op; }
public static nfs_argop4 generateRequest(String name, fattr4 attribs) { nfs_argop4 op = new nfs_argop4(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); op.argop = nfs_opnum4.OP_CREATE; op.opcreate = new CREATE4args(); op.opcreate.objname = new component4(); op.opcreate.objname.value = new utf8str_cs(new utf8string(encoding.GetBytes(name))); op.opcreate.createattrs = attribs; op.opcreate.objtype = new createtype4(); //we will create only directories op.opcreate.objtype.type = nfs_ftype4.NF4DIR; return(op); }
public void xdrDecode(XdrDecodingStream xdr) { ne_attrs = new fattr4(xdr); }
public static nfs_argop4 normalCREATE(String path, int sequenceId, clientid4 clientid, int access) { System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); nfs_argop4 op = new nfs_argop4(); op.argop = nfs_opnum4.OP_OPEN; op.opopen = new OPEN4args(); op.opopen.seqid = new seqid4(new uint32_t(sequenceId)); state_owner4 owner = new state_owner4(); owner.clientid = clientid; owner.owner = encoding.GetBytes("nfsclient"); op.opopen.owner = new open_owner4(owner); //if ((access & NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_DELEG_MASK) == 0) // { // access |= NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_NO_DELEG; // } op.opopen.share_access = new uint32_t(access); op.opopen.share_deny = new uint32_t(NFSv4Protocol.OPEN4_SHARE_DENY_NONE); openflag4 flag = new openflag4(); flag.opentype = opentype4.OPEN4_CREATE; // createhow4(mode, attrs, verifier) createhow4 how = new createhow4(); how.mode = createmode4.GUARDED4; //how.mode = createmode4.EXCLUSIVE4_1; fattr4 attr = new fattr4(); attr.attrmask = openFattrBitmap(); attr.attr_vals = new attrlist4(); attr.attr_vals.value = openAttrs(7, 7, 7, 0); how.createattrs = attr; how.createverf = new verifier4(0); //it is long //how.mode = createmode4.GUARDED4; flag.how = how; op.opopen.openhow = flag; open_claim4 claim = new open_claim4(); claim.claim = open_claim_type4.CLAIM_NULL; claim.file = new component4(new utf8str_cs(new utf8string(encoding .GetBytes(path)))); claim.delegate_type = NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_NO_DELEG; claim.file_delegate_prev = null; claim.oc_delegate_stateid = null; claim.delegate_type = 0; claim.delegate_cur_info = null; op.opopen.claim = claim; return(op); }
public static nfs_argop4 normalCREATE(String path, int sequenceId, clientid4 clientid, int access) { System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); nfs_argop4 op = new nfs_argop4(); op.argop = nfs_opnum4.OP_OPEN; op.opopen = new OPEN4args(); op.opopen.seqid = new seqid4(new uint32_t(sequenceId)); state_owner4 owner = new state_owner4(); owner.clientid = clientid; owner.owner = encoding.GetBytes("nfsclient"); op.opopen.owner = new open_owner4(owner); //if ((access & NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_DELEG_MASK) == 0) // { // access |= NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_NO_DELEG; // } op.opopen.share_access = new uint32_t(access); op.opopen.share_deny = new uint32_t(NFSv4Protocol.OPEN4_SHARE_DENY_NONE); openflag4 flag = new openflag4(); flag.opentype = opentype4.OPEN4_CREATE; // createhow4(mode, attrs, verifier) createhow4 how = new createhow4(); how.mode = createmode4.GUARDED4; //how.mode = createmode4.EXCLUSIVE4_1; fattr4 attr = new fattr4(); attr.attrmask = openFattrBitmap(); attr.attr_vals = new attrlist4(); attr.attr_vals.value = openAttrs(7,7,7,0); how.createattrs = attr; how.createverf = new verifier4(0); //it is long //how.mode = createmode4.GUARDED4; flag.how = how; op.opopen.openhow = flag; open_claim4 claim = new open_claim4(); claim.claim = open_claim_type4.CLAIM_NULL; claim.file = new component4(new utf8str_cs(new utf8string(encoding .GetBytes(path)))); claim.delegate_type = NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_NO_DELEG; claim.file_delegate_prev = null; claim.oc_delegate_stateid = null; claim.delegate_type = 0; claim.delegate_cur_info = null; op.opopen.claim = claim; return op; }