- /* deal with case insensitive, case-preserving filesystems. */
- if ((stat(upath, st) == 0) && strdiacasecmp(oldname, newname))
- return AFPERR_EXIST;
-
- } else if (stat(upath, st ) == 0)
+ if (stat(upath, st) == 0 || caseenumerate(vol, &path, curdir) == 0) {
+ if (!stat(p, &nst) && !(nst.st_dev == st->st_dev && nst.st_ino == st->st_ino) ) {
+ /* not the same file */
+ return AFPERR_EXIST;
+ }
+ errno = 0;
+ }
+ } else if (stat(upath, st ) == 0 || caseenumerate(vol, &path, curdir) == 0)