/** * Retrieve existing INodes from a path. The number of INodes is equal * to the number of path components. For a snapshot path * (e.g. /foo/.snapshot/s1/bar), the ".snapshot/s1" will be represented in * one path component corresponding to its Snapshot.Root inode. This 1-1 * mapping ensures the path can always be properly reconstructed. * * <p> * Example: <br> * Given the path /c1/c2/c3 where only /c1/c2 exists, resulting in the * following path components: ["","c1","c2","c3"] * * <p> * <code>getExistingPathINodes(["","c1","c2"])</code> should fill * the array with [rootINode,c1,c2], <br> * <code>getExistingPathINodes(["","c1","c2","c3"])</code> should * fill the array with [rootINode,c1,c2,null] * * @param startingDir the starting directory * @param components array of path component name * @return the specified number of existing INodes in the path */ static INodesInPath resolve(final INodeDirectory startingDir, final byte[][] components) { return resolve(startingDir, components, false); }
public INodesInPath getINodesInPath(byte[][] components, DirOp dirOp) throws UnresolvedLinkException, AccessControlException, ParentNotDirectoryException { INodesInPath iip = INodesInPath.resolve(rootDir, components); checkTraverse(null, iip, dirOp); return iip; }
/** * Construct {@link INodesInPath} from {@link INode} and its root * {@link INodeDirectory}. INodesInPath constructed this way will * each have its snapshot and latest snapshot id filled in. * * This routine is specifically for * {@link LeaseManager#getINodeWithLeases(INodeDirectory)} to get * open files along with their snapshot details which is used during * new snapshot creation to capture their meta data. * * @param rootDir the root {@link INodeDirectory} under which inode * needs to be resolved * @param inode the {@link INode} to be resolved * @return INodesInPath */ static INodesInPath fromINode(final INodeDirectory rootDir, INode inode) { byte[][] paths = getPaths(getINodes(inode)); return resolve(rootDir, paths); }
INodesInPath getExistingPathINodes(byte[][] components) throws UnresolvedLinkException { return INodesInPath.resolve(rootDir, components, false); }
INodesInPath getExistingPathINodes(byte[][] components) throws UnresolvedLinkException { return INodesInPath.resolve(rootDir, components, false); }
INodesInPath iip = INodesInPath.resolve(rootDir, components, isRaw);
/** @return the {@link INodesInPath} containing all inodes in the path. */ public INodesInPath getINodesInPath(String path, boolean resolveLink) throws UnresolvedLinkException { final byte[][] components = INode.getPathComponents(path); return INodesInPath.resolve(rootDir, components, resolveLink); }
/** @return the {@link INodesInPath} containing all inodes in the path. */ public INodesInPath getINodesInPath(String path, boolean resolveLink) throws UnresolvedLinkException { final byte[][] components = INode.getPathComponents(path); return INodesInPath.resolve(rootDir, components, resolveLink); }
/** * @return the INodesInPath of the components in src * @throws UnresolvedLinkException if symlink can't be resolved * @throws SnapshotAccessControlException if path is in RO snapshot */ INodesInPath getINodesInPath4Write(String src, boolean resolveLink) throws UnresolvedLinkException, SnapshotAccessControlException { final byte[][] components = INode.getPathComponents(src); INodesInPath inodesInPath = INodesInPath.resolve(rootDir, components, resolveLink); if (inodesInPath.isSnapshot()) { throw new SnapshotAccessControlException( "Modification on a read-only snapshot is disallowed"); } return inodesInPath; }
/** * @return the INodesInPath of the components in src * @throws UnresolvedLinkException if symlink can't be resolved * @throws SnapshotAccessControlException if path is in RO snapshot */ INodesInPath getINodesInPath4Write(String src, boolean resolveLink) throws UnresolvedLinkException, SnapshotAccessControlException { final byte[][] components = INode.getPathComponents(src); INodesInPath inodesInPath = INodesInPath.resolve(rootDir, components, resolveLink); if (inodesInPath.isSnapshot()) { throw new SnapshotAccessControlException( "Modification on a read-only snapshot is disallowed"); } return inodesInPath; }
INodesInPath resolvePath(FSPermissionChecker pc, String src, boolean resolveLink) throws UnresolvedLinkException, FileNotFoundException, AccessControlException { byte[][] components = INode.getPathComponents(src); if (isPermissionEnabled && pc != null && isReservedRawName(components)) { pc.checkSuperuserPrivilege(); } components = resolveComponents(components, this); return INodesInPath.resolve(rootDir, components, resolveLink); }
INodesInPath resolvePath(FSPermissionChecker pc, String src, boolean resolveLink) throws UnresolvedLinkException, FileNotFoundException, AccessControlException { byte[][] components = INode.getPathComponents(src); if (isPermissionEnabled && pc != null && isReservedRawName(components)) { pc.checkSuperuserPrivilege(); } components = resolveComponents(components, this); return INodesInPath.resolve(rootDir, components, resolveLink); }
INodesInPath nodesInPath = INodesInPath.resolve(fsdir.rootDir, components, false); assertEquals(file1.toString(), nodesInPath.getPath(3)); nodesInPath = INodesInPath.resolve(fsdir.rootDir, components, false); assertEquals(nodesInPath.length(), components.length); assertSnapshot(nodesInPath, false, null, -1);
INodesInPath nodesInPath = INodesInPath.resolve(fsdir.rootDir, components, false); nodesInPath = INodesInPath.resolve(fsdir.rootDir, components, false); assertEquals(nodesInPath.length(), components.length - 1); assertSnapshot(nodesInPath, true, snapshot, 3); nodesInPath = INodesInPath.resolve(fsdir.rootDir, components, false);
INodesInPath nodesInPath = INodesInPath.resolve(fsdir.rootDir, components, false); INodesInPath ssNodesInPath = INodesInPath.resolve(fsdir.rootDir, components, false); INodesInPath newNodesInPath = INodesInPath.resolve(fsdir.rootDir, components, false); assertSnapshot(newNodesInPath, false, s3, -1);