recovery: turn is_dualboot_enabled() into generic function
The new function compares the value of the variable with one given as parameter. Signed-off-by: Hector Palacios <hector.palacios@digi.com>
This commit is contained in:
parent
ec08b1277a
commit
6910a11eab
|
|
@ -74,29 +74,29 @@ static char *emmc_parts_blacklist[] = {
|
||||||
static char *rootfs[] = { "rootfs", NULL };
|
static char *rootfs[] = { "rootfs", NULL };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function: is_device_closed
|
* Function: check_uboot_var
|
||||||
* Description: check if the device is in dualboot mode
|
* Description: Compares an env variable with a given value
|
||||||
*/
|
*/
|
||||||
static bool is_dualboot_enabled(void)
|
static bool check_uboot_var(char *name, char *value)
|
||||||
{
|
{
|
||||||
const char *var;
|
const char *val;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
/* Parse dualboot */
|
/* Parse variable */
|
||||||
if (uboot_getenv("dualboot", &var)) {
|
if (uboot_getenv(name, &val)) {
|
||||||
fprintf(stderr, "Error: getenv 'dualboot'\n");
|
fprintf(stderr, "Error: getenv '%s'\n", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Consider dualboot not enabled if variable doesn't exist */
|
/* Return false if variable doesn't exist */
|
||||||
if (!var)
|
if (!val)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Is dualboot enabled */
|
/* Is val == value */
|
||||||
if (!strcmp(var, "yes"))
|
if (!strcmp(val, value))
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
free(var);
|
free(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ static int append_recovery_command(const char *value)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* Check if we are in dualboot mode */
|
/* Check if we are in dualboot mode */
|
||||||
if (is_dualboot_enabled()) {
|
if (check_uboot_var("dualboot", "yes")) {
|
||||||
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
@ -622,7 +622,7 @@ int update_firmware(const char *swu_path)
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
/* Check if we are in dualboot mode */
|
/* Check if we are in dualboot mode */
|
||||||
if (is_dualboot_enabled()) {
|
if (check_uboot_var("dualboot", "yes")) {
|
||||||
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
@ -668,7 +668,7 @@ int reboot_recovery(unsigned int reboot_timeout)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* Check if we are in dualboot mode */
|
/* Check if we are in dualboot mode */
|
||||||
if (is_dualboot_enabled()) {
|
if (check_uboot_var("dualboot", "yes")) {
|
||||||
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
@ -718,7 +718,7 @@ int set_encryption_key(char *key, unsigned char force)
|
||||||
unsigned char i = 0;
|
unsigned char i = 0;
|
||||||
|
|
||||||
/* Check if we are in dualboot mode */
|
/* Check if we are in dualboot mode */
|
||||||
if (is_dualboot_enabled()) {
|
if (check_uboot_var("dualboot", "yes")) {
|
||||||
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -822,7 +822,7 @@ int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Check if we are in dualboot mode */
|
/* Check if we are in dualboot mode */
|
||||||
if (is_dualboot_enabled()) {
|
if (check_uboot_var("dualboot", "yes")) {
|
||||||
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
fprintf(stderr, "Error: dualboot enabled recovery cannot be used\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue