diff --git a/userspace/ksud/src/event.rs b/userspace/ksud/src/event.rs index d82fb78e..5183cda6 100644 --- a/userspace/ksud/src/event.rs +++ b/userspace/ksud/src/event.rs @@ -13,6 +13,11 @@ fn mount_partition(partition: &str, lowerdir: &mut Vec) { return; } + // if /partition is a symlink and linked to /system/partition, then we don't need to overlay it separately + if Path::new(&format!("/{}", partition)).read_link().is_ok() { + println!("partition: {} is a symlink", partition); + return; + } // add /partition as the lowerest dir let lowest_dir = format!("/{}", partition); lowerdir.push(lowest_dir.clone()); @@ -67,7 +72,9 @@ pub fn do_systemless_mount(module_dir: &str) -> Result<()> { system_lowerdir.push(format!("{}", module_system.display())); for part in &partition { - let part_path = Path::new(&module_system).join(part); + // if /partition is a mountpoint, we would move it to $MODPATH/$partition when install + // otherwise it must be a symlink and we don't need to overlay! + let part_path = Path::new(&module).join(part); if !part_path.exists() { continue; } diff --git a/userspace/ksud/src/installer.sh b/userspace/ksud/src/installer.sh index 846aded0..fc685c31 100644 --- a/userspace/ksud/src/installer.sh +++ b/userspace/ksud/src/installer.sh @@ -281,6 +281,22 @@ is_legacy_script() { return $? } +handle_partition() { + # if /system/vendor is a symlink, we need to move it out of $MODPATH/system, otherwise it will be overlayed + # if /system/vendor is a normal directory, it is ok to overlay it and we don't need to overlay it separately. + if [ ! -e $MODPATH/system/$1 ]; then + # no partition found + return; + fi + + if [ -L "/system/$1" ] && [ "$(readlink -f /system/$1)" = "/$1" ]; then + ui_print "- Handle partition /$1" + # we create a symlink if module want to access $MODPATH/system/$1 + # but it doesn't always work(ie. write it in post-fs-data.sh would fail because it is readonly) + mv -f $MODPATH/system/$1 $MODPATH/$1 && ln -sf /$1 $MODPATH/system/$1 + fi +} + # Require OUTFD, ZIPFILE to be set install_module() { rm -rf $TMPDIR @@ -355,6 +371,10 @@ install_module() { [ -f $MODPATH/customize.sh ] && . $MODPATH/customize.sh fi + handle_partition vendor + handle_partition system_ext + handle_partition product + # Handle replace folders for TARGET in $REPLACE; do ui_print "- Replace target: $TARGET"