Skip to content

Commit

Permalink
Reorganize sources
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Aug 9, 2018
1 parent 6add682 commit 5bac442
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 25 deletions.
23 changes: 12 additions & 11 deletions native/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -105,14 +104,16 @@ LOCAL_C_INCLUDES := \
$(LIBFDT)

LOCAL_SRC_FILES := \
magiskboot/cpio.c \
magiskboot/main.c \
magiskboot/bootimg.c \
magiskboot/hexpatch.c \
magiskboot/compress.c \
magiskboot/format.c \
magiskboot/dtb.c \
magiskboot/ramdisk.c \
$(UTIL_SRC)
magiskboot/pattern.c \
$(COMMON_UTILS)

LOCAL_CFLAGS := -DXWRAP_EXIT
LOCAL_LDLIBS := -lz
Expand Down
1 change: 1 addition & 0 deletions native/jni/core/bootstages.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions native/jni/include/img.h
Original file line number Diff line number Diff line change
@@ -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
14 changes: 0 additions & 14 deletions native/jni/include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions native/jni/magiskboot/magiskboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <string.h>

#include "utils.h"
#include "magiskboot.h"

static int check_verity_pattern(const char *s) {
int skip = 0;
Expand Down
1 change: 1 addition & 0 deletions native/jni/utils/img.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5bac442

Please sign in to comment.