Skip to content

Commit

Permalink
logger: fix file open issue if crypto algorithm is disabled
Browse files Browse the repository at this point in the history
Create empty file even if crypto key is not stored into the beginning
of the log file to allow file logger to always append log data into
existing file.
  • Loading branch information
jnippula committed Dec 27, 2024
1 parent 81552fc commit 38a0fe3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/modules/logger/log_writer_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ bool LogWriterFile::init_logfile_encryption(const char *filename)
{
if (_algorithm == CRYPTO_NONE) {
_min_blocksize = 1;

// No encryption, just create empty log file
int fd = ::open((const char *)filename, O_CREAT | O_WRONLY | O_DIRECT | O_SYNC, PX4_O_MODE_666);

if (fd < 0) {
PX4_ERR("Can't open log file, errno: %d", errno);
return false;
}

::close(fd);
return true;
}

Expand Down

0 comments on commit 38a0fe3

Please sign in to comment.