recovery: rework is_dualboot_enabled() function
- The function is only used internally in this file, so make it static.
- Convert the function from 'int' to 'bool', since no other values are
evaluated.
- Only return true if the variable 'dualboot' is set to 'yes'. Before,
the function returned true if 'dualboot' was different than 'no'.
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
(cherry picked from commit 9a519570ba)
This commit is contained in:
parent
53759cd29c
commit
846bccc8bf
|
|
@ -70,11 +70,4 @@ int set_encryption_key(char *key, unsigned char force);
|
|||
*/
|
||||
int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force);
|
||||
|
||||
/*
|
||||
* Check if device has dualboot enabled.
|
||||
*
|
||||
* Return: 1 if enabled and 0 if disabled, -1 on error when reading the environment
|
||||
*/
|
||||
int is_dualboot_enabled(void);
|
||||
|
||||
#endif /* RECOVERY_H */
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#define _GNU_SOURCE /* For GNU version of basename */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -72,6 +73,32 @@ static char *emmc_parts_blacklist[] = {
|
|||
|
||||
static char *rootfs[] = { "rootfs", NULL };
|
||||
|
||||
/*
|
||||
* Function: is_device_closed
|
||||
* Description: check if the device is in dualboot mode
|
||||
*/
|
||||
static bool is_dualboot_enabled(void)
|
||||
{
|
||||
const char *var;
|
||||
bool ret = false;
|
||||
|
||||
/* Parse dualboot */
|
||||
if (uboot_getenv("dualboot", &var)) {
|
||||
fprintf(stderr, "Error: getenv 'dualboot'\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Consider dualboot not enabled if variable doesn't exist */
|
||||
if (!var)
|
||||
return false;
|
||||
|
||||
/* Is dualboot enabled */
|
||||
if (!strcmp(var, "yes"))
|
||||
ret = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: append_recovery_command
|
||||
* Description: append configuration to the 'recovery_command' variable
|
||||
|
|
@ -961,32 +988,3 @@ err:
|
|||
|
||||
return ret < 0 ? -1 : ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: is_device_closed
|
||||
* Description: check if the device is in dualboot mode
|
||||
*/
|
||||
int is_dualboot_enabled (void)
|
||||
{
|
||||
const char *var;
|
||||
int ret;
|
||||
|
||||
/* Parse dualboot */
|
||||
ret = uboot_getenv("dualboot", &var);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Error: getenv 'dualboot'\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Consider dualboot not enabled if variable doesn't exist */
|
||||
if (!var)
|
||||
return 0;
|
||||
|
||||
/* Is dualboot enabled */
|
||||
if (!strcmp(var, "no"))
|
||||
ret = 0;
|
||||
else
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue