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
340bac7e
Commit
340bac7e
authored
Feb 23, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add decompression command
parent
1d3ce9fe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
ramdisk.cpp
native/jni/magiskboot/ramdisk.cpp
+21
-0
OutStream.h
native/jni/utils/include/OutStream.h
+8
-2
No files found.
native/jni/magiskboot/ramdisk.cpp
View file @
340bac7e
...
@@ -29,6 +29,7 @@ public:
...
@@ -29,6 +29,7 @@ public:
void
restore
();
void
restore
();
void
backup
(
const
char
*
orig
);
void
backup
(
const
char
*
orig
);
void
compress
();
void
compress
();
void
decompress
();
};
};
void
magisk_cpio
::
patch
(
bool
keepverity
,
bool
keepforceencrypt
)
{
void
magisk_cpio
::
patch
(
bool
keepverity
,
bool
keepforceencrypt
)
{
...
@@ -206,6 +207,8 @@ void magisk_cpio::backup(const char *orig) {
...
@@ -206,6 +207,8 @@ void magisk_cpio::backup(const char *orig) {
}
}
void
magisk_cpio
::
compress
()
{
void
magisk_cpio
::
compress
()
{
if
(
exists
(
ramdisk_xz
))
return
;
fprintf
(
stderr
,
"Compressing cpio -> [%s]
\n
"
,
ramdisk_xz
);
fprintf
(
stderr
,
"Compressing cpio -> [%s]
\n
"
,
ramdisk_xz
);
auto
init
=
entries
.
extract
(
"init"
);
auto
init
=
entries
.
extract
(
"init"
);
XZEncoder
encoder
;
XZEncoder
encoder
;
...
@@ -219,6 +222,22 @@ void magisk_cpio::compress() {
...
@@ -219,6 +222,22 @@ void magisk_cpio::compress() {
insert
(
xz
);
insert
(
xz
);
}
}
void
magisk_cpio
::
decompress
()
{
auto
it
=
entries
.
find
(
ramdisk_xz
);
if
(
it
==
entries
.
end
())
return
;
fprintf
(
stderr
,
"Decompressing cpio [%s]
\n
"
,
ramdisk_xz
);
LZMADecoder
decoder
;
decoder
.
set_out
(
make_unique
<
BufOutStream
>
());
decoder
.
write
(
it
->
second
->
data
,
it
->
second
->
filesize
);
decoder
.
finalize
();
entries
.
erase
(
it
);
char
*
buf
;
size_t
sz
;
static_cast
<
BufOutStream
*>
(
decoder
.
get_out
())
->
getbuf
(
buf
,
sz
);
load_cpio
(
buf
,
sz
);
}
int
cpio_commands
(
int
argc
,
char
*
argv
[])
{
int
cpio_commands
(
int
argc
,
char
*
argv
[])
{
char
*
incpio
=
argv
[
0
];
char
*
incpio
=
argv
[
0
];
++
argv
;
++
argv
;
...
@@ -251,6 +270,8 @@ int cpio_commands(int argc, char *argv[]) {
...
@@ -251,6 +270,8 @@ int cpio_commands(int argc, char *argv[]) {
return
0
;
return
0
;
}
else
if
(
strcmp
(
cmdv
[
0
],
"compress"
)
==
0
){
}
else
if
(
strcmp
(
cmdv
[
0
],
"compress"
)
==
0
){
cpio
.
compress
();
cpio
.
compress
();
}
else
if
(
strcmp
(
cmdv
[
0
],
"decompress"
)
==
0
){
cpio
.
decompress
();
}
else
if
(
cmdc
==
2
&&
strcmp
(
cmdv
[
0
],
"exists"
)
==
0
)
{
}
else
if
(
cmdc
==
2
&&
strcmp
(
cmdv
[
0
],
"exists"
)
==
0
)
{
exit
(
!
cpio
.
exists
(
cmdv
[
1
]));
exit
(
!
cpio
.
exists
(
cmdv
[
1
]));
}
else
if
(
cmdc
==
2
&&
strcmp
(
cmdv
[
0
],
"backup"
)
==
0
)
{
}
else
if
(
cmdc
==
2
&&
strcmp
(
cmdv
[
0
],
"backup"
)
==
0
)
{
...
...
native/jni/utils/include/OutStream.h
View file @
340bac7e
...
@@ -64,14 +64,20 @@ public:
...
@@ -64,14 +64,20 @@ public:
return
true
;
return
true
;
}
}
template
<
typename
T
>
template
<
typename
bytes
,
typename
length
>
void
release
(
void
*&
b
,
T
&
len
)
{
void
release
(
bytes
*&
b
,
length
&
len
)
{
b
=
buf
;
b
=
buf
;
len
=
off
;
len
=
off
;
buf
=
nullptr
;
buf
=
nullptr
;
off
=
cap
=
0
;
off
=
cap
=
0
;
}
}
template
<
typename
bytes
,
typename
length
>
void
getbuf
(
bytes
*&
b
,
length
&
len
)
const
{
b
=
buf
;
len
=
off
;
}
~
BufOutStream
()
override
{
~
BufOutStream
()
override
{
free
(
buf
);
free
(
buf
);
}
}
...
...
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