Quote:
Originally Posted by ratiz
That would interesting to see. Do you use a loop device? I don't see otherwise how you can do that without touching the partitions.
|
Yeah, I do a loop device, but the real trickery is that I have an additional init binary at /init (which takes priority) which mounts them, handles a/b switching, patches the loaded kernel via /dev/kmem (rather than a kernel module so it's universal) to swap the device major/minor for the sdcard partitions to the loop one (replacing an unused syscall with kmalloc to do the memory allocation for the hook trampoline from userspace), patches some scripts which care about it (there's only about 3, and it's relatively minor) by bind-mounting over it, then execs the real init. This allows everything else to work unmodified, including Kobo's USB mass storage mode. I originally wrote this for testing multiple firmware versions in parallel while working on patches. I didn't publish it since there are a few pitfalls, and new versions need to be audited (since if they started using udev netlink, this doesn't handle it).
I don't have time to polish it for the next 3 weeks, but you can probably get 90% of the way there having a LLM remake it from my description.