RTEMS | rename() fails when source and target are the same - violates POSIX compliance (#5487)

Bhuvan B (@BhuvanB404) gitlab at rtems.org
Thu Feb 12 15:27:08 UTC 2026



Bhuvan B created an issue: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5487



## Summary

The RTEMS implementation of `rename()` does not comply with POSIX standards. When the source and target paths resolve to the same file, `rename()` incorrectly fails instead of succeeding as a no-op as required by POSIX.

In `cpukit/libcsupport/src/_rename_r.c`

## Steps to reproduce

**Steps to reproduce**

Environment:

* BSP: `sparc/erc32` (sis simulator)

1. Start RTEMS shell in shell sample
2. Create a file:

   ```
   touch a
   ```
   3. Attempt to rename file to itself:

      ```
      SHLL [/] # mv a a   # Should succeed as a no-op
      
      rename a to a: File exists
      ```

**POSIX.1-2024 requirement:** "If the old argument and the new argument resolve to either the same existing directory entry or different directory entries for the same existing file, rename() shall return successfully and perform no other action."

**Expected result:** `mv a a` should succeed as a no-op (do nothing, return success)

**Actual result:** `rename()` returns error `"rename a to a: File exists"`

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5487
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/20260212/3c24ed4a/attachment-0001.htm>


More information about the bugs mailing list