Skip to content

fs: Correct errno when not finding a mounted filesystem #5373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions platform/mbed_retarget.cpp
Original file line number Diff line number Diff line change
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