Skip to content

Commit 38a0fe3

Browse files
committed
logger: fix file open issue if crypto algorithm is disabled
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.
1 parent 81552fc commit 38a0fe3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/modules/logger/log_writer_file.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ bool LogWriterFile::init_logfile_encryption(const char *filename)
9292
{
9393
if (_algorithm == CRYPTO_NONE) {
9494
_min_blocksize = 1;
95+
96+
// No encryption, just create empty log file
97+
int fd = ::open((const char *)filename, O_CREAT | O_WRONLY | O_DIRECT | O_SYNC, PX4_O_MODE_666);
98+
99+
if (fd < 0) {
100+
PX4_ERR("Can't open log file, errno: %d", errno);
101+
return false;
102+
}
103+
104+
::close(fd);
95105
return true;
96106
}
97107

0 commit comments

Comments
 (0)