Re-organize functions
This commit is contained in:
parent
b3e0d5ba58
commit
9275975b2c
@ -86,7 +86,7 @@ static void *logcat_thread(void *) {
|
||||
char line[4096];
|
||||
while (1) {
|
||||
// Start logcat
|
||||
log_pid = exec_array(false, &log_fd, nullptr, log_cmd.data());
|
||||
log_pid = exec_command(false, &log_fd, nullptr, log_cmd.data());
|
||||
FILE *logs = fdopen(log_fd, "r");
|
||||
while (fgets(line, sizeof(line), logs)) {
|
||||
if (line[0] == '-')
|
||||
@ -107,7 +107,7 @@ static void *logcat_thread(void *) {
|
||||
|
||||
LOGI("magisklogd: logcat output EOF");
|
||||
// Clear buffer
|
||||
log_pid = exec_array(false, nullptr, nullptr, clear_cmd.data());
|
||||
log_pid = exec_command(false, nullptr, nullptr, clear_cmd.data());
|
||||
waitpid(log_pid, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ boot_img::~boot_img() {
|
||||
#define CHROMEOS_RET 2
|
||||
#define ELF32_RET 3
|
||||
#define ELF64_RET 4
|
||||
#define pos_align() pos = align(pos, page_size())
|
||||
#define pos_align() pos = do_align(pos, page_size())
|
||||
|
||||
int boot_img::parse_image(const char * image) {
|
||||
mmap_ro(image, (void **) &map_addr, &map_size);
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define parse_align() lseek(fd, align(lseek(fd, 0, SEEK_CUR), 4), SEEK_SET)
|
||||
#define parse_align() lseek(fd, do_align(lseek(fd, 0, SEEK_CUR), 4), SEEK_SET)
|
||||
|
||||
static uint32_t x8u(char *hex) {
|
||||
uint32_t val, inpos = 8, outpos;
|
||||
|
@ -12,19 +12,6 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define str_contains(s, ss) ((ss) != nullptr && (s).find(ss) != string::npos)
|
||||
#define str_starts(s, ss) ((ss) != nullptr && (s).compare(0, strlen(ss), ss) == 0)
|
||||
|
||||
std::vector<std::string> file_to_vector(const char *filename);
|
||||
char *strdup2(const char *s, size_t *size = nullptr);
|
||||
|
||||
int exec_array(bool err, int *fd, void (*pre_exec)(), const char **argv);
|
||||
int exec_command(bool err, int *fd, void (*cb)(), const char *argv0, ...);
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@ -94,7 +81,6 @@ int xpoll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||
unsigned get_shell_uid();
|
||||
unsigned get_system_uid();
|
||||
unsigned get_radio_uid();
|
||||
int exec_command_sync(const char *argv0, ...);
|
||||
int fork_dont_care();
|
||||
void gen_rand_str(char *buf, int len);
|
||||
int strend(const char *s1, const char *s2);
|
||||
@ -109,8 +95,8 @@ int __fsetxattr(int fd, const char *name, const void *value, size_t size, int fl
|
||||
|
||||
// file.cpp
|
||||
|
||||
#define align(p, a) (((p) + (a) - 1) / (a) * (a))
|
||||
#define align_off(p, a) (align(p, a) - (p))
|
||||
#define do_align(p, a) (((p) + (a) - 1) / (a) * (a))
|
||||
#define align_off(p, a) (do_align(p, a) - (p))
|
||||
|
||||
extern const char **excl_list;
|
||||
|
||||
@ -148,6 +134,20 @@ void write_zero(int fd, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define str_contains(s, ss) ((ss) != nullptr && (s).find(ss) != string::npos)
|
||||
#define str_starts(s, ss) ((ss) != nullptr && (s).compare(0, strlen(ss), ss) == 0)
|
||||
|
||||
std::vector<std::string> file_to_vector(const char *filename);
|
||||
char *strdup2(const char *s, size_t *size = nullptr);
|
||||
|
||||
int exec_command(bool err, int *fd, void (*pre_exec)(), const char **argv);
|
||||
int exec_command(bool err, int *fd, void (*cb)(), const char *argv0, ...);
|
||||
int exec_command_sync(const char *argv0, ...);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -161,7 +161,7 @@ int __fsetxattr(int fd, const char *name, const void *value, size_t size, int fl
|
||||
*fd >= 0 -> STDOUT (or STDERR) will be redirected to *fd
|
||||
*pre_exec -> A callback function called after forking, before execvp
|
||||
*/
|
||||
int exec_array(bool err, int *fd, void (*pre_exec)(void), const char **argv) {
|
||||
int exec_command(bool err, int *fd, void (*pre_exec)(void), const char **argv) {
|
||||
int pipefd[2], outfd = -1;
|
||||
|
||||
if (fd) {
|
||||
@ -207,7 +207,7 @@ static int v_exec_command(bool err, int *fd, void (*cb)(void), const char *argv0
|
||||
for (const char *arg = va_arg(argv, char*); arg; arg = va_arg(argv, char*))
|
||||
args.push_back(arg);
|
||||
args.push_back(nullptr);
|
||||
int pid = exec_array(err, fd, cb, args.data());
|
||||
int pid = exec_command(err, fd, cb, args.data());
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user