openwrt-packages/utils/telldus-core/patches/920-openwrt_missing_var_con...

19 lines
633 B
Diff

On OpenWrt targets the tmp filesystem is wiped upon power cycle, so files
requires to be created.
--- a/service/SettingsConfuse.cpp
+++ b/service/SettingsConfuse.cpp
@@ -436,6 +436,13 @@ bool readVarConfig(cfg_t **cfg) {
FILE *fp = fopen(VAR_CONFIG_FILE, "re"); // e for setting O_CLOEXEC on the file handle
if (!fp) {
(*cfg) = 0;
+ fp = fopen(VAR_CONFIG_FILE, "we"); // If missing, create file if possible
+ if(fp) {
+ fclose(fp);
+ }
+ else {
+ Log::warning("Unable to create var config file, %s", VAR_CONFIG_FILE);
+ }
Log::warning("Unable to open var config file, %s", VAR_CONFIG_FILE);
return false;
}