public static ImmutableList<AclEntry> loadAclEntries( AclFeatureProto proto, final String[] stringTable) { ImmutableList.Builder<AclEntry> b = ImmutableList.builder(); for (int v : proto.getEntriesList()) { int p = v & ACL_ENTRY_PERM_MASK; int t = (v >> ACL_ENTRY_TYPE_OFFSET) & ACL_ENTRY_TYPE_MASK; int s = (v >> ACL_ENTRY_SCOPE_OFFSET) & ACL_ENTRY_SCOPE_MASK; int nid = (v >> ACL_ENTRY_NAME_OFFSET) & ACL_ENTRY_NAME_MASK; String name = stringTable[nid]; b.add(new AclEntry.Builder().setName(name) .setPermission(FSACTION_VALUES[p]) .setScope(ACL_ENTRY_SCOPE_VALUES[s]) .setType(ACL_ENTRY_TYPE_VALUES[t]).build()); } return b.build(); }
private static AclFeatureProto.Builder buildAclEntries(AclFeature f, final SaverContext.DeduplicationMap<String> map) { AclFeatureProto.Builder b = AclFeatureProto.newBuilder(); for (int pos = 0, e; pos < f.getEntriesSize(); pos++) { e = f.getEntryAt(pos); int nameId = map.getId(AclEntryStatusFormat.getName(e)); int v = ((nameId & ACL_ENTRY_NAME_MASK) << ACL_ENTRY_NAME_OFFSET) | (AclEntryStatusFormat.getType(e).ordinal() << ACL_ENTRY_TYPE_OFFSET) | (AclEntryStatusFormat.getScope(e).ordinal() << ACL_ENTRY_SCOPE_OFFSET) | (AclEntryStatusFormat.getPermission(e).ordinal()); b.addEntries(v); } return b; }
private void dumpAcls(AclFeatureProto aclFeatureProto) { ImmutableList<AclEntry> aclEntryList = FSImageFormatPBINode.Loader .loadAclEntries(aclFeatureProto, stringTable); if (aclEntryList.size() > 0) { out.print("<acls>"); for (AclEntry aclEntry : aclEntryList) { o("acl", aclEntry.toString()); } out.print("</acls>"); } }
private static AclFeatureProto.Builder buildAclEntries(AclFeature f, final SaverContext.DeduplicationMap<String> map) { AclFeatureProto.Builder b = AclFeatureProto.newBuilder(); for (AclEntry e : f.getEntries()) { int v = ((map.getId(e.getName()) & ACL_ENTRY_NAME_MASK) << ACL_ENTRY_NAME_OFFSET) | (e.getType().ordinal() << ACL_ENTRY_TYPE_OFFSET) | (e.getScope().ordinal() << ACL_ENTRY_SCOPE_OFFSET) | (e.getPermission().ordinal()); b.addEntries(v); } return b; }