Skip to content

Commit e4acabe

Browse files
AdrianDCnkk71
authored andcommitted
multirom: trampoline: Fully handle /proc/cmdline outputs
* In cases where the cmdline would be multiline, /proc/cmdline should be fully analyzed Change-Id: I251988330832665ab15d936c22bc35b8401f688d Signed-off-by: Adrian DC <[email protected]>
1 parent dacba1a commit e4acabe

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

trampoline/trampoline.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,24 @@ static int mount_and_run(struct fstab *fstab)
222222
static int is_charger_mode(void)
223223
{
224224
char buff[2048] = { 0 };
225+
int charger_mode = 0;
225226

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

230-
fgets(buff, sizeof(buff), f);
231+
while (fgets(buff, sizeof(buff), f) != NULL)
232+
{
233+
if (strstr(buff, "androidboot.mode=charger") != NULL)
234+
{
235+
charger_mode = 1;
236+
break;
237+
}
238+
}
239+
231240
fclose(f);
232241

233-
return (strstr(buff, "androidboot.mode=charger") != NULL);
242+
return charger_mode;
234243
}
235244

236245
static void fixup_symlinks(void)

0 commit comments

Comments
 (0)