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
d75fa62c
Commit
d75fa62c
authored
Jul 10, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust run_command function
parent
3d43c3c5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
15 deletions
+15
-15
bootstages.c
jni/daemon/bootstages.c
+1
-1
proc_monitor.c
jni/magiskhide/proc_monitor.c
+1
-1
img.c
jni/utils/img.c
+3
-3
misc.c
jni/utils/misc.c
+6
-6
utils.h
jni/utils/utils.h
+1
-1
xwrap.c
jni/utils/xwrap.c
+3
-3
No files found.
jni/daemon/bootstages.c
View file @
d75fa62c
...
...
@@ -749,7 +749,7 @@ void late_start(int client) {
"CLASSPATH=/system/framework/pm.jar "
"/system/bin/app_process /system/bin "
"com.android.commands.pm.Pm install -r "
MANAGERAPK
,
NULL
};
int
apk_res
=
0
,
pid
;
int
apk_res
=
-
1
,
pid
;
pid
=
run_command
(
1
,
&
apk_res
,
"/system/bin/sh"
,
command
);
waitpid
(
pid
,
NULL
,
0
);
fdgets
(
buf
,
PATH_MAX
,
apk_res
);
...
...
jni/magiskhide/proc_monitor.c
View file @
d75fa62c
...
...
@@ -127,7 +127,7 @@ void proc_monitor() {
// Monitor am_proc_start
char
*
const
command
[]
=
{
"logcat"
,
"-b"
,
"events"
,
"-v"
,
"raw"
,
"-s"
,
"am_proc_start"
,
NULL
};
log_fd
=
0
;
log_fd
=
-
1
;
log_pid
=
run_command
(
0
,
&
log_fd
,
"/system/bin/logcat"
,
command
);
if
(
log_pid
<
0
)
continue
;
...
...
jni/utils/img.c
View file @
d75fa62c
...
...
@@ -13,7 +13,7 @@
static
int
e2fsck
(
const
char
*
img
)
{
// Check and repair ext4 image
char
buffer
[
128
];
int
pid
,
fd
=
0
;
int
pid
,
fd
=
-
1
;
char
*
const
command
[]
=
{
"e2fsck"
,
"-yf"
,
(
char
*
)
img
,
NULL
};
pid
=
run_command
(
1
,
&
fd
,
"/system/bin/e2fsck"
,
command
);
if
(
pid
<
0
)
...
...
@@ -75,7 +75,7 @@ int get_img_size(const char *img, int *used, int *total) {
if
(
access
(
img
,
R_OK
)
==
-
1
)
return
1
;
char
buffer
[
PATH_MAX
];
int
pid
,
fd
=
0
,
status
=
1
;
int
pid
,
fd
=
-
1
,
status
=
1
;
char
*
const
command
[]
=
{
"e2fsck"
,
"-n"
,
(
char
*
)
img
,
NULL
};
pid
=
run_command
(
1
,
&
fd
,
"/system/bin/e2fsck"
,
command
);
if
(
pid
<
0
)
...
...
@@ -107,7 +107,7 @@ int resize_img(const char *img, int size) {
if
(
e2fsck
(
img
))
return
1
;
char
buffer
[
128
];
int
pid
,
status
,
fd
=
0
;
int
pid
,
status
,
fd
=
-
1
;
snprintf
(
buffer
,
sizeof
(
buffer
),
"%dM"
,
size
);
char
*
const
command
[]
=
{
"resize2fs"
,
(
char
*
)
img
,
buffer
,
NULL
};
pid
=
run_command
(
1
,
&
fd
,
"/system/bin/resize2fs"
,
command
);
...
...
jni/utils/misc.c
View file @
d75fa62c
...
...
@@ -221,21 +221,21 @@ void setup_sighandlers(void (*handler)(int)) {
/*
fd == NULL -> Ignore output
*fd
== 0
-> Open pipe and set *fd to the read end
*fd
!
= 0 -> STDOUT (or STDERR) will be redirected to *fd
*fd
< 0
-> Open pipe and set *fd to the read end
*fd
>
= 0 -> STDOUT (or STDERR) will be redirected to *fd
*/
int
run_command
(
int
err
,
int
*
fd
,
const
char
*
path
,
char
*
const
argv
[])
{
int
pipefd
[
2
],
writeEnd
=
-
1
;
if
(
fd
)
{
if
(
*
fd
)
{
writeEnd
=
*
fd
;
}
else
{
if
(
pipe
(
pipefd
)
==
-
1
)
if
(
*
fd
<
0
)
{
if
(
xpipe2
(
pipefd
,
O_CLOEXEC
)
==
-
1
)
return
-
1
;
writeEnd
=
pipefd
[
1
];
// Give the read end of the pipe
*
fd
=
pipefd
[
0
];
}
else
{
writeEnd
=
*
fd
;
}
}
...
...
jni/utils/utils.h
View file @
d75fa62c
...
...
@@ -31,7 +31,7 @@ int xopen3(const char *pathname, int flags, mode_t mode);
ssize_t
xwrite
(
int
fd
,
const
void
*
buf
,
size_t
count
);
ssize_t
xread
(
int
fd
,
void
*
buf
,
size_t
count
);
ssize_t
xxread
(
int
fd
,
void
*
buf
,
size_t
count
);
int
xpipe
(
int
pipefd
[
2
]
);
int
xpipe
2
(
int
pipefd
[
2
],
int
flags
);
int
xsetns
(
int
fd
,
int
nstype
);
DIR
*
xopendir
(
const
char
*
name
);
struct
dirent
*
xreaddir
(
DIR
*
dirp
);
...
...
jni/utils/xwrap.c
View file @
d75fa62c
...
...
@@ -82,10 +82,10 @@ ssize_t xxread(int fd, void *buf, size_t count) {
return
ret
;
}
int
xpipe
(
int
pipefd
[
2
]
)
{
int
ret
=
pipe
(
pipefd
);
int
xpipe
2
(
int
pipefd
[
2
],
int
flags
)
{
int
ret
=
pipe
2
(
pipefd
,
flags
);
if
(
ret
==
-
1
)
{
PLOGE
(
"pipe"
);
PLOGE
(
"pipe
2
"
);
}
return
ret
;
}
...
...
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