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
2a40cb60
Commit
2a40cb60
authored
Mar 22, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Behave more sane in extreme conditions
parent
d371d017
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
bootstages.cpp
native/jni/core/bootstages.cpp
+15
-9
No files found.
native/jni/core/bootstages.cpp
View file @
2a40cb60
...
@@ -29,6 +29,7 @@ using namespace std;
...
@@ -29,6 +29,7 @@ using namespace std;
static
char
buf
[
PATH_MAX
],
buf2
[
PATH_MAX
];
static
char
buf
[
PATH_MAX
],
buf2
[
PATH_MAX
];
static
vector
<
string
>
module_list
;
static
vector
<
string
>
module_list
;
static
bool
seperate_vendor
;
static
bool
seperate_vendor
;
static
bool
no_secure_dir
=
false
;
char
*
system_block
,
*
vendor_block
,
*
data_block
;
char
*
system_block
,
*
vendor_block
,
*
data_block
;
...
@@ -341,9 +342,11 @@ static bool magisk_env() {
...
@@ -341,9 +342,11 @@ static bool magisk_env() {
LOGI
(
"* Initializing Magisk environment
\n
"
);
LOGI
(
"* Initializing Magisk environment
\n
"
);
// Alternative binaries paths
// Alternative binaries paths
const
char
*
alt_bin
[]
=
{
"/cache/data_adb/magisk"
,
"/data/magisk"
,
constexpr
const
char
*
alt_bin
[]
=
{
"/data/data/com.topjohnwu.magisk/install"
,
"/cache/data_adb/magisk"
,
"/data/magisk"
,
"/data/user_de/0/com.topjohnwu.magisk/install"
};
"/data/data/com.topjohnwu.magisk/install"
,
"/data/user_de/0/com.topjohnwu.magisk/install"
};
for
(
auto
&
alt
:
alt_bin
)
{
for
(
auto
&
alt
:
alt_bin
)
{
struct
stat
st
;
struct
stat
st
;
if
(
lstat
(
alt
,
&
st
)
!=
-
1
)
{
if
(
lstat
(
alt
,
&
st
)
!=
-
1
)
{
...
@@ -363,17 +366,18 @@ static bool magisk_env() {
...
@@ -363,17 +366,18 @@ static bool magisk_env() {
unlink
(
"/data/magisk.img"
);
unlink
(
"/data/magisk.img"
);
unlink
(
"/data/magisk_debug.log"
);
unlink
(
"/data/magisk_debug.log"
);
//
Legacy support
//
Backwards compatibility
symlink
(
MAGISKTMP
,
"/sbin/.core"
);
symlink
(
MAGISKTMP
,
"/sbin/.core"
);
symlink
(
MODULEMNT
,
MAGISKTMP
"/img"
);
symlink
(
MODULEMNT
,
MAGISKTMP
"/img"
);
//
Create d
irectories in tmpfs overlay
//
D
irectories in tmpfs overlay
xmkdirs
(
MIRRDIR
"/system"
,
0755
);
xmkdirs
(
MIRRDIR
"/system"
,
0755
);
xmkdir
(
MIRRDIR
"/data"
,
0755
);
xmkdir
(
MIRRDIR
"/data"
,
0755
);
xmkdir
(
BBPATH
,
0755
);
xmkdir
(
BBPATH
,
0755
);
xmkdir
(
MODULEMNT
,
0755
);
xmkdir
(
MODULEMNT
,
0755
);
// /data/adb directories
// Directories in /data/adb
xmkdir
(
DATABIN
,
0755
);
xmkdir
(
MODULEROOT
,
0755
);
xmkdir
(
MODULEROOT
,
0755
);
xmkdir
(
SECURE_DIR
"/post-fs-data.d"
,
0755
);
xmkdir
(
SECURE_DIR
"/post-fs-data.d"
,
0755
);
xmkdir
(
SECURE_DIR
"/service.d"
,
0755
);
xmkdir
(
SECURE_DIR
"/service.d"
,
0755
);
...
@@ -600,6 +604,7 @@ void post_fs_data(int client) {
...
@@ -600,6 +604,7 @@ void post_fs_data(int client) {
* do NOT proceed further. Manual creation of the folder
* do NOT proceed further. Manual creation of the folder
* will cause bootloops on FBE devices. */
* will cause bootloops on FBE devices. */
LOGE
(
SECURE_DIR
" is not present, abort..."
);
LOGE
(
SECURE_DIR
" is not present, abort..."
);
no_secure_dir
=
true
;
unblock_boot_process
();
unblock_boot_process
();
}
}
...
@@ -619,7 +624,7 @@ void post_fs_data(int client) {
...
@@ -619,7 +624,7 @@ void post_fs_data(int client) {
fclose(cf);
fclose(cf);
#endif
#endif
// No
uninstaller or
core-only mode
// No
t
core-only mode
if
(
access
(
DISABLEFILE
,
F_OK
)
!=
0
)
{
if
(
access
(
DISABLEFILE
,
F_OK
)
!=
0
)
{
simple_mount
(
"/system"
);
simple_mount
(
"/system"
);
simple_mount
(
"/vendor"
);
simple_mount
(
"/vendor"
);
...
@@ -715,9 +720,10 @@ void late_start(int client) {
...
@@ -715,9 +720,10 @@ void late_start(int client) {
dump_logs
();
dump_logs
();
if
(
access
(
SECURE_DIR
,
F_OK
)
!=
0
)
{
if
(
no_secure_dir
)
{
// It's safe to create the folder at this point if the system didn't create it
// It's safe to create the folder at this point if the system didn't create it
xmkdir
(
SECURE_DIR
,
0700
);
if
(
access
(
SECURE_DIR
,
F_OK
)
!=
0
)
xmkdir
(
SECURE_DIR
,
0700
);
// And reboot to make proper setup possible
// And reboot to make proper setup possible
exec_command_sync
(
"/system/bin/reboot"
);
exec_command_sync
(
"/system/bin/reboot"
);
}
}
...
...
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