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
7ac41652
Commit
7ac41652
authored
Nov 05, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Brand new dummy cloning: No bugs and faster
parent
24a510bc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
49 deletions
+52
-49
magic_mask.sh
scripts/magic_mask.sh
+52
-49
No files found.
scripts/magic_mask.sh
View file @
7ac41652
...
@@ -48,7 +48,7 @@ run_scripts() {
...
@@ -48,7 +48,7 @@ run_scripts() {
if
[
!
-f
"
$MOD
/disable"
]
;
then
if
[
!
-f
"
$MOD
/disable"
]
;
then
if
[
-f
"
$MOD
/
$1
.sh"
]
;
then
if
[
-f
"
$MOD
/
$1
.sh"
]
;
then
chmod
755
$MOD
/
$1
.sh
chmod
755
$MOD
/
$1
.sh
chcon
'u:object_r:system_file:s0'
$MOD
/
$1
.sh
chcon
"u:object_r:system_file:s0"
"
$MOD
/
$1
.sh"
log_print
"
$1
:
$MOD
/
$1
.sh"
log_print
"
$1
:
$MOD
/
$1
.sh"
sh
$MOD
/
$1
.sh
sh
$MOD
/
$1
.sh
fi
fi
...
@@ -75,66 +75,69 @@ target_size_check() {
...
@@ -75,66 +75,69 @@ target_size_check() {
}
}
travel
()
{
travel
()
{
cd
$1
/
$2
cd
"
$1
/
$2
"
if
[
-f
".replace"
]
;
then
if
[
-f
".replace"
]
;
then
rm
-rf
$MOUNTINFO
/
$2
rm
-rf
"
$MOUNTINFO
/
$2
"
mktouch
$MOUNTINFO
/
$2
$1
mktouch
"
$MOUNTINFO
/
$2
"
"
$1
"
else
else
for
ITEM
in
*
;
do
for
ITEM
in
*
;
do
if
[
!
-e
"/
$2
/
$ITEM
"
]
;
then
if
[
!
-e
"/
$2
/
$ITEM
"
]
;
then
# New item found
# New item found
if
[
$2
=
"system"
]
;
then
if
[
"
$2
"
=
"system"
]
;
then
# We cannot add new items to /system root, delete it
# We cannot add new items to /system root, delete it
rm
-rf
$ITEM
rm
-rf
"
$ITEM
"
else
else
if
[
-d
"
$MOUNTINFO
/dummy/
$2
"
]
;
then
# If we are in a higher level, delete the lower levels
# We are in a higher level, delete the lower levels
rm
-rf
"
$MOUNTINFO
/dummy/
$2
"
rm
-rf
$MOUNTINFO
/dummy/
$2
fi
# Mount the dummy parent
# Mount the dummy parent
mktouch
$MOUNTINFO
/dummy/
$2
mktouch
"
$MOUNTINFO
/dummy/
$2
"
mkdir
-p
$DUMMDIR
/
$2
2>/dev/null
if
[
-d
"
$ITEM
"
]
;
then
if
[
-d
"
$ITEM
"
]
;
then
# Create new dummy directory
# Create new dummy directory and mount it
mkdir
-p
$DUMMDIR
/
$2
/
$ITEM
mkdir
-p
"
$DUMMDIR
/
$2
/
$ITEM
"
mktouch
"
$MOUNTINFO
/
$2
/
$ITEM
"
"
$1
"
elif
[
-L
"
$ITEM
"
]
;
then
elif
[
-L
"
$ITEM
"
]
;
then
# Symlinks are small, copy them
# Symlinks are small, copy them
$TOOLPATH
/cp
-afc
$ITEM
$DUMMDIR
/
$2
/
$ITEM
mkdir
-p
"
$DUMMDIR
/
$2
"
2>/dev/null
else
$TOOLPATH
/cp
-afc
"
$ITEM
"
"
$DUMMDIR
/
$2
/
$ITEM
"
# Create new dummy file
mktouch
$DUMMDIR
/
$2
/
$ITEM
fi
# Clone the original /system structure (depth 1)
if
[
-e
"/
$2
"
]
;
then
for
DUMMY
in
/
$2
/
*
;
do
if
[
-d
"
$DUMMY
"
]
;
then
# Create dummy directory
mkdir
-p
$DUMMDIR$DUMMY
elif
[
-L
"
$DUMMY
"
]
;
then
# Symlinks are small, copy them
$TOOLPATH
/cp
-afc
$DUMMY
$DUMMDIR$DUMMY
else
else
# Create dummy file
# Create new dummy file and mount it
mktouch
$DUMMDIR$DUMMY
mktouch
"
$DUMMDIR
/
$2
/
$ITEM
"
fi
mktouch
"
$MOUNTINFO
/
$2
/
$ITEM
"
"
$1
"
done
fi
fi
fi
fi
fi
else
if
[
-d
"
$ITEM
"
]
;
then
if
[
-d
"
$ITEM
"
]
;
then
# It's an directory, travel deeper
# It's an directory, travel deeper
(
travel
$1
$2
/
$ITEM
)
(
travel
"
$1
"
"
$2
/
$ITEM
"
)
elif
[
!
-L
"
$ITEM
"
]
;
then
elif
[
!
-L
"
$ITEM
"
]
;
then
# Mount this file
# Mount this file
mktouch
$MOUNTINFO
/
$2
/
$ITEM
$1
mktouch
"
$MOUNTINFO
/
$2
/
$ITEM
"
"
$1
"
fi
fi
fi
done
done
fi
fi
}
}
clone_dummy
()
{
for
ITEM
in
"
$1
/"
*
;
do
if
[
-d
"
$DUMMDIR$ITEM
"
]
;
then
(
clone_dummy
"
$ITEM
"
)
else
if
[
-d
"
$ITEM
"
]
;
then
# Create dummy directory
mkdir
-p
"
$DUMMDIR$ITEM
"
elif
[
-L
"
$ITEM
"
]
;
then
# Symlinks are small, copy them
$TOOLPATH
/cp
-afc
"
$ITEM
"
"
$DUMMDIR$ITEM
"
else
# Create dummy file
mktouch
"
$DUMMDIR$ITEM
"
fi
fi
done
}
bind_mount
()
{
bind_mount
()
{
if
[
-e
"
$1
"
-a
-e
"
$2
"
]
;
then
if
[
-e
"
$1
"
-a
-e
"
$2
"
]
;
then
mount
-o
bind
$1
$2
mount
-o
bind
$1
$2
...
@@ -270,7 +273,7 @@ case $1 in
...
@@ -270,7 +273,7 @@ case $1 in
mv
/cache/stock_boot.img /data 2>/dev/null
mv
/cache/stock_boot.img /data 2>/dev/null
chcon
-R
'u:object_r:system_file:s0'
$BINPATH
$TOOLPATH
chcon
-R
"u:object_r:system_file:s0"
$BINPATH
$TOOLPATH
# Image merging
# Image merging
chmod
644
$IMG
/cache/magisk.img /data/magisk_merge.img 2>/dev/null
chmod
644
$IMG
/cache/magisk.img /data/magisk_merge.img 2>/dev/null
...
@@ -334,11 +337,6 @@ case $1 in
...
@@ -334,11 +337,6 @@ case $1 in
fi
fi
done
done
# Proper permissions for generated items
$TOOLPATH
/find
$DUMMDIR
-type
d
-exec
chmod
755
{}
\;
$TOOLPATH
/find
$DUMMDIR
-type
f
-exec
chmod
644
{}
\;
$TOOLPATH
/find
$DUMMDIR
-exec
chcon
'u:object_r:system_file:s0'
{}
\;
# linker(64), t*box, and app_process* are required if we need to dummy mount bin folder
# linker(64), t*box, and app_process* are required if we need to dummy mount bin folder
if
[
-f
"
$MOUNTINFO
/dummy/system/bin"
]
;
then
if
[
-f
"
$MOUNTINFO
/dummy/system/bin"
]
;
then
rm
-f
$DUMMDIR
/system/bin/linker
*
$DUMMDIR
/system/bin/t
*
box
$DUMMDIR
/system/bin/app_process
*
rm
-f
$DUMMDIR
/system/bin/linker
*
$DUMMDIR
/system/bin/t
*
box
$DUMMDIR
/system/bin/app_process
*
...
@@ -355,10 +353,16 @@ case $1 in
...
@@ -355,10 +353,16 @@ case $1 in
log_print
"Bind mount dummy system"
log_print
"Bind mount dummy system"
$TOOLPATH
/find
$MOUNTINFO
/dummy
-type
f 2>/dev/null |
while
read
ITEM
;
do
$TOOLPATH
/find
$MOUNTINFO
/dummy
-type
f 2>/dev/null |
while
read
ITEM
;
do
TARGET
=
${
ITEM
#
$MOUNTINFO
/dummy
}
TARGET
=
${
ITEM
#
$MOUNTINFO
/dummy
}
ORIG
=
$DUMMDIR$TARGET
ORIG
=
"
$DUMMDIR$TARGET
"
bind_mount
$ORIG
$TARGET
clone_dummy
"
$TARGET
"
bind_mount
"
$ORIG
"
"
$TARGET
"
done
done
# Proper permissions for generated items
$TOOLPATH
/find
$TMPDIR
-type
d
-exec
chmod
755
"{}"
\;
$TOOLPATH
/find
$TMPDIR
-type
f
-exec
chmod
644
"{}"
\;
$TOOLPATH
/find
$TMPDIR
-exec
chcon
"u:object_r:system_file:s0"
"{}"
\;
# Stage 2
# Stage 2
log_print
"Bind mount module items"
log_print
"Bind mount module items"
$TOOLPATH
/find
$MOUNTINFO
/system
-type
f 2>/dev/null |
while
read
ITEM
;
do
$TOOLPATH
/find
$MOUNTINFO
/system
-type
f 2>/dev/null |
while
read
ITEM
;
do
...
@@ -423,7 +427,6 @@ case $1 in
...
@@ -423,7 +427,6 @@ case $1 in
$COREDIR
/magiskhide/add com.google.android.gms.unstable
$COREDIR
/magiskhide/add com.google.android.gms.unstable
log_print
"** Starting Magisk Hide"
log_print
"** Starting Magisk Hide"
/data/magisk/magiskhide
/data/magisk/magiskhide
fi
fi
;;
;;
...
...
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