recovery: change way of deciding if platform uses NAND or eMMC
Instead of checking for the existence of /proc/mtd, which might lead to false positives, check the "root" parameter in /proc/cmdline. Assume eMMC in case of any error. https://onedigi.atlassian.net/browse/DEL-7539 Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
parent
a61873f7f1
commit
8c19cda181
|
|
@ -169,7 +169,7 @@ quit_with_error() {
|
|||
# @return - "yes" if the system is running in NAND, "no" otherwise
|
||||
#------------------------------------------------------------------------------
|
||||
is_nand() {
|
||||
if [ -f /proc/mtd ] && grep -qs mtd /proc/mtd; then
|
||||
if grep -qs "\broot=\(ubi\|mtd\)" /proc/cmdline; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
|
|
|
|||
|
|
@ -141,12 +141,28 @@ static int is_device_closed(void)
|
|||
*/
|
||||
static int is_device_nand(void)
|
||||
{
|
||||
const char *path_mtd = "/proc/mtd";
|
||||
|
||||
if (access(path_mtd, F_OK) != -1)
|
||||
return 1;
|
||||
FILE *fp;
|
||||
char dump[256];
|
||||
char *root_start;
|
||||
char *root_end;
|
||||
const char *cmdline = "/proc/cmdline";
|
||||
|
||||
fp = fopen(cmdline, "r");
|
||||
if (!fp)
|
||||
return 0;
|
||||
|
||||
if (!fgets(dump, sizeof(dump), fp))
|
||||
return 0;
|
||||
|
||||
root_start = strstr(dump, "root=");
|
||||
if (!root_start)
|
||||
return 0;
|
||||
root_end = strstr(root_start, " ");
|
||||
/* Truncate at root_end so that root_start contains the args for root */
|
||||
if (root_end)
|
||||
*root_end = '\0';
|
||||
|
||||
return strstr(root_start, "ubi") || strstr(root_start, "mtd");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue