Created px4_access to handle check of virtual files

uORBManager_posix.cpp did a stat to see if a file exists but the
file is actually a virtual file. Using stat was incorrect because
it required a stat buffer that was never used. The POSIX access
function is a better choice so I created a px4_access version to
handle virtual files.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-06-03 16:22:14 -07:00
parent 9882b78383
commit f985a48fbc
3 changed files with 15 additions and 5 deletions
+10
View File
@@ -293,6 +293,16 @@ int px4_fsync(int fd)
return 0;
}
int px4_access(const char *pathname, int mode)
{
if (mode == F_OK) {
errno = EINVAL;
return -1;
}
VDev *dev = VDev::getDev(pathname);
return (dev != nullptr) ? 0 : -1;
}
void px4_show_devices()
{
VDev::showDevices();