Skip to content

Commit

Permalink
Fix legacy rootfs devices
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Jan 25, 2021
1 parent 4cc41ec commit 3e47972
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion native/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
2 changes: 1 addition & 1 deletion native/jni/init/mount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions native/jni/init/rootdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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);
Expand Down

0 comments on commit 3e47972

Please sign in to comment.