mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 20:15:29 +00:00
Update exec functions signatures
This commit is contained in:
parent
b01a8cace6
commit
731455f164
@ -317,7 +317,7 @@ static void exec_common_script(const char* stage) {
|
||||
if (access(entry->d_name, X_OK) == -1)
|
||||
continue;
|
||||
LOGI("%s.d: exec [%s]\n", stage, entry->d_name);
|
||||
int pid = exec_command(0, nullptr,
|
||||
int pid = exec_command(false, nullptr,
|
||||
strcmp(stage, "post-fs-data") ? set_path : set_mirror_path,
|
||||
"sh", entry->d_name, nullptr);
|
||||
if (pid != -1)
|
||||
@ -336,8 +336,7 @@ static void exec_module_script(const char* stage) {
|
||||
if (access(buf2, F_OK) == -1 || access(buf, F_OK) == 0)
|
||||
continue;
|
||||
LOGI("%s: exec [%s.sh]\n", module, stage);
|
||||
int pid = exec_command(
|
||||
0, nullptr,
|
||||
int pid = exec_command(false, nullptr,
|
||||
strcmp(stage, "post-fs-data") ? set_path : set_mirror_path,
|
||||
"sh", buf2, nullptr);
|
||||
if (pid != -1)
|
||||
@ -555,7 +554,7 @@ static void install_apk(const char *apk) {
|
||||
sleep(5);
|
||||
LOGD("apk_install: attempting to install APK");
|
||||
int apk_res = -1, pid;
|
||||
pid = exec_command(1, &apk_res, nullptr, "/system/bin/pm", "install", "-r", apk, nullptr);
|
||||
pid = exec_command(true, &apk_res, nullptr, "/system/bin/pm", "install", "-r", apk, nullptr);
|
||||
if (pid != -1) {
|
||||
int err = 0;
|
||||
while (fdgets(buf, PATH_MAX, apk_res) > 0) {
|
||||
|
@ -83,7 +83,7 @@ static void *logcat_thread(void *) {
|
||||
char line[4096];
|
||||
while (1) {
|
||||
// Start logcat
|
||||
log_pid = exec_array(0, &log_fd, nullptr, log_cmd.data());
|
||||
log_pid = exec_array(false, &log_fd, nullptr, log_cmd.data());
|
||||
FILE *logs = fdopen(log_fd, "r");
|
||||
while (fgets(line, sizeof(line), logs)) {
|
||||
if (line[0] == '-')
|
||||
@ -104,7 +104,7 @@ static void *logcat_thread(void *) {
|
||||
|
||||
LOGI("magisklogd: logcat output EOF");
|
||||
// Clear buffer
|
||||
log_pid = exec_array(0, nullptr, nullptr, clear_cmd.data());
|
||||
log_pid = exec_array(false, nullptr, nullptr, clear_cmd.data());
|
||||
waitpid(log_pid, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
@ -91,8 +91,8 @@ unsigned get_system_uid();
|
||||
unsigned get_radio_uid();
|
||||
ssize_t fdgets(char *buf, size_t size, int fd);
|
||||
int is_num(const char *s);
|
||||
int exec_array(int err, int *fd, void (*cb)(void), const char *argv[]);
|
||||
int exec_command(int err, int *fd, void (*cb)(void), const char *argv0, ...);
|
||||
int exec_array(bool err, int *fd, void (*cb)(void), const char **argv);
|
||||
int exec_command(bool err, int *fd, void (*cb)(void), const char *argv0, ...);
|
||||
int exec_command_sync(const char *argv0, ...);
|
||||
int fork_dont_care();
|
||||
void gen_rand_str(char *buf, int len);
|
||||
|
@ -181,21 +181,21 @@ int __fsetxattr(int fd, const char *name, const void *value, size_t size, int fl
|
||||
}
|
||||
|
||||
/*
|
||||
fd == NULL -> Ignore output
|
||||
fd == nullptr -> 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 calls after forking
|
||||
*/
|
||||
int exec_array(int err, int *fd, void (*cb)(void), const char *argv[]) {
|
||||
int pipefd[2], write_end = -1;
|
||||
int exec_array(bool err, int *fd, void (*cb)(void), const char **argv) {
|
||||
int pipefd[2], outfd = -1;
|
||||
|
||||
if (fd) {
|
||||
if (*fd < 0) {
|
||||
if (xpipe2(pipefd, O_CLOEXEC) == -1)
|
||||
return -1;
|
||||
write_end = pipefd[1];
|
||||
outfd = pipefd[1];
|
||||
} else {
|
||||
write_end = *fd;
|
||||
outfd = *fd;
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,9 +210,9 @@ int exec_array(int err, int *fd, void (*cb)(void), const char *argv[]) {
|
||||
}
|
||||
|
||||
if (fd) {
|
||||
xdup2(write_end, STDOUT_FILENO);
|
||||
xdup2(outfd, STDOUT_FILENO);
|
||||
if (err)
|
||||
xdup2(write_end, STDERR_FILENO);
|
||||
xdup2(outfd, STDERR_FILENO);
|
||||
}
|
||||
|
||||
// Setup environment
|
||||
@ -224,7 +224,7 @@ int exec_array(int err, int *fd, void (*cb)(void), const char *argv[]) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int v_exec_command(int err, int *fd, void (*cb)(void), const char *argv0, va_list argv) {
|
||||
static int v_exec_command(bool err, int *fd, void (*cb)(void), const char *argv0, va_list argv) {
|
||||
// Collect va_list into vector
|
||||
Vector<const char *> args;
|
||||
args.push_back(argv0);
|
||||
@ -239,7 +239,7 @@ int exec_command_sync(const char *argv0, ...) {
|
||||
va_list argv;
|
||||
va_start(argv, argv0);
|
||||
int pid, status;
|
||||
pid = v_exec_command(0, NULL, NULL, argv0, argv);
|
||||
pid = v_exec_command(false, nullptr, nullptr, argv0, argv);
|
||||
va_end(argv);
|
||||
if (pid < 0)
|
||||
return pid;
|
||||
@ -247,7 +247,7 @@ int exec_command_sync(const char *argv0, ...) {
|
||||
return WEXITSTATUS(status);
|
||||
}
|
||||
|
||||
int exec_command(int err, int *fd, void (*cb)(void), const char *argv0, ...) {
|
||||
int exec_command(bool err, int *fd, void (*cb)(void), const char *argv0, ...) {
|
||||
va_list argv;
|
||||
va_start(argv, argv0);
|
||||
int pid = v_exec_command(err, fd, cb, argv0, argv);
|
||||
|
Loading…
Reference in New Issue
Block a user