rename unnamed dmmap section

This commit is contained in:
Suvendhu Hansa 2025-09-04 18:56:38 +05:30 committed by IOPSYS Dev
parent ca8707b320
commit 2f3a0805b0
No known key found for this signature in database
2 changed files with 38 additions and 10 deletions

View file

@ -430,12 +430,22 @@ void synchronize_specific_config_sections_with_dmmap(const char *package, const
char *v = NULL; char *v = NULL;
uci_foreach_sections(package, section_type, s) { uci_foreach_sections(package, section_type, s) {
char sec_name[64] = {0};
snprintf(sec_name, sizeof(sec_name), "%s_%s", section_type, section_name(s));
/* /*
* create/update corresponding dmmap section that have same config_section link and using param_value_array * create/update corresponding dmmap section that have same config_section link and using param_value_array
*/ */
if ((dmmap_sect = get_dup_section_in_dmmap(dmmap_package, section_type, section_name(s))) == NULL) { if ((dmmap_sect = get_dup_section_in_dmmap(dmmap_package, section_type, section_name(s))) == NULL) {
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect); dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect);
dmuci_rename_section_by_section(dmmap_sect, sec_name);
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(s)); dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(s));
} else {
const char *reg_exp = "^cfg[0-9a-fA-F]{6}$";
if (match(section_name(dmmap_sect), reg_exp, 0, NULL) == true) {
dmuci_rename_section_by_section(dmmap_sect, sec_name);
}
} }
/* /*

View file

@ -20,33 +20,51 @@
**************************************************************/ **************************************************************/
static void _exec_reboot(const void *arg1, void *arg2) static void _exec_reboot(const void *arg1, void *arg2)
{ {
char config_name[16] = {0}; struct bbfdm_ctx d_ctx = {0};
struct blob_buf bb = {0};
snprintf(config_name, sizeof(config_name), "%s", "sysmngr"); bbfdm_init_ctx(&d_ctx);
memset(&bb, 0, sizeof(struct blob_buf));
blob_buf_init(&bb, 0);
// Set last_reboot_cause to 'RemoteReboot' because the upcoming reboot will be initiated by USP Operate // Set last_reboot_cause to 'RemoteReboot' because the upcoming reboot will be initiated by USP Operate
dmuci_set_value(config_name, "reboots", "last_reboot_cause", "RemoteReboot"); bbfdm_uci_set(&d_ctx, "sysmngr", "reboots", "last_reboot_cause", "RemoteReboot");
dmuci_commit_package(config_name); bbfdm_uci_commit_package(&d_ctx, "sysmngr");
sleep(3); sleep(3);
dmubus_call_set("rpc-sys", "reboot", UBUS_ARGS{0}, 0);
bbfdm_ubus_invoke_sync(&d_ctx, "rpc-sys", "reboot", bb.head, 5000, NULL, NULL);
sleep(30); // Wait for reboot to happen sleep(30); // Wait for reboot to happen
BBF_ERR("Reboot call failed with rpc-sys, trying again with system"); BBF_ERR("Reboot call failed with rpc-sys, trying again with system");
dmubus_call_set("system", "reboot", UBUS_ARGS{0}, 0); bbfdm_ubus_invoke_sync(&d_ctx, "system", "reboot", bb.head, 5000, NULL, NULL);
sleep(30); // Wait for reboot sleep(30); // Wait for reboot
BBF_ERR("Reboot call failed!!!"); BBF_ERR("Reboot call failed!!!");
// Set last_reboot_cause to empty because there is a problem in the system reboot // Set last_reboot_cause to empty because there is a problem in the system reboot
dmuci_set_value(config_name, "reboots", "last_reboot_cause", ""); bbfdm_uci_set(&d_ctx, "sysmngr", "reboots", "last_reboot_cause", "");
dmuci_commit_package(config_name); bbfdm_uci_commit_package(&d_ctx, "sysmngr");
bbfdm_free_ctx(&d_ctx);
blob_buf_free(&bb);
} }
static void _exec_factoryreset(const void *arg1, void *arg2) static void _exec_factoryreset(const void *arg1, void *arg2)
{ {
struct bbfdm_ctx d_ctx = {0};
struct blob_buf bb = {0};
bbfdm_init_ctx(&d_ctx);
memset(&bb, 0, sizeof(struct blob_buf));
blob_buf_init(&bb, 0);
sleep(2); sleep(2);
dmubus_call_set("rpc-sys", "factory", UBUS_ARGS{0}, 0); bbfdm_ubus_invoke_sync(&d_ctx, "rpc-sys", "factory", bb.head, 5000, NULL, NULL);
sleep(5); // Wait for reboot to happen sleep(5); // Wait for reboot to happen
BBF_ERR("FactoryReset via rpc-sys failed, trying defaultreset"); BBF_ERR("FactoryReset via rpc-sys failed, trying defaultreset");
bbfdm_free_ctx(&d_ctx);
blob_buf_free(&bb);
dmcmd_no_wait("/sbin/defaultreset", 0); dmcmd_no_wait("/sbin/defaultreset", 0);
sleep(5); // Wait for reboot to happen sleep(5); // Wait for reboot to happen
BBF_ERR("FactoryReset call failed!!!"); BBF_ERR("FactoryReset call failed!!!");