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
ff0a7660
Commit
ff0a7660
authored
Dec 04, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect 2SI after system_root mount on legacy SAR
parent
dead7480
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
33 deletions
+21
-33
init.cpp
native/jni/init/init.cpp
+2
-6
init.hpp
native/jni/init/init.hpp
+7
-14
mount.cpp
native/jni/init/mount.cpp
+11
-12
twostage.cpp
native/jni/init/twostage.cpp
+1
-1
No files found.
native/jni/init/init.cpp
View file @
ff0a7660
...
@@ -166,18 +166,14 @@ int main(int argc, char *argv[]) {
...
@@ -166,18 +166,14 @@ int main(int argc, char *argv[]) {
// This will also mount /sys and /proc
// This will also mount /sys and /proc
load_kernel_info
(
&
cmd
);
load_kernel_info
(
&
cmd
);
bool
two_stage
=
check_two_stage
();
if
(
cmd
.
skip_initramfs
)
{
if
(
cmd
.
skip_initramfs
)
{
if
(
two_stage
)
init
=
new
SARInit
(
argv
,
&
cmd
);
init
=
new
SARFirstStageInit
(
argv
,
&
cmd
);
else
init
=
new
SARInit
(
argv
,
&
cmd
);
}
else
{
}
else
{
if
(
cmd
.
force_normal_boot
)
if
(
cmd
.
force_normal_boot
)
init
=
new
FirstStageInit
(
argv
,
&
cmd
);
init
=
new
FirstStageInit
(
argv
,
&
cmd
);
else
if
(
access
(
"/sbin/recovery"
,
F_OK
)
==
0
||
access
(
"/system/bin/recovery"
,
F_OK
)
==
0
)
else
if
(
access
(
"/sbin/recovery"
,
F_OK
)
==
0
||
access
(
"/system/bin/recovery"
,
F_OK
)
==
0
)
init
=
new
RecoveryInit
(
argv
,
&
cmd
);
init
=
new
RecoveryInit
(
argv
,
&
cmd
);
else
if
(
two_stage
)
else
if
(
check_two_stage
()
)
init
=
new
FirstStageInit
(
argv
,
&
cmd
);
init
=
new
FirstStageInit
(
argv
,
&
cmd
);
else
else
init
=
new
RootFSInit
(
argv
,
&
cmd
);
init
=
new
RootFSInit
(
argv
,
&
cmd
);
...
...
native/jni/init/init.hpp
View file @
ff0a7660
...
@@ -128,28 +128,21 @@ public:
...
@@ -128,28 +128,21 @@ public:
*************/
*************/
class
SARInit
:
public
SARBase
{
class
SARInit
:
public
SARBase
{
protected
:
void
early_mount
()
override
;
public
:
SARInit
(
char
*
argv
[],
cmdline
*
cmd
)
:
SARBase
(
argv
,
cmd
)
{
LOGD
(
"%s
\n
"
,
__FUNCTION__
);
};
};
// Special case for legacy SAR on Android 10+
// Should be followed by normal 2SI SecondStageInit
class
SARFirstStageInit
:
public
SARBase
{
private
:
private
:
void
prepare
();
bool
is_two_stage
;
void
first_stage_prep
();
protected
:
protected
:
void
early_mount
()
override
;
void
early_mount
()
override
;
public
:
public
:
SAR
FirstStageInit
(
char
*
argv
[],
cmdline
*
cmd
)
:
SARBase
(
argv
,
cmd
)
{
SAR
Init
(
char
*
argv
[],
cmdline
*
cmd
)
:
SARBase
(
argv
,
cmd
),
is_two_stage
(
false
)
{
LOGD
(
"%s
\n
"
,
__FUNCTION__
);
LOGD
(
"%s
\n
"
,
__FUNCTION__
);
};
};
void
start
()
override
{
void
start
()
override
{
early_mount
();
early_mount
();
prepare
();
if
(
is_two_stage
)
first_stage_prep
();
else
patch_rootdir
();
exec_init
();
exec_init
();
}
}
};
};
...
...
native/jni/init/mount.cpp
View file @
ff0a7660
...
@@ -338,23 +338,22 @@ mount_root:
...
@@ -338,23 +338,22 @@ mount_root:
}
}
void
SARInit
::
early_mount
()
{
void
SARInit
::
early_mount
()
{
// Make dev writable
xmkdir
(
"/dev"
,
0755
);
xmount
(
"tmpfs"
,
"/dev"
,
"tmpfs"
,
0
,
"mode=755"
);
mount_list
.
emplace_back
(
"/dev"
);
backup_files
();
backup_files
();
mount_system_root
();
mount_system_root
();
switch_root
(
"/system_root"
);
switch_root
(
"/system_root"
);
mount_with_dt
();
{
}
auto
init
=
raw_data
::
mmap_ro
(
"/init"
);
is_two_stage
=
init
.
contains
(
"selinux_setup"
);
}
void
SARFirstStageInit
::
early_mount
()
{
if
(
!
is_two_stage
)
{
backup_files
();
// Make dev writable
mount_system_root
();
xmkdir
(
"/dev"
,
0755
);
switch_root
(
"/system_root"
);
xmount
(
"tmpfs"
,
"/dev"
,
"tmpfs"
,
0
,
"mode=755"
);
mount_list
.
emplace_back
(
"/dev"
);
mount_with_dt
();
}
}
}
void
SecondStageInit
::
early_mount
()
{
void
SecondStageInit
::
early_mount
()
{
...
...
native/jni/init/twostage.cpp
View file @
ff0a7660
...
@@ -139,7 +139,7 @@ void FirstStageInit::prepare() {
...
@@ -139,7 +139,7 @@ void FirstStageInit::prepare() {
#define INIT_PATH "/system/bin/init"
#define INIT_PATH "/system/bin/init"
#define REDIR_PATH "/system/bin/am"
#define REDIR_PATH "/system/bin/am"
void
SAR
FirstStageInit
::
prepare
()
{
void
SAR
Init
::
first_stage_prep
()
{
int
pid
=
getpid
();
int
pid
=
getpid
();
xmount
(
"tmpfs"
,
"/dev"
,
"tmpfs"
,
0
,
"mode=755"
);
xmount
(
"tmpfs"
,
"/dev"
,
"tmpfs"
,
0
,
"mode=755"
);
...
...
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