mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-15 18:10:23 +00:00
Make sure uninstall.sh is executed on remove
This commit is contained in:
@@ -198,3 +198,17 @@ uint32_t binary_gcd(uint32_t u, uint32_t v) {
|
||||
} while (v != 0);
|
||||
return u << shift;
|
||||
}
|
||||
|
||||
int switch_mnt_ns(int pid) {
|
||||
char mnt[32];
|
||||
snprintf(mnt, sizeof(mnt), "/proc/%d/ns/mnt", pid);
|
||||
if (access(mnt, R_OK) == -1) return 1; // Maybe process died..
|
||||
|
||||
int fd, ret;
|
||||
fd = xopen(mnt, O_RDONLY);
|
||||
if (fd < 0) return 1;
|
||||
// Switch to its namespace
|
||||
ret = xsetns(fd, 0);
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ void init_argv0(int argc, char **argv);
|
||||
void set_nice_name(const char *name);
|
||||
int parse_int(const char *s);
|
||||
uint32_t binary_gcd(uint32_t u, uint32_t v);
|
||||
int switch_mnt_ns(int pid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -96,4 +97,4 @@ int exec_command_sync(Args &&...args) {
|
||||
|
||||
bool ends_with(const std::string_view &s1, const std::string_view &s2);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user