Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
e5c62f57
Commit
e5c62f57
authored
Dec 05, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow post-fs-data module scripts to change module state
parent
4084e879
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
27 deletions
+34
-27
bootstages.cpp
native/jni/daemon/bootstages.cpp
+34
-27
No files found.
native/jni/daemon/bootstages.cpp
View file @
e5c62f57
...
@@ -332,8 +332,7 @@ static void exec_common_script(const char* stage) {
...
@@ -332,8 +332,7 @@ static void exec_common_script(const char* stage) {
static
void
exec_module_script
(
const
char
*
stage
)
{
static
void
exec_module_script
(
const
char
*
stage
)
{
for
(
const
char
*
module
:
module_list
)
{
for
(
const
char
*
module
:
module_list
)
{
snprintf
(
buf2
,
PATH_MAX
,
"%s/%s/%s.sh"
,
MOUNTPOINT
,
module
,
stage
);
snprintf
(
buf2
,
PATH_MAX
,
"%s/%s/%s.sh"
,
MOUNTPOINT
,
module
,
stage
);
snprintf
(
buf
,
PATH_MAX
,
"%s/%s/disable"
,
MOUNTPOINT
,
module
);
if
(
access
(
buf2
,
F_OK
)
==
-
1
)
if
(
access
(
buf2
,
F_OK
)
==
-
1
||
access
(
buf
,
F_OK
)
==
0
)
continue
;
continue
;
LOGI
(
"%s: exec [%s.sh]
\n
"
,
module
,
stage
);
LOGI
(
"%s: exec [%s.sh]
\n
"
,
module
,
stage
);
int
pid
=
exec_command
(
false
,
nullptr
,
int
pid
=
exec_command
(
false
,
nullptr
,
...
@@ -489,6 +488,34 @@ static bool magisk_env() {
...
@@ -489,6 +488,34 @@ static bool magisk_env() {
return
true
;
return
true
;
}
}
static
void
collect_modules
()
{
chdir
(
MOUNTPOINT
);
DIR
*
dir
=
xopendir
(
"."
);
struct
dirent
*
entry
;
while
((
entry
=
xreaddir
(
dir
)))
{
if
(
entry
->
d_type
==
DT_DIR
)
{
if
(
strcmp
(
entry
->
d_name
,
"."
)
==
0
||
strcmp
(
entry
->
d_name
,
".."
)
==
0
||
strcmp
(
entry
->
d_name
,
".core"
)
==
0
||
strcmp
(
entry
->
d_name
,
"lost+found"
)
==
0
)
continue
;
chdir
(
entry
->
d_name
);
if
(
access
(
"remove"
,
F_OK
)
==
0
)
{
chdir
(
".."
);
LOGI
(
"%s: remove
\n
"
,
entry
->
d_name
);
rm_rf
(
entry
->
d_name
);
continue
;
}
unlink
(
"update"
);
if
(
access
(
"disable"
,
F_OK
))
module_list
.
push_back
(
entry
->
d_name
);
chdir
(
".."
);
}
}
closedir
(
dir
);
chdir
(
"/"
);
}
static
bool
prepare_img
()
{
static
bool
prepare_img
()
{
const
char
*
alt_img
[]
=
const
char
*
alt_img
[]
=
{
"/cache/magisk.img"
,
"/data/magisk_merge.img"
,
"/data/adb/magisk_merge.img"
};
{
"/cache/magisk.img"
,
"/data/magisk_merge.img"
,
"/data/adb/magisk_merge.img"
};
...
@@ -526,31 +553,7 @@ static bool prepare_img() {
...
@@ -526,31 +553,7 @@ static bool prepare_img() {
symlink
(
SECURE_DIR
"/post-fs-data.d"
,
LEGACY_CORE
"/post-fs-data.d"
);
symlink
(
SECURE_DIR
"/post-fs-data.d"
,
LEGACY_CORE
"/post-fs-data.d"
);
symlink
(
SECURE_DIR
"/service.d"
,
LEGACY_CORE
"/service.d"
);
symlink
(
SECURE_DIR
"/service.d"
,
LEGACY_CORE
"/service.d"
);
DIR
*
dir
=
xopendir
(
MOUNTPOINT
);
collect_modules
();
struct
dirent
*
entry
;
while
((
entry
=
xreaddir
(
dir
)))
{
if
(
entry
->
d_type
==
DT_DIR
)
{
if
(
strcmp
(
entry
->
d_name
,
"."
)
==
0
||
strcmp
(
entry
->
d_name
,
".."
)
==
0
||
strcmp
(
entry
->
d_name
,
".core"
)
==
0
||
strcmp
(
entry
->
d_name
,
"lost+found"
)
==
0
)
continue
;
snprintf
(
buf
,
PATH_MAX
,
"%s/%s"
,
MOUNTPOINT
,
entry
->
d_name
);
chdir
(
buf
);
if
(
access
(
"remove"
,
F_OK
)
==
0
)
{
chdir
(
".."
);
rm_rf
(
buf
);
continue
;
}
unlink
(
"update"
);
if
(
access
(
"disable"
,
F_OK
)
==
0
)
continue
;
module_list
.
push_back
(
entry
->
d_name
);
}
}
closedir
(
dir
);
chdir
(
"/"
);
return
trim_img
(
MAINIMG
,
MOUNTPOINT
,
magiskloop
)
==
0
;
return
trim_img
(
MAINIMG
,
MOUNTPOINT
,
magiskloop
)
==
0
;
}
}
...
@@ -805,6 +808,10 @@ void post_fs_data(int client) {
...
@@ -805,6 +808,10 @@ void post_fs_data(int client) {
LOGI
(
"* Running module post-fs-data scripts
\n
"
);
LOGI
(
"* Running module post-fs-data scripts
\n
"
);
exec_module_script
(
"post-fs-data"
);
exec_module_script
(
"post-fs-data"
);
// Recollect modules
module_list
.
clear
(
true
);
collect_modules
();
// Create the system root entry
// Create the system root entry
node_entry
*
sys_root
=
new
node_entry
(
"system"
,
IS_INTER
);
node_entry
*
sys_root
=
new
node_entry
(
"system"
,
IS_INTER
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment