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
8c500709
Commit
8c500709
authored
Dec 12, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove SAR compatibility mode
parent
490e6a6f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
72 deletions
+14
-72
init.cpp
native/jni/init/init.cpp
+1
-4
init.h
native/jni/init/init.h
+12
-29
mount.cpp
native/jni/init/mount.cpp
+0
-28
rootdir.cpp
native/jni/init/rootdir.cpp
+1
-11
No files found.
native/jni/init/init.cpp
View file @
8c500709
...
...
@@ -220,10 +220,7 @@ int main(int argc, char *argv[]) {
if
(
cmd
.
force_normal_boot
)
{
init
=
make_unique
<
ABFirstStageInit
>
(
argv
,
&
cmd
);
}
else
if
(
cmd
.
skip_initramfs
)
{
if
(
access
(
"/overlay"
,
F_OK
)
==
0
)
/* Compatible mode */
init
=
make_unique
<
SARCompatInit
>
(
argv
,
&
cmd
);
else
init
=
make_unique
<
SARInit
>
(
argv
,
&
cmd
);
init
=
make_unique
<
SARInit
>
(
argv
,
&
cmd
);
}
else
{
decompress_ramdisk
();
if
(
access
(
"/sbin/recovery"
,
F_OK
)
==
0
||
access
(
"/system/bin/recovery"
,
F_OK
)
==
0
)
...
...
native/jni/init/init.h
View file @
8c500709
...
...
@@ -60,20 +60,6 @@ public:
MagiskInit
(
char
*
argv
[],
cmdline
*
cmd
)
:
BaseInit
(
argv
,
cmd
)
{};
};
class
RootFSBase
:
public
MagiskInit
{
protected
:
int
root
=
-
1
;
virtual
void
setup_rootfs
();
public
:
RootFSBase
(
char
*
argv
[],
cmdline
*
cmd
)
:
MagiskInit
(
argv
,
cmd
)
{};
void
start
()
override
{
early_mount
();
setup_rootfs
();
exec_init
();
}
};
class
SARBase
:
public
MagiskInit
{
protected
:
raw_data
config
;
...
...
@@ -95,7 +81,7 @@ public:
* *************/
class
ABFirstStageInit
:
public
BaseInit
{
pr
otected
:
pr
ivate
:
void
prepare
();
public
:
ABFirstStageInit
(
char
*
argv
[],
cmdline
*
cmd
)
:
BaseInit
(
argv
,
cmd
)
{};
...
...
@@ -106,7 +92,7 @@ public:
};
class
AFirstStageInit
:
public
BaseInit
{
pr
otected
:
pr
ivate
:
void
prepare
();
public
:
AFirstStageInit
(
char
*
argv
[],
cmdline
*
cmd
)
:
BaseInit
(
argv
,
cmd
)
{};
...
...
@@ -139,23 +125,20 @@ public:
* Initramfs
* **********/
class
RootFSInit
:
public
RootFSBase
{
class
RootFSInit
:
public
MagiskInit
{
private
:
int
root
=
-
1
;
void
setup_rootfs
();
protected
:
void
early_mount
()
override
;
public
:
RootFSInit
(
char
*
argv
[],
cmdline
*
cmd
)
:
RootFSBase
(
argv
,
cmd
)
{};
};
RootFSInit
(
char
*
argv
[],
cmdline
*
cmd
)
:
MagiskInit
(
argv
,
cmd
)
{};
/* ****************
* Compat-mode SAR
* ****************/
class
SARCompatInit
:
public
RootFSBase
{
protected
:
void
early_mount
()
override
;
void
setup_rootfs
()
override
;
public
:
SARCompatInit
(
char
*
argv
[],
cmdline
*
cmd
)
:
RootFSBase
(
argv
,
cmd
)
{};
void
start
()
override
{
early_mount
();
setup_rootfs
();
exec_init
();
}
};
void
load_kernel_info
(
cmdline
*
cmd
);
...
...
native/jni/init/mount.cpp
View file @
8c500709
...
...
@@ -112,10 +112,6 @@ static bool read_dt_fstab(cmdline *cmd, const char *name) {
return
false
;
}
#define link_root(name) \
if (is_lnk("/system_root" name)) \
cp_afc("/system_root" name, name)
#define mount_root(name) \
if (!is_lnk("/" #name) && read_dt_fstab(cmd, #name)) { \
LOGD("Early mount " #name "\n"); \
...
...
@@ -138,30 +134,6 @@ void RootFSInit::early_mount() {
mount_root
(
odm
);
}
void
SARCompatInit
::
early_mount
()
{
full_read
(
"/init"
,
self
.
buf
,
self
.
sz
);
LOGD
(
"Cleaning rootfs
\n
"
);
root
=
xopen
(
"/"
,
O_RDONLY
|
O_CLOEXEC
);
frm_rf
(
root
,
{
".backup"
,
"overlay"
,
"overlay.d"
,
"proc"
,
"sys"
});
LOGD
(
"Early mount system_root
\n
"
);
sprintf
(
partname
,
"system%s"
,
cmd
->
slot
);
setup_block
();
xmkdir
(
"/system_root"
,
0755
);
if
(
xmount
(
block_dev
,
"/system_root"
,
"ext4"
,
MS_RDONLY
,
nullptr
))
xmount
(
block_dev
,
"/system_root"
,
"erofs"
,
MS_RDONLY
,
nullptr
);
xmkdir
(
"/system"
,
0755
);
xmount
(
"/system_root/system"
,
"/system"
,
nullptr
,
MS_BIND
,
nullptr
);
link_root
(
"/vendor"
);
link_root
(
"/product"
);
link_root
(
"/odm"
);
mount_root
(
vendor
);
mount_root
(
product
);
mount_root
(
odm
);
}
static
void
switch_root
(
const
string
&
path
)
{
LOGD
(
"Switch root to %s
\n
"
,
path
.
data
());
vector
<
string
>
mounts
;
...
...
native/jni/init/rootdir.cpp
View file @
8c500709
...
...
@@ -85,7 +85,7 @@ static void load_overlay_rc(int dirfd) {
rewinddir
(
dir
);
}
void
RootFS
Base
::
setup_rootfs
()
{
void
RootFS
Init
::
setup_rootfs
()
{
if
(
patch_sepolicy
())
{
char
*
addr
;
size_t
size
;
...
...
@@ -141,16 +141,6 @@ void RootFSBase::setup_rootfs() {
close
(
fd
);
}
void
SARCompatInit
::
setup_rootfs
()
{
// Clone rootfs
LOGD
(
"Clone root dir from system to rootfs
\n
"
);
int
system_root
=
xopen
(
"/system_root"
,
O_RDONLY
|
O_CLOEXEC
);
clone_dir
(
system_root
,
root
,
false
);
close
(
system_root
);
RootFSBase
::
setup_rootfs
();
}
bool
MagiskInit
::
patch_sepolicy
(
const
char
*
file
)
{
bool
patch_init
=
false
;
...
...
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