From 6461c5502bece3f453f32ac72311e4d9667e2f89 Mon Sep 17 00:00:00 2001 From: 5ec1cff Date: Sat, 23 Nov 2024 17:58:58 +0800 Subject: [PATCH] ksud: fix odm not magic-mounted --- userspace/ksud/src/installer.sh | 10 ++++++---- userspace/ksud/src/magic_mount.rs | 9 +++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/userspace/ksud/src/installer.sh b/userspace/ksud/src/installer.sh index c9b2a4e0..15c2e5f2 100644 --- a/userspace/ksud/src/installer.sh +++ b/userspace/ksud/src/installer.sh @@ -303,12 +303,13 @@ is_legacy_script() { handle_partition() { PARTITION="$1" + REQUIRE_SYMLINK="$2" if [ ! -e "$MODPATH/system/$PARTITION" ]; then # no partition found return; fi - if [ -L "/system/$PARTITION" ] && [ "$(readlink -f "/system/$PARTITION")" = "/$PARTITION" ]; then + if [ "$REQUIRE_SYMLINK" = "false" ] || [ -L "/system/$PARTITION" ] && [ "$(readlink -f "/system/$PARTITION")" = "/$PARTITION" ]; then ui_print "- Handle partition /$PARTITION" ln -sf "$MODPATH/system/$PARTITION" "$MODPATH/$PARTITION" fi @@ -388,9 +389,10 @@ install_module() { [ -f $MODPATH/customize.sh ] && . $MODPATH/customize.sh fi - handle_partition vendor - handle_partition system_ext - handle_partition product + handle_partition vendor true + handle_partition system_ext true + handle_partition product true + handle_partition odm false # Handle replace folders for TARGET in $REPLACE; do diff --git a/userspace/ksud/src/magic_mount.rs b/userspace/ksud/src/magic_mount.rs index 22cfcc76..f4b45d2a 100644 --- a/userspace/ksud/src/magic_mount.rs +++ b/userspace/ksud/src/magic_mount.rs @@ -148,10 +148,15 @@ fn collect_module_files() -> Result> { } if has_file { - for partition in ["vendor", "system_ext", "product", "odm"] { + for (partition, require_symlink) in [ + ("vendor", true), + ("system_ext", true), + ("product", true), + ("odm", false), + ] { let path_of_root = Path::new("/").join(partition); let path_of_system = Path::new("/system").join(partition); - if path_of_root.is_dir() && path_of_system.is_symlink() { + if path_of_root.is_dir() && (!require_symlink || path_of_system.is_symlink()) { let name = partition.to_string(); if let Some(node) = system.children.remove(&name) { root.children.insert(name, node);