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
b7b4164f
Commit
b7b4164f
authored
Sep 09, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cpio-mv action
parent
7e652964
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
10 deletions
+40
-10
cpio.c
jni/magiskboot/cpio.c
+38
-10
cpio.h
jni/magiskboot/cpio.h
+1
-0
main.c
jni/magiskboot/main.c
+1
-0
No files found.
jni/magiskboot/cpio.c
View file @
b7b4164f
...
@@ -40,7 +40,7 @@ static void cpio_vec_insert(struct vector *v, cpio_file *n) {
...
@@ -40,7 +40,7 @@ static void cpio_vec_insert(struct vector *v, cpio_file *n) {
vec_push_back
(
v
,
n
);
vec_push_back
(
v
,
n
);
}
}
static
int
cpio_c
ompare
(
const
void
*
a
,
const
void
*
b
)
{
static
int
cpio_c
mp
(
const
void
*
a
,
const
void
*
b
)
{
return
strcmp
((
*
(
cpio_file
**
)
a
)
->
filename
,
(
*
(
cpio_file
**
)
b
)
->
filename
);
return
strcmp
((
*
(
cpio_file
**
)
a
)
->
filename
,
(
*
(
cpio_file
**
)
b
)
->
filename
);
}
}
...
@@ -92,7 +92,7 @@ static void dump_cpio(const char *filename, struct vector *v) {
...
@@ -92,7 +92,7 @@ static void dump_cpio(const char *filename, struct vector *v) {
unsigned
inode
=
300000
;
unsigned
inode
=
300000
;
char
header
[
111
];
char
header
[
111
];
// Sort by name
// Sort by name
vec_sort
(
v
,
cpio_c
ompare
);
vec_sort
(
v
,
cpio_c
mp
);
cpio_file
*
f
;
cpio_file
*
f
;
vec_for_each
(
v
,
f
)
{
vec_for_each
(
v
,
f
)
{
if
(
f
->
remove
)
continue
;
if
(
f
->
remove
)
continue
;
...
@@ -139,13 +139,15 @@ static void cpio_vec_destroy(struct vector *v) {
...
@@ -139,13 +139,15 @@ static void cpio_vec_destroy(struct vector *v) {
static
void
cpio_rm
(
int
recursive
,
const
char
*
entry
,
struct
vector
*
v
)
{
static
void
cpio_rm
(
int
recursive
,
const
char
*
entry
,
struct
vector
*
v
)
{
cpio_file
*
f
;
cpio_file
*
f
;
vec_for_each
(
v
,
f
)
{
vec_for_each
(
v
,
f
)
{
if
((
recursive
&&
strncmp
(
f
->
filename
,
entry
,
strlen
(
entry
))
==
0
)
if
(
strncmp
(
f
->
filename
,
entry
,
strlen
(
entry
))
==
0
)
{
||
(
strcmp
(
f
->
filename
,
entry
)
==
0
)
)
{
char
next
=
f
->
filename
[
strlen
(
entry
)];
if
(
!
f
->
remove
)
{
if
((
recursive
&&
next
==
'/'
)
||
next
==
'\0'
)
{
fprintf
(
stderr
,
"Remove [%s]
\n
"
,
entry
);
if
(
!
f
->
remove
)
{
f
->
remove
=
1
;
fprintf
(
stderr
,
"Remove [%s]
\n
"
,
f
->
filename
);
f
->
remove
=
1
;
}
if
(
!
recursive
)
return
;
}
}
if
(
!
recursive
)
return
;
}
}
}
}
}
}
...
@@ -345,8 +347,8 @@ static void cpio_backup(const char *orig, struct vector *v) {
...
@@ -345,8 +347,8 @@ static void cpio_backup(const char *orig, struct vector *v) {
cpio_rm
(
1
,
".backup"
,
v
);
cpio_rm
(
1
,
".backup"
,
v
);
// Sort both vectors before comparing
// Sort both vectors before comparing
vec_sort
(
v
,
cpio_c
ompare
);
vec_sort
(
v
,
cpio_c
mp
);
vec_sort
(
o
,
cpio_c
ompare
);
vec_sort
(
o
,
cpio_c
mp
);
// Init the directory and rmlist
// Init the directory and rmlist
dir
->
filename
=
strdup
(
".backup"
);
dir
->
filename
=
strdup
(
".backup"
);
...
@@ -470,6 +472,27 @@ static void cpio_stocksha1(struct vector *v) {
...
@@ -470,6 +472,27 @@ static void cpio_stocksha1(struct vector *v) {
}
}
}
}
static
void
cpio_mv
(
struct
vector
*
v
,
const
char
*
from
,
const
char
*
to
)
{
struct
cpio_file
*
f
,
*
t
;
vec_for_each
(
v
,
f
)
{
if
(
strcmp
(
f
->
filename
,
from
)
==
0
)
{
fprintf
(
stderr
,
"Move [%s] -> [%s]
\n
"
,
from
,
to
);
vec_for_each
(
v
,
t
)
{
if
(
strcmp
(
t
->
filename
,
to
)
==
0
)
{
t
->
remove
=
1
;
break
;
}
}
free
(
f
->
filename
);
f
->
namesize
=
strlen
(
to
)
+
1
;
f
->
filename
=
strdup
(
to
);
return
;
}
}
fprintf
(
stderr
,
"Cannot find entry %s
\n
"
,
from
);
exit
(
1
);
}
int
cpio_commands
(
const
char
*
command
,
int
argc
,
char
*
argv
[])
{
int
cpio_commands
(
const
char
*
command
,
int
argc
,
char
*
argv
[])
{
int
recursive
=
0
,
ret
=
0
;
int
recursive
=
0
,
ret
=
0
;
command_t
cmd
;
command_t
cmd
;
...
@@ -491,6 +514,8 @@ int cpio_commands(const char *command, int argc, char *argv[]) {
...
@@ -491,6 +514,8 @@ int cpio_commands(const char *command, int argc, char *argv[]) {
++
argv
;
++
argv
;
--
argc
;
--
argc
;
}
}
}
else
if
(
argc
==
2
&&
strcmp
(
command
,
"mv"
)
==
0
)
{
cmd
=
MV
;
}
else
if
(
argc
==
2
&&
strcmp
(
command
,
"patch"
)
==
0
)
{
}
else
if
(
argc
==
2
&&
strcmp
(
command
,
"patch"
)
==
0
)
{
cmd
=
PATCH
;
cmd
=
PATCH
;
}
else
if
(
argc
==
2
&&
strcmp
(
command
,
"extract"
)
==
0
)
{
}
else
if
(
argc
==
2
&&
strcmp
(
command
,
"extract"
)
==
0
)
{
...
@@ -532,6 +557,9 @@ int cpio_commands(const char *command, int argc, char *argv[]) {
...
@@ -532,6 +557,9 @@ int cpio_commands(const char *command, int argc, char *argv[]) {
case
ADD
:
case
ADD
:
cpio_add
(
strtoul
(
argv
[
0
],
NULL
,
8
),
argv
[
1
],
argv
[
2
],
&
v
);
cpio_add
(
strtoul
(
argv
[
0
],
NULL
,
8
),
argv
[
1
],
argv
[
2
],
&
v
);
break
;
break
;
case
MV
:
cpio_mv
(
&
v
,
argv
[
0
],
argv
[
1
]);
break
;
case
NONE
:
case
NONE
:
return
1
;
return
1
;
}
}
...
...
jni/magiskboot/cpio.h
View file @
b7b4164f
...
@@ -52,6 +52,7 @@ typedef enum {
...
@@ -52,6 +52,7 @@ typedef enum {
RM
,
RM
,
MKDIR
,
MKDIR
,
ADD
,
ADD
,
MV
,
EXTRACT
,
EXTRACT
,
TEST
,
TEST
,
PATCH
,
PATCH
,
...
...
jni/magiskboot/main.c
View file @
b7b4164f
...
@@ -24,6 +24,7 @@ static void usage(char *arg0) {
...
@@ -24,6 +24,7 @@ static void usage(char *arg0) {
" -rm [-r] <entry>
\n
Remove entry from <incpio>, flag -r to remove recursively
\n
"
" -rm [-r] <entry>
\n
Remove entry from <incpio>, flag -r to remove recursively
\n
"
" -mkdir <mode> <entry>
\n
Create directory as an <entry>
\n
"
" -mkdir <mode> <entry>
\n
Create directory as an <entry>
\n
"
" -add <mode> <entry> <infile>
\n
Add <infile> as an <entry>; replaces <entry> if already exists
\n
"
" -add <mode> <entry> <infile>
\n
Add <infile> as an <entry>; replaces <entry> if already exists
\n
"
" -mv <from-entry> <to-entry>
\n
Move <from-entry> to <to-entry>
\n
"
" -extract <entry> <outfile>
\n
Extract <entry> to <outfile>
\n
"
" -extract <entry> <outfile>
\n
Extract <entry> to <outfile>
\n
"
" -test
\n
Return value: 0/not patched 1/Magisk 2/Other (e.g. phh, SuperSU)
\n
"
" -test
\n
Return value: 0/not patched 1/Magisk 2/Other (e.g. phh, SuperSU)
\n
"
" -patch <KEEPVERITY> <KEEPFORCEENCRYPT>
\n
Patch cpio for Magisk. KEEP**** are true/false values
\n
"
" -patch <KEEPVERITY> <KEEPFORCEENCRYPT>
\n
Patch cpio for Magisk. KEEP**** are true/false values
\n
"
...
...
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