param_import: add mark_saved argument

Behavior of the 'param import' command:
- if no file provided, parameters are marked as saved (differs from before)
- if a file is provided: parameters are not marked as saved
This commit is contained in:
Beat Küng
2020-10-12 15:22:26 +02:00
parent f6e8ddfaa0
commit 3e9692c5bd
6 changed files with 19 additions and 12 deletions
@@ -362,5 +362,5 @@ int flash_param_load()
int flash_param_import()
{
return param_import_internal(false);
return param_import_internal(true);
}
+2 -1
View File
@@ -308,10 +308,11 @@ __EXPORT int param_export(int fd, bool only_unsaved, param_filter_func filter);
* This function merges the imported parameters with the current parameter set.
*
* @param fd File descriptor to import from (-1 selects the FLASH storage).
* @param mark_saved Whether to mark imported parameters as already saved
* @return Zero on success, nonzero if an error occurred during import.
* Note that in the failure case, parameters may be inconsistent.
*/
__EXPORT int param_import(int fd);
__EXPORT int param_import(int fd, bool mark_saved);
/**
* Load parameters from a file.
+2 -2
View File
@@ -1300,13 +1300,13 @@ param_import_internal(int fd, bool mark_saved)
}
int
param_import(int fd)
param_import(int fd, bool mark_saved)
{
if (fd < 0) {
return flash_param_import();
}
return param_import_internal(fd, false);
return param_import_internal(fd, mark_saved);
}
int
+3 -3
View File
@@ -1073,7 +1073,7 @@ param_load_default_no_notify()
return 1;
}
int result = param_import(fd_load);
int result = param_import(fd_load, true);
close(fd_load);
@@ -1351,10 +1351,10 @@ param_import_internal(int fd, bool mark_saved)
}
int
param_import(int fd)
param_import(int fd, bool mark_saved)
{
#if !defined(FLASH_BASED_PARAMS)
return param_import_internal(fd, false);
return param_import_internal(fd, mark_saved);
#else
(void)fd; // unused
// no need for locking here