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
2212800a
Commit
2212800a
authored
Dec 03, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add symlink feature to cpio
parent
2e25431b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
1 deletion
+15
-1
cpio.h
jni/include/cpio.h
+1
-0
main.c
jni/magiskboot/main.c
+3
-1
ramdisk.c
jni/magiskboot/ramdisk.c
+2
-0
cpio.c
jni/utils/cpio.c
+9
-0
No files found.
jni/include/cpio.h
View file @
2212800a
...
@@ -47,6 +47,7 @@ void dump_cpio(struct vector *v, const char *filename);
...
@@ -47,6 +47,7 @@ void dump_cpio(struct vector *v, const char *filename);
void
cpio_vec_destroy
(
struct
vector
*
v
);
void
cpio_vec_destroy
(
struct
vector
*
v
);
void
cpio_rm
(
struct
vector
*
v
,
int
recursive
,
const
char
*
entry
);
void
cpio_rm
(
struct
vector
*
v
,
int
recursive
,
const
char
*
entry
);
void
cpio_mkdir
(
struct
vector
*
v
,
mode_t
mode
,
const
char
*
entry
);
void
cpio_mkdir
(
struct
vector
*
v
,
mode_t
mode
,
const
char
*
entry
);
void
cpio_ln
(
struct
vector
*
v
,
const
char
*
target
,
const
char
*
entry
);
void
cpio_add
(
struct
vector
*
v
,
mode_t
mode
,
const
char
*
entry
,
const
char
*
filename
);
void
cpio_add
(
struct
vector
*
v
,
mode_t
mode
,
const
char
*
entry
,
const
char
*
filename
);
int
cpio_mv
(
struct
vector
*
v
,
const
char
*
from
,
const
char
*
to
);
int
cpio_mv
(
struct
vector
*
v
,
const
char
*
from
,
const
char
*
to
);
int
cpio_extract
(
struct
vector
*
v
,
const
char
*
entry
,
const
char
*
filename
);
int
cpio_extract
(
struct
vector
*
v
,
const
char
*
entry
,
const
char
*
filename
);
...
...
jni/magiskboot/main.c
View file @
2212800a
...
@@ -35,9 +35,11 @@ static void usage(char *arg0) {
...
@@ -35,9 +35,11 @@ static void usage(char *arg0) {
" Do cpio related cmds to <incpio> (modifications are done directly)
\n
"
" Do cpio related cmds to <incpio> (modifications are done directly)
\n
"
" Supported commands:
\n
"
" Supported commands:
\n
"
" -rm [-r] <entry>
\n
"
" -rm [-r] <entry>
\n
"
" Remove entry from <incpio>, flag
-r
to remove recursively
\n
"
" Remove entry from <incpio>, flag
[-r]
to remove recursively
\n
"
" -mkdir <mode> <entry>
\n
"
" -mkdir <mode> <entry>
\n
"
" Create directory as an <entry>
\n
"
" Create directory as an <entry>
\n
"
" -ln <target> <entry>
\n
"
" Create symlink <entry> to point to <target>
\n
"
" -add <mode> <entry> <infile>
\n
"
" -add <mode> <entry> <infile>
\n
"
" Add <infile> as an <entry>; replaces <entry> if already exists
\n
"
" Add <infile> as an <entry>; replaces <entry> if already exists
\n
"
" -mv <from-entry> <to-entry>
\n
"
" -mv <from-entry> <to-entry>
\n
"
...
...
jni/magiskboot/ramdisk.c
View file @
2212800a
...
@@ -105,6 +105,8 @@ int cpio_commands(const char *command, int argc, char *argv[]) {
...
@@ -105,6 +105,8 @@ int cpio_commands(const char *command, int argc, char *argv[]) {
return
cpio_extract
(
&
v
,
argv
[
0
],
argv
[
1
]);
return
cpio_extract
(
&
v
,
argv
[
0
],
argv
[
1
]);
}
else
if
(
argc
==
2
&&
strcmp
(
command
,
"mkdir"
)
==
0
)
{
}
else
if
(
argc
==
2
&&
strcmp
(
command
,
"mkdir"
)
==
0
)
{
cpio_mkdir
(
&
v
,
strtoul
(
argv
[
0
],
NULL
,
8
),
argv
[
1
]);
cpio_mkdir
(
&
v
,
strtoul
(
argv
[
0
],
NULL
,
8
),
argv
[
1
]);
}
else
if
(
argc
==
2
&&
strcmp
(
command
,
"ln"
)
==
0
)
{
cpio_ln
(
&
v
,
argv
[
0
],
argv
[
1
]);
}
else
if
(
argc
==
3
&&
strcmp
(
command
,
"add"
)
==
0
)
{
}
else
if
(
argc
==
3
&&
strcmp
(
command
,
"add"
)
==
0
)
{
cpio_add
(
&
v
,
strtoul
(
argv
[
0
],
NULL
,
8
),
argv
[
1
],
argv
[
2
]);
cpio_add
(
&
v
,
strtoul
(
argv
[
0
],
NULL
,
8
),
argv
[
1
],
argv
[
2
]);
}
else
{
}
else
{
...
...
jni/utils/cpio.c
View file @
2212800a
...
@@ -164,6 +164,15 @@ void cpio_mkdir(struct vector *v, mode_t mode, const char *entry) {
...
@@ -164,6 +164,15 @@ void cpio_mkdir(struct vector *v, mode_t mode, const char *entry) {
fprintf
(
stderr
,
"Create directory [%s] (%04o)
\n
"
,
entry
,
mode
);
fprintf
(
stderr
,
"Create directory [%s] (%04o)
\n
"
,
entry
,
mode
);
}
}
void
cpio_ln
(
struct
vector
*
v
,
const
char
*
target
,
const
char
*
entry
)
{
cpio_entry
*
f
=
xcalloc
(
sizeof
(
*
f
),
1
);
f
->
mode
=
S_IFLNK
;
f
->
filename
=
strdup
(
entry
);
f
->
data
=
strdup
(
target
);
cpio_vec_insert
(
v
,
f
);
fprintf
(
stderr
,
"Create symlink [%s] -> [%s]
\n
"
,
entry
,
target
);
}
void
cpio_add
(
struct
vector
*
v
,
mode_t
mode
,
const
char
*
entry
,
const
char
*
filename
)
{
void
cpio_add
(
struct
vector
*
v
,
mode_t
mode
,
const
char
*
entry
,
const
char
*
filename
)
{
int
fd
=
xopen
(
filename
,
O_RDONLY
);
int
fd
=
xopen
(
filename
,
O_RDONLY
);
cpio_entry
*
f
=
xcalloc
(
sizeof
(
*
f
),
1
);
cpio_entry
*
f
=
xcalloc
(
sizeof
(
*
f
),
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