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
dbfe49c5
Commit
dbfe49c5
authored
Sep 27, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unlock blocks before flashing boot image
parent
98e21f9f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
28 deletions
+30
-28
magisk.c
jni/daemon/magisk.c
+21
-24
flash_script.sh
scripts/flash_script.sh
+1
-1
util_functions.sh
scripts/util_functions.sh
+8
-3
No files found.
jni/daemon/magisk.c
View file @
dbfe49c5
...
@@ -41,37 +41,31 @@ static void usage() {
...
@@ -41,37 +41,31 @@ static void usage() {
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") (by topjohnwu) multi-call binary
\n
"
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") (by topjohnwu) multi-call binary
\n
"
"
\n
"
"
\n
"
"Usage: %s [applet [arguments]...]
\n
"
"Usage: %s [applet [arguments]...]
\n
"
" or: %s
--install [SOURCE] DIR
\n
"
" or: %s
[options]...
\n
"
"
if SOURCE not provided, will link itself
\n
"
"
\n
"
"
or: %s --list
\n
"
"
Options:
\n
"
"
or: %s --createimg IMG SIZE
\n
"
"
-c print current binary version
\n
"
"
create ext4 image, SIZE is interpreted in MB
\n
"
"
-v print running daemon version
\n
"
"
or: %s --imgsize IMG
\n
"
"
-V print running daemon version code
\n
"
"
or: %s --resizeimg IMG SIZE
\n
"
"
--list list all availible applets
\n
"
" SIZE is interpreted in MB
\n
"
" --install [SOURCE] DIR symlink all applets to DIR. SOURCE is optional
\n
"
"
or: %s --mountimg IMG PATH
\n
"
"
--createimg IMG SIZE create ext4 image. SIZE is interpreted in MB
\n
"
"
mount IMG to PATH and prints the loop devic
e
\n
"
"
--imgsize IMG report ext4 image used/total siz
e
\n
"
"
or: %s --umountimg PATH LOOP
\n
"
"
--resizeimg IMG SIZE resize ext4 image. SIZE is interpreted in MB
\n
"
"
or: %s --[boot stage]
\n
"
"
--mountimg IMG PATH mount IMG to PATH and prints the loop device
\n
"
"
start boot stage ser
vice
\n
"
"
--umountimg PATH LOOP unmount PATH and delete LOOP de
vice
\n
"
"
or: %s [options]
\n
"
"
--[boot stage] start boot stage service
\n
"
"
or: applet [arguments]...
\n
"
"
--unlock-blocks set BLKROSET flag to OFF for all block devices
\n
"
"
\n
"
"
\n
"
"Supported boot stages:
\n
"
"Supported boot stages:
\n
"
" post-fs, post-fs-data, service
\n
"
" post-fs, post-fs-data, service
\n
"
"
\n
"
"
\n
"
"Options:
\n
"
" -c print client version
\n
"
" -v print daemon version
\n
"
" -V print daemon version code
\n
"
"
\n
"
"Supported applets:
\n
"
"Supported applets:
\n
"
,
argv0
,
argv0
,
argv0
,
argv0
,
argv0
,
argv0
,
argv0
,
argv0
,
argv0
,
argv0
);
,
argv0
,
argv0
);
for
(
int
i
=
0
;
applet
[
i
];
++
i
)
{
for
(
int
i
=
0
;
applet
[
i
];
++
i
)
fprintf
(
stderr
,
i
?
", %s"
:
" %s"
,
applet
[
i
]);
fprintf
(
stderr
,
i
?
", %s"
:
" %s"
,
applet
[
i
]);
}
fprintf
(
stderr
,
"
\n\n
"
);
fprintf
(
stderr
,
"
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -149,6 +143,9 @@ int main(int argc, char *argv[]) {
...
@@ -149,6 +143,9 @@ int main(int argc, char *argv[]) {
if
(
argc
<
4
)
usage
();
if
(
argc
<
4
)
usage
();
umount_image
(
argv
[
2
],
argv
[
3
]);
umount_image
(
argv
[
2
],
argv
[
3
]);
return
0
;
return
0
;
}
else
if
(
strcmp
(
argv
[
1
],
"--unlock-blocks"
)
==
0
)
{
unlock_blocks
();
return
0
;
}
else
if
(
strcmp
(
argv
[
1
],
"--post-fs"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
1
],
"--post-fs"
)
==
0
)
{
int
fd
=
connect_daemon
();
int
fd
=
connect_daemon
();
write_int
(
fd
,
POST_FS
);
write_int
(
fd
,
POST_FS
);
...
...
scripts/flash_script.sh
View file @
dbfe49c5
...
@@ -101,7 +101,7 @@ if [ -d /system/addon.d ]; then
...
@@ -101,7 +101,7 @@ if [ -d /system/addon.d ]; then
chmod
755 /system/addon.d/99-magisk.sh
chmod
755 /system/addon.d/99-magisk.sh
fi
fi
$BOOTMODE
&&
boot_actions
||
recovery_actions
$BOOTMODE
||
recovery_actions
##########################################################################################
##########################################################################################
# Boot patching
# Boot patching
...
...
scripts/util_functions.sh
View file @
dbfe49c5
...
@@ -10,6 +10,9 @@
...
@@ -10,6 +10,9 @@
MAGISK_VERSION_STUB
MAGISK_VERSION_STUB
SCRIPT_VERSION
=
$MAGISK_VER_CODE
SCRIPT_VERSION
=
$MAGISK_VER_CODE
# Default location, will override if needed
MAGISKBIN
=
/data/magisk
get_outfd
()
{
get_outfd
()
{
readlink
/proc/
$$
/fd/
$OUTFD
2>/dev/null |
grep
/tmp
>
/dev/null
readlink
/proc/
$$
/fd/
$OUTFD
2>/dev/null |
grep
/tmp
>
/dev/null
if
[
"
$?
"
-eq
"0"
]
;
then
if
[
"
$?
"
-eq
"0"
]
;
then
...
@@ -118,21 +121,23 @@ find_boot_image() {
...
@@ -118,21 +121,23 @@ find_boot_image() {
migrate_boot_backup
()
{
migrate_boot_backup
()
{
# Update the broken boot backup
# Update the broken boot backup
if
[
-f
/data/stock_boot_.img.gz
]
;
then
if
[
-f
/data/stock_boot_.img.gz
]
;
then
.
/magiskboot
--decompress
/data/stock_boot_.img.gz
$MAGISKBIN
/magiskboot
--decompress
/data/stock_boot_.img.gz
mv
/data/stock_boot_.img /data/stock_boot.img
mv
/data/stock_boot_.img /data/stock_boot.img
fi
fi
# Update our previous backup to new format if exists
# Update our previous backup to new format if exists
if
[
-f
/data/stock_boot.img
]
;
then
if
[
-f
/data/stock_boot.img
]
;
then
ui_print
"- Migrating boot image backup"
ui_print
"- Migrating boot image backup"
SHA1
=
`
.
/magiskboot
--sha1
/data/stock_boot.img 2>/dev/null
`
SHA1
=
`
$MAGISKBIN
/magiskboot
--sha1
/data/stock_boot.img 2>/dev/null
`
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
mv
/data/stock_boot.img
$STOCKDUMP
mv
/data/stock_boot.img
$STOCKDUMP
.
/magiskboot
--compress
$STOCKDUMP
$MAGISKBIN
/magiskboot
--compress
$STOCKDUMP
fi
fi
mv
/data/magisk/stock_boot
*
/data 2>/dev/null
mv
/data/magisk/stock_boot
*
/data 2>/dev/null
}
}
flash_boot_image
()
{
flash_boot_image
()
{
# Make sure all blocks are writable
$MAGISKBIN
/magisk
--unlock-blocks
case
"
$1
"
in
case
"
$1
"
in
*
.gz
)
COMMAND
=
"gzip -d <
\"
$1
\"
"
;;
*
.gz
)
COMMAND
=
"gzip -d <
\"
$1
\"
"
;;
*
)
COMMAND
=
"cat
\"
$1
\"
"
;;
*
)
COMMAND
=
"cat
\"
$1
\"
"
;;
...
...
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