Fix legacy rootfs devices

This commit is contained in:
topjohnwu 2021-01-25 00:19:10 -08:00
parent 4cc41eccb3
commit 3e479726ec
4 changed files with 9 additions and 8 deletions

View File

@ -28,6 +28,6 @@ kapt.incremental.apt=true
# Magisk
magisk.stubVersion=16
magisk.versionCode=21402
magisk.versionCode=21403
magisk.ndkVersion=21d
magisk.fullNdkVersion=21.3.6528147

View File

@ -14,7 +14,7 @@ android {
externalNativeBuild {
ndkBuild {
// Pass arguments to ndk-build.
arguments("B_MAGISK=1", "B_INIT64=1", "B_BOOT=1", "B_TEST=1",
arguments("B_MAGISK=1", "B_INIT=1", "B_BOOT=1", "B_TEST=1",
"MAGISK_DEBUG=1", "MAGISK_VERSION=debug", "MAGISK_VER_CODE=INT_MAX")
}
}

View File

@ -86,7 +86,7 @@ static int64_t setup_block(bool write_block) {
sprintf(blk_info.block_dev, "/dev/block/%s", dev.devname);
}
dev_t rdev = makedev(dev.major, dev.minor);
mknod(blk_info.block_dev, S_IFBLK | 0600, rdev);
xmknod(blk_info.block_dev, S_IFBLK | 0600, rdev);
return rdev;
}
// Wait 10ms and try again

View File

@ -322,8 +322,14 @@ void SARBase::patch_rootdir() {
#define TMP_RULESDIR "/.backup/.sepolicy.rules"
void RootFSInit::patch_rootfs() {
// Create hardlink mirror of /sbin to /root
mkdir("/root", 0777);
clone_attr("/sbin", "/root");
link_path("/sbin", "/root");
// Handle custom sepolicy rules
xmkdir(TMP_MNTDIR, 0755);
xmkdir("/dev/block", 0755);
mount_rules_dir("/dev/block", TMP_MNTDIR);
// Preserve custom rule path
if (!custom_rules_dir.empty()) {
@ -346,11 +352,6 @@ void RootFSInit::patch_rootfs() {
patch_init_rc("/init.rc", "/init.p.rc", "/sbin");
rename("/init.p.rc", "/init.rc");
// Create hardlink mirror of /sbin to /root
mkdir("/root", 0750);
clone_attr("/sbin", "/root");
link_path("/sbin", "/root");
// Dump magiskinit as magisk
int fd = xopen("/sbin/magisk", O_WRONLY | O_CREAT, 0755);
write(fd, self.buf, self.sz);