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
d959c357
Commit
d959c357
authored
Apr 19, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make cleaner mount info
parent
69a9d748
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
12 deletions
+17
-12
module.cpp
native/jni/core/module.cpp
+1
-1
init.hpp
native/jni/init/init.hpp
+0
-1
mount.cpp
native/jni/init/mount.cpp
+4
-2
rootdir.cpp
native/jni/init/rootdir.cpp
+12
-8
No files found.
native/jni/core/module.cpp
View file @
d959c357
native/jni/init/init.hpp
View file @
d959c357
...
@@ -69,7 +69,6 @@ class SARBase : public MagiskInit {
...
@@ -69,7 +69,6 @@ class SARBase : public MagiskInit {
protected
:
protected
:
raw_data
config
;
raw_data
config
;
std
::
vector
<
raw_file
>
overlays
;
std
::
vector
<
raw_file
>
overlays
;
std
::
string
tmp_dir
;
void
backup_files
();
void
backup_files
();
void
patch_rootdir
();
void
patch_rootdir
();
...
...
native/jni/init/mount.cpp
View file @
d959c357
...
@@ -153,11 +153,13 @@ static void switch_root(const string &path) {
...
@@ -153,11 +153,13 @@ static void switch_root(const string &path) {
static
void
mount_persist
(
const
char
*
dev_base
,
const
char
*
mnt_base
)
{
static
void
mount_persist
(
const
char
*
dev_base
,
const
char
*
mnt_base
)
{
string
mnt_point
=
mnt_base
+
"/persist"
s
;
string
mnt_point
=
mnt_base
+
"/persist"
s
;
strcpy
(
partname
,
"persist"
);
strcpy
(
partname
,
"persist"
);
sprintf
(
block_dev
,
"%s/persist"
,
dev_base
);
xrealpath
(
dev_base
,
block_dev
);
char
*
s
=
block_dev
+
strlen
(
block_dev
);
strcpy
(
s
,
"/persist"
);
if
(
setup_block
(
false
)
<
0
)
{
if
(
setup_block
(
false
)
<
0
)
{
// Fallback to cache
// Fallback to cache
strcpy
(
partname
,
"cache"
);
strcpy
(
partname
,
"cache"
);
s
printf
(
block_dev
,
"%s/cache"
,
dev_base
);
s
trcpy
(
s
,
"/cache"
);
if
(
setup_block
(
false
)
<
0
)
{
if
(
setup_block
(
false
)
<
0
)
{
// Try NVIDIA's BS
// Try NVIDIA's BS
strcpy
(
partname
,
"CAC"
);
strcpy
(
partname
,
"CAC"
);
...
...
native/jni/init/rootdir.cpp
View file @
d959c357
...
@@ -222,24 +222,28 @@ static void magic_mount(const string &sdir, const string &ddir = "") {
...
@@ -222,24 +222,28 @@ static void magic_mount(const string &sdir, const string &ddir = "") {
#define LIBSELINUX "/system/" LIBNAME "/libselinux.so"
#define LIBSELINUX "/system/" LIBNAME "/libselinux.so"
void
SARBase
::
patch_rootdir
()
{
void
SARBase
::
patch_rootdir
()
{
char
tmp_dir
[
128
];
// TODO: dynamic paths
// TODO: dynamic paths
tmp_dir
=
"/sbin"
;
char
*
p
=
tmp_dir
+
sprintf
(
tmp_dir
,
"%s"
,
"/sbin"
)
;
setup_tmp
(
tmp_dir
.
data
()
,
self
,
config
);
setup_tmp
(
tmp_dir
,
self
,
config
);
persist_dir
=
tmp_dir
+
"/"
MIRRDIR
"/persist"
;
persist_dir
=
string
(
tmp_dir
)
+
"/"
MIRRDIR
"/persist"
;
chdir
(
tmp_dir
.
data
()
);
chdir
(
tmp_dir
);
// Mount system_root mirror
// Mount system_root mirror
struct
stat
st
;
struct
stat
st
;
xstat
(
"/"
,
&
st
);
xstat
(
"/"
,
&
st
);
xmkdir
(
ROOTMIR
,
0755
);
xmkdir
(
ROOTMIR
,
0755
);
mknod
(
ROOTBLK
,
S_IFBLK
|
0600
,
st
.
st_dev
);
mknod
(
ROOTBLK
,
S_IFBLK
|
0600
,
st
.
st_dev
);
if
(
xmount
(
ROOTBLK
,
ROOTMIR
,
"ext4"
,
MS_RDONLY
,
nullptr
))
strcpy
(
p
,
"/"
ROOTBLK
);
xmount
(
ROOTBLK
,
ROOTMIR
,
"erofs"
,
MS_RDONLY
,
nullptr
);
if
(
xmount
(
tmp_dir
,
ROOTMIR
,
"ext4"
,
MS_RDONLY
,
nullptr
))
xmount
(
tmp_dir
,
ROOTMIR
,
"erofs"
,
MS_RDONLY
,
nullptr
);
*
p
=
'\0'
;
// Recreate original sbin structure if necessary
// Recreate original sbin structure if necessary
if
(
tmp_dir
==
"/sbin"
)
if
(
tmp_dir
==
"/sbin"
sv
)
recreate_sbin
(
ROOTMIR
"/sbin"
,
true
);
recreate_sbin
(
ROOTMIR
"/sbin"
,
true
);
// Patch init
// Patch init
...
@@ -303,7 +307,7 @@ void SARBase::patch_rootdir() {
...
@@ -303,7 +307,7 @@ void SARBase::patch_rootdir() {
if
(
connect
(
sockfd
,
(
struct
sockaddr
*
)
&
sun
,
setup_sockaddr
(
&
sun
,
INIT_SOCKET
))
==
0
)
{
if
(
connect
(
sockfd
,
(
struct
sockaddr
*
)
&
sun
,
setup_sockaddr
(
&
sun
,
INIT_SOCKET
))
==
0
)
{
LOGD
(
"ACK init tracer to write backup files
\n
"
);
LOGD
(
"ACK init tracer to write backup files
\n
"
);
// Let tracer know where tmp_dir is
// Let tracer know where tmp_dir is
write_string
(
sockfd
,
tmp_dir
.
data
()
);
write_string
(
sockfd
,
tmp_dir
);
// Wait for tracer to finish copying files
// Wait for tracer to finish copying files
int
ack
;
int
ack
;
read
(
sockfd
,
&
ack
,
sizeof
(
ack
));
read
(
sockfd
,
&
ack
,
sizeof
(
ack
));
...
...
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