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
696ab677
Commit
696ab677
authored
Feb 21, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New pre-init magic mount implementation
parent
0d229dac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
rootdir.cpp
native/jni/init/rootdir.cpp
+7
-11
No files found.
native/jni/init/rootdir.cpp
View file @
696ab677
...
@@ -245,20 +245,18 @@ static void recreate_sbin(const char *mirror, bool use_bind_mount) {
...
@@ -245,20 +245,18 @@ static void recreate_sbin(const char *mirror, bool use_bind_mount) {
static
string
magic_mount_list
;
static
string
magic_mount_list
;
static
void
magic_mount
(
int
dirfd
,
const
string
&
path
)
{
static
void
magic_mount
(
const
string
&
sdir
,
const
string
&
ddir
=
""
)
{
DIR
*
dir
=
xfdopendir
(
dirfd
);
auto
dir
=
xopen_dir
(
sdir
.
data
()
);
for
(
dirent
*
entry
;
(
entry
=
readdir
(
dir
));)
{
for
(
dirent
*
entry
;
(
entry
=
readdir
(
dir
.
get
()
));)
{
if
(
entry
->
d_name
==
"."
sv
||
entry
->
d_name
==
".."
sv
)
if
(
entry
->
d_name
==
"."
sv
||
entry
->
d_name
==
".."
sv
)
continue
;
continue
;
string
dest
=
path
+
"/"
+
entry
->
d_name
;
string
src
=
sdir
+
"/"
+
entry
->
d_name
;
string
dest
=
ddir
+
"/"
+
entry
->
d_name
;
if
(
access
(
dest
.
data
(),
F_OK
)
==
0
)
{
if
(
access
(
dest
.
data
(),
F_OK
)
==
0
)
{
if
(
entry
->
d_type
==
DT_DIR
)
{
if
(
entry
->
d_type
==
DT_DIR
)
{
// Recursive
// Recursive
int
fd
=
xopenat
(
dirfd
,
entry
->
d_name
,
O_RDONLY
|
O_CLOEXEC
);
magic_mount
(
src
,
dest
);
magic_mount
(
fd
,
dest
);
close
(
fd
);
}
else
{
}
else
{
string
src
=
ROOTOVL
+
dest
;
LOGD
(
"Mount [%s] -> [%s]
\n
"
,
src
.
data
(),
dest
.
data
());
LOGD
(
"Mount [%s] -> [%s]
\n
"
,
src
.
data
(),
dest
.
data
());
xmount
(
src
.
data
(),
dest
.
data
(),
nullptr
,
MS_BIND
,
nullptr
);
xmount
(
src
.
data
(),
dest
.
data
(),
nullptr
,
MS_BIND
,
nullptr
);
magic_mount_list
+=
dest
;
magic_mount_list
+=
dest
;
...
@@ -360,9 +358,7 @@ void SARBase::patch_rootdir() {
...
@@ -360,9 +358,7 @@ void SARBase::patch_rootdir() {
clone_attr
(
"/init.rc"
,
ROOTOVL
"/init.rc"
);
clone_attr
(
"/init.rc"
,
ROOTOVL
"/init.rc"
);
// Mount rootdir
// Mount rootdir
src
=
xopen
(
ROOTOVL
,
O_RDONLY
|
O_CLOEXEC
);
magic_mount
(
ROOTOVL
);
magic_mount
(
src
,
""
);
close
(
src
);
dest
=
xopen
(
ROOTMNT
,
O_WRONLY
|
O_CREAT
|
O_CLOEXEC
);
dest
=
xopen
(
ROOTMNT
,
O_WRONLY
|
O_CREAT
|
O_CLOEXEC
);
write
(
dest
,
magic_mount_list
.
data
(),
magic_mount_list
.
length
());
write
(
dest
,
magic_mount_list
.
data
(),
magic_mount_list
.
length
());
close
(
dest
);
close
(
dest
);
...
...
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