Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8410720d authored by Luca Weiss's avatar Luca Weiss
Browse files

proc: Replace skip_initramfs to androidboot.force_normal_boot

The bootloader always adds skip_initramfs if we boot into Android, and
doesn't add it if we want to boot to recovery.

With retrofitted dynamic partitions we always need the initramfs, but
now androidboot.force_normal_boot is used for booting into Android.

Patch up the cmdline so we can get this behavior.

Issue: FP3-A11#146
Change-Id: I6712cce574e6981577bed6718ad0b3daf57aee2a
parent 844541f1
Loading
Loading
Loading
Loading
+26 −1
Original line number Original line Diff line number Diff line
@@ -2,10 +2,13 @@
#include <linux/init.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/seq_file.h>
#include <asm/setup.h>

static char new_command_line[COMMAND_LINE_SIZE];


static int cmdline_proc_show(struct seq_file *m, void *v)
static int cmdline_proc_show(struct seq_file *m, void *v)
{
{
	seq_printf(m, "%s\n", saved_command_line);
	seq_printf(m, "%s\n", new_command_line);
	return 0;
	return 0;
}
}


@@ -21,8 +24,30 @@ static const struct file_operations cmdline_proc_fops = {
	.release	= single_release,
	.release	= single_release,
};
};


#define DYN_PART_CMDLINE_FIND "skip_initramfs"
#define DYN_PART_CMDLINE_REPLACE "androidboot.force_normal_boot=1"

static int __init proc_cmdline_init(void)
static int __init proc_cmdline_init(void)
{
{
	size_t tail_len;
	char *offset_addr;
	char *cmd = new_command_line;

	strcpy(cmd, saved_command_line);

	// Find offset of find string
	offset_addr = strstr(cmd, DYN_PART_CMDLINE_FIND);
	if (offset_addr) {
		tail_len = strlen(offset_addr + strlen(DYN_PART_CMDLINE_FIND));

		// Move tail back so we have space for replace string
		memmove(offset_addr + strlen(DYN_PART_CMDLINE_REPLACE),
				offset_addr + strlen(DYN_PART_CMDLINE_FIND),
				tail_len + 1);
		// Copy replacement into the newly empty space
		memcpy(offset_addr, DYN_PART_CMDLINE_REPLACE, strlen(DYN_PART_CMDLINE_REPLACE));
	}

	proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
	proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
	return 0;
	return 0;
}
}