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
dab32e15
Commit
dab32e15
authored
Apr 08, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use our own device nodes for mirrors
parent
bc286fd4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
23 deletions
+18
-23
bootstages.cpp
native/jni/core/bootstages.cpp
+15
-15
magisk.h
native/jni/include/magisk.h
+1
-0
proc_monitor.cpp
native/jni/magiskhide/proc_monitor.cpp
+2
-8
No files found.
native/jni/core/bootstages.cpp
View file @
dab32e15
...
...
@@ -301,19 +301,17 @@ static int bind_mount(const char *from, const char *to, bool log) {
return
ret
;
}
char
*
system_block
;
char
*
vendor_block
;
char
*
data_block
;
static
char
*&
system_root_block
=
system_block
;
#define MIRRPNT(part) MIRRDIR "/" #part
#define mount_mirror(part, flag) \
sscanf(line.data(), "%s %*s %s", buf, buf2); \
part##_block = strdup(buf); \
xmkdir(MIRRPNT(part), 0755); \
xmount(part##_block, MIRRPNT(part), buf2, flag, nullptr); \
VLOGI("mount", part##_block, MIRRPNT(part))
#define MIRRMNT(part) MIRRDIR "/" #part
#define PARTBLK(part) BLOCKDIR "/" #part
#define mount_mirror(part, flag) { \
sscanf(line.data(), "%s %*s %s", buf, buf2); \
xstat(buf, &st); \
mknod(PARTBLK(part), S_IFBLK | 0600, st.st_rdev); \
xmkdir(MIRRMNT(part), 0755); \
xmount(PARTBLK(part), MIRRMNT(part), buf2, flag, nullptr); \
VLOGI("mount", PARTBLK(part), MIRRMNT(part)); \
}
static
bool
magisk_env
()
{
LOGI
(
"* Initializing Magisk environment
\n
"
);
...
...
@@ -348,7 +346,8 @@ static bool magisk_env() {
symlink
(
MODULEMNT
,
MAGISKTMP
"/img"
);
// Directories in tmpfs overlay
xmkdirs
(
MIRRPNT
(
system
),
0755
);
xmkdir
(
MIRRDIR
,
0
);
xmkdir
(
BLOCKDIR
,
0
);
xmkdir
(
BBPATH
,
0755
);
xmkdir
(
MODULEMNT
,
0755
);
...
...
@@ -360,10 +359,11 @@ static bool magisk_env() {
LOGI
(
"* Mounting mirrors"
);
bool
system_as_root
=
false
;
struct
stat
st
;
file_readline
(
"/proc/mounts"
,
[
&
](
string_view
line
)
->
bool
{
if
(
str_contains
(
line
,
" /system_root "
))
{
mount_mirror
(
system_root
,
MS_RDONLY
);
bind_mount
(
MIRRPNT
(
system_root
)
"/system"
,
MIRRP
NT
(
system
));
xsymlink
(
MIRRMNT
(
system_root
)
"/system"
,
MIRRM
NT
(
system
));
system_as_root
=
true
;
}
else
if
(
!
system_as_root
&&
str_contains
(
line
,
" /system "
))
{
mount_mirror
(
system
,
MS_RDONLY
);
...
...
native/jni/include/magisk.h
View file @
dab32e15
...
...
@@ -11,6 +11,7 @@
#define DISABLEFILE "/cache/.disable_magisk"
#define MAGISKTMP "/sbin/.magisk"
#define MIRRDIR MAGISKTMP "/mirror"
#define BLOCKDIR MAGISKTMP "/block"
#define BBPATH MAGISKTMP "/busybox"
#define MODULEMNT MAGISKTMP "/modules"
#define SECURE_DIR "/data/adb"
...
...
native/jni/magiskhide/proc_monitor.cpp
View file @
dab32e15
...
...
@@ -28,10 +28,6 @@
using
namespace
std
;
extern
char
*
system_block
;
extern
char
*
vendor_block
;
extern
char
*
data_block
;
static
int
inotify_fd
=
-
1
;
static
void
term_thread
(
int
sig
=
SIGTERMTHRD
);
...
...
@@ -202,11 +198,9 @@ static void hide_daemon(int pid) {
lazy_unmount
(
s
.
data
());
targets
.
clear
();
// Unmount
everything under /system, /vendor, and data
mounts
// Unmount
all Magisk created
mounts
file_readline
(
"/proc/self/mounts"
,
[
&
](
string_view
s
)
->
bool
{
if
((
str_contains
(
s
,
" /system/"
)
||
str_contains
(
s
,
" /vendor/"
))
&&
(
str_contains
(
s
,
system_block
)
||
str_contains
(
s
,
vendor_block
)
||
str_contains
(
s
,
data_block
)))
{
if
(
str_contains
(
s
,
BLOCKDIR
))
{
char
*
path
=
(
char
*
)
s
.
data
();
// Skip first token
strtok_r
(
nullptr
,
" "
,
&
path
);
...
...
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