diff --git a/jni/bootimgtools/Android.mk b/jni/bootimgtools/Android.mk index 1862c5d80..6d6fc8f6f 100644 --- a/jni/bootimgtools/Android.mk +++ b/jni/bootimgtools/Android.mk @@ -3,6 +3,6 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := bootimgtools LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := main.c extract.c repack.c hexpatch.c +LOCAL_SRC_FILES := main.c unpack.c repack.c hexpatch.c LOCAL_CFLAGS += -std=gnu11 include $(BUILD_EXECUTABLE) diff --git a/jni/bootimgtools/bootimg.h b/jni/bootimgtools/bootimg.h index 65f81b34e..3a7e46353 100644 --- a/jni/bootimgtools/bootimg.h +++ b/jni/bootimgtools/bootimg.h @@ -93,7 +93,7 @@ struct boot_img_hdr ** else: jump to kernel_addr */ -int extract(const char *image); +int unpack(const char *image); int repack(const char *image); int hexpatch(char *image, char *from, char *to); diff --git a/jni/bootimgtools/hexpatch.c b/jni/bootimgtools/hexpatch.c index 33a0ee10b..588e524cb 100644 --- a/jni/bootimgtools/hexpatch.c +++ b/jni/bootimgtools/hexpatch.c @@ -9,7 +9,7 @@ #include "bootimg.h" -int hex2int(char c) { +static int hex2int(char c) { int first = c / 16 - 3; int second = c % 16; int result = first * 10 + second; @@ -17,13 +17,13 @@ int hex2int(char c) { return result; } -int hex2ascii(char c, char d) { +static int hex2ascii(char c, char d) { int high = hex2int(c) * 16; int low = hex2int(d); return high+low; } -void hexstr2str(char *hex, char *str) { +static void hexstr2str(char *hex, char *str) { char buf = 0; for(int i = 0, length = strlen(hex); i < length; ++i){ if(i % 2){ diff --git a/jni/bootimgtools/main.c b/jni/bootimgtools/main.c index 3155bcefd..7ff39e5f9 100644 --- a/jni/bootimgtools/main.c +++ b/jni/bootimgtools/main.c @@ -7,22 +7,21 @@ Patch Boot Image *********************/ -int usage(char *arg0) { +static int usage(char *arg0) { fprintf(stderr, "Boot Image Unpack/Repack Tool\n"); - fprintf(stderr, "%s --extract \n", arg0); + fprintf(stderr, "%s --unpack \n", arg0); fprintf(stderr, " Unpack into current directory\n\n"); fprintf(stderr, "%s --repack \n", arg0); - fprintf(stderr, " Repack kernel, dt, ramdisk... from current directory to new-image.img\n is the image you've just unpacked\n\n"); + fprintf(stderr, " Repack kernel, dtb, ramdisk... from current directory to new-image.img\n is the image you've just unpacked\n\n"); fprintf(stderr, "%s --hexpatch \n", arg0); fprintf(stderr, " Search in , and replace with \n\n"); return 1; } -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { char ch; struct option long_options[] = { - {"extract", required_argument, NULL, 'e'}, + {"unpack", required_argument, NULL, 'u'}, {"repack", required_argument, NULL, 'r'}, {"hexpatch", required_argument, NULL, 'p'}, {NULL, 0, NULL, 0} @@ -30,7 +29,7 @@ int main(int argc, char *argv[]) while ((ch = getopt_long(argc, argv, "e:r:p:", long_options, NULL)) != -1) { switch (ch) { case 'e': - return extract(optarg); + return unpack(optarg); case 'r': return repack(optarg); case 'p': @@ -42,4 +41,4 @@ int main(int argc, char *argv[]) } } return 0; -} \ No newline at end of file +} diff --git a/jni/bootimgtools/repack.c b/jni/bootimgtools/repack.c index 9c3ac2123..23c443bf7 100644 --- a/jni/bootimgtools/repack.c +++ b/jni/bootimgtools/repack.c @@ -12,8 +12,8 @@ #include "bootimg.h" // Global pointer of current positions -void *ibase, *ipos; -int ofd, opos; +static void *ibase, *ipos; +static int ofd, opos; static size_t dump(const char *filename) { int fd = open(filename, O_RDONLY); @@ -60,7 +60,7 @@ static int aosp() { printf("AOSP Boot Image Detected\n"); char *name; - struct boot_img_hdr hdr, ihdr; + boot_img_hdr hdr, ihdr; // Read the original header memcpy(&ihdr, ibase, sizeof(ihdr)); diff --git a/jni/bootimgtools/extract.c b/jni/bootimgtools/unpack.c similarity index 97% rename from jni/bootimgtools/extract.c rename to jni/bootimgtools/unpack.c index 71735781c..5b0e48bb3 100644 --- a/jni/bootimgtools/extract.c +++ b/jni/bootimgtools/unpack.c @@ -12,7 +12,7 @@ #include "bootimg.h" // Global pointer of current positions -unsigned char *base, *pos; +static unsigned char *base, *pos; static void dump(size_t size, const char *filename) { unlink(filename); @@ -37,7 +37,7 @@ static int aosp() { char name[PATH_MAX], *ext; // Read the header - struct boot_img_hdr hdr; + boot_img_hdr hdr; memcpy(&hdr, base, sizeof(hdr)); pos = base + hdr.page_size; @@ -108,7 +108,7 @@ static int aosp() { return 0; } -int extract(const char* image) { +int unpack(const char* image) { int fd = open(image, O_RDONLY), ret = 0; size_t size = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET);