From 02e9519ab008c0e1db1b14582a4658bf99b214e7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 30 Oct 2020 08:03:43 +1100 Subject: [PATCH] AP_Filesystem: fixed stat call for @SYS files --- libraries/AP_Filesystem/AP_Filesystem_Sys.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Filesystem/AP_Filesystem_Sys.cpp b/libraries/AP_Filesystem/AP_Filesystem_Sys.cpp index 868a9ea730..546f4bea97 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_Sys.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_Sys.cpp @@ -226,7 +226,11 @@ int AP_Filesystem_Sys::stat(const char *pathname, struct stat *stbuf) stbuf->st_size = 0; // just a placeholder value return 0; } - int8_t pos = file_in_sysfs(&pathname[1]); + const char *pathname_noslash = pathname; + if (pathname[0] == '/') { + pathname_noslash = &pathname[1]; + } + int8_t pos = file_in_sysfs(pathname_noslash); if (pos < 0) { errno = ENOENT; return -1;