Skip to content

Commit

Permalink
multirom: trampoline: Fully handle /proc/cmdline outputs
Browse files Browse the repository at this point in the history
 * In cases where the cmdline would be multiline,
    /proc/cmdline should be fully analyzed

Change-Id: I251988330832665ab15d936c22bc35b8401f688d
Signed-off-by: Adrian DC <[email protected]>
  • Loading branch information
AdrianDC authored and nkk71 committed May 8, 2017
1 parent dacba1a commit e4acabe
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions trampoline/trampoline.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,24 @@ static int mount_and_run(struct fstab *fstab)
static int is_charger_mode(void)
{
char buff[2048] = { 0 };
int charger_mode = 0;

FILE *f = fopen("/proc/cmdline", "re");
if(!f)
return 0;

fgets(buff, sizeof(buff), f);
while (fgets(buff, sizeof(buff), f) != NULL)
{
if (strstr(buff, "androidboot.mode=charger") != NULL)
{
charger_mode = 1;
break;
}
}

fclose(f);

return (strstr(buff, "androidboot.mode=charger") != NULL);
return charger_mode;
}

static void fixup_symlinks(void)
Expand Down

0 comments on commit e4acabe

Please sign in to comment.