/// <exception cref="System.IO.IOException"/> internal static HdfsFileStatus GetFileInfo(FSDirectory fsd, string src, bool resolveLink , bool isRawPath, bool includeStoragePolicy) { string srcs = FSDirectory.NormalizePath(src); if (srcs.EndsWith(HdfsConstants.SeparatorDotSnapshotDir)) { if (fsd.GetINode4DotSnapshot(srcs) != null) { return(new HdfsFileStatus(0, true, 0, 0, 0, 0, null, null, null, null, HdfsFileStatus .EmptyName, -1L, 0, null, BlockStoragePolicySuite.IdUnspecified)); } return(null); } fsd.ReadLock(); try { INodesInPath iip = fsd.GetINodesInPath(srcs, resolveLink); return(GetFileInfo(fsd, src, iip, isRawPath, includeStoragePolicy)); } finally { fsd.ReadUnlock(); } }
/// <summary> /// Currently we only support "ls /xxx/.snapshot" which will return all the /// snapshots of a directory. /// </summary> /// <remarks> /// Currently we only support "ls /xxx/.snapshot" which will return all the /// snapshots of a directory. The FSCommand Ls will first call getFileInfo to /// make sure the file/directory exists (before the real getListing call). /// Since we do not have a real INode for ".snapshot", we return an empty /// non-null HdfsFileStatus here. /// </remarks> /// <exception cref="Org.Apache.Hadoop.FS.UnresolvedLinkException"/> private static HdfsFileStatus GetFileInfo4DotSnapshot(FSDirectory fsd, string src ) { if (fsd.GetINode4DotSnapshot(src) != null) { return(new HdfsFileStatus(0, true, 0, 0, 0, 0, null, null, null, null, HdfsFileStatus .EmptyName, -1L, 0, null, BlockStoragePolicySuite.IdUnspecified)); } return(null); }
/// <exception cref="System.IO.IOException"/> internal static AclStatus GetAclStatus(FSDirectory fsd, string src) { CheckAclsConfigFlag(fsd); FSPermissionChecker pc = fsd.GetPermissionChecker(); byte[][] pathComponents = FSDirectory.GetPathComponentsForReservedPath(src); src = fsd.ResolvePath(pc, src, pathComponents); string srcs = FSDirectory.NormalizePath(src); fsd.ReadLock(); try { // There is no real inode for the path ending in ".snapshot", so return a // non-null, unpopulated AclStatus. This is similar to getFileInfo. if (srcs.EndsWith(HdfsConstants.SeparatorDotSnapshotDir) && fsd.GetINode4DotSnapshot (srcs) != null) { return(new AclStatus.Builder().Owner(string.Empty).Group(string.Empty).Build()); } INodesInPath iip = fsd.GetINodesInPath(srcs, true); if (fsd.IsPermissionEnabled()) { fsd.CheckTraverse(pc, iip); } INode inode = FSDirectory.ResolveLastINode(iip); int snapshotId = iip.GetPathSnapshotId(); IList <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(); } }