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
0f8f4e36
Commit
0f8f4e36
authored
May 10, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update collect log logic
parent
3733b589
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
19 deletions
+27
-19
bootstages.cpp
native/jni/core/bootstages.cpp
+27
-19
No files found.
native/jni/core/bootstages.cpp
View file @
0f8f4e36
...
...
@@ -189,18 +189,23 @@ void unlock_blocks() {
}
}
static
bool
log_dump
=
false
;
static
void
dump_logs
()
{
if
(
log_dump
)
static
void
collect_logs
(
bool
reset
)
{
static
bool
running
=
false
;
static
pthread_mutex_t
log_lock
=
PTHREAD_MUTEX_INITIALIZER
;
{
mutex_guard
lock
(
log_lock
);
if
(
running
)
return
;
int
test
=
exec_command_sync
(
"/system/bin/logcat"
,
"-d"
,
"-f"
,
"/dev/null"
);
chmod
(
"/dev/null"
,
0666
);
if
(
test
!=
0
)
return
;
running
=
true
;
}
if
(
reset
)
rename
(
LOGFILE
,
LOGFILE
".bak"
);
log_dump
=
true
;
// Start a daemon thread and wait indefinitely
new_daemon_thread
([]
()
->
void
{
new_daemon_thread
([]{
int
fd
=
xopen
(
LOGFILE
,
O_WRONLY
|
O_APPEND
|
O_CREAT
|
O_CLOEXEC
,
0644
);
exec_t
exec
{
.
fd
=
fd
,
...
...
@@ -209,7 +214,8 @@ static void dump_logs() {
int
pid
=
exec_command
(
exec
,
"/system/bin/logcat"
,
"-s"
,
"Magisk"
);
close
(
fd
);
if
(
pid
<
0
)
{
log_dump
=
false
;
mutex_guard
lock
(
log_lock
);
running
=
false
;
}
else
{
waitpid
(
pid
,
nullptr
,
0
);
}
...
...
@@ -220,7 +226,7 @@ static void dump_logs() {
* Entry points *
****************/
[[
noreturn
]]
static
void
unblock_boot_process
()
{
[[
noreturn
]]
static
void
exit_post_fs_data
()
{
close
(
xopen
(
UNBLOCKFILE
,
O_RDONLY
|
O_CREAT
,
0
));
pthread_exit
(
nullptr
);
}
...
...
@@ -234,9 +240,9 @@ void post_fs_data(int client) {
xmount
(
nullptr
,
"/"
,
nullptr
,
MS_REMOUNT
|
MS_RDONLY
,
nullptr
);
if
(
!
check_data
())
unblock_boot_process
();
exit_post_fs_data
();
dump_logs
(
);
collect_logs
(
true
);
LOGI
(
"** post-fs-data mode running
\n
"
);
...
...
@@ -249,12 +255,12 @@ void post_fs_data(int client) {
* will cause bootloops on FBE devices. */
LOGE
(
SECURE_DIR
" is not present, abort..."
);
no_secure_dir
=
true
;
unblock_boot_process
();
exit_post_fs_data
();
}
if
(
!
magisk_env
())
{
LOGE
(
"* Magisk environment setup incomplete, abort
\n
"
);
unblock_boot_process
();
exit_post_fs_data
();
}
if
(
getprop
(
"persist.sys.safemode"
,
true
)
==
"1"
)
{
...
...
@@ -272,7 +278,7 @@ void post_fs_data(int client) {
// We still want to do magic mount because root itself might need it
magic_mount
();
pfs_done
=
true
;
unblock_boot_process
();
exit_post_fs_data
();
}
void
late_start
(
int
client
)
{
...
...
@@ -281,7 +287,7 @@ void late_start(int client) {
write_int
(
client
,
0
);
close
(
client
);
dump_logs
(
);
collect_logs
(
false
);
if
(
no_secure_dir
)
{
// It's safe to create the folder at this point if the system didn't create it
...
...
@@ -313,6 +319,8 @@ void boot_complete(int client) {
write_int
(
client
,
0
);
close
(
client
);
collect_logs
(
false
);
if
(
!
pfs_done
||
safe_mode
)
return
;
...
...
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