diff --git a/platform/mbed_retarget.cpp b/platform/mbed_retarget.cpp index 6c5f12031e..f77b3ce4fc 100644 --- a/platform/mbed_retarget.cpp +++ b/platform/mbed_retarget.cpp @@ -254,7 +254,7 @@ extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) { /* The first part of the filename (between first 2 '/') is not a * registered mount point in the namespace. */ - return handle_open_errors(-ENOENT, fh_i); + return handle_open_errors(-ENODEV, fh_i); } if (path.isFile()) { @@ -262,7 +262,7 @@ extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) { } else { FileSystemHandle *fs = path.fileSystem(); if (fs == NULL) { - return handle_open_errors(-ENOENT, fh_i); + return handle_open_errors(-ENODEV, fh_i); } int posix_mode = openmode_to_posix(openmode); int err = fs->open(&res, path.fileName(), posix_mode); @@ -567,7 +567,7 @@ extern "C" int remove(const char *path) { FilePath fp(path); FileSystemHandle *fs = fp.fileSystem(); if (fs == NULL) { - errno = ENOENT; + errno = ENODEV; return -1; } @@ -587,7 +587,7 @@ extern "C" int rename(const char *oldname, const char *newname) { FileSystemHandle *fsNew = fpNew.fileSystem(); if (fsOld == NULL) { - errno = ENOENT; + errno = ENODEV; return -1; } @@ -627,7 +627,7 @@ extern "C" DIR *opendir(const char *path) { FilePath fp(path); FileSystemHandle* fs = fp.fileSystem(); if (fs == NULL) { - errno = ENOENT; + errno = ENODEV; return NULL; } @@ -679,7 +679,10 @@ extern "C" void seekdir(DIR *dir, off_t off) { extern "C" int mkdir(const char *path, mode_t mode) { FilePath fp(path); FileSystemHandle *fs = fp.fileSystem(); - if (fs == NULL) return -1; + if (fs == NULL) { + errno = ENODEV; + return -1; + } int err = fs->mkdir(fp.fileName(), mode); if (err < 0) { @@ -693,7 +696,10 @@ extern "C" int mkdir(const char *path, mode_t mode) { extern "C" int stat(const char *path, struct stat *st) { FilePath fp(path); FileSystemHandle *fs = fp.fileSystem(); - if (fs == NULL) return -1; + if (fs == NULL) { + errno = ENODEV; + return -1; + } int err = fs->stat(fp.fileName(), st); if (err < 0) {