aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ports/unix/guts/rename.c14
-rw-r--r--ports/unix/guts/renameat.c14
2 files changed, 16 insertions, 12 deletions
diff --git a/ports/unix/guts/rename.c b/ports/unix/guts/rename.c
index 5073c71..7e4a499 100644
--- a/ports/unix/guts/rename.c
+++ b/ports/unix/guts/rename.c
@@ -29,6 +29,14 @@
newrc = base_lstat(newpath, &newbuf);
oldrc = base_lstat(oldpath, &oldbuf);
+ /* nothing to do for a "rename" of a link to itself */
+ if (newrc != -1 && oldrc != -1 &&
+ newbuf.st_dev == oldbuf.st_dev &&
+ newbuf.st_ino == oldbuf.st_ino) {
+ pseudo_debug(PDBGF_OP, "rename: paths are the same\n");
+ return real_rename(oldpath, newpath);
+ }
+
errno = save_errno;
/* newpath must be removed. */
@@ -58,12 +66,6 @@
return rc;
}
save_errno = errno;
- /* nothing to do for a "rename" of a link to itself */
- if (newrc != -1 && oldrc != -1 &&
- newbuf.st_dev == oldbuf.st_dev &&
- newbuf.st_ino == oldbuf.st_ino) {
- return rc;
- }
/* rename(3) is not mv(1). rename(file, dir) fails; you must provide
* the corrected path yourself. You can rename over a directory only
diff --git a/ports/unix/guts/renameat.c b/ports/unix/guts/renameat.c
index 735a60a..8064818 100644
--- a/ports/unix/guts/renameat.c
+++ b/ports/unix/guts/renameat.c
@@ -41,6 +41,14 @@
newrc = base_fstatat(newdirfd, newpath, &newbuf, AT_SYMLINK_NOFOLLOW);
#endif
+ /* nothing to do for a "rename" of a link to itself */
+ if (newrc != -1 && oldrc != -1 &&
+ newbuf.st_dev == oldbuf.st_dev &&
+ newbuf.st_ino == oldbuf.st_ino) {
+ pseudo_debug(PDBGF_OP, "renameat: paths are the same\n");
+ return real_renameat(olddirfd, oldpath, newdirfd, newpath);
+ }
+
errno = save_errno;
/* newpath must be removed. */
@@ -71,12 +79,6 @@
return rc;
}
save_errno = errno;
- /* nothing to do for a "rename" of a link to itself */
- if (newrc != -1 && oldrc != -1 &&
- newbuf.st_dev == oldbuf.st_dev &&
- newbuf.st_ino == oldbuf.st_ino) {
- return rc;
- }
/* rename(3) is not mv(1). rename(file, dir) fails; you must provide
* the corrected path yourself. You can rename over a directory only