/** {@inheritDoc} */ @Override public void setWorkingDirectory(Path newPath) { if (newPath == null) workingDir = getHomeDirectory(); else { Path fixedNewPath = fixRelativePart(newPath); String res = fixedNewPath.toUri().getPath(); if (!DFSUtil.isValidName(res)) throw new IllegalArgumentException("Invalid DFS directory name " + res); workingDir = fixedNewPath; } }
private static String validatePath(CacheDirectiveInfo directive) throws InvalidRequestException { if (directive.getPath() == null) { throw new InvalidRequestException("No path specified."); } String path = directive.getPath().toUri().getPath(); if (!DFSUtil.isValidName(path)) { throw new InvalidRequestException("Invalid path '" + path + "'."); } return path; }
NameNode.stateChangeLog.debug(builder.toString()); if (!DFSUtil.isValidName(src) || FSDirectory.isExactReservedName(src) || (FSDirectory.isReservedName(src)
FSDirectory fsd = fsn.getFSDirectory(); String link = linkArg; if (!DFSUtil.isValidName(link)) { throw new InvalidPathException("Invalid link name: " + link);
boolean isCreate = (dirOp == DirOp.CREATE || dirOp == DirOp.CREATE_LINK); if (isCreate && !DFSUtil.isValidName(src)) { throw new InvalidPathException("Invalid file name: " + src);
/** * Checks that the passed URI belongs to this filesystem and returns * just the path component. Expects a URI with an absolute path. * * @param file URI with absolute path * @return path component of {file} * @throws IllegalArgumentException if URI does not belong to this DFS */ private String getPathName(Path file) { checkPath(file); String result = file.toUri().getPath(); if (!DFSUtil.isValidName(result)) { throw new IllegalArgumentException("Pathname " + result + " from " + file+" is not a valid DFS filename."); } return result; }
@Override public void setWorkingDirectory(Path dir) { String result = fixRelativePart(dir).toUri().getPath(); if (!DFSUtil.isValidName(result)) { throw new IllegalArgumentException("Invalid DFS directory name " + result); } workingDir = fixRelativePart(dir); }
@Override public synchronized void setWorkingDirectory(final Path dir) { String result = makeAbsolute(dir).toUri().getPath(); if (!DFSUtil.isValidName(result)) { throw new IllegalArgumentException("Invalid DFS directory name " + result); } workingDir = makeAbsolute(dir); }
/** * Checks that the passed URI belongs to this filesystem and returns * just the path component. Expects a URI with an absolute path. * * @param file URI with absolute path * @return path component of {file} * @throws IllegalArgumentException if URI does not belong to this DFS */ private String getPathName(Path file) { checkPath(file); String result = file.toUri().getPath(); if (!DFSUtil.isValidName(result)) { throw new IllegalArgumentException("Pathname " + result + " from " + file+" is not a valid DFS filename."); } return result; }
@Override public void setWorkingDirectory(Path dir) { String result = fixRelativePart(dir).toUri().getPath(); if (!DFSUtil.isValidName(result)) { throw new IllegalArgumentException("Invalid DFS directory name " + result); } workingDir = fixRelativePart(dir); }
@Override public synchronized void setWorkingDirectory(final Path dir) { String result = makeAbsolute(dir).toUri().getPath(); if (!DFSUtil.isValidName(result)) { throw new IllegalArgumentException("Invalid DFS directory name " + result); } workingDir = makeAbsolute(dir); }
public void setWorkingDirectory(Path dir) { String result = makeAbsolute(dir).toUri().getPath(); if (!DFSUtil.isValidName(result)) { throw new IllegalArgumentException("Invalid DFS directory name " + result); } workingDir = makeAbsolute(dir); }
private String getPathName(Path file) { checkPath(file); String result = makeAbsolute(file).toUri().getPath(); if (!DFSUtil.isValidName(result)) { throw new IllegalArgumentException("Pathname " + result + " from " + file+" is not a valid DFS filename."); } return result; }
private static String validatePath(CacheDirectiveInfo directive) throws InvalidRequestException { if (directive.getPath() == null) { throw new InvalidRequestException("No path specified."); } String path = directive.getPath().toUri().getPath(); if (!DFSUtil.isValidName(path)) { throw new InvalidRequestException("Invalid path '" + path + "'."); } return path; }
private static String validatePath(CacheDirectiveInfo directive) throws InvalidRequestException { if (directive.getPath() == null) { throw new InvalidRequestException("No path specified."); } String path = directive.getPath().toUri().getPath(); if (!DFSUtil.isValidName(path)) { throw new InvalidRequestException("Invalid path '" + path + "'."); } return path; }
@Test (timeout=15000) public void testIsValidName() { assertFalse(DFSUtil.isValidName("/foo/../bar")); assertFalse(DFSUtil.isValidName("/foo/./bar")); assertFalse(DFSUtil.isValidName("/foo//bar")); assertTrue(DFSUtil.isValidName("/")); assertTrue(DFSUtil.isValidName("/bar/")); assertFalse(DFSUtil.isValidName("/foo/:/bar")); assertFalse(DFSUtil.isValidName("/foo:bar")); }
/** * The new rename which has the POSIX semantic. */ static Map.Entry<BlocksMapUpdateInfo, HdfsFileStatus> renameToInt( FSDirectory fsd, final String srcArg, final String dstArg, boolean logRetryCache, Options.Rename... options) throws IOException { String src = srcArg; String dst = dstArg; if (NameNode.stateChangeLog.isDebugEnabled()) { NameNode.stateChangeLog.debug("DIR* NameSystem.renameTo: with options -" + " " + src + " to " + dst); } if (!DFSUtil.isValidName(dst)) { throw new InvalidPathException("Invalid name: " + dst); } final FSPermissionChecker pc = fsd.getPermissionChecker(); BlocksMapUpdateInfo collectedBlocks = new BlocksMapUpdateInfo(); // returns resolved path dst = renameTo(fsd, pc, src, dst, collectedBlocks, logRetryCache, options); INodesInPath dstIIP = fsd.getINodesInPath(dst, false); HdfsFileStatus resultingStat = fsd.getAuditFileInfo(dstIIP); return new AbstractMap.SimpleImmutableEntry<>( collectedBlocks, resultingStat); }
private synchronized boolean renameToInternal(String src, String dst ) throws IOException { NameNode.stateChangeLog.debug("DIR* NameSystem.renameTo: " + src + " to " + dst); if (isInSafeMode()) throw new SafeModeException("Cannot rename " + src, safeMode); if (!DFSUtil.isValidName(dst)) { throw new IOException("Invalid name: " + dst); } if (isPermissionEnabled) { //We should not be doing this. This is move() not renameTo(). //but for now, String actualdst = dir.isDir(dst)? dst + Path.SEPARATOR + new Path(src).getName(): dst; checkParentAccess(src, FsAction.WRITE); checkAncestorAccess(actualdst, FsAction.WRITE); } FileStatus dinfo = dir.getFileInfo(dst); if (dir.renameTo(src, dst)) { changeLease(src, dst, dinfo); // update lease with new filename return true; } return false; }
@Deprecated static RenameOldResult renameToInt( FSDirectory fsd, final String srcArg, final String dstArg, boolean logRetryCache) throws IOException { String src = srcArg; String dst = dstArg; if (NameNode.stateChangeLog.isDebugEnabled()) { NameNode.stateChangeLog.debug("DIR* NameSystem.renameTo: " + src + " to " + dst); } if (!DFSUtil.isValidName(dst)) { throw new IOException("Invalid name: " + dst); } FSPermissionChecker pc = fsd.getPermissionChecker(); HdfsFileStatus resultingStat = null; // Rename does not operate on link targets // Do not resolveLink when checking permissions of src and dst INodesInPath srcIIP = fsd.resolvePathForWrite(pc, src, false); INodesInPath dstIIP = fsd.resolvePathForWrite(pc, dst, false); @SuppressWarnings("deprecation") final boolean status = renameTo(fsd, pc, srcIIP, dstIIP, logRetryCache); if (status) { dstIIP = fsd.getINodesInPath(dstIIP.getPath(), false); resultingStat = fsd.getAuditFileInfo(dstIIP); } return new RenameOldResult(status, resultingStat); }
/** * Get the file info for a specific file. * * @param srcArg The string representation of the path to the file * @param resolveLink whether to throw UnresolvedLinkException * if src refers to a symlink * * @return object containing information regarding the file * or null if file not found */ static HdfsFileStatus getFileInfo( FSDirectory fsd, String srcArg, boolean resolveLink) throws IOException { String src = srcArg; if (!DFSUtil.isValidName(src)) { throw new InvalidPathException("Invalid file name: " + src); } if (fsd.isPermissionEnabled()) { FSPermissionChecker pc = fsd.getPermissionChecker(); final INodesInPath iip = fsd.resolvePath(pc, srcArg, resolveLink); src = iip.getPath(); fsd.checkPermission(pc, iip, false, null, null, null, null, false); } else { src = FSDirectory.resolvePath(srcArg, fsd); } return getFileInfo(fsd, src, FSDirectory.isReservedRawName(srcArg), resolveLink); }