Acls { public static int toAccessMask(int mode, boolean isDir, boolean isOwner) { int mask = ACE4_READ_ATTRIBUTES; if (isOwner) { mask |= ACE4_WRITE_ACL | ACE4_WRITE_ATTRIBUTES | ACE4_READ_ATTRIBUTES | ACE4_READ_ACL; } if ((mode & RBIT) != 0) { mask |= ACE4_READ_DATA | ACE4_READ_ACL | ACE4_READ_ATTRIBUTES; } if ((mode & WBIT) != 0) { mask |= ACE4_WRITE_DATA | ACE4_APPEND_DATA; if (isDir) { mask |= ACE4_DELETE_CHILD; } } if ((mode & XBIT) != 0) { mask |= ACE4_EXECUTE; } return mask; } private  Acls(); static nfsace4[] addACE(nfsace4 ace, nfsace4[] acl); static nfsace4[] addACE(nfsace4[] acl, nfsace4 ace); static nfsace4[] of(int mode, boolean isDir); static int toAccessMask(int mode, boolean isDir, boolean isOwner); @SuppressWarnings("PointlessBitwiseExpression") static int toMode(nfsace4[] acl); static nfsace4[] adjust(nfsace4[] acl, int mode); static nfsace4[] compact(nfsace4[] acl); static boolean wantModify(int accessMask); static final int RBIT; static final int WBIT; static final int XBIT; final static utf8str_mixed OWNER; final static utf8str_mixed GROUP; final static utf8str_mixed EVERYONE; }
@Test public void testListDirNoReadBit() { int mode = 0711; int aclMode = Acls.toAccessMask(mode, true, false); assertTrue("List allowed without read bit", (aclMode & ACE4_LIST_DIRECTORY) == 0); }