@Test public void testSetPermissionCannotSetAclBit() throws IOException { FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750)); fs.setPermission(path, FsPermission.createImmutable((short)0700)); assertPermission((short)0700); fs.setPermission(path, new FsPermissionExtension(FsPermission. createImmutable((short)0755), true, true)); INode inode = cluster.getNamesystem().getFSDirectory().getINode( path.toUri().getPath(), false); assertNotNull(inode); FsPermission perm = inode.getFsPermission(); assertNotNull(perm); assertEquals(0755, perm.toShort()); assertEquals(0755, perm.toExtendedShort()); assertAclFeature(false); }
@Test public void testSetPermissionCannotSetAclBit() throws IOException { FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750)); fs.setPermission(path, FsPermission.createImmutable((short)0700)); assertPermission((short)0700); fs.setPermission(path, new FsPermissionExtension(FsPermission. createImmutable((short)0755), true, true)); INode inode = cluster.getNamesystem().getFSDirectory().getNode( path.toUri().getPath(), false); assertNotNull(inode); FsPermission perm = inode.getFsPermission(); assertNotNull(perm); assertEquals(0755, perm.toShort()); assertEquals(0755, perm.toExtendedShort()); assertAclFeature(false); }
/** Convert a string to a FsPermission object. */ static FsPermission toFsPermission( final String s, Boolean aclBit, Boolean encBit) { FsPermission perm = new FsPermission(Short.parseShort(s, 8)); final boolean aBit = (aclBit != null) ? aclBit : false; final boolean eBit = (encBit != null) ? encBit : false; if (aBit || eBit) { return new FsPermissionExtension(perm, aBit, eBit); } else { return perm; } }
public static FsPermission convert(FsPermissionProto p) { return new FsPermissionExtension((short)p.getPerm()); }