mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 10:35:26 +00:00
Fix adbd on GSIs
This commit is contained in:
parent
d7d76f54cc
commit
a6958ac139
@ -534,8 +534,15 @@ void startup() {
|
|||||||
// Remove some traits of Magisk
|
// Remove some traits of Magisk
|
||||||
unlink("/init.magisk.rc");
|
unlink("/init.magisk.rc");
|
||||||
|
|
||||||
|
// GSIs will have to override /sbin/adbd with /system/bin/adbd
|
||||||
|
if (access("/sbin/adbd", F_OK) == 0 && access("/system/bin/adbd", F_OK) == 0) {
|
||||||
|
umount2("/sbin/adbd", MNT_DETACH);
|
||||||
|
cp_afc("/system/bin/adbd", "/sbin/adbd");
|
||||||
|
}
|
||||||
|
|
||||||
// Create hardlink mirror of /sbin to /root
|
// Create hardlink mirror of /sbin to /root
|
||||||
mkdir("/root", 0750);
|
mkdir("/root", 0750);
|
||||||
|
clone_attr("/sbin", "/root");
|
||||||
full_read("/sbin/magisk", &magisk, &magisk_size);
|
full_read("/sbin/magisk", &magisk, &magisk_size);
|
||||||
unlink("/sbin/magisk");
|
unlink("/sbin/magisk");
|
||||||
full_read("/sbin/magiskinit", &init, &init_size);
|
full_read("/sbin/magiskinit", &init, &init_size);
|
||||||
|
@ -166,7 +166,6 @@ void cp_afc(const char *source, const char *destination) {
|
|||||||
xmkdirs(destination, a.st.st_mode & 0777);
|
xmkdirs(destination, a.st.st_mode & 0777);
|
||||||
src = xopen(source, O_RDONLY | O_CLOEXEC);
|
src = xopen(source, O_RDONLY | O_CLOEXEC);
|
||||||
dest = xopen(destination, O_RDONLY | O_CLOEXEC);
|
dest = xopen(destination, O_RDONLY | O_CLOEXEC);
|
||||||
fsetattr(dest, &a);
|
|
||||||
clone_dir(src, dest);
|
clone_dir(src, dest);
|
||||||
close(src);
|
close(src);
|
||||||
close(dest);
|
close(dest);
|
||||||
@ -176,17 +175,16 @@ void cp_afc(const char *source, const char *destination) {
|
|||||||
src = xopen(source, O_RDONLY);
|
src = xopen(source, O_RDONLY);
|
||||||
dest = xopen(destination, O_WRONLY | O_CREAT | O_TRUNC);
|
dest = xopen(destination, O_WRONLY | O_CREAT | O_TRUNC);
|
||||||
xsendfile(dest, src, NULL, a.st.st_size);
|
xsendfile(dest, src, NULL, a.st.st_size);
|
||||||
fsetattr(src, &a);
|
|
||||||
close(src);
|
close(src);
|
||||||
close(dest);
|
close(dest);
|
||||||
} else if (S_ISLNK(a.st.st_mode)) {
|
} else if (S_ISLNK(a.st.st_mode)) {
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
xreadlink(source, buf, sizeof(buf));
|
xreadlink(source, buf, sizeof(buf));
|
||||||
xsymlink(buf, destination);
|
xsymlink(buf, destination);
|
||||||
|
}
|
||||||
|
}
|
||||||
setattr(destination, &a);
|
setattr(destination, &a);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void clone_dir(int src, int dest) {
|
void clone_dir(int src, int dest) {
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
|
Loading…
Reference in New Issue
Block a user