mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-16 21:53:04 +00:00
Add busybox into PATH for scripts
This commit is contained in:
@@ -15,7 +15,7 @@ static int e2fsck(const char *img) {
|
||||
char buffer[128];
|
||||
int pid, fd = -1;
|
||||
char *const command[] = { "e2fsck", "-yf", (char *) img, NULL };
|
||||
pid = run_command(1, &fd, "/system/bin/e2fsck", command);
|
||||
pid = run_command(1, &fd, NULL, "/system/bin/e2fsck", command);
|
||||
if (pid < 0)
|
||||
return 1;
|
||||
while (fdgets(buffer, sizeof(buffer), fd))
|
||||
@@ -63,7 +63,7 @@ int create_img(const char *img, int size) {
|
||||
char buffer[16];
|
||||
snprintf(buffer, sizeof(buffer), "%dM", size);
|
||||
char *const command[] = { "make_ext4fs", "-l", buffer, "-a", "/magisk", "-S", filename, (char *) img, NULL };
|
||||
pid = run_command(0, NULL, "/system/bin/make_ext4fs", command);
|
||||
pid = run_command(0, NULL, NULL, "/system/bin/make_ext4fs", command);
|
||||
if (pid < 0)
|
||||
return 1;
|
||||
waitpid(pid, &status, 0);
|
||||
@@ -77,7 +77,7 @@ int get_img_size(const char *img, int *used, int *total) {
|
||||
char buffer[PATH_MAX];
|
||||
int pid, fd = -1, status = 1;
|
||||
char *const command[] = { "e2fsck", "-n", (char *) img, NULL };
|
||||
pid = run_command(1, &fd, "/system/bin/e2fsck", command);
|
||||
pid = run_command(1, &fd, NULL, "/system/bin/e2fsck", command);
|
||||
if (pid < 0)
|
||||
return 1;
|
||||
while (fdgets(buffer, sizeof(buffer), fd)) {
|
||||
@@ -110,7 +110,7 @@ int resize_img(const char *img, int size) {
|
||||
int pid, status, fd = -1;
|
||||
snprintf(buffer, sizeof(buffer), "%dM", size);
|
||||
char *const command[] = { "resize2fs", (char *) img, buffer, NULL };
|
||||
pid = run_command(1, &fd, "/system/bin/resize2fs", command);
|
||||
pid = run_command(1, &fd, NULL, "/system/bin/resize2fs", command);
|
||||
if (pid < 0)
|
||||
return 1;
|
||||
while (fdgets(buffer, sizeof(buffer), fd))
|
||||
|
@@ -223,8 +223,9 @@ void setup_sighandlers(void (*handler)(int)) {
|
||||
fd == NULL -> Ignore output
|
||||
*fd < 0 -> Open pipe and set *fd to the read end
|
||||
*fd >= 0 -> STDOUT (or STDERR) will be redirected to *fd
|
||||
*cb -> A callback function which runs after fork
|
||||
*/
|
||||
int run_command(int err, int *fd, const char *path, char *const argv[]) {
|
||||
int run_command(int err, int *fd, void (*cb)(void), const char *path, char *const argv[]) {
|
||||
int pipefd[2], writeEnd = -1;
|
||||
|
||||
if (fd) {
|
||||
@@ -247,6 +248,8 @@ int run_command(int err, int *fd, const char *path, char *const argv[]) {
|
||||
return pid;
|
||||
}
|
||||
|
||||
if (cb) cb();
|
||||
|
||||
if (fd) {
|
||||
xdup2(writeEnd, STDOUT_FILENO);
|
||||
if (err) xdup2(writeEnd, STDERR_FILENO);
|
||||
@@ -406,3 +409,11 @@ int switch_mnt_ns(int pid) {
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void link_busybox() {
|
||||
mkdir_p(BBPATH, 0755);
|
||||
char *const command[] = { "busybox", "--install", "-s", BBPATH, NULL};
|
||||
int pid = run_command(0, NULL, NULL, BBBIN, command);
|
||||
if (pid != -1)
|
||||
waitpid(pid, NULL, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user