Skip to content

Commit ac82578

Browse files
geky0xc0170
authored andcommitted
fs: Corrected errno when not finding a mounted filesystem
1 parent 31feb1d commit ac82578

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

platform/mbed_retarget.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) {
252252
/* The first part of the filename (between first 2 '/') is not a
253253
* registered mount point in the namespace.
254254
*/
255-
return handle_open_errors(-ENOENT, fh_i);
255+
return handle_open_errors(-ENODEV, fh_i);
256256
}
257257

258258
if (path.isFile()) {
259259
res = path.file();
260260
} else {
261261
FileSystemHandle *fs = path.fileSystem();
262262
if (fs == NULL) {
263-
return handle_open_errors(-ENOENT, fh_i);
263+
return handle_open_errors(-ENODEV, fh_i);
264264
}
265265
int posix_mode = openmode_to_posix(openmode);
266266
int err = fs->open(&res, path.fileName(), posix_mode);
@@ -565,7 +565,7 @@ extern "C" int remove(const char *path) {
565565
FilePath fp(path);
566566
FileSystemHandle *fs = fp.fileSystem();
567567
if (fs == NULL) {
568-
errno = ENOENT;
568+
errno = ENODEV;
569569
return -1;
570570
}
571571

@@ -585,7 +585,7 @@ extern "C" int rename(const char *oldname, const char *newname) {
585585
FileSystemHandle *fsNew = fpNew.fileSystem();
586586

587587
if (fsOld == NULL) {
588-
errno = ENOENT;
588+
errno = ENODEV;
589589
return -1;
590590
}
591591

@@ -625,7 +625,7 @@ extern "C" DIR *opendir(const char *path) {
625625
FilePath fp(path);
626626
FileSystemHandle* fs = fp.fileSystem();
627627
if (fs == NULL) {
628-
errno = ENOENT;
628+
errno = ENODEV;
629629
return NULL;
630630
}
631631

@@ -677,7 +677,10 @@ extern "C" void seekdir(DIR *dir, off_t off) {
677677
extern "C" int mkdir(const char *path, mode_t mode) {
678678
FilePath fp(path);
679679
FileSystemHandle *fs = fp.fileSystem();
680-
if (fs == NULL) return -1;
680+
if (fs == NULL) {
681+
errno = ENODEV;
682+
return -1;
683+
}
681684

682685
int err = fs->mkdir(fp.fileName(), mode);
683686
if (err < 0) {
@@ -691,7 +694,10 @@ extern "C" int mkdir(const char *path, mode_t mode) {
691694
extern "C" int stat(const char *path, struct stat *st) {
692695
FilePath fp(path);
693696
FileSystemHandle *fs = fp.fileSystem();
694-
if (fs == NULL) return -1;
697+
if (fs == NULL) {
698+
errno = ENODEV;
699+
return -1;
700+
}
695701

696702
int err = fs->stat(fp.fileName(), st);
697703
if (err < 0) {

0 commit comments

Comments
 (0)