|
@@ -106,16 +106,16 @@ class FSDirStatAndListingOp {
|
|
|
if (!DFSUtil.isValidName(src)) {
|
|
|
throw new InvalidPathException("Invalid file name: " + src);
|
|
|
}
|
|
|
+ final INodesInPath iip;
|
|
|
if (fsd.isPermissionEnabled()) {
|
|
|
FSPermissionChecker pc = fsd.getPermissionChecker();
|
|
|
- final INodesInPath iip = fsd.resolvePath(pc, srcArg, resolveLink);
|
|
|
- src = iip.getPath();
|
|
|
+ iip = fsd.resolvePath(pc, srcArg, resolveLink);
|
|
|
fsd.checkPermission(pc, iip, false, null, null, null, null, false);
|
|
|
} else {
|
|
|
src = FSDirectory.resolvePath(srcArg, fsd);
|
|
|
+ iip = fsd.getINodesInPath(src, resolveLink);
|
|
|
}
|
|
|
- return getFileInfo(fsd, src, FSDirectory.isReservedRawName(srcArg),
|
|
|
- resolveLink);
|
|
|
+ return getFileInfo(fsd, iip);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -226,7 +226,6 @@ class FSDirStatAndListingOp {
|
|
|
String src, byte[] startAfter, boolean needLocation, boolean isSuperUser)
|
|
|
throws IOException {
|
|
|
String srcs = FSDirectory.normalizePath(src);
|
|
|
- final boolean isRawPath = FSDirectory.isReservedRawName(src);
|
|
|
if (FSDirectory.isExactReservedName(srcs)) {
|
|
|
return getReservedListing(fsd);
|
|
|
}
|
|
@@ -253,7 +252,7 @@ class FSDirStatAndListingOp {
|
|
|
return new DirectoryListing(
|
|
|
new HdfsFileStatus[]{ createFileStatus(
|
|
|
fsd, HdfsFileStatus.EMPTY_NAME, nodeAttrs,
|
|
|
- needLocation, parentStoragePolicy, snapshot, isRawPath, iip)
|
|
|
+ needLocation, parentStoragePolicy, iip)
|
|
|
}, 0);
|
|
|
}
|
|
|
|
|
@@ -278,7 +277,7 @@ class FSDirStatAndListingOp {
|
|
|
cur.getLocalNameBytes());
|
|
|
listing[i] = createFileStatus(fsd, cur.getLocalNameBytes(), nodeAttrs,
|
|
|
needLocation, getStoragePolicyID(curPolicy, parentStoragePolicy),
|
|
|
- snapshot, isRawPath, iipWithChild);
|
|
|
+ iipWithChild);
|
|
|
listingCnt++;
|
|
|
if (needLocation) {
|
|
|
// Once we hit lsLimit locations, stop.
|
|
@@ -335,7 +334,6 @@ class FSDirStatAndListingOp {
|
|
|
listing[i] = createFileStatus(
|
|
|
fsd, sRoot.getLocalNameBytes(), nodeAttrs,
|
|
|
HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED,
|
|
|
- Snapshot.CURRENT_STATE_ID, false,
|
|
|
INodesInPath.fromINode(sRoot));
|
|
|
}
|
|
|
return new DirectoryListing(
|
|
@@ -359,10 +357,8 @@ class FSDirStatAndListingOp {
|
|
|
* @return object containing information regarding the file
|
|
|
* or null if file not found
|
|
|
*/
|
|
|
- static HdfsFileStatus getFileInfo(
|
|
|
- FSDirectory fsd, String path, INodesInPath iip, boolean isRawPath,
|
|
|
- boolean includeStoragePolicy)
|
|
|
- throws IOException {
|
|
|
+ static HdfsFileStatus getFileInfo(FSDirectory fsd,
|
|
|
+ INodesInPath iip, boolean includeStoragePolicy) throws IOException {
|
|
|
fsd.readLock();
|
|
|
try {
|
|
|
final INode node = iip.getLastINode();
|
|
@@ -373,23 +369,21 @@ class FSDirStatAndListingOp {
|
|
|
byte policyId = includeStoragePolicy && !node.isSymlink() ?
|
|
|
node.getStoragePolicyID() :
|
|
|
HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED;
|
|
|
- INodeAttributes nodeAttrs = getINodeAttributes(fsd, path,
|
|
|
+ INodeAttributes nodeAttrs = getINodeAttributes(fsd, iip.getPath(),
|
|
|
HdfsFileStatus.EMPTY_NAME,
|
|
|
node, iip.getPathSnapshotId());
|
|
|
return createFileStatus(fsd, HdfsFileStatus.EMPTY_NAME, nodeAttrs,
|
|
|
- policyId, iip.getPathSnapshotId(), isRawPath, iip);
|
|
|
+ policyId, iip);
|
|
|
} finally {
|
|
|
fsd.readUnlock();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static HdfsFileStatus getFileInfo(
|
|
|
- FSDirectory fsd, String src, boolean resolveLink, boolean isRawPath)
|
|
|
+ static HdfsFileStatus getFileInfo(FSDirectory fsd, INodesInPath iip)
|
|
|
throws IOException {
|
|
|
fsd.readLock();
|
|
|
try {
|
|
|
HdfsFileStatus status = null;
|
|
|
- final INodesInPath iip = fsd.getINodesInPath(src, resolveLink);
|
|
|
if (FSDirectory.isExactReservedName(iip.getPathComponents())) {
|
|
|
status = FSDirectory.DOT_RESERVED_STATUS;
|
|
|
} else if (iip.isDotSnapshotDir()) {
|
|
@@ -397,7 +391,7 @@ class FSDirStatAndListingOp {
|
|
|
status = FSDirectory.DOT_SNAPSHOT_DIR_STATUS;
|
|
|
}
|
|
|
} else {
|
|
|
- status = getFileInfo(fsd, src, iip, isRawPath, true);
|
|
|
+ status = getFileInfo(fsd, iip, true);
|
|
|
}
|
|
|
return status;
|
|
|
} finally {
|
|
@@ -419,15 +413,12 @@ class FSDirStatAndListingOp {
|
|
|
*/
|
|
|
private static HdfsFileStatus createFileStatus(
|
|
|
FSDirectory fsd, byte[] path, INodeAttributes nodeAttrs,
|
|
|
- boolean needLocation, byte storagePolicy, int snapshot, boolean isRawPath,
|
|
|
- INodesInPath iip)
|
|
|
+ boolean needLocation, byte storagePolicy, INodesInPath iip)
|
|
|
throws IOException {
|
|
|
if (needLocation) {
|
|
|
- return createLocatedFileStatus(fsd, path, nodeAttrs, storagePolicy,
|
|
|
- snapshot, isRawPath, iip);
|
|
|
+ return createLocatedFileStatus(fsd, path, nodeAttrs, storagePolicy, iip);
|
|
|
} else {
|
|
|
- return createFileStatus(fsd, path, nodeAttrs, storagePolicy,
|
|
|
- snapshot, isRawPath, iip);
|
|
|
+ return createFileStatus(fsd, path, nodeAttrs, storagePolicy, iip);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -441,8 +432,7 @@ class FSDirStatAndListingOp {
|
|
|
INodesInPath iip) throws IOException {
|
|
|
INodeAttributes nodeAttrs = getINodeAttributes(
|
|
|
fsd, fullPath, path, iip.getLastINode(), snapshot);
|
|
|
- return createFileStatus(fsd, path, nodeAttrs, storagePolicy,
|
|
|
- snapshot, isRawPath, iip);
|
|
|
+ return createFileStatus(fsd, path, nodeAttrs, storagePolicy, iip);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -450,14 +440,15 @@ class FSDirStatAndListingOp {
|
|
|
* @param iip the INodesInPath containing the target INode and its ancestors
|
|
|
*/
|
|
|
static HdfsFileStatus createFileStatus(
|
|
|
- FSDirectory fsd, byte[] path,
|
|
|
- INodeAttributes nodeAttrs, byte storagePolicy, int snapshot,
|
|
|
- boolean isRawPath, INodesInPath iip) throws IOException {
|
|
|
+ FSDirectory fsd, byte[] path, INodeAttributes nodeAttrs,
|
|
|
+ byte storagePolicy, INodesInPath iip) throws IOException {
|
|
|
long size = 0; // length is zero for directories
|
|
|
short replication = 0;
|
|
|
long blocksize = 0;
|
|
|
final boolean isEncrypted;
|
|
|
final INode node = iip.getLastINode();
|
|
|
+ final int snapshot = iip.getPathSnapshotId();
|
|
|
+ final boolean isRawPath = iip.isRaw();
|
|
|
|
|
|
final FileEncryptionInfo feInfo = isRawPath ? null : FSDirEncryptionZoneOp
|
|
|
.getFileEncryptionInfo(fsd, node, snapshot, iip);
|
|
@@ -503,10 +494,9 @@ class FSDirStatAndListingOp {
|
|
|
* Create FileStatus with location info by file INode
|
|
|
* @param iip the INodesInPath containing the target INode and its ancestors
|
|
|
*/
|
|
|
- private static HdfsLocatedFileStatus createLocatedFileStatus(
|
|
|
+ private static HdfsFileStatus createLocatedFileStatus(
|
|
|
FSDirectory fsd, byte[] path, INodeAttributes nodeAttrs,
|
|
|
- byte storagePolicy, int snapshot,
|
|
|
- boolean isRawPath, INodesInPath iip) throws IOException {
|
|
|
+ byte storagePolicy, INodesInPath iip) throws IOException {
|
|
|
assert fsd.hasReadLock();
|
|
|
long size = 0; // length is zero for directories
|
|
|
short replication = 0;
|
|
@@ -514,6 +504,8 @@ class FSDirStatAndListingOp {
|
|
|
LocatedBlocks loc = null;
|
|
|
final boolean isEncrypted;
|
|
|
final INode node = iip.getLastINode();
|
|
|
+ final int snapshot = iip.getPathSnapshotId();
|
|
|
+ final boolean isRawPath = iip.isRaw();
|
|
|
|
|
|
final FileEncryptionInfo feInfo = isRawPath ? null : FSDirEncryptionZoneOp
|
|
|
.getFileEncryptionInfo(fsd, node, snapshot, iip);
|