Changeset 1680


Ignore:
Timestamp:
Dec 2, 2004, 8:00:37 AM (21 years ago)
Author:
bird
Message:

Bugfixing rename.

Location:
trunk/src/emx/src/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.83 to 1.84
    r1679 r1680  
    12751275    "DosLoadModuleEx" @1292
    12761276    "DosFreeModuleEx" @1293
     1277    "___libc_Back_fsRename" @1294
  • trunk/src/emx/src/lib/sys/b_fsRename.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1679 r1680  
    103103                if (!strcmp(&szNativePathOld[0], &szNativePathNew[0]))
    104104                    rc = 0;
    105                 else if (rc != ERROR_SHARING_VIOLATION)
     105                else
    106106                {
    107107                    /*
     
    110110                     */
    111111                    FILESTATUS3     fsts3Old;
    112                     rc = DosQueryPathInfo((PCSZ)&szNativePathOld[0], FIL_STANDARD, &fsts3Old, sizeof(fsts3Old));
    113                     if (rc)
     112                    int rc2 = DosQueryPathInfo((PCSZ)&szNativePathOld[0], FIL_STANDARD, &fsts3Old, sizeof(fsts3Old));
     113                    if (rc2)
    114114                    {
    115115                        /*
     
    117117                         * Anyway, we're done.
    118118                         */
    119                         rc = -__libc_native2errno(rc);
     119                        rc = -__libc_native2errno(rc2);
    120120                    }
    121121                    else
    122122                    {
    123                         FILESTATUS3     fsts3New;
    124                         rc = DosQueryPathInfo((PCSZ)&szNativePathNew[0], FIL_STANDARD, &fsts3New, sizeof(fsts3New));
    125                         if (rc)
    126                         {
    127                             /*
    128                              * No target, source must be busy doing something.
    129                              */
     123                        /*
     124                         * This is where we stop with ERROR_SHARING_VIOLATION.
     125                         */
     126                        if (rc == ERROR_SHARING_VIOLATION)
    130127                            rc = fsts3Old.attrFile & FILE_DIRECTORY ? -EBUSY : -ETXTBSY;
    131                         }
    132128                        else
    133129                        {
    134                             if (    (fsts3New.attrFile & FILE_DIRECTORY)
    135                                 && !(fsts3Old.attrFile & FILE_DIRECTORY))
     130                            FILESTATUS3     fsts3New;
     131                            rc2 = DosQueryPathInfo((PCSZ)&szNativePathNew[0], FIL_STANDARD, &fsts3New, sizeof(fsts3New));
     132                            if (rc2)
    136133                            {
    137134                                /*
    138                                  * The target is a directory while the source is not.
     135                                 * No target, source must be busy doing something.
    139136                                 */
    140                                 rc = -EISDIR;
     137                                rc = fsts3Old.attrFile & FILE_DIRECTORY ? -EBUSY : -ETXTBSY;
    141138                            }
    142139                            else
    143140                            {
    144                                 /*
    145                                  * Ok, now we start cooking.
    146                                  *
    147                                  * This should've been done atomically, but non-atomically is
    148                                  * better than not doing anything (usually). We use the loop
    149                                  * to retry the move operation and handle races with other
    150                                  * processes somewhat ok...
    151                                  */
    152                                 if (fsts3New.attrFile & FILE_DIRECTORY)
     141                                if (    (fsts3New.attrFile & FILE_DIRECTORY)
     142                                    && !(fsts3Old.attrFile & FILE_DIRECTORY))
    153143                                {
    154                                     rc = DosDeleteDir((PCSZ)&szNativePathNew[0]);
    155                                     LIBCLOG_MSG("DosDeleteDir('%s') -> %d\n", szNativePathNew, rc);
    156                                     if (!rc)
    157                                         continue;
    158                                     else if (rc == ERROR_ACCESS_DENIED)
    159                                         rc = -ENOTEMPTY;
    160                                     else
    161                                         rc = -__libc_native2errno(rc);
     144                                    /*
     145                                     * The target is a directory while the source is not.
     146                                     */
     147                                    rc = -EISDIR;
    162148                                }
    163149                                else
    164150                                {
    165                                     rc = DosDelete((PCSZ)&szNativePathNew[0]);
    166                                     LIBCLOG_MSG("DosDelete('%s') -> %d\n", szNativePathNew, rc);
    167                                     if (!rc)
    168                                         continue;
     151                                    /*
     152                                     * Ok, now we start cooking.
     153                                     *
     154                                     * This should've been done atomically, but non-atomically is
     155                                     * better than not doing anything (usually). We use the loop
     156                                     * to retry the move operation and handle races with other
     157                                     * processes somewhat ok...
     158                                     */
     159                                    if (fsts3New.attrFile & FILE_DIRECTORY)
     160                                    {
     161                                        rc2 = DosDeleteDir((PCSZ)&szNativePathNew[0]);
     162                                        LIBCLOG_MSG("DosDeleteDir('%s') -> %d\n", szNativePathNew, rc2);
     163                                        if (!rc2)
     164                                            continue;
     165                                        else if (rc2 == ERROR_ACCESS_DENIED)
     166                                            rc = -ENOTEMPTY;
     167                                        else
     168                                            rc = -__libc_native2errno(rc2);
     169                                    }
    169170                                    else
    170                                         rc = -__libc_native2errno(rc);
     171                                    {
     172                                        rc2 = DosDelete((PCSZ)&szNativePathNew[0]);
     173                                        LIBCLOG_MSG("DosDelete('%s') -> %d\n", szNativePathNew, rc2);
     174                                        if (!rc2)
     175                                            continue;
     176                                        else
     177                                            rc = -__libc_native2errno(rc2);
     178                                    }
    171179                                }
    172 
    173180                            }
    174                         }
     181                        } /* !ERROR_SHARING_VIOLATION */
    175182                    }
    176183                }
    177                 else if (rc == ERROR_DIRECTORY_IN_CDS || rc == ERROR_CIRCULARITY_REQUESTED)
    178                     rc = -EINVAL;
    179                 else
    180                     rc = -__libc_native2errno(rc);
    181184            }
     185            else if (rc == ERROR_DIRECTORY_IN_CDS || rc == ERROR_CIRCULARITY_REQUESTED)
     186                rc = -EINVAL;
     187            else
     188                rc = -__libc_native2errno(rc);
    182189            break;
    183190        }
Note: See TracChangeset for help on using the changeset viewer.