/** * @return if .snapshot is the last path component. */ boolean isDotSnapshotDir() { return isDotSnapshotDir(getLastLocalName()); }
/** * @param length number of ancestral INodes in the returned INodesInPath * instance * @return the INodesInPath instance containing ancestral INodes. Note that * this method only handles non-snapshot paths. */ private INodesInPath getAncestorINodesInPath(int length) { Preconditions.checkArgument(length >= 0 && length < inodes.length); Preconditions.checkState(isDotSnapshotDir() || !isSnapshot()); final INode[] anodes = new INode[length]; final byte[][] apath = new byte[length][]; System.arraycopy(this.inodes, 0, anodes, 0, length); System.arraycopy(this.path, 0, apath, 0, length); return new INodesInPath(anodes, apath, isRaw, false, snapshotId); }
INode getINode4DotSnapshot(INodesInPath iip) throws UnresolvedLinkException { Preconditions.checkArgument( iip.isDotSnapshotDir(), "%s does not end with %s", iip.getPath(), HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR); final INode node = iip.getINode(-2); if (node != null && node.isDirectory() && node.asDirectory().isSnapshottable()) { return node; } return null; }
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(); } }
if (iip.isDotSnapshotDir()) { ecPolicy = null; } else if (iip.getLastINode() == null) {
throws IOException { Preconditions.checkState(fsd.hasReadLock()); Preconditions.checkArgument(iip.isDotSnapshotDir(), "%s does not end with %s", iip.getPath(), HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR);
if (isDotSnapshotDir(childName) && dir.isSnapshottable()) { isSnapshot = true;
boolean isDotSnapshotDir() { return isDotSnapshotDir(getLastLocalName()); }
boolean isDotSnapshotDir() { return isDotSnapshotDir(getLastLocalName()); }
if (iip.isDotSnapshotDir()) { return getSnapshotsListing(fsd, iip, startAfter);
static AclStatus getAclStatus( FSDirectory fsd, FSPermissionChecker pc, String src) throws IOException { checkAclsConfigFlag(fsd); fsd.readLock(); try { INodesInPath iip = fsd.resolvePath(pc, src, DirOp.READ); // There is no real inode for the path ending in ".snapshot", so return a // non-null, unpopulated AclStatus. This is similar to getFileInfo. if (iip.isDotSnapshotDir() && fsd.getINode4DotSnapshot(iip) != null) { return new AclStatus.Builder().owner("").group("").build(); } INode inode = FSDirectory.resolveLastINode(iip); int snapshotId = iip.getPathSnapshotId(); List<AclEntry> acl = AclStorage.readINodeAcl(fsd.getAttributes(iip)); FsPermission fsPermission = inode.getFsPermission(snapshotId); return new AclStatus.Builder() .owner(inode.getUserName()).group(inode.getGroupName()) .stickyBit(fsPermission.getStickyBit()) .setPermission(fsPermission) .addEntries(acl).build(); } catch (AclException e){ throw new AclException(e.getMessage() + " Path: " + src, e); } finally { fsd.readUnlock(); } }
INode getINode4DotSnapshot(INodesInPath iip) throws UnresolvedLinkException { Preconditions.checkArgument( iip.isDotSnapshotDir(), "%s does not end with %s", iip.getPath(), HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR); final INode node = iip.getINode(-2); if (node != null && node.isDirectory() && node.asDirectory().isSnapshottable()) { return node; } return null; }
INode getINode4DotSnapshot(INodesInPath iip) throws UnresolvedLinkException { Preconditions.checkArgument( iip.isDotSnapshotDir(), "%s does not end with %s", iip.getPath(), HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR); final INode node = iip.getINode(-2); if (node != null && node.isDirectory() && node.asDirectory().isSnapshottable()) { return node; } return null; }
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(); } }
if (isDotSnapshotDir(childName) && dir.isSnapshottable()) { if (isSnapshot && !isDotSnapshotDir(components[components.length - 1])) {
if (isDotSnapshotDir(childName) && dir.isSnapshottable()) { if (isSnapshot && !isDotSnapshotDir(components[components.length - 1])) {
static AclStatus getAclStatus( FSDirectory fsd, String src) throws IOException { checkAclsConfigFlag(fsd); FSPermissionChecker pc = fsd.getPermissionChecker(); fsd.readLock(); try { INodesInPath iip = fsd.resolvePath(pc, src); src = iip.getPath(); // There is no real inode for the path ending in ".snapshot", so return a // non-null, unpopulated AclStatus. This is similar to getFileInfo. if (iip.isDotSnapshotDir() && fsd.getINode4DotSnapshot(iip) != null) { return new AclStatus.Builder().owner("").group("").build(); } if (fsd.isPermissionEnabled()) { fsd.checkTraverse(pc, iip); } INode inode = FSDirectory.resolveLastINode(iip); int snapshotId = iip.getPathSnapshotId(); List<AclEntry> acl = AclStorage.readINodeAcl(fsd.getAttributes(src, inode.getLocalNameBytes(), inode, snapshotId)); FsPermission fsPermission = inode.getFsPermission(snapshotId); return new AclStatus.Builder() .owner(inode.getUserName()).group(inode.getGroupName()) .stickyBit(fsPermission.getStickyBit()) .setPermission(fsPermission) .addEntries(acl).build(); } finally { fsd.readUnlock(); } }
static AclStatus getAclStatus( FSDirectory fsd, String src) throws IOException { checkAclsConfigFlag(fsd); FSPermissionChecker pc = fsd.getPermissionChecker(); fsd.readLock(); try { INodesInPath iip = fsd.resolvePath(pc, src); src = iip.getPath(); // There is no real inode for the path ending in ".snapshot", so return a // non-null, unpopulated AclStatus. This is similar to getFileInfo. if (iip.isDotSnapshotDir() && fsd.getINode4DotSnapshot(iip) != null) { return new AclStatus.Builder().owner("").group("").build(); } if (fsd.isPermissionEnabled()) { fsd.checkTraverse(pc, iip); } INode inode = FSDirectory.resolveLastINode(iip); int snapshotId = iip.getPathSnapshotId(); List<AclEntry> acl = AclStorage.readINodeAcl(fsd.getAttributes(src, inode.getLocalNameBytes(), inode, snapshotId)); FsPermission fsPermission = inode.getFsPermission(snapshotId); return new AclStatus.Builder() .owner(inode.getUserName()).group(inode.getGroupName()) .stickyBit(fsPermission.getStickyBit()) .setPermission(fsPermission) .addEntries(acl).build(); } finally { fsd.readUnlock(); } }