private static void validateDestination( String src, String dst, INode srcInode) throws IOException { String error; if (srcInode.isSymlink() && dst.equals(srcInode.asSymlink().getSymlinkString())) { throw new FileAlreadyExistsException("Cannot rename symlink " + src + " to its target " + dst); } // dst cannot be a directory or a file under src if (dst.startsWith(src) && dst.charAt(src.length()) == Path.SEPARATOR_CHAR) { error = "Rename destination " + dst + " is a directory or file under source " + src; NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: " + error); throw new IOException(error); } if (FSDirectory.isExactReservedName(src) || FSDirectory.isExactReservedName(dst)) { error = "Cannot rename to or from /.reserved"; throw new InvalidPathException(error); } }
static HdfsFileStatus getFileInfo(FSDirectory fsd, INodesInPath iip, boolean needLocation, boolean needBlockToken) throws IOException { fsd.readLock(); try { HdfsFileStatus status = null; if (FSDirectory.isExactReservedName(iip.getPathComponents())) { status = FSDirectory.DOT_RESERVED_STATUS; } else if (iip.isDotSnapshotDir()) { if (fsd.getINode4DotSnapshot(iip) != null) { status = FSDirectory.DOT_SNAPSHOT_DIR_STATUS; } } else { status = getFileInfo(fsd, iip, true, needLocation, needBlockToken); } return status; } finally { fsd.readUnlock(); } }
FSDirectory.isExactReservedName(src) || (FSDirectory.isReservedName(src) && !FSDirectory.isReservedRawName(src)
assert fsn.hasReadLock(); if (FSDirectory.isExactReservedName(src)) { return null;
static FileStatus setPermission( FSDirectory fsd, FSPermissionChecker pc, final String src, FsPermission permission) throws IOException { if (FSDirectory.isExactReservedName(src)) { throw new InvalidPathException(src); } INodesInPath iip; fsd.writeLock(); try { iip = fsd.resolvePath(pc, src, DirOp.WRITE); fsd.checkOwner(pc, iip); unprotectedSetPermission(fsd, iip, permission); } finally { fsd.writeUnlock(); } fsd.getEditLog().logSetPermissions(iip.getPath(), permission); return fsd.getAuditFileInfo(iip); }
|| FSDirectory.isExactReservedName(target)) { throw new InvalidPathException("Invalid target name: " + target);
static FileStatus setOwner( FSDirectory fsd, FSPermissionChecker pc, String src, String username, String group) throws IOException { if (FSDirectory.isExactReservedName(src)) { throw new InvalidPathException(src); } INodesInPath iip; fsd.writeLock(); try { iip = fsd.resolvePath(pc, src, DirOp.WRITE); fsd.checkOwner(pc, iip); if (!pc.isSuperUser()) { if (username != null && !pc.getUser().equals(username)) { throw new AccessControlException("User " + pc.getUser() + " is not a super user (non-super user cannot change owner)."); } if (group != null && !pc.isMemberOfGroup(group)) { throw new AccessControlException( "User " + pc.getUser() + " does not belong to " + group); } } unprotectedSetOwner(fsd, iip, username, group); } finally { fsd.writeUnlock(); } fsd.getEditLog().logSetOwner(iip.getPath(), username, group); return fsd.getAuditFileInfo(iip); }
FSDirectory fsd = fsn.getFSDirectory(); if (FSDirectory.isExactReservedName(src)) { throw new InvalidPathException(src);
byte[] startAfter, boolean needLocation, boolean includeStoragePolicy) throws IOException { if (FSDirectory.isExactReservedName(iip.getPathComponents())) { return getReservedListing(fsd);
static HdfsFileStatus getFileInfo( FSDirectory fsd, String src, boolean resolveLink, boolean isRawPath) throws IOException { fsd.readLock(); try { HdfsFileStatus status = null; final INodesInPath iip = fsd.getINodesInPath(src, resolveLink); if (FSDirectory.isExactReservedName(iip.getPathComponents())) { status = new HdfsFileStatus(0, true, 0, 0, 0, 0, new FsPermission((short) 01770), null, null, null, HdfsFileStatus.EMPTY_NAME, -1L, 0, null, BlockStoragePolicySuite.ID_UNSPECIFIED); } else if (iip.isDotSnapshotDir()) { if (fsd.getINode4DotSnapshot(iip) != null) { status = FSDirectory.DOT_SNAPSHOT_DIR_STATUS; } } else { status = getFileInfo(fsd, src, iip, isRawPath, true); } return status; } finally { fsd.readUnlock(); } }
static HdfsFileStatus getFileInfo( FSDirectory fsd, String src, boolean resolveLink, boolean isRawPath) throws IOException { fsd.readLock(); try { HdfsFileStatus status = null; final INodesInPath iip = fsd.getINodesInPath(src, resolveLink); if (FSDirectory.isExactReservedName(iip.getPathComponents())) { status = new HdfsFileStatus(0, true, 0, 0, 0, 0, new FsPermission((short) 01770), null, null, null, HdfsFileStatus.EMPTY_NAME, -1L, 0, null, BlockStoragePolicySuite.ID_UNSPECIFIED); } else if (iip.isDotSnapshotDir()) { if (fsd.getINode4DotSnapshot(iip) != null) { status = FSDirectory.DOT_SNAPSHOT_DIR_STATUS; } } else { status = getFileInfo(fsd, src, iip, isRawPath, true); } return status; } finally { fsd.readUnlock(); } }