Index: /branches/libc-0.6/src/emx/src/lib/sys/b_fsRename.c
===================================================================
--- /branches/libc-0.6/src/emx/src/lib/sys/b_fsRename.c	(revision 3904)
+++ /branches/libc-0.6/src/emx/src/lib/sys/b_fsRename.c	(revision 3905)
@@ -156,4 +156,7 @@
                                      * to retry the move operation and handle races with other
                                      * processes somewhat ok...
+                                     *
+                                     * Try clear the read-only attribute on files before deleting them.
+                                     * Directories cannot have read-only attributes on OS/2 it seems.
                                      */
                                     if (fsts3New.attrFile & FILE_DIRECTORY)
@@ -163,5 +166,5 @@
                                         if (!rc2)
                                             continue;
-                                        else if (rc2 == ERROR_ACCESS_DENIED)
+                                        if (rc2 == ERROR_ACCESS_DENIED)
                                             rc = -ENOTEMPTY;
                                         else
@@ -170,10 +173,17 @@
                                     else
                                     {
+                                        if (fsts3New.attrFile & FILE_READONLY)
+                                        {
+                                            fsts3New.attrFile &= ~FILE_READONLY;
+                                            rc2 = DosSetPathInfo((PCSZ)&szNativePathNew[0], FIL_STANDARD, &fsts3New,
+                                                                 sizeof(fsts3New), 0 /*fOptions*/);
+                                            LIBCLOG_MSG("DosSetPathInfo('%s',read-write) -> %d\n", szNativePathNew, rc2);
+                                        }
+
                                         rc2 = DosDelete((PCSZ)&szNativePathNew[0]);
                                         LIBCLOG_MSG("DosDelete('%s') -> %d\n", szNativePathNew, rc2);
                                         if (!rc2)
                                             continue;
-                                        else
-                                            rc = -__libc_native2errno(rc2);
+                                        rc = -__libc_native2errno(rc2);
                                     }
                                 }
Index: /trunk/libc/src/kNIX/os2/b_fsRename.c
===================================================================
--- /trunk/libc/src/kNIX/os2/b_fsRename.c	(revision 3904)
+++ /trunk/libc/src/kNIX/os2/b_fsRename.c	(revision 3905)
@@ -144,4 +144,7 @@
                                      * to retry the move operation and handle races with other
                                      * processes somewhat ok...
+                                     *
+                                     * Try clear the read-only attribute on files before deleting them.
+                                     * Directories cannot have read-only attributes on OS/2 it seems.
                                      */
                                     if (fsts3New.attrFile & FILE_DIRECTORY)
@@ -151,5 +154,5 @@
                                         if (!rc2)
                                             continue;
-                                        else if (rc2 == ERROR_ACCESS_DENIED)
+                                        if (rc2 == ERROR_ACCESS_DENIED)
                                             rc = -ENOTEMPTY;
                                         else
@@ -158,10 +161,17 @@
                                     else
                                     {
+                                        if (fsts3New.attrFile & FILE_READONLY)
+                                        {
+                                            fsts3New.attrFile &= ~FILE_READONLY;
+                                            rc2 = DosSetPathInfo((PCSZ)&szNativePathNew[0], FIL_STANDARD, &fsts3New,
+                                                                 sizeof(fsts3New), 0 /*fOptions*/);
+                                            LIBCLOG_MSG("DosSetPathInfo('%s',read-write) -> %d\n", szNativePathNew, rc2);
+                                        }
+
                                         rc2 = DosDelete((PCSZ)&szNativePathNew[0]);
                                         LIBCLOG_MSG("DosDelete('%s') -> %d\n", szNativePathNew, rc2);
                                         if (!rc2)
                                             continue;
-                                        else
-                                            rc = -__libc_back_native2errno(rc2);
+                                        rc = -__libc_back_native2errno(rc2);
                                     }
                                 }
