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
89fff483
Commit
89fff483
authored
Nov 03, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mount proper system_root mirror in magiskd
parent
16e4c679
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
19 deletions
+25
-19
bootstages.cpp
native/jni/core/bootstages.cpp
+21
-11
rootdir.cpp
native/jni/init/rootdir.cpp
+4
-8
No files found.
native/jni/core/bootstages.cpp
View file @
89fff483
...
@@ -26,17 +26,20 @@ static bool safe_mode = false;
...
@@ -26,17 +26,20 @@ static bool safe_mode = false;
#define SETMIR(b, part) sprintf(b, "%s/" MIRRDIR "/" #part, MAGISKTMP.data())
#define SETMIR(b, part) sprintf(b, "%s/" MIRRDIR "/" #part, MAGISKTMP.data())
#define SETBLK(b, part) sprintf(b, "%s/" BLOCKDIR "/" #part, MAGISKTMP.data())
#define SETBLK(b, part) sprintf(b, "%s/" BLOCKDIR "/" #part, MAGISKTMP.data())
#define mount_mirror(part, flag) \
#define do_mount_mirror(part, flag) {\
else if (MNT_DIR_IS("/" #part) && me->mnt_type != "tmpfs"sv && lstat(me->mnt_dir, &st) == 0) { \
SETMIR(buf1, part); \
SETMIR(buf1, part); \
SETBLK(buf2, part); \
SETBLK(buf2, part); \
unlink(buf2); \
unlink(buf2); \
mknod(buf2, S_IFBLK | 0600, st.st_dev); \
mknod(buf2, S_IFBLK | 0600, st.st_dev); \
xmkdir(buf1, 0755); \
xmkdir(buf1, 0755); \
xmount(buf2, buf1, me->mnt_type, flag, nullptr); \
xmount(buf2, buf1, me->mnt_type, flag, nullptr); \
LOGI("mount: %s\n", buf1); \
LOGI("mount: %s\n", buf1); \
}
}
#define mount_mirror(part, flag) \
else if (MNT_DIR_IS("/" #part) && me->mnt_type != "tmpfs"sv && lstat(me->mnt_dir, &st) == 0) \
do_mount_mirror(part, flag)
#define link_mirror(part) \
#define link_mirror(part) \
SETMIR(buf1, part); \
SETMIR(buf1, part); \
if (access("/system/" #part, F_OK) == 0 && access(buf1, F_OK) != 0) { \
if (access("/system/" #part, F_OK) == 0 && access(buf1, F_OK) != 0) { \
...
@@ -119,10 +122,17 @@ static bool magisk_env() {
...
@@ -119,10 +122,17 @@ static bool magisk_env() {
return
true
;
return
true
;
});
});
SETMIR
(
buf1
,
system
);
SETMIR
(
buf1
,
system
);
SETMIR
(
buf2
,
system_root
);
if
(
access
(
buf1
,
F_OK
)
!=
0
)
{
if
(
access
(
buf1
,
F_OK
)
!=
0
&&
access
(
buf2
,
F_OK
)
==
0
)
{
xsymlink
(
"./system_root/system"
,
buf1
);
xsymlink
(
"./system_root/system"
,
buf1
);
LOGI
(
"link: %s
\n
"
,
buf1
);
LOGI
(
"link: %s
\n
"
,
buf1
);
parse_mnt
(
"/proc/mounts"
,
[
&
](
mntent
*
me
)
{
struct
stat
st
;
if
(
MNT_DIR_IS
(
"/"
)
&&
me
->
mnt_type
!=
"rootfs"
sv
&&
stat
(
"/"
,
&
st
)
==
0
)
{
do_mount_mirror
(
system_root
,
MS_RDONLY
)
return
false
;
}
return
true
;
});
}
}
link_mirror
(
vendor
)
link_mirror
(
vendor
)
link_mirror
(
product
)
link_mirror
(
product
)
...
...
native/jni/init/rootdir.cpp
View file @
89fff483
...
@@ -183,13 +183,12 @@ static void magic_mount(const string &sdir, const string &ddir = "") {
...
@@ -183,13 +183,12 @@ static void magic_mount(const string &sdir, const string &ddir = "") {
}
}
#define ROOTMIR MIRRDIR "/system_root"
#define ROOTMIR MIRRDIR "/system_root"
#define ROOTBLK BLOCKDIR "/system_root"
#define MONOPOLICY "/sepolicy"
#define MONOPOLICY "/sepolicy"
#define LIBSELINUX "/system/" LIBNAME "/libselinux.so"
#define LIBSELINUX "/system/" LIBNAME "/libselinux.so"
#define NEW_INITRC "/system/etc/init/hw/init.rc"
#define NEW_INITRC "/system/etc/init/hw/init.rc"
void
SARBase
::
patch_rootdir
()
{
void
SARBase
::
patch_rootdir
()
{
char
tmp_dir
[
16
];
char
tmp_dir
[
32
];
const
char
*
sepol
;
const
char
*
sepol
;
char
*
p
;
char
*
p
;
...
@@ -208,13 +207,10 @@ void SARBase::patch_rootdir() {
...
@@ -208,13 +207,10 @@ void SARBase::patch_rootdir() {
mount_rules_dir
(
BLOCKDIR
,
MIRRDIR
);
mount_rules_dir
(
BLOCKDIR
,
MIRRDIR
);
// Mount system_root mirror
// Mount system_root mirror
struct
stat
st
;
xstat
(
"/"
,
&
st
);
xmkdir
(
ROOTMIR
,
0755
);
xmkdir
(
ROOTMIR
,
0755
);
mknod
(
ROOTBLK
,
S_IFBLK
|
0600
,
st
.
st_dev
);
xmount
(
"/"
,
ROOTMIR
,
nullptr
,
MS_BIND
,
nullptr
);
strcpy
(
p
,
"/"
ROOTBLK
);
strcpy
(
p
,
"/"
ROOTMIR
);
if
(
xmount
(
tmp_dir
,
ROOTMIR
,
"ext4"
,
MS_RDONLY
,
nullptr
))
mount_list
.
emplace_back
(
tmp_dir
);
xmount
(
tmp_dir
,
ROOTMIR
,
"erofs"
,
MS_RDONLY
,
nullptr
);
*
p
=
'\0'
;
*
p
=
'\0'
;
// Recreate original sbin structure if necessary
// Recreate original sbin structure if necessary
...
...
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