<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style="--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>
GitLab
</title>
<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>
<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style="font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";">
<div class="content">
<p class="details" style="font-style: italic; color: #626168;">
<a href="https://gitlab.rtems.org/Mazen_Hassan">Mazen hassan</a> created a merge request: <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1191">!1191</a>
</p>
<div class="branch">
Project:Branches: Mazen_Hassan/rtems:fix/rename-posix-same-file-v2 to rtems/rtos/rtems:main
</div>
<div class="author">
Author: Mazen hassan
</div>
<div class="assignee">
Assignees:
</div>
<div class="reviewer">
Reviewers:
</div>
<div class="md gl-mt-5" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word; margin-top: 1rem;">
<h2 id="user-content-summary" dir="auto" style="margin-top: 0; margin-bottom: 10px;" align="initial">Summary<a href="#summary" aria-label="Link to heading 'Summary'" data-heading-content="Summary" class="anchor" style="margin-top: 0;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">cpukit/libcsupport: Fix rename() same-file POSIX compliance</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">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.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">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.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">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.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Closes <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5487" title="rename() fails when source and target are the same - violates POSIX compliance" class="gfm gfm-issue" data-original="#5487" data-link="false" data-link-reference="false" data-issue="29510" data-project="26" data-iid="5487" data-namespace-path="rtems/rtos/rtems" data-project-path="rtems/rtos/rtems" data-issue-type="issue" data-container="body" data-placement="top" data-reference-type="issue" style="margin-top: 0;">#5487</a></p>
<h2 id="user-content-generative-ai" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Generative AI<a href="#generative-ai" aria-label="Link to heading 'Generative AI'" data-heading-content="Generative AI" class="anchor" style="margin-top: 0;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0;" align="initial">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 <a href="https://gitlab.rtems.org/groups/rtems/-/milestones/8" class="gfm gfm-milestone has-tooltip" data-original="%7.1" data-link="false" data-link-reference="false" data-milestone="141" data-group="3" data-namespace="3" data-container="body" data-placement="top" data-reference-type="milestone" style="margin-top: 0;">%7.1</a></p>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">
—
<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1191">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.rtems.org">gitlab.rtems.org</a>. <a href="https://gitlab.rtems.org/-/sent_notifications/3-0o2aqedtpxhk3bsp43btpv1vl/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.rtems.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.rtems.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1191 at 1775650675
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Merge request","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1191"}}</script>
</p>
</div>
</body>
</html>