host fst - return a better error for ChangePathGS when destination file exists and DestroyGS when file is non-empty directory

This commit is contained in:
Kelvin Sherlock 2018-08-20 21:28:09 -04:00
parent 67a8d7a0c6
commit 30491a39a0
2 changed files with 6 additions and 1 deletions

View File

@ -256,6 +256,9 @@ word32 host_map_errno(int xerrno) {
return outOfMem; return outOfMem;
case EEXIST: case EEXIST:
return dupPathname; return dupPathname;
case ENOTEMPTY:
return invalidAccess;
default: default:
return drvrIOError; return drvrIOError;
} }

View File

@ -1527,7 +1527,9 @@ static word32 fst_change_path(int class, const char *path1, const char *path2) {
if (host_is_root(&st)) if (host_is_root(&st))
return invalidAccess; return invalidAccess;
// rename will delete any previous file. // rename will delete any previous file. ChangePath should return an error.
if (stat(path2, &st) == 0) return dupPathname;
if (rename(path1, path2) < 0) return host_map_errno_path(errno, path2); if (rename(path1, path2) < 0) return host_map_errno_path(errno, path2);
return 0; return 0;
} }