static fattr4 getAttributes(bitmap4 bitmap, VirtualFileSystem fs, Inode inode, Stat stat, CompoundContext context) throws IOException, OncRpcException { /* * bitmap we send back. can't be uninitialized. */ bitmap4 processedAttributes = new bitmap4(new int[0]); byte[] retBytes; try (Xdr xdr = new Xdr(1024)) { xdr.beginEncoding(); for (int i : bitmap) { Optional<XdrAble> optionalAttr = (Optional<XdrAble>) fattr2xdr(i, fs, inode, stat, context); if (optionalAttr.isPresent()) { XdrAble attr = optionalAttr.get(); _log.debug(" getAttributes : {} ({}) OK.", i, attrMask2String(i)); attr.xdrEncode(xdr); processedAttributes.set(i); } else { _log.debug(" getAttributes : {} ({}) NOT SUPPORTED.", i, attrMask2String(i)); } } xdr.endEncoding(); retBytes = xdr.getBytes(); } fattr4 attributes = new fattr4(); attributes.attrmask = processedAttributes; attributes.attr_vals = new attrlist4(retBytes); return attributes; }
@Test public void testSetNoValues() { bitmap4 bitmap = new bitmap4(); bitmap.set(5); assertTrue(bitmap.isSet(5)); }
static bitmap4 setAttributes(fattr4 attributes, Inode inode, CompoundContext context) throws IOException, OncRpcException { /* * bitmap we send back. can't be uninitialized. */ bitmap4 processedAttributes = new bitmap4(); Stat stat = new Stat(); try (Xdr xdr = new Xdr(attributes.attr_vals.value)) { xdr.beginDecoding(); try { for (int i : attributes.attrmask) { xdr2fattr(i, stat, inode, context, xdr); _log.debug(" setAttributes : {} ({}) OK", i, OperationGETATTR.attrMask2String(i)); processedAttributes.set(i); } } catch (BadXdrOncRpcException e) { throw new BadXdrException(e.getMessage()); } if (xdr.hasMoreData()) { throw new BadXdrException("garbage in attr bitmap"); } xdr.endDecoding(); } context.getFs().setattr(inode, stat); return processedAttributes; }
@Test public void testSetWithValues() { bitmap4 bitmap = bitmap4.of(5, 34, 80, 129); bitmap.set(7); assertTrue(bitmap.isSet(5)); assertTrue(bitmap.isSet(7)); assertTrue(bitmap.isSet(34)); assertTrue(bitmap.isSet(80)); assertTrue(bitmap.isSet(129)); assertFalse(bitmap.isSet(6)); }
if (createMode.isPresent()) { mode = createMode.get().value; appliedAttribytes.set(nfs4_prot.FATTR4_MODE);