diff options
Diffstat (limited to 'ports/unix')
-rw-r--r-- | ports/unix/guts/rename.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ports/unix/guts/rename.c b/ports/unix/guts/rename.c index ad28293..b8ee8b0 100644 --- a/ports/unix/guts/rename.c +++ b/ports/unix/guts/rename.c @@ -11,6 +11,7 @@ int oldrc, newrc; int save_errno; int old_db_entry = 0; + int may_unlinked = 0; pseudo_debug(PDBGF_OP, "rename: %s->%s\n", oldpath ? oldpath : "<nil>", @@ -32,10 +33,13 @@ /* as with unlink, we have to mark that the file may get deleted */ msg = pseudo_client_op(OP_MAY_UNLINK, 0, -1, -1, newpath, newrc ? NULL : &newbuf); if (msg && msg->result == RESULT_SUCCEED) + may_unlinked = 1; + msg = pseudo_client_op(OP_STAT, 0, -1, -1, oldpath, oldrc ? NULL : &oldbuf); + if (msg && msg->result == RESULT_SUCCEED) old_db_entry = 1; rc = real_rename(oldpath, newpath); save_errno = errno; - if (old_db_entry) { + if (may_unlinked) { if (rc == -1) { /* since we failed, that wasn't really unlinked -- put * it back. |