Skip to content

Commit

Permalink
fs: Corrected errno when not finding a mounted filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
geky committed Oct 24, 2017
1 parent 1566395 commit 400c254
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions platform/mbed_retarget.cpp
Expand Up @@ -254,15 +254,15 @@ 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()) {
res = path.file();
} 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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 400c254

Please sign in to comment.