Mazen hassan created a merge request: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1191

Project:Branches: Mazen_Hassan/rtems:fix/rename-posix-same-file-v2 to 
rtems/rtos/rtems:main
Author:   Mazen hassan



## Summary

cpukit/libcsupport: Fix rename() same-file POSIX compliance

POSIX 1003.1-2024 requires that rename() returns success when old and new 
resolve to the same file. The previous implementation used RTEMS_FS_EXCLUSIVE 
when evaluating the new path, causing it to fail with EEXIST in the same-file 
case.

Fix by first evaluating the new path without RTEMS_FS_EXCLUSIVE to detect the 
same-file case via node_access pointer comparison. If old and new resolve to 
the same filesystem node, return 0 immediately as a no-op. Otherwise clean up 
and re-evaluate with the original flags so normal rename behaviour is preserved.

Note: Renaming over an existing destination (mv a b where b exists) still 
requires further work inside each filesystem rename_h implementation and is out 
of scope for this fix.

Closes #5487

## Generative AI

Used Claude (Anthropic) as a coding assistant to help diagnose the root cause, 
understand the RTEMS filesystem path evaluation API 
(\`rtems_filesystem_eval_path_start\`, \`RTEMS_FS_EXCLUSIVE\`, 
\`node_access\`), and structure the fix. The approach - evaluating the 
destination path twice, with and without \`RTEMS_FS_EXCLUSIVE\`, and comparing 
\`node_access\` pointers for same-file detection -was developed and verified by 
the contributor. All code was reviewed, understood, and tested manually before 
submission. /milestone %7.1

<!--Default settings, if it is a dropdown it will set after submission-->

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1191
You're receiving this email because of your account on gitlab.rtems.org.


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to