mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
dataman: explicitly check file existence to init
- on NuttX if the SD card was just cleared (quick format) it's possible for the newly created uninitialized dataman file to still have the previous compatibility key, which causes the initialization to be skipped
This commit is contained in:
parent
def4ce6ba8
commit
3476831246
@ -529,6 +529,8 @@ _file_clear(dm_item_t item)
|
||||
static int
|
||||
_file_initialize(unsigned max_offset)
|
||||
{
|
||||
const bool file_existed = (access(k_data_manager_device_path, F_OK) == 0);
|
||||
|
||||
/* Open or create the data manager file */
|
||||
dm_operations_data.file.fd = open(k_data_manager_device_path, O_RDWR | O_CREAT | O_BINARY, PX4_O_MODE_666);
|
||||
|
||||
@ -553,7 +555,7 @@ _file_initialize(unsigned max_offset)
|
||||
|
||||
dm_operations_data.silence = false;
|
||||
|
||||
if (compat_state.key != DM_COMPAT_KEY) {
|
||||
if (!file_existed || (compat_state.key != DM_COMPAT_KEY)) {
|
||||
|
||||
/* Write current compat info */
|
||||
compat_state.key = DM_COMPAT_KEY;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user