Reorganize sources

This commit is contained in:
topjohnwu 2018-08-10 00:40:23 +08:00
parent 6add682705
commit 5bac442b18
9 changed files with 30 additions and 25 deletions

View File

@ -10,14 +10,12 @@ LIBLZ4 := $(EXT_PATH)/lz4/lib
LIBBZ2 := $(EXT_PATH)/bzip2
LIBFDT := $(EXT_PATH)/dtc/libfdt
LIBNANOPB := $(EXT_PATH)/nanopb
UTIL_SRC := utils/cpio.c \
utils/file.c \
utils/img.c \
utils/list.c \
utils/misc.c \
utils/pattern.c \
utils/vector.c \
utils/xwrap.c
COMMON_UTILS := \
utils/file.c \
utils/list.c \
utils/misc.c \
utils/vector.c \
utils/xwrap.c
########################
# Binaries
@ -55,7 +53,8 @@ LOCAL_SRC_FILES := \
su/pts.c \
su/su_daemon.c \
su/su_socket.c \
$(UTIL_SRC)
utils/img.c \
$(COMMON_UTILS)
LOCAL_CFLAGS := -DIS_DAEMON -DSELINUX
LOCAL_LDLIBS := -llog
@ -83,7 +82,7 @@ LOCAL_SRC_FILES := \
magiskpolicy/magiskpolicy.c \
magiskpolicy/rules.c \
magiskpolicy/sepolicy.c \
$(UTIL_SRC)
$(COMMON_UTILS)
LOCAL_LDFLAGS := -static
include $(BUILD_EXECUTABLE)
@ -105,6 +104,7 @@ LOCAL_C_INCLUDES := \
$(LIBFDT)
LOCAL_SRC_FILES := \
magiskboot/cpio.c \
magiskboot/main.c \
magiskboot/bootimg.c \
magiskboot/hexpatch.c \
@ -112,7 +112,8 @@ LOCAL_SRC_FILES := \
magiskboot/format.c \
magiskboot/dtb.c \
magiskboot/ramdisk.c \
$(UTIL_SRC)
magiskboot/pattern.c \
$(COMMON_UTILS)
LOCAL_CFLAGS := -DXWRAP_EXIT
LOCAL_LDLIBS := -lz

View File

@ -18,6 +18,7 @@
#include "magisk.h"
#include "db.h"
#include "utils.h"
#include "img.h"
#include "daemon.h"
#include "resetprop.h"
#include "magiskpolicy.h"

11
native/jni/include/img.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef IMG_H
#define IMG_H
int create_img(const char *img, int size);
int resize_img(const char *img, int size);
char *mount_image(const char *img, const char *target);
int umount_image(const char *target, const char *device);
int merge_img(const char *source, const char *target);
int trim_img(const char *img, const char *mount, char *loop);
#endif //IMG_H

View File

@ -147,18 +147,4 @@ void full_read_at(int dirfd, const char *filename, void **buf, size_t *size);
void stream_full_read(int fd, void **buf, size_t *size);
void write_zero(int fd, size_t size);
// img.c
int create_img(const char *img, int size);
int resize_img(const char *img, int size);
char *mount_image(const char *img, const char *target);
int umount_image(const char *target, const char *device);
int merge_img(const char *source, const char *target);
int trim_img(const char *img, const char *mount, char *loop);
// pattern.c
int patch_verity(void **buf, uint32_t *size, int patch);
void patch_encryption(void **buf, uint32_t *size);
#endif

View File

@ -32,4 +32,8 @@ size_t lz4_legacy(int mode, int fd, const void *buf, size_t size);
long long comp(format_t type, int to, const void *from, size_t size);
long long decomp(format_t type, int to, const void *from, size_t size);
// Pattern
int patch_verity(void **buf, uint32_t *size, int patch);
void patch_encryption(void **buf, uint32_t *size);
#endif

View File

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

View File

@ -14,6 +14,7 @@
#include "magisk.h"
#include "utils.h"
#include "img.h"
#define round_size(a) ((((a) / 32) + 2) * 32)
#define SOURCE_TMP "/dev/.img_src"