Allow entrypoint for rootfs construction simulation

This commit is contained in:
topjohnwu 2019-03-16 04:45:56 -04:00
parent 8893cbd64a
commit c0447009db
2 changed files with 13 additions and 3 deletions

View File

@ -53,7 +53,12 @@
#define DEFAULT_DT_DIR "/proc/device-tree/firmware/android" #define DEFAULT_DT_DIR "/proc/device-tree/firmware/android"
int (*init_applet_main[])(int, char *[]) = { magiskpolicy_main, magiskpolicy_main, nullptr }; static int test_main(int argc, char *argv[]);
constexpr const char *init_applet[] =
{ "magiskpolicy", "supolicy", "init_test", nullptr };
constexpr int (*init_applet_main[])(int, char *[]) =
{ magiskpolicy_main, magiskpolicy_main, test_main, nullptr };
struct cmdline { struct cmdline {
bool system_as_root; bool system_as_root;
@ -597,7 +602,7 @@ void MagiskInit::test() {
cmdline_logging(); cmdline_logging();
log_cb.ex = nop_ex; log_cb.ex = nop_ex;
chdir(argv[1]); chdir(dirname(argv[0]));
chroot("."); chroot(".");
chdir("/"); chdir("/");
@ -608,6 +613,12 @@ void MagiskInit::test() {
cleanup(); cleanup();
} }
static int test_main(int argc, char *argv[]) {
MagiskInit init(argv);
init.test();
return 0;
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
umask(0); umask(0);

View File

@ -29,7 +29,6 @@
extern int SDK_INT; extern int SDK_INT;
constexpr const char *applet_names[] = { "magisk", "su", "resetprop", "magiskhide", nullptr }; constexpr const char *applet_names[] = { "magisk", "su", "resetprop", "magiskhide", nullptr };
constexpr const char *init_applet[] = { "magiskpolicy", "supolicy", nullptr };
// Multi-call entrypoints // Multi-call entrypoints
int magisk_main(int argc, char *argv[]); int magisk_main(int argc, char *argv[]);