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
d66c284b
Commit
d66c284b
authored
May 04, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix several small issues
parent
69384828
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
34 deletions
+47
-34
bootstages.c
jni/daemon/bootstages.c
+18
-17
magiskhide.c
jni/magiskhide/magiskhide.c
+0
-3
resetprop.cpp
jni/resetprop/resetprop.cpp
+0
-5
misc.c
jni/utils/misc.c
+14
-8
utils.h
jni/utils/utils.h
+1
-0
vector.c
jni/utils/vector.c
+10
-0
vector.h
jni/utils/vector.h
+3
-0
flash_script.sh
scripts/flash_script.sh
+1
-1
No files found.
jni/daemon/bootstages.c
View file @
d66c284b
...
@@ -109,10 +109,9 @@ static int get_img_size(const char *img, int *used, int *total) {
...
@@ -109,10 +109,9 @@ static int get_img_size(const char *img, int *used, int *total) {
#define round_size(a) ((((a) / 32) + 1) * 32)
#define round_size(a) ((((a) / 32) + 1) * 32)
static
int
resize_img
(
const
char
*
img
,
int
size
)
{
static
int
resize_img
(
const
char
*
img
,
int
size
)
{
char
buffer
[
ARG_MAX
];
LOGI
(
"resize %s to %dM
\n
"
,
img
,
size
);
LOGI
(
"resize %s to %dM
\n
"
,
img
,
size
);
snprintf
(
buf
fer
,
sizeof
(
buffer
),
"e2fsck -yf %s &&
resize2fs %s %dM;"
,
img
,
img
,
size
);
snprintf
(
buf
,
PATH_MAX
,
"e2fsck -yf %s;
resize2fs %s %dM;"
,
img
,
img
,
size
);
return
system
(
buf
fer
);
return
system
(
buf
);
}
}
static
int
merge_img
(
const
char
*
source
,
const
char
*
target
)
{
static
int
merge_img
(
const
char
*
source
,
const
char
*
target
)
{
...
@@ -194,11 +193,11 @@ void exec_common_script(const char* stage) {
...
@@ -194,11 +193,11 @@ void exec_common_script(const char* stage) {
while
((
entry
=
xreaddir
(
dir
)))
{
while
((
entry
=
xreaddir
(
dir
)))
{
if
(
entry
->
d_type
==
DT_REG
)
{
if
(
entry
->
d_type
==
DT_REG
)
{
snprintf
(
buf
,
PATH_MAX
,
"%s/%s"
,
buf
,
entry
->
d_name
);
snprintf
(
buf
2
,
PATH_MAX
,
"%s/%s"
,
buf
,
entry
->
d_name
);
if
(
access
(
buf
,
X_OK
)
==
-
1
)
if
(
access
(
buf
2
,
X_OK
)
==
-
1
)
continue
;
continue
;
LOGI
(
"%s.d: exec [%s]
\n
"
,
stage
,
entry
->
d_name
);
LOGI
(
"%s.d: exec [%s]
\n
"
,
stage
,
entry
->
d_name
);
char
*
const
command
[]
=
{
"sh"
,
buf
,
NULL
};
char
*
const
command
[]
=
{
"sh"
,
buf
2
,
NULL
};
int
pid
=
run_command
(
NULL
,
"/system/bin/sh"
,
command
);
int
pid
=
run_command
(
NULL
,
"/system/bin/sh"
,
command
);
if
(
pid
!=
-
1
)
if
(
pid
!=
-
1
)
waitpid
(
pid
,
NULL
,
0
);
waitpid
(
pid
,
NULL
,
0
);
...
@@ -249,13 +248,14 @@ static char *get_full_path(struct node_entry *node) {
...
@@ -249,13 +248,14 @@ static char *get_full_path(struct node_entry *node) {
return
strdup
(
buffer
);
return
strdup
(
buffer
);
}
}
// Free the node and all children recursively
static
void
destroy_subtree
(
struct
node_entry
*
node
)
{
static
void
destroy_subtree
(
struct
node_entry
*
node
)
{
// Never free parent, since it shall be freed by themselves
// Never free parent, since it shall be freed by themselves
free
(
node
->
name
);
struct
node_entry
*
e
;
struct
node_entry
*
e
;
vec_for_each
(
node
->
children
,
e
)
{
vec_for_each
(
node
->
children
,
e
)
{
destroy_subtree
(
e
);
destroy_subtree
(
e
);
}
}
free
(
node
->
name
);
vec_destroy
(
node
->
children
);
vec_destroy
(
node
->
children
);
free
(
node
->
children
);
free
(
node
->
children
);
free
(
node
);
free
(
node
);
...
@@ -271,7 +271,9 @@ static void insert_child(struct node_entry *p, struct node_entry *c) {
...
@@ -271,7 +271,9 @@ static void insert_child(struct node_entry *p, struct node_entry *c) {
vec_for_each
(
p
->
children
,
e
)
{
vec_for_each
(
p
->
children
,
e
)
{
if
(
strcmp
(
e
->
name
,
c
->
name
)
==
0
)
{
if
(
strcmp
(
e
->
name
,
c
->
name
)
==
0
)
{
// Exist duplicate, replace
// Exist duplicate, replace
destroy_subtree
(
e
);
c
->
children
=
e
->
children
;
free
(
e
->
name
);
free
(
e
);
vec_entry
(
p
->
children
)[
_
]
=
c
;
vec_entry
(
p
->
children
)[
_
]
=
c
;
return
;
return
;
}
}
...
@@ -353,7 +355,8 @@ static void clone_skeleton(struct node_entry *node, const char *real_path) {
...
@@ -353,7 +355,8 @@ static void clone_skeleton(struct node_entry *node, const char *real_path) {
closedir
(
dir
);
closedir
(
dir
);
snprintf
(
buf
,
PATH_MAX
,
"%s%s"
,
DUMMDIR
,
real_path
);
snprintf
(
buf
,
PATH_MAX
,
"%s%s"
,
DUMMDIR
,
real_path
);
xmkdir_p
(
buf
,
0755
);
mkdir_p
(
buf
,
0755
);
clone_attr
(
real_path
,
buf
);
bind_mount
(
buf
,
real_path
);
bind_mount
(
buf
,
real_path
);
vec_for_each
(
node
->
children
,
child
)
{
vec_for_each
(
node
->
children
,
child
)
{
...
@@ -445,14 +448,7 @@ static void simple_mount(const char *path) {
...
@@ -445,14 +448,7 @@ static void simple_mount(const char *path) {
// Actual file path
// Actual file path
snprintf
(
buf
,
PATH_MAX
,
"%s/%s"
,
buf
,
entry
->
d_name
);
snprintf
(
buf
,
PATH_MAX
,
"%s/%s"
,
buf
,
entry
->
d_name
);
// Clone all attributes
// Clone all attributes
struct
stat
s
;
clone_attr
(
buf2
,
buf
);
xstat
(
buf2
,
&
s
);
chmod
(
buf
,
s
.
st_mode
&
0777
);
chown
(
buf
,
s
.
st_uid
,
s
.
st_gid
);
char
*
con
;
getfilecon
(
buf2
,
&
con
);
setfilecon
(
buf
,
con
);
free
(
con
);
// Finally, mount the file
// Finally, mount the file
bind_mount
(
buf
,
buf2
);
bind_mount
(
buf
,
buf2
);
}
}
...
@@ -689,6 +685,7 @@ void post_fs_data(int client) {
...
@@ -689,6 +685,7 @@ void post_fs_data(int client) {
if
(
strcmp
(
hide_prop
,
"1"
)
==
0
)
{
if
(
strcmp
(
hide_prop
,
"1"
)
==
0
)
{
pthread_t
thread
;
pthread_t
thread
;
xpthread_create
(
&
thread
,
NULL
,
start_magisk_hide
,
NULL
);
xpthread_create
(
&
thread
,
NULL
,
start_magisk_hide
,
NULL
);
pthread_detach
(
thread
);
}
}
free
(
hide_prop
);
free
(
hide_prop
);
}
}
...
@@ -703,6 +700,10 @@ void late_start(int client) {
...
@@ -703,6 +700,10 @@ void late_start(int client) {
write_int
(
client
,
0
);
write_int
(
client
,
0
);
close
(
client
);
close
(
client
);
// Allocate buffer
if
(
buf
==
NULL
)
buf
=
xmalloc
(
PATH_MAX
);
if
(
buf2
==
NULL
)
buf2
=
xmalloc
(
PATH_MAX
);
// Wait till the full patch is done
// Wait till the full patch is done
pthread_join
(
sepol_patch
,
NULL
);
pthread_join
(
sepol_patch
,
NULL
);
...
...
jni/magiskhide/magiskhide.c
View file @
d66c284b
...
@@ -57,9 +57,6 @@ void launch_magiskhide(int client) {
...
@@ -57,9 +57,6 @@ void launch_magiskhide(int client) {
hideEnabled
=
1
;
hideEnabled
=
1
;
if
(
init_resetprop
())
goto
error
;
if
(
client
!=
-
1
)
{
if
(
client
!=
-
1
)
{
if
(
setprop
(
"persist.magisk.hide"
,
"1"
))
if
(
setprop
(
"persist.magisk.hide"
,
"1"
))
goto
error
;
goto
error
;
...
...
jni/resetprop/resetprop.cpp
View file @
d66c284b
...
@@ -277,11 +277,6 @@ int resetprop_main(int argc, char *argv[]) {
...
@@ -277,11 +277,6 @@ int resetprop_main(int argc, char *argv[]) {
}
}
}
}
PRINT_D
(
"resetprop by nkk71 & topjohnwu
\n
"
);
if
(
init_resetprop
())
return
-
1
;
if
(
file
)
{
if
(
file
)
{
return
read_prop_file
(
filename
,
trigger
);
return
read_prop_file
(
filename
,
trigger
);
}
else
if
(
del
)
{
}
else
if
(
del
)
{
...
...
jni/utils/misc.c
View file @
d66c284b
...
@@ -308,7 +308,7 @@ int cp_afc(const char *source, const char *target) {
...
@@ -308,7 +308,7 @@ int cp_afc(const char *source, const char *target) {
int
clone_dir
(
const
char
*
source
,
const
char
*
target
)
{
int
clone_dir
(
const
char
*
source
,
const
char
*
target
)
{
DIR
*
dir
;
DIR
*
dir
;
struct
dirent
*
entry
;
struct
dirent
*
entry
;
char
*
s_path
,
*
t_path
,
*
con
;
char
*
s_path
,
*
t_path
;
if
(
!
(
dir
=
xopendir
(
source
)))
if
(
!
(
dir
=
xopendir
(
source
)))
return
1
;
return
1
;
...
@@ -316,13 +316,8 @@ int clone_dir(const char *source, const char *target) {
...
@@ -316,13 +316,8 @@ int clone_dir(const char *source, const char *target) {
s_path
=
xmalloc
(
PATH_MAX
);
s_path
=
xmalloc
(
PATH_MAX
);
t_path
=
xmalloc
(
PATH_MAX
);
t_path
=
xmalloc
(
PATH_MAX
);
struct
stat
buf
;
mkdir_p
(
target
,
0755
);
xstat
(
source
,
&
buf
);
clone_attr
(
source
,
target
);
mkdir_p
(
target
,
buf
.
st_mode
&
0777
);
xchmod
(
target
,
buf
.
st_mode
&
0777
);
lgetfilecon
(
source
,
&
con
);
lsetfilecon
(
target
,
con
);
free
(
con
);
while
((
entry
=
xreaddir
(
dir
)))
{
while
((
entry
=
xreaddir
(
dir
)))
{
if
(
strcmp
(
entry
->
d_name
,
"."
)
==
0
||
strcmp
(
entry
->
d_name
,
".."
)
==
0
)
if
(
strcmp
(
entry
->
d_name
,
"."
)
==
0
||
strcmp
(
entry
->
d_name
,
".."
)
==
0
)
...
@@ -380,3 +375,14 @@ int rm_rf(const char *target) {
...
@@ -380,3 +375,14 @@ int rm_rf(const char *target) {
}
}
return
0
;
return
0
;
}
}
void
clone_attr
(
const
char
*
source
,
const
char
*
target
)
{
struct
stat
buf
;
xstat
(
source
,
&
buf
);
chmod
(
target
,
buf
.
st_mode
&
0777
);
chown
(
target
,
buf
.
st_uid
,
buf
.
st_gid
);
char
*
con
;
lgetfilecon
(
source
,
&
con
);
lsetfilecon
(
target
,
con
);
free
(
con
);
}
jni/utils/utils.h
View file @
d66c284b
...
@@ -88,5 +88,6 @@ int open_new(const char *filename);
...
@@ -88,5 +88,6 @@ int open_new(const char *filename);
int
cp_afc
(
const
char
*
source
,
const
char
*
target
);
int
cp_afc
(
const
char
*
source
,
const
char
*
target
);
int
clone_dir
(
const
char
*
source
,
const
char
*
target
);
int
clone_dir
(
const
char
*
source
,
const
char
*
target
);
int
rm_rf
(
const
char
*
target
);
int
rm_rf
(
const
char
*
target
);
void
clone_attr
(
const
char
*
source
,
const
char
*
target
);
#endif
#endif
jni/utils/vector.c
View file @
d66c284b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
*/
*/
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include "vector.h"
#include "vector.h"
...
@@ -49,3 +50,12 @@ void vec_deep_destroy(struct vector *v) {
...
@@ -49,3 +50,12 @@ void vec_deep_destroy(struct vector *v) {
}
}
vec_destroy
(
v
);
vec_destroy
(
v
);
}
}
struct
vector
*
vec_dup
(
struct
vector
*
v
)
{
struct
vector
*
ret
=
malloc
(
sizeof
(
*
ret
));
vec_size
(
ret
)
=
vec_size
(
v
);
vec_cap
(
ret
)
=
vec_cap
(
v
);
vec_entry
(
v
)
=
malloc
(
sizeof
(
void
*
)
*
vec_cap
(
ret
));
memcpy
(
vec_entry
(
ret
),
vec_entry
(
v
),
sizeof
(
void
*
)
*
vec_cap
(
ret
));
return
ret
;
}
jni/utils/vector.h
View file @
d66c284b
...
@@ -11,11 +11,14 @@ struct vector {
...
@@ -11,11 +11,14 @@ struct vector {
size_t
cap
;
size_t
cap
;
void
**
data
;
void
**
data
;
};
};
void
vec_init
(
struct
vector
*
v
);
void
vec_init
(
struct
vector
*
v
);
void
vec_push_back
(
struct
vector
*
v
,
void
*
p
);
void
vec_push_back
(
struct
vector
*
v
,
void
*
p
);
void
vec_sort
(
struct
vector
*
v
,
int
(
*
compar
)(
const
void
*
,
const
void
*
));
void
vec_sort
(
struct
vector
*
v
,
int
(
*
compar
)(
const
void
*
,
const
void
*
));
void
vec_destroy
(
struct
vector
*
v
);
void
vec_destroy
(
struct
vector
*
v
);
void
vec_deep_destroy
(
struct
vector
*
v
);
void
vec_deep_destroy
(
struct
vector
*
v
);
struct
vector
*
vec_dup
(
struct
vector
*
v
);
#define vec_size(v) (v)->size
#define vec_size(v) (v)->size
#define vec_cap(v) (v)->cap
#define vec_cap(v) (v)->cap
#define vec_entry(v) (v)->data
#define vec_entry(v) (v)->data
...
...
scripts/flash_script.sh
View file @
d66c284b
...
@@ -285,7 +285,7 @@ if [ -f $IMG ]; then
...
@@ -285,7 +285,7 @@ if [ -f $IMG ]; then
ui_print
"-
$IMG
detected!"
ui_print
"-
$IMG
detected!"
else
else
ui_print
"- Creating
$IMG
"
ui_print
"- Creating
$IMG
"
make_ext4fs
-l
64
M
-a
/magisk
-S
$COMMONDIR
/file_contexts_image
$IMG
make_ext4fs
-l
32
M
-a
/magisk
-S
$COMMONDIR
/file_contexts_image
$IMG
fi
fi
mount_image
$IMG
/magisk
mount_image
$IMG
/magisk
...
...
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