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
ba55e2bc
Commit
ba55e2bc
authored
Jan 21, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backup proper magiskinit in A-only 2SI
parent
0a2c99f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
init.h
native/jni/init/init.h
+1
-1
mount.cpp
native/jni/init/mount.cpp
+4
-4
rootdir.cpp
native/jni/init/rootdir.cpp
+16
-12
No files found.
native/jni/init/init.h
View file @
ba55e2bc
...
@@ -68,7 +68,7 @@ protected:
...
@@ -68,7 +68,7 @@ protected:
raw_data
config
;
raw_data
config
;
dev_t
system_dev
;
dev_t
system_dev
;
void
backup_files
();
void
backup_files
(
const
char
*
self_path
);
void
patch_rootdir
();
void
patch_rootdir
();
public
:
public
:
SARBase
(
char
*
argv
[],
cmdline
*
cmd
)
:
MagiskInit
(
argv
,
cmd
)
{
SARBase
(
char
*
argv
[],
cmdline
*
cmd
)
:
MagiskInit
(
argv
,
cmd
)
{
...
...
native/jni/init/mount.cpp
View file @
ba55e2bc
...
@@ -183,11 +183,11 @@ void RootFSInit::early_mount() {
...
@@ -183,11 +183,11 @@ void RootFSInit::early_mount() {
mount_list
.
emplace_back
(
"/dev/mnt/cache"
);
mount_list
.
emplace_back
(
"/dev/mnt/cache"
);
}
}
void
SARBase
::
backup_files
()
{
void
SARBase
::
backup_files
(
const
char
*
self_path
)
{
if
(
access
(
"/overlay.d"
,
F_OK
)
==
0
)
if
(
access
(
"/overlay.d"
,
F_OK
)
==
0
)
cp_afc
(
"/overlay.d"
,
"/dev/overlay.d"
);
cp_afc
(
"/overlay.d"
,
"/dev/overlay.d"
);
full_read
(
"/init"
,
self
.
buf
,
self
.
sz
);
full_read
(
self_path
,
self
.
buf
,
self
.
sz
);
full_read
(
"/.backup/.magisk"
,
config
.
buf
,
config
.
sz
);
full_read
(
"/.backup/.magisk"
,
config
.
buf
,
config
.
sz
);
}
}
...
@@ -197,7 +197,7 @@ void SARInit::early_mount() {
...
@@ -197,7 +197,7 @@ void SARInit::early_mount() {
xmount
(
"tmpfs"
,
"/dev"
,
"tmpfs"
,
0
,
"mode=755"
);
xmount
(
"tmpfs"
,
"/dev"
,
"tmpfs"
,
0
,
"mode=755"
);
mount_list
.
emplace_back
(
"/dev"
);
mount_list
.
emplace_back
(
"/dev"
);
backup_files
();
backup_files
(
"/init"
);
LOGD
(
"Cleaning rootfs
\n
"
);
LOGD
(
"Cleaning rootfs
\n
"
);
int
root
=
xopen
(
"/"
,
O_RDONLY
|
O_CLOEXEC
);
int
root
=
xopen
(
"/"
,
O_RDONLY
|
O_CLOEXEC
);
...
@@ -232,7 +232,7 @@ void SARInit::early_mount() {
...
@@ -232,7 +232,7 @@ void SARInit::early_mount() {
void
SecondStageInit
::
early_mount
()
{
void
SecondStageInit
::
early_mount
()
{
// Early mounts should already be done by first stage init
// Early mounts should already be done by first stage init
backup_files
();
backup_files
(
"/system/bin/init"
);
rm_rf
(
"/system"
);
rm_rf
(
"/system"
);
rm_rf
(
"/.backup"
);
rm_rf
(
"/.backup"
);
rm_rf
(
"/overlay.d"
);
rm_rf
(
"/overlay.d"
);
...
...
native/jni/init/rootdir.cpp
View file @
ba55e2bc
...
@@ -407,20 +407,24 @@ static void patch_fstab(const string &fstab) {
...
@@ -407,20 +407,24 @@ static void patch_fstab(const string &fstab) {
#define FSR "/first_stage_ramdisk"
#define FSR "/first_stage_ramdisk"
void
ABFirstStageInit
::
prepare
()
{
void
ABFirstStageInit
::
prepare
()
{
auto
dir
=
xopen_dir
(
FSR
);
// It is actually possible to NOT have FSR, create it just in case
if
(
!
dir
)
xmkdir
(
FSR
,
0755
);
return
;
string
fstab
(
FSR
"/"
);
if
(
auto
dir
=
xopen_dir
(
FSR
);
dir
)
{
for
(
dirent
*
de
;
(
de
=
xreaddir
(
dir
.
get
()));)
{
string
fstab
(
FSR
"/"
);
if
(
strstr
(
de
->
d_name
,
"fstab"
))
{
for
(
dirent
*
de
;
(
de
=
xreaddir
(
dir
.
get
()));)
{
fstab
+=
de
->
d_name
;
if
(
strstr
(
de
->
d_name
,
"fstab"
))
{
break
;
fstab
+=
de
->
d_name
;
break
;
}
}
}
}
if
(
fstab
.
length
()
==
sizeof
(
FSR
))
if
(
fstab
.
length
()
==
sizeof
(
FSR
))
return
;
return
;
patch_fstab
(
fstab
);
patch_fstab
(
fstab
);
}
else
{
return
;
}
// Move stuffs for next stage
// Move stuffs for next stage
xmkdir
(
FSR
"/system"
,
0755
);
xmkdir
(
FSR
"/system"
,
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