Skip to content
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

Return FILE_EXISTS error when File::open fails due to include_excl=true #698

Closed
saba-ja opened this issue Jun 10, 2021 · 0 comments
Closed

Comments

@saba-ja
Copy link
Contributor

saba-ja commented Jun 10, 2021

F´ Version
Affected Component

Feature Description

As described PR #666 the introduced change (defaulting include_excl=true) could silently break components using file OPEN_CREATE mode.
This happened in one of the custom ComLoggers with resetOnMax option. The open file was breaking with error OTHER_ERROR which was not clear.

To reduce the ambiguity of the file open returned error on file exist we should add error EEXIST 17 /* File exists */
to the following:

fprime/Os/Linux/File.cpp

Lines 87 to 105 in 0d717b0

NATIVE_INT_TYPE fd = ::open(fileName,flags,userFlags);
if (-1 == fd) {
this->m_lastError = errno;
switch (errno) {
case ENOSPC:
stat = NO_SPACE;
break;
case ENOENT:
stat = DOESNT_EXIST;
break;
case EACCES:
stat = NO_PERMISSION;
break;
default:
stat = OTHER_ERROR;
break;
}
}

...
case EEXIST:
    stat = FILE_EXISTS;
    break; 
...

Rationale

Returning general error OTHER_ERROR might be ambiguous when a file exist. Adding a more specific error type such as FILE_EXISTS might help reduce the ambiguity of the file open issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant