From 30491a39a08d5ec78475a4a2a3d4d2b1ca71bfa6 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 20 Aug 2018 21:28:09 -0400 Subject: [PATCH] host fst - return a better error for ChangePathGS when destination file exists and DestroyGS when file is non-empty directory --- src/host_common.c | 3 +++ src/host_fst.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/host_common.c b/src/host_common.c index ddb12d4..158db53 100644 --- a/src/host_common.c +++ b/src/host_common.c @@ -256,6 +256,9 @@ word32 host_map_errno(int xerrno) { return outOfMem; case EEXIST: return dupPathname; + case ENOTEMPTY: + return invalidAccess; + default: return drvrIOError; } diff --git a/src/host_fst.c b/src/host_fst.c index 940d63f..c1cfbd1 100644 --- a/src/host_fst.c +++ b/src/host_fst.c @@ -1527,7 +1527,9 @@ static word32 fst_change_path(int class, const char *path1, const char *path2) { if (host_is_root(&st)) 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); return 0; }