preinit: strip trailing newline(s) on /proc/cmdline

This commit is contained in:
Daniel Barlow 2023-11-03 20:49:24 +00:00
parent e6ef4f78bb
commit 155a29d9b3

View file

@ -50,8 +50,13 @@ int main(int argc, char *argv[], char *envp[])
if(cmdline>=0) { if(cmdline>=0) {
int len = read(cmdline, buf, sizeof buf - 1); int len = read(cmdline, buf, sizeof buf - 1);
buf[len]='\0'; buf[len]='\0';
write(1, "cmdline ", 8); while(buf[len-1]=='\n') {
buf[len-1]='\0';
len--;
}
write(1, "cmdline: \"", 10);
write(1, buf, len); write(1, buf, len);
write(1, "\"\n", 2);
}; };
parseopts(buf, &rootdevice, &rootfstype); parseopts(buf, &rootdevice, &rootfstype);