internal static bool RenameForEditLog(FSDirectory fsd, string src, string dst, long timestamp) { if (fsd.IsDir(dst)) { dst += Path.Separator + new Path(src).GetName(); } INodesInPath srcIIP = fsd.GetINodesInPath4Write(src, false); INodesInPath dstIIP = fsd.GetINodesInPath4Write(dst, false); return(UnprotectedRenameTo(fsd, src, dst, srcIIP, dstIIP, timestamp)); }
private static bool RenameTo(FSDirectory fsd, FSPermissionChecker pc, string src, string dst, bool logRetryCache) { // Rename does not operate on link targets // Do not resolveLink when checking permissions of src and dst // Check write access to parent of src INodesInPath srcIIP = fsd.GetINodesInPath4Write(src, false); // Note: We should not be doing this. This is move() not renameTo(). string actualDst = fsd.IsDir(dst) ? dst + Path.Separator + new Path(src).GetName( ) : dst; INodesInPath dstIIP = fsd.GetINodesInPath4Write(actualDst, false); if (fsd.IsPermissionEnabled()) { fsd.CheckPermission(pc, srcIIP, false, null, FsAction.Write, null, null, false); // Check write access to ancestor of dst fsd.CheckPermission(pc, dstIIP, false, FsAction.Write, null, null, null, false); } if (NameNode.stateChangeLog.IsDebugEnabled()) { NameNode.stateChangeLog.Debug("DIR* FSDirectory.renameTo: " + src + " to " + dst); } long mtime = Time.Now(); bool stat = false; fsd.WriteLock(); try { stat = UnprotectedRenameTo(fsd, src, actualDst, srcIIP, dstIIP, mtime); } finally { fsd.WriteUnlock(); } if (stat) { fsd.GetEditLog().LogRename(src, actualDst, mtime, logRetryCache); return(true); } return(false); }