mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-02 10:23:25 +08:00
AP_Filesystem: give a ROMFS directory record back when opendir fails
opendir() took one of the four directory records, and kept it when the directory turned out not to exist. Four such attempts left every later ROMFS opendir() failing with ENFILE until a reboot; over MAVFTP, four listings of a missing @ROMFS path were enough. It also returned without setting errno. Free the record and set ENOENT.
This commit is contained in:
committed by
Peter Barker
parent
ec00ad8e0d
commit
5fac29cd7f
@@ -156,6 +156,7 @@ void *AP_Filesystem_ROMFS::opendir(const char *pathname)
|
||||
dir[idx].ofs = 0;
|
||||
dir[idx].path = strdup(pathname);
|
||||
if (!dir[idx].path) {
|
||||
errno = ENOMEM;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -163,7 +164,10 @@ void *AP_Filesystem_ROMFS::opendir(const char *pathname)
|
||||
const char *name = AP_ROMFS::dir_list(dir[idx].path, dir[idx].ofs);
|
||||
dir[idx].ofs = 0;
|
||||
if (!name) {
|
||||
// Directory does not exist
|
||||
// Directory does not exist; give the record back
|
||||
free(dir[idx].path);
|
||||
dir[idx].path = nullptr;
|
||||
errno = ENOENT;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user