You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Move MagiskInit to rust
This commit is contained in:
@@ -45,7 +45,7 @@ static void parse_device(devinfo *dev, const char *uevent) {
|
||||
});
|
||||
}
|
||||
|
||||
void MagiskInit::collect_devices() {
|
||||
void MagiskInit::collect_devices() const noexcept {
|
||||
char path[PATH_MAX];
|
||||
devinfo dev{};
|
||||
if (auto dir = xopen_dir("/sys/dev/block"); dir) {
|
||||
@@ -72,7 +72,7 @@ void MagiskInit::collect_devices() {
|
||||
}
|
||||
}
|
||||
|
||||
dev_t MagiskInit::find_block(const char *partname) {
|
||||
uint64_t MagiskInit::find_block(const char *partname) const noexcept {
|
||||
if (dev_list.empty())
|
||||
collect_devices();
|
||||
|
||||
@@ -103,7 +103,7 @@ dev_t MagiskInit::find_block(const char *partname) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MagiskInit::mount_preinit_dir() {
|
||||
void MagiskInit::mount_preinit_dir() const noexcept {
|
||||
if (preinit_dev.empty()) return;
|
||||
auto dev = find_block(preinit_dev.data());
|
||||
if (dev == 0) {
|
||||
@@ -143,7 +143,7 @@ void MagiskInit::mount_preinit_dir() {
|
||||
}
|
||||
}
|
||||
|
||||
bool MagiskInit::mount_system_root() {
|
||||
bool MagiskInit::mount_system_root() noexcept {
|
||||
LOGD("Mounting system_root\n");
|
||||
|
||||
// there's no /dev in stub cpio
|
||||
@@ -210,9 +210,10 @@ mount_root:
|
||||
return is_two_stage;
|
||||
}
|
||||
|
||||
void MagiskInit::exec_init() {
|
||||
void MagiskInit::exec_init() const noexcept {
|
||||
// Unmount in reverse order
|
||||
for (auto &p : reversed(mount_list)) {
|
||||
for (auto i = mount_list.size(); i > 0; --i) {
|
||||
auto &p = mount_list[i - 1];
|
||||
if (xumount2(p.data(), MNT_DETACH) == 0)
|
||||
LOGD("Unmount [%s]\n", p.data());
|
||||
}
|
||||
@@ -220,7 +221,7 @@ void MagiskInit::exec_init() {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void MagiskInit::prepare_data() {
|
||||
void MagiskInit::prepare_data() const noexcept {
|
||||
LOGD("Setup data tmp\n");
|
||||
xmkdir("/data", 0755);
|
||||
xmount("magisk", "/data", "tmpfs", 0, "mode=755");
|
||||
@@ -230,7 +231,7 @@ void MagiskInit::prepare_data() {
|
||||
cp_afc("/overlay.d", "/data/overlay.d");
|
||||
}
|
||||
|
||||
void MagiskInit::setup_tmp(const char *path) {
|
||||
void MagiskInit::setup_tmp(const char *path) const noexcept {
|
||||
LOGD("Setup Magisk tmp at %s\n", path);
|
||||
chdir("/data");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user