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
62ef8ade
Unverified
Commit
62ef8ade
authored
Dec 29, 2021
by
LoveSy
Committed by
GitHub
Dec 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip loading Magisk when detecting DSU
Fix #4402 Co-authored-by:
topjohnwu
<
topjohnwu@gmail.com
>
parent
3d88dd31
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
init.hpp
native/jni/init/init.hpp
+1
-0
mount.cpp
native/jni/init/mount.cpp
+22
-1
twostage.cpp
native/jni/init/twostage.cpp
+6
-0
No files found.
native/jni/init/init.hpp
View file @
62ef8ade
...
@@ -38,6 +38,7 @@ extern std::vector<std::string> mount_list;
...
@@ -38,6 +38,7 @@ extern std::vector<std::string> mount_list;
bool
unxz
(
int
fd
,
const
uint8_t
*
buf
,
size_t
size
);
bool
unxz
(
int
fd
,
const
uint8_t
*
buf
,
size_t
size
);
void
load_kernel_info
(
BootConfig
*
config
);
void
load_kernel_info
(
BootConfig
*
config
);
bool
is_dsu
();
bool
check_two_stage
();
bool
check_two_stage
();
void
setup_klog
();
void
setup_klog
();
const
char
*
backup_init
();
const
char
*
backup_init
();
...
...
native/jni/init/mount.cpp
View file @
62ef8ade
...
@@ -93,7 +93,7 @@ static int64_t setup_block(bool write_block) {
...
@@ -93,7 +93,7 @@ static int64_t setup_block(bool write_block) {
}
}
static
bool
is_lnk
(
const
char
*
name
)
{
static
bool
is_lnk
(
const
char
*
name
)
{
struct
stat
st
;
struct
stat
st
{}
;
if
(
lstat
(
name
,
&
st
))
if
(
lstat
(
name
,
&
st
))
return
false
;
return
false
;
return
S_ISLNK
(
st
.
st_mode
);
return
S_ISLNK
(
st
.
st_mode
);
...
@@ -196,6 +196,27 @@ static void switch_root(const string &path) {
...
@@ -196,6 +196,27 @@ static void switch_root(const string &path) {
frm_rf
(
root
);
frm_rf
(
root
);
}
}
bool
is_dsu
()
{
strcpy
(
blk_info
.
partname
,
"metadata"
);
xmkdir
(
"/metadata"
,
0755
);
if
(
setup_block
(
true
)
<
0
||
xmount
(
blk_info
.
block_dev
,
"/metadata"
,
"ext4"
,
MS_RDONLY
,
nullptr
))
{
PLOGE
(
"Failed to mount /metadata"
);
return
false
;
}
else
{
run_finally
f
([]{
xumount2
(
"/metadata"
,
MNT_DETACH
);
});
constexpr
auto
dsu_status
=
"/metadata/gsi/dsu/install_status"
;
if
(
xaccess
(
dsu_status
,
F_OK
)
==
0
)
{
char
status
[
PATH_MAX
]
=
{
0
};
auto
fp
=
xopen_file
(
dsu_status
,
"r"
);
fgets
(
status
,
sizeof
(
status
),
fp
.
get
());
if
(
status
==
"ok"
sv
||
status
==
"0"
sv
)
return
true
;
}
}
return
false
;
}
void
MagiskInit
::
mount_rules_dir
(
const
char
*
dev_base
,
const
char
*
mnt_base
)
{
void
MagiskInit
::
mount_rules_dir
(
const
char
*
dev_base
,
const
char
*
mnt_base
)
{
char
path
[
128
];
char
path
[
128
];
xrealpath
(
dev_base
,
blk_info
.
block_dev
);
xrealpath
(
dev_base
,
blk_info
.
block_dev
);
...
...
native/jni/init/twostage.cpp
View file @
62ef8ade
...
@@ -63,6 +63,12 @@ static bool read_fstab_file(const char *fstab_file, vector<fstab_entry> &fstab)
...
@@ -63,6 +63,12 @@ static bool read_fstab_file(const char *fstab_file, vector<fstab_entry> &fstab)
extern
uint32_t
patch_verity
(
void
*
buf
,
uint32_t
size
);
extern
uint32_t
patch_verity
(
void
*
buf
,
uint32_t
size
);
void
FirstStageInit
::
prepare
()
{
void
FirstStageInit
::
prepare
()
{
if
(
is_dsu
())
{
rename
(
backup_init
(),
"/init"
);
LOGI
(
"Skip loading Magisk because of DSU
\n
"
);
return
;
}
run_finally
finally
([]{
chdir
(
"/"
);
});
run_finally
finally
([]{
chdir
(
"/"
);
});
if
(
config
->
force_normal_boot
)
{
if
(
config
->
force_normal_boot
)
{
xmkdirs
(
FSR
"/system/bin"
,
0755
);
xmkdirs
(
FSR
"/system/bin"
,
0755
);
...
...
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