/// <exception cref="System.IO.IOException"/> internal static HdfsFileStatus SetOwner(FSDirectory fsd, string src, string username , string group) { FSPermissionChecker pc = fsd.GetPermissionChecker(); byte[][] pathComponents = FSDirectory.GetPathComponentsForReservedPath(src); INodesInPath iip; fsd.WriteLock(); try { src = fsd.ResolvePath(pc, src, pathComponents); iip = fsd.GetINodesInPath4Write(src); fsd.CheckOwner(pc, iip); if (!pc.IsSuperUser()) { if (username != null && !pc.GetUser().Equals(username)) { throw new AccessControlException("Non-super user cannot change owner"); } if (group != null && !pc.ContainsGroup(group)) { throw new AccessControlException("User does not belong to " + group); } } UnprotectedSetOwner(fsd, src, username, group); } finally { fsd.WriteUnlock(); } fsd.GetEditLog().LogSetOwner(src, username, group); return(fsd.GetAuditFileInfo(iip)); }
/// <exception cref="System.IO.IOException"/> internal static SnapshottableDirectoryStatus[] GetSnapshottableDirListing(FSDirectory fsd, SnapshotManager snapshotManager) { FSPermissionChecker pc = fsd.GetPermissionChecker(); fsd.ReadLock(); try { string user = pc.IsSuperUser() ? null : pc.GetUser(); return(snapshotManager.GetSnapshottableDirListing(user)); } finally { fsd.ReadUnlock(); } }