Commit 00d3cb09 authored by vvb2060's avatar vvb2060 Committed by John Wu

magisk_node: check target exists

parent d35072d4
...@@ -522,6 +522,10 @@ public: ...@@ -522,6 +522,10 @@ public:
explicit magisk_node(const char *name) : node_entry(name, DT_REG, this) {} explicit magisk_node(const char *name) : node_entry(name, DT_REG, this) {}
void mount() override { void mount() override {
const string src = MAGISKTMP + "/" + name();
if (access(src.data(), F_OK))
return;
const string &dir_name = parent()->node_path(); const string &dir_name = parent()->node_path();
if (name() == "magisk") { if (name() == "magisk") {
for (int i = 0; applet_names[i]; ++i) { for (int i = 0; applet_names[i]; ++i) {
...@@ -534,7 +538,7 @@ public: ...@@ -534,7 +538,7 @@ public:
VLOGD("create", "./magiskpolicy", dest.data()); VLOGD("create", "./magiskpolicy", dest.data());
xsymlink("./magiskpolicy", dest.data()); xsymlink("./magiskpolicy", dest.data());
} }
create_and_mount(MAGISKTMP + "/" + name()); create_and_mount(src);
} }
}; };
...@@ -624,7 +628,7 @@ void magic_mount() { ...@@ -624,7 +628,7 @@ void magic_mount() {
if (!system->is_empty()) { if (!system->is_empty()) {
// Handle special read-only partitions // Handle special read-only partitions
for (const char *part : { "/vendor", "/product", "/system_ext" }) { for (const char *part : { "/vendor", "/product", "/system_ext" }) {
struct stat st; struct stat st{};
if (lstat(part, &st) == 0 && S_ISDIR(st.st_mode)) { if (lstat(part, &st) == 0 && S_ISDIR(st.st_mode)) {
if (auto old = system->extract(part + 1)) { if (auto old = system->extract(part + 1)) {
auto new_node = new root_node(old); auto new_node = new root_node(old);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment