RTEMS | rename() fails when source and target are the same - violates POSIX compliance (#5487)
Somil Gupta (@somil)
gitlab at rtems.org
Fri Mar 6 21:12:16 UTC 2026
Somil Gupta commented: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5487#note_144709
I looked into the issue with `rename()` failing when both paths refer to the same file. Instead of removing `RTEMS_FS_EXCLUSIVE` entirely (which caused problems when renaming over an existing file like `mv a b`), I tried a slightly different approach. I first evaluate the destination path without `RTEMS_FS_EXCLUSIVE` just to check if `old` and `new` resolve to the same filesystem node. If they do, I return success since POSIX treats that as a no-op. If not, I clean up that lookup and evaluate the path again with `RTEMS_FS_EXCLUSIVE`, so the existing rename logic stays unchanged. I’ll run a bit more testing on this and then submit an MR.
Although this still wouldn't take care of the overwriting part in case of mv a b , That might need changing rename implemented by each filesystem
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5487#note_144709
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260306/83069671/attachment.htm>
More information about the bugs
mailing list