Created
August 20, 2019 11:05
-
-
Save shakalaca/e9d95710101694e52aa67044d85e0555 to your computer and use it in GitHub Desktop.
build mkbootfs (Android Q)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cpio/Makefile b/cpio/Makefile | |
new file mode 100644 | |
index 000000000..c6b24f135 | |
--- /dev/null | |
+++ b/cpio/Makefile | |
@@ -0,0 +1,42 @@ | |
+#################### | |
+# COMPILER | |
+#################### | |
+CC=gcc | |
+CFLAGS+=-DALOGE=printf | |
+ | |
+CXX=g++ | |
+CXXFLAGS+=-g -std=c++11 | |
+ | |
+INCLUDE+=-I../libcutils/include | |
+INCLUDE+=-I../base/include | |
+INCLUDE+=-I../liblog/include | |
+INCLUDE+=-I../libutils/include | |
+ | |
+#################### | |
+# FILES | |
+#################### | |
+VPATH+=../libcutils | |
+CXX_SRC+=fs_config.cpp | |
+ | |
+VPATH+=../base | |
+CXX_SRC+=strings.cpp | |
+ | |
+C_SRC=mkbootfs.c | |
+ | |
+OBJ=$(CXX_SRC:.cpp=.o) $(C_SRC:.c=.o) | |
+BIN=mkbootfs | |
+ | |
+#################### | |
+# TARGETS | |
+#################### | |
+$(BIN): $(OBJ) | |
+ $(CXX) -o $@ $^ | |
+ | |
+%.o: %.c | |
+ $(CC) -o $@ -c $< $(CFLAGS) $(INCLUDE) | |
+ | |
+%.o: %.cpp | |
+ $(CXX) -o $@ -c $< $(CXXFLAGS) $(CFLAGS) $(INCLUDE) | |
+ | |
+clean: | |
+ rm -f $(OBJ) $(BIN) | |
diff --git a/cpio/mkbootfs.c b/cpio/mkbootfs.c | |
index e52762e9b..a79223609 100644 | |
--- a/cpio/mkbootfs.c | |
+++ b/cpio/mkbootfs.c | |
@@ -156,6 +156,16 @@ static int compare(const void* a, const void* b) { | |
return strcmp(*(const char**)a, *(const char**)b); | |
} | |
+static int _dot_exception(char *fname) { | |
+ if (!strcmp(".backup", fname)) { | |
+ return 1; | |
+ } | |
+ if (!strcmp(".magisk", fname)) { | |
+ return 1; | |
+ } | |
+ return 0; | |
+} | |
+ | |
static void _archive_dir(char *in, char *out, int ilen, int olen) | |
{ | |
int i, t; | |
@@ -180,7 +190,7 @@ static void _archive_dir(char *in, char *out, int ilen, int olen) | |
while((de = readdir(d)) != 0){ | |
/* xxx: feature? maybe some dotfiles are okay */ | |
- if(de->d_name[0] == '.') continue; | |
+ if(de->d_name[0] == '.' && !_dot_exception(de->d_name)) continue; | |
/* xxx: hack. use a real exclude list */ | |
if(!strcmp(de->d_name, "root")) continue; | |
diff --git a/libutils/include/utils/Compat.h b/libutils/include/utils/Compat.h | |
index dee577e36..7f7610e23 100644 | |
--- a/libutils/include/utils/Compat.h | |
+++ b/libutils/include/utils/Compat.h | |
@@ -19,6 +19,8 @@ | |
#include <unistd.h> | |
+#define typeof(x) std::remove_reference<decltype((x))>::type | |
+ | |
#if defined(__APPLE__) | |
/* Mac OS has always had a 64-bit off_t, so it doesn't have off64_t. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment