-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use androidboot.partition_map
as a fallback for matching partition names in the preinit finding.
#8293
Conversation
a script replicates magiskinit SecondStageInit collect_devices parse_device() {
local device_name="$1"
local devpath=$(readlink -f "/sys/dev/block/$device_name")
local uevent_file="/sys/dev/block/$device_name/uevent"
local dm_name_file="/sys/dev/block/$device_name/dm/name"
while IFS='=' read -r key value; do
case "$key" in
MAJOR)
local major="$value"
;;
MINOR)
local minor="$value"
;;
DEVNAME)
local devname="$value"
;;
PARTNAME)
local partname="$value"
;;
esac
done < "$uevent_file"
local dmname=$(cat "$dm_name_file" 2>/dev/null) || dm_name=""
printf "%-18s\t%-18s\t%-18s\t%s\n" "$partname" "$dmname" "$devname" "$devpath"
}
printf "%-18s\t%-18s\t%-18s\t%s\n" "partname" "dmname" "devname" "devpath"
for device in /sys/dev/block/*; do
parse_device "$(basename "$device")"
done output:
kernel cmdline fragment |
send mountinfo? |
also send /proc/self/mounts? |
Do you think maybe the fix should be a magisk |
hmm, both of them show |
|
No, we have no permission to call |
Back to the pr state. I tested the change on the production one. turns out it runs the same version of android as the dev one. The patched system boots and the log looks good, but I can't get adb to work to check if magisk is working. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some code style issue
699813b
to
eb9288a
Compare
partition_map was added since Android 13; bootconfig was added since Android 12, so I think we only need to parse bootconfig. |
Google Play Games passes The partition_map might be considered dynamic, I assume that the bootconfig is hardcoded in the ROM and can't be changed, so Google Play Games Emulator does the cmdline way. |
I will check the kernel cmdline and bootconfig later |
The bootconfig document said so:
|
Maybe the bootloader is bugging out, I notice the difference in bootconfig size between before and after patching the |
f6ded27
to
9317e55
Compare
9317e55
to
9831c2a
Compare
283a1e8
to
15474a2
Compare
@yujincheng08 can you review and approve once the change is in an acceptable state? |
15474a2
to
8269dcc
Compare
8851d67
to
28be995
Compare
else if (key == "PARTNAME") | ||
strcpy(dev->partname, value.data()); | ||
strscpy(dev->partname, value.data(), sizeof(dev->devname)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional that this is using sizeof(dev->devname)
instead of sizeof(dev->partname)
? Might be irrelevant, I'm not exactly sure how this code is called, I just happened to glance at it the other day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't really matter, partname and devname are both 32.
@yujincheng08 Can you answer whether this is intentional or not?
I'm also worried that strscpy doesn't add zero terminators, maybe we should use strncat(dst, src, buffer_size - 1)
or use strncasecmp
instead of strcastcmp
when comparing.
Fixes Play Games Developer Emulator
magiskinit: Cannot find preinit metadata, abort!
.only tested on the Play Games Developer Emulator, need to do some test on the production one, which runs on older version of Android iirc.