mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-03-24 02:01:07 +00:00
Support non-ext4 filesystem for vendor and system
Signed-off-by: Erfan Abdi <erfangplus@gmail.com>
This commit is contained in:
parent
f0639390aa
commit
6698c189fc
@ -160,7 +160,7 @@ static bool setup_block(struct device *dev, const char *partname) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool read_fstab_dt(const struct cmdline *cmd, const char *mnt_point, char *partname) {
|
static bool read_fstab_dt(const struct cmdline *cmd, const char *mnt_point, char *partname, char *partfs) {
|
||||||
char buf[128];
|
char buf[128];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
sprintf(buf, "/%s", mnt_point);
|
sprintf(buf, "/%s", mnt_point);
|
||||||
@ -175,7 +175,14 @@ static bool read_fstab_dt(const struct cmdline *cmd, const char *mnt_point, char
|
|||||||
close(fd);
|
close(fd);
|
||||||
char *name = strrchr(buf, '/') + 1;
|
char *name = strrchr(buf, '/') + 1;
|
||||||
sprintf(partname, "%s%s", name, strend(name, cmd->slot) ? cmd->slot : "");
|
sprintf(partname, "%s%s", name, strend(name, cmd->slot) ? cmd->slot : "");
|
||||||
return true;
|
sprintf(buf, "%s/fstab/%s/type", cmd->dt_dir, mnt_point);
|
||||||
|
if (access(buf, F_OK) == 0) {
|
||||||
|
int fd = open(buf, O_RDONLY | O_CLOEXEC);
|
||||||
|
lstat(buf, &st);
|
||||||
|
read(fd, partfs, st.st_size);
|
||||||
|
close(fd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -419,6 +426,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
struct device dev;
|
struct device dev;
|
||||||
char partname[32];
|
char partname[32];
|
||||||
|
char partfs[32];
|
||||||
|
|
||||||
if (cmd.early_boot) {
|
if (cmd.early_boot) {
|
||||||
sprintf(partname, "system%s", cmd.slot);
|
sprintf(partname, "system%s", cmd.slot);
|
||||||
@ -436,15 +444,15 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
xmkdir("/system", 0755);
|
xmkdir("/system", 0755);
|
||||||
xmount("/system_root/system", "/system", nullptr, MS_BIND, nullptr);
|
xmount("/system_root/system", "/system", nullptr, MS_BIND, nullptr);
|
||||||
} else if (read_fstab_dt(&cmd, "system", partname)) {
|
} else if (read_fstab_dt(&cmd, "system", partname, partfs)) {
|
||||||
setup_block(&dev, partname);
|
setup_block(&dev, partname);
|
||||||
xmount(dev.path, "/system", "ext4", MS_RDONLY, nullptr);
|
xmount(dev.path, "/system", partfs, MS_RDONLY, nullptr);
|
||||||
mnt_system = true;
|
mnt_system = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_fstab_dt(&cmd, "vendor", partname)) {
|
if (read_fstab_dt(&cmd, "vendor", partname, partfs)) {
|
||||||
setup_block(&dev, partname);
|
setup_block(&dev, partname);
|
||||||
xmount(dev.path, "/vendor", "ext4", MS_RDONLY, nullptr);
|
xmount(dev.path, "/vendor", partfs, MS_RDONLY, nullptr);
|
||||||
mnt_vendor = true;
|
mnt_vendor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ mount_partitions() {
|
|||||||
[ -f /system/build.prop ] || is_mounted /system || mount -o ro /system 2>/dev/null
|
[ -f /system/build.prop ] || is_mounted /system || mount -o ro /system 2>/dev/null
|
||||||
if ! is_mounted /system && ! [ -f /system/build.prop ]; then
|
if ! is_mounted /system && ! [ -f /system/build.prop ]; then
|
||||||
SYSTEMBLOCK=`find_block system$SLOT`
|
SYSTEMBLOCK=`find_block system$SLOT`
|
||||||
mount -t ext4 -o ro $SYSTEMBLOCK /system
|
mount -o ro $SYSTEMBLOCK /system
|
||||||
fi
|
fi
|
||||||
[ -f /system/build.prop ] || is_mounted /system || abort "! Cannot mount /system"
|
[ -f /system/build.prop ] || is_mounted /system || abort "! Cannot mount /system"
|
||||||
grep -qE '/dev/root|/system_root' /proc/mounts && SYSTEM_ROOT=true || SYSTEM_ROOT=false
|
grep -qE '/dev/root|/system_root' /proc/mounts && SYSTEM_ROOT=true || SYSTEM_ROOT=false
|
||||||
@ -106,7 +106,7 @@ mount_partitions() {
|
|||||||
is_mounted /vendor || mount -o ro /vendor 2>/dev/null
|
is_mounted /vendor || mount -o ro /vendor 2>/dev/null
|
||||||
if ! is_mounted /vendor; then
|
if ! is_mounted /vendor; then
|
||||||
VENDORBLOCK=`find_block vendor$SLOT`
|
VENDORBLOCK=`find_block vendor$SLOT`
|
||||||
mount -t ext4 -o ro $VENDORBLOCK /vendor
|
mount -o ro $VENDORBLOCK /vendor
|
||||||
fi
|
fi
|
||||||
is_mounted /vendor || abort "! Cannot mount /vendor"
|
is_mounted /vendor || abort "! Cannot mount /vendor"
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user