settings: file: do not create file when loading
File backend can be read-only with the use of `settings_file_src()` API. It makes no sense to create file when `settings_load()` is called and registered file backend won't be used for saving files (because `settings_file_dst()` was not used). Do not create file during `settings_load()` if it does not exist yet. This just requires to remove FS_O_CREATE flag in `fs_open()` invocation. Open file with read-only access, which is now possible after removal of `FS_O_CREATE` flag. Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This commit is contained in:
parent
37c4110104
commit
976520c77e
1 changed files with 5 additions and 1 deletions
|
@ -137,8 +137,12 @@ static int settings_file_load_priv(struct settings_store *cs, line_load_cb cb,
|
|||
|
||||
fs_file_t_init(&file);
|
||||
|
||||
rc = fs_open(&file, cf->cf_name, FS_O_CREATE | FS_O_RDWR);
|
||||
rc = fs_open(&file, cf->cf_name, FS_O_READ);
|
||||
if (rc != 0) {
|
||||
if (rc == -ENOENT) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue