Clean/refactor includes

This commit is contained in:
topjohnwu 2019-02-10 03:57:51 -05:00
parent 5746614ccf
commit 71ecbb3af3
32 changed files with 91 additions and 85 deletions

View File

@ -4,8 +4,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "magisk.h" #include <magisk.h>
#include "selinux.h" #include <selinux.h>
static int (*applet_main[]) (int, char *[]) = static int (*applet_main[]) (int, char *[]) =
{ magisk_main, su_client_main, resetprop_main, magiskhide_main, imgtool_main, nullptr }; { magisk_main, su_client_main, resetprop_main, magiskhide_main, imgtool_main, nullptr };

View File

@ -14,13 +14,13 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/mount.h> #include <sys/mount.h>
#include "magisk.h" #include <magisk.h>
#include "utils.h" #include <utils.h>
#include "daemon.h" #include <daemon.h>
#include "selinux.h" #include <selinux.h>
#include "db.h" #include <db.h>
#include "resetprop.h" #include <resetprop.h>
#include "flags.h" #include <flags.h>
int SDK_INT = -1; int SDK_INT = -1;
struct stat SERVER_STAT; struct stat SERVER_STAT;

View File

@ -5,9 +5,9 @@
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "magisk.h" #include <magisk.h>
#include "db.h" #include <db.h>
#include "daemon.h" #include <daemon.h>
#define DB_VERSION 7 #define DB_VERSION 7

View File

@ -14,10 +14,10 @@
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <linux/loop.h> #include <linux/loop.h>
#include "magisk.h" #include <magisk.h>
#include "utils.h" #include <utils.h>
#include "img.h" #include <img.h>
#include "flags.h" #include <flags.h>
#define round_size(a) ((((a) / 32) + 2) * 32) #define round_size(a) ((((a) / 32) + 2) * 32)
#define SOURCE_TMP "/dev/.img_src" #define SOURCE_TMP "/dev/.img_src"

View File

@ -37,16 +37,15 @@
#include <string_view> #include <string_view>
#include <xz.h> #include <xz.h>
#include <magisk.h>
#include <magiskpolicy.h>
#include <selinux.h>
#include <utils.h>
#include <flags.h>
#include "binaries.h" #include "binaries.h"
#include "binaries_arch.h" #include "binaries_arch.h"
#include "magiskrc.h" #include "magiskrc.h"
#include "magisk.h"
#include "magiskpolicy.h"
#include "selinux.h"
#include "utils.h"
#include "flags.h"
#define DEFAULT_DT_DIR "/proc/device-tree/firmware/android" #define DEFAULT_DT_DIR "/proc/device-tree/firmware/android"

View File

@ -1,5 +1,5 @@
#include "magisk.h" #include <magisk.h>
#include "magiskpolicy.h" #include <magiskpolicy.h>
static const char magiskrc[] = static const char magiskrc[] =

View File

@ -6,10 +6,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <endian.h> #include <endian.h>
#include "daemon.h" #include <daemon.h>
#include "logging.h" #include <logging.h>
#include "utils.h" #include <utils.h>
#include "magisk.h" #include <magisk.h>
#define ABS_SOCKET_LEN(sun) (sizeof(sa_family_t) + strlen(sun->sun_path + 1) + 1) #define ABS_SOCKET_LEN(sun) (sizeof(sa_family_t) + strlen(sun->sun_path + 1) + 1)

View File

@ -4,7 +4,6 @@
#ifndef _DAEMON_H_ #ifndef _DAEMON_H_
#define _DAEMON_H_ #define _DAEMON_H_
#include <stdbool.h>
#include <pthread.h> #include <pthread.h>
#include <sys/un.h> #include <sys/un.h>
#include <sys/socket.h> #include <sys/socket.h>

View File

@ -27,7 +27,6 @@
#define SIMPLEMOUNT SECURE_DIR "/magisk_simple" #define SIMPLEMOUNT SECURE_DIR "/magisk_simple"
#define BOOTCOUNT SECURE_DIR "/.boot_count" #define BOOTCOUNT SECURE_DIR "/.boot_count"
#define MANAGERAPK DATABIN "/magisk.apk" #define MANAGERAPK DATABIN "/magisk.apk"
#define MAGISKRC "/init.magisk.rc"
// selinux consts // selinux consts
#define SELINUX_PATH "/sys/fs/selinux" #define SELINUX_PATH "/sys/fs/selinux"
@ -38,8 +37,6 @@
#define SEPOL_PROC_DOMAIN "magisk" #define SEPOL_PROC_DOMAIN "magisk"
#define SEPOL_FILE_DOMAIN "magisk_file" #define SEPOL_FILE_DOMAIN "magisk_file"
#define MAGISKHIDE_PROP "persist.magisk.hide"
extern char *argv0; /* For changing process name */ extern char *argv0; /* For changing process name */
extern int SDK_INT; extern int SDK_INT;

View File

@ -6,11 +6,11 @@
#include <mincrypt/sha.h> #include <mincrypt/sha.h>
#include <mincrypt/sha256.h> #include <mincrypt/sha256.h>
#include <utils.h>
#include <logging.h>
#include "bootimg.h" #include "bootimg.h"
#include "magiskboot.h" #include "magiskboot.h"
#include "utils.h"
#include "logging.h"
static void dump(void *buf, size_t size, const char *filename) { static void dump(void *buf, size_t size, const char *filename) {
if (size == 0) if (size == 0)

View File

@ -10,10 +10,10 @@
#include <lz4frame.h> #include <lz4frame.h>
#include <lz4hc.h> #include <lz4hc.h>
#include <bzlib.h> #include <bzlib.h>
#include <logging.h>
#include <utils.h>
#include "magiskboot.h" #include "magiskboot.h"
#include "logging.h"
#include "utils.h"
#define CHUNK 0x40000 #define CHUNK 0x40000

View File

@ -4,9 +4,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <algorithm>
#include <utils.h>
#include <logging.h>
#include "cpio.h" #include "cpio.h"
#include "utils.h"
#include "logging.h"
using namespace std; using namespace std;

View File

@ -3,9 +3,9 @@
extern "C" { extern "C" {
#include <libfdt.h> #include <libfdt.h>
} }
#include <utils.h>
#include "magiskboot.h" #include "magiskboot.h"
#include "utils.h"
static void print_props(const void *fdt, int node, int depth) { static void print_props(const void *fdt, int node, int depth) {
int prop; int prop;

View File

@ -3,8 +3,9 @@
#include <string.h> #include <string.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <utils.h>
#include "magiskboot.h" #include "magiskboot.h"
#include "utils.h"
static void hex2byte(uint8_t *hex, uint8_t *str) { static void hex2byte(uint8_t *hex, uint8_t *str) {
char high, low; char high, low;

View File

@ -5,11 +5,11 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <mincrypt/sha.h> #include <mincrypt/sha.h>
#include <logging.h>
#include <utils.h>
#include <flags.h>
#include "magiskboot.h" #include "magiskboot.h"
#include "logging.h"
#include "utils.h"
#include "flags.h"
/******************** /********************
Patch Boot Image Patch Boot Image

View File

@ -1,8 +1,9 @@
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include <utils.h>
#include "magiskboot.h" #include "magiskboot.h"
#include "utils.h"
static int check_verity_pattern(const char *s) { static int check_verity_pattern(const char *s) {
int skip = 0; int skip = 0;

View File

@ -2,9 +2,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <utils.h>
#include "magiskboot.h" #include "magiskboot.h"
#include "cpio.h" #include "cpio.h"
#include "utils.h"
using namespace std; using namespace std;

View File

@ -7,10 +7,11 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/types.h> #include <sys/types.h>
#include "magisk.h" #include <magisk.h>
#include <daemon.h>
#include <flags.h>
#include "magiskhide.h" #include "magiskhide.h"
#include "daemon.h"
#include "flags.h"
bool hide_enabled = false; bool hide_enabled = false;

View File

@ -8,11 +8,12 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <magisk.h>
#include <utils.h>
#include <flags.h>
#include "sepolicy.h" #include "sepolicy.h"
#include "magiskpolicy.h" #include "magiskpolicy.h"
#include "magisk.h"
#include "utils.h"
#include "flags.h"
using namespace std; using namespace std;

View File

@ -1,4 +1,5 @@
#include "magisk.h" #include <magisk.h>
#include "magiskpolicy.h" #include "magiskpolicy.h"
#include "sepolicy.h" #include "sepolicy.h"

View File

@ -19,10 +19,11 @@
#include <sepol/policydb/conditional.h> #include <sepol/policydb/conditional.h>
#include <sepol/policydb/constraint.h> #include <sepol/policydb/constraint.h>
#include "utils.h" #include <utils.h>
#include <logging.h>
#include "magiskpolicy.h" #include "magiskpolicy.h"
#include "sepolicy.h" #include "sepolicy.h"
#include "logging.h"
policydb_t *policydb = NULL; policydb_t *policydb = NULL;
extern int policydb_index_decls(sepol_handle_t * handle, policydb_t * p); extern int policydb_index_decls(sepol_handle_t * handle, policydb_t * p);

View File

@ -4,15 +4,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <vector> #include <vector>
#include <pb.h> #include <pb.h>
#include <pb_decode.h> #include <pb_decode.h>
#include <pb_encode.h> #include <pb_encode.h>
#include <utils.h>
#include "_resetprop.h" #include "_resetprop.h"
#include "utils.h"
using namespace std; using namespace std;

View File

@ -9,15 +9,15 @@
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <magisk.h>
#include <resetprop.h>
#include <utils.h>
#include <flags.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include "private/_system_properties.h" #include "private/_system_properties.h"
#include "private/system_properties.h" #include "private/system_properties.h"
#include "magisk.h"
#include "resetprop.h"
#include "_resetprop.h" #include "_resetprop.h"
#include "utils.h"
#include "flags.h"
using namespace std; using namespace std;

View File

@ -12,9 +12,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include "magisk.h" #include <magisk.h>
#include "daemon.h" #include <daemon.h>
#include "utils.h" #include <utils.h>
#include "su.h" #include "su.h"
#define BROADCAST_BOOT_COMPLETED \ #define BROADCAST_BOOT_COMPLETED \

View File

@ -17,7 +17,8 @@
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <pthread.h>
#include "magisk.h" #include <magisk.h>
#include "pts.h" #include "pts.h"
/** /**

View File

@ -21,12 +21,13 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "magisk.h" #include <magisk.h>
#include "daemon.h" #include <daemon.h>
#include "utils.h" #include <utils.h>
#include <flags.h>
#include "su.h" #include "su.h"
#include "pts.h" #include "pts.h"
#include "flags.h"
int quit_signals[] = { SIGALRM, SIGABRT, SIGHUP, SIGPIPE, SIGQUIT, SIGTERM, SIGINT, 0 }; int quit_signals[] = { SIGALRM, SIGABRT, SIGHUP, SIGPIPE, SIGQUIT, SIGTERM, SIGINT, 0 };

View File

@ -11,12 +11,13 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "magisk.h" #include <magisk.h>
#include "daemon.h" #include <daemon.h>
#include "utils.h" #include <utils.h>
#include <selinux.h>
#include "su.h" #include "su.h"
#include "pts.h" #include "pts.h"
#include "selinux.h"
#define LOCK_CACHE() pthread_mutex_lock(&cache_lock) #define LOCK_CACHE() pthread_mutex_lock(&cache_lock)
#define UNLOCK_CACHE() pthread_mutex_unlock(&cache_lock) #define UNLOCK_CACHE() pthread_mutex_unlock(&cache_lock)

View File

@ -11,9 +11,9 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <linux/fs.h> #include <linux/fs.h>
#include "magisk.h" #include <magisk.h>
#include "utils.h" #include <utils.h>
#include "selinux.h" #include <selinux.h>
using namespace std; using namespace std;

View File

@ -2,8 +2,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <android/log.h> #include <android/log.h>
#include "logging.h" #include <logging.h>
#include "flags.h" #include <flags.h>
int nop_log(const char *fmt, va_list ap) { int nop_log(const char *fmt, va_list ap) {
return 0; return 0;

View File

@ -13,8 +13,8 @@
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <vector> #include <vector>
#include "logging.h" #include <logging.h>
#include "utils.h" #include <utils.h>
using namespace std; using namespace std;

View File

@ -5,9 +5,9 @@
#include <syscall.h> #include <syscall.h>
#include <sys/xattr.h> #include <sys/xattr.h>
#include "magisk.h" #include <magisk.h>
#include "utils.h" #include <utils.h>
#include "selinux.h" #include <selinux.h>
#define UNLABEL_CON "u:object_r:unlabeled:s0" #define UNLABEL_CON "u:object_r:unlabeled:s0"
#define SYSTEM_CON "u:object_r:system_file:s0" #define SYSTEM_CON "u:object_r:system_file:s0"

View File

@ -22,8 +22,8 @@
#include <sys/sendfile.h> #include <sys/sendfile.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include "logging.h" #include <logging.h>
#include "utils.h" #include <utils.h>
FILE *xfopen(const char *pathname, const char *mode) { FILE *xfopen(const char *pathname, const char *mode) {
FILE *fp = fopen(pathname, mode); FILE *fp = fopen(pathname, mode);