mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Save uci changes in place of commit
This commit is contained in:
parent
2e3a7f30ad
commit
823183c11e
4 changed files with 73 additions and 3 deletions
20
dmentry.c
20
dmentry.c
|
|
@ -409,7 +409,7 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
|
|||
break;
|
||||
#endif
|
||||
}
|
||||
dmuci_commit();
|
||||
dmuci_save();
|
||||
return usp_fault_map(fault);
|
||||
}
|
||||
|
||||
|
|
@ -435,7 +435,7 @@ int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1, char *arg2)
|
|||
} else {
|
||||
dmuci_set_value("cwmp", "acs", "ParameterKey", arg1 ? arg1 : "");
|
||||
dmuci_change_packages(&head_package_change);
|
||||
dmuci_commit();
|
||||
dmuci_save();
|
||||
}
|
||||
free_all_set_list_tmp(ctx);
|
||||
break;
|
||||
|
|
@ -452,7 +452,7 @@ int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1, char *arg2)
|
|||
//Should not happen
|
||||
dmuci_revert();
|
||||
} else {
|
||||
dmuci_commit();
|
||||
dmuci_save();
|
||||
}
|
||||
free_all_set_list_tmp(ctx);
|
||||
break;
|
||||
|
|
@ -875,6 +875,20 @@ int dm_entry_restart_services(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int dm_entry_revert_changes(void)
|
||||
{
|
||||
struct package_change *pc;
|
||||
|
||||
list_for_each_entry(pc, &head_package_change, list) {
|
||||
if(strcmp(pc->package, "cwmp") == 0)
|
||||
continue;
|
||||
dmubus_call_set("uci", "revert", UBUS_ARGS{{"config", pc->package, String}}, 1);
|
||||
}
|
||||
free_all_list_package_change(&head_package_change);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dm_apply_config(void)
|
||||
{
|
||||
apply_end_session();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ int dm_entry_reload_enabled_notify(unsigned int dm_type, unsigned int amd_versio
|
|||
int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, char **value);
|
||||
int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value);
|
||||
int dm_entry_restart_services(void);
|
||||
int dm_entry_revert_changes(void);
|
||||
int usp_fault_map(int fault);
|
||||
#ifdef BBF_TR064
|
||||
int dm_entry_upnp_restart_services(void);
|
||||
|
|
|
|||
|
|
@ -319,6 +319,50 @@ end:
|
|||
return rc;
|
||||
}
|
||||
|
||||
int dmuci_save_package(char *package)
|
||||
{
|
||||
struct uci_ptr ptr = {0};
|
||||
|
||||
if (uci_lookup_ptr(uci_ctx, &ptr, package, true) != UCI_OK)
|
||||
return -1;
|
||||
|
||||
if (uci_save(uci_ctx, ptr.p) != UCI_OK)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dmuci_save(void)
|
||||
{
|
||||
char **configs = NULL;
|
||||
char **bbfdm_configs = NULL;
|
||||
char **p;
|
||||
int rc = 0;
|
||||
|
||||
if ((uci_list_configs(uci_ctx, &configs) != UCI_OK) || !configs) {
|
||||
rc = -1;
|
||||
goto end;
|
||||
}
|
||||
for (p = configs; *p; p++)
|
||||
dmuci_save_package(*p);
|
||||
|
||||
if (uci_ctx_bbfdm) {
|
||||
if ((uci_list_configs(uci_ctx_bbfdm, &bbfdm_configs) != UCI_OK) || !bbfdm_configs) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
for (p = bbfdm_configs; *p; p++)
|
||||
dmuci_save_package_bbfdm(*p);
|
||||
|
||||
free(bbfdm_configs);
|
||||
}
|
||||
|
||||
out:
|
||||
free(configs);
|
||||
end:
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**** UCI REVERT *****/
|
||||
static int dmuci_revert_package(char *package)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -280,6 +280,15 @@ int dmuci_commit_package_##UCI_PATH(char *package) \
|
|||
uci_ctx = save_uci_ctx; \
|
||||
return res; \
|
||||
}\
|
||||
int dmuci_save_package_##UCI_PATH(char *package) \
|
||||
{\
|
||||
struct uci_context *save_uci_ctx; \
|
||||
save_uci_ctx = uci_ctx; \
|
||||
uci_ctx = uci_ctx_##UCI_PATH; \
|
||||
int res = dmuci_save_package(package); \
|
||||
uci_ctx = save_uci_ctx; \
|
||||
return res; \
|
||||
}\
|
||||
|
||||
int dmuci_init(void);
|
||||
int dmuci_end(void);
|
||||
|
|
@ -288,6 +297,7 @@ void uci_add_list_to_list(struct uci_list *addlist, struct uci_list *list);
|
|||
void free_all_list_package_change(struct list_head *clist);
|
||||
int dmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value);
|
||||
int dmuci_commit(void);
|
||||
int dmuci_save(void);
|
||||
int dmuci_revert(void);
|
||||
int dmuci_change_packages(struct list_head *clist);
|
||||
|
||||
|
|
@ -311,6 +321,7 @@ int dmuci_del_list_value_by_section(struct uci_section *s, char *option, char *v
|
|||
int dmuci_rename_section_by_section(struct uci_section *s, char *value);
|
||||
struct uci_section *dmuci_walk_section(char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk);
|
||||
int dmuci_commit_package(char *package);
|
||||
int dmuci_save_package(char *package);
|
||||
|
||||
int dmuci_get_option_value_string_bbfdm(char *package, char *section, char *option, char **value);
|
||||
char *dmuci_set_value_bbfdm(char *package, char *section, char *option, char *value);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue