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
1816ca6b
Commit
1816ca6b
authored
Sep 14, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Seperate logging to another header
parent
7394ff93
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
72 additions
and
60 deletions
+72
-60
Android.mk
jni/Android.mk
+1
-2
magisk.c
jni/daemon/magisk.c
+16
-0
logging.h
jni/include/logging.h
+49
-0
magisk.h
jni/include/magisk.h
+3
-29
utils.h
jni/include/utils.h
+0
-1
magisk.h
jni/magiskboot/magisk.h
+0
-10
magiskboot.h
jni/magiskboot/magiskboot.h
+1
-1
misc.c
jni/utils/misc.c
+1
-16
xwrap.c
jni/utils/xwrap.c
+1
-1
No files found.
jni/Android.mk
View file @
1816ca6b
...
@@ -56,7 +56,7 @@ LOCAL_SRC_FILES := \
...
@@ -56,7 +56,7 @@ LOCAL_SRC_FILES := \
su/su_daemon.c \
su/su_daemon.c \
su/su_socket.c
su/su_socket.c
LOCAL_CFLAGS := -Wno-implicit-exception-spec-mismatch
LOCAL_CFLAGS := -Wno-implicit-exception-spec-mismatch
-DIS_DAEMON
LOCAL_CPPFLAGS := -std=c++11
LOCAL_CPPFLAGS := -std=c++11
LOCAL_LDLIBS := -llog
LOCAL_LDLIBS := -llog
include $(BUILD_EXECUTABLE)
include $(BUILD_EXECUTABLE)
...
@@ -66,7 +66,6 @@ include $(CLEAR_VARS)
...
@@ -66,7 +66,6 @@ include $(CLEAR_VARS)
LOCAL_MODULE := magiskboot
LOCAL_MODULE := magiskboot
LOCAL_STATIC_LIBRARIES := libz liblzma liblz4 libbz2
LOCAL_STATIC_LIBRARIES := libz liblzma liblz4 libbz2
LOCAL_C_INCLUDES := \
LOCAL_C_INCLUDES := \
jni/magiskboot \
jni/include \
jni/include \
$(LIBZ) \
$(LIBZ) \
$(LIBLZMA) \
$(LIBLZMA) \
...
...
jni/daemon/magisk.c
View file @
1816ca6b
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include "utils.h"
#include "utils.h"
#include "magisk.h"
#include "magisk.h"
...
@@ -16,6 +17,21 @@ char *applet[] =
...
@@ -16,6 +17,21 @@ char *applet[] =
int
(
*
applet_main
[])
(
int
,
char
*
[])
=
int
(
*
applet_main
[])
(
int
,
char
*
[])
=
{
su_client_main
,
resetprop_main
,
secilc_main
,
magiskpolicy_main
,
magiskpolicy_main
,
magiskpolicy_main
,
magiskhide_main
,
NULL
};
{
su_client_main
,
resetprop_main
,
secilc_main
,
magiskpolicy_main
,
magiskpolicy_main
,
magiskpolicy_main
,
magiskhide_main
,
NULL
};
int
create_links
(
const
char
*
bin
,
const
char
*
path
)
{
char
self
[
PATH_MAX
],
linkpath
[
PATH_MAX
];
if
(
bin
==
NULL
)
{
xreadlink
(
"/proc/self/exe"
,
self
,
sizeof
(
self
));
bin
=
self
;
}
int
ret
=
0
;
for
(
int
i
=
0
;
applet
[
i
];
++
i
)
{
snprintf
(
linkpath
,
sizeof
(
linkpath
),
"%s/%s"
,
path
,
applet
[
i
]);
unlink
(
linkpath
);
ret
|=
symlink
(
bin
,
linkpath
);
}
return
ret
;
}
// Global error hander function
// Global error hander function
// Should be changed each thread/process
// Should be changed each thread/process
__thread
void
(
*
err_handler
)(
void
);
__thread
void
(
*
err_handler
)(
void
);
...
...
jni/include/logging.h
0 → 100644
View file @
1816ca6b
/* logging.h - Error handling and logging
*/
#ifndef _LOGGING_H_
#define _LOGGING_H_
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#ifdef IS_DAEMON
#include <pthread.h>
#include <android/log.h>
#define LOG_TAG "Magisk"
// Global handler for PLOGE
extern
__thread
void
(
*
err_handler
)(
void
);
// Common error handlers
static
inline
void
exit_proc
()
{
exit
(
1
);
}
static
inline
void
exit_thread
()
{
pthread_exit
(
NULL
);
}
static
inline
void
do_nothing
()
{}
// Dummy function to depress debug message
static
inline
void
stub
(
const
char
*
fmt
,
...)
{}
#ifdef MAGISK_DEBUG
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#else
#define LOGD(...) stub(__VA_ARGS__)
#endif
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define PLOGE(fmt, args...) { LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno)); err_handler(); }
#else // IS_DAEMON
#include <stdio.h>
#define LOGE(err, ...) { fprintf(stderr, __VA_ARGS__); exit(err); }
#define PLOGE(fmt, args...) { fprintf(stderr, fmt " failed with %d: %s\n\n", ##args, errno, strerror(errno)); exit(1); }
#endif // IS_DAEMON
#endif // _LOGGING_H_
jni/include/magisk.h
View file @
1816ca6b
...
@@ -4,11 +4,7 @@
...
@@ -4,11 +4,7 @@
#ifndef _MAGISK_H_
#ifndef _MAGISK_H_
#define _MAGISK_H_
#define _MAGISK_H_
#include <stdlib.h>
#include "logging.h"
#include <errno.h>
#include <string.h>
#include <pthread.h>
#include <android/log.h>
#define str(a) #a
#define str(a) #a
#define xstr(a) str(a)
#define xstr(a) str(a)
...
@@ -16,8 +12,6 @@
...
@@ -16,8 +12,6 @@
#define MAGISK_VER_STR xstr(MAGISK_VERSION) ":MAGISK"
#define MAGISK_VER_STR xstr(MAGISK_VERSION) ":MAGISK"
#define REQUESTOR_DAEMON_PATH "\0MAGISK"
#define REQUESTOR_DAEMON_PATH "\0MAGISK"
#define LOG_TAG "Magisk"
#ifndef ARG_MAX
#ifndef ARG_MAX
#define ARG_MAX 4096
#define ARG_MAX 4096
#endif
#endif
...
@@ -48,33 +42,13 @@
...
@@ -48,33 +42,13 @@
#define MAGISKHIDE_PROP "persist.magisk.hide"
#define MAGISKHIDE_PROP "persist.magisk.hide"
// Global handler for PLOGE
extern
__thread
void
(
*
err_handler
)(
void
);
// Common error handlers
static
inline
void
exit_proc
()
{
exit
(
1
);
}
static
inline
void
exit_thread
()
{
pthread_exit
(
NULL
);
}
static
inline
void
do_nothing
()
{}
// Dummy function to depress debug message
static
inline
void
stub
(
const
char
*
fmt
,
...)
{}
#ifdef MAGISK_DEBUG
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#else
#define LOGD(...) stub(__VA_ARGS__)
#endif
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define PLOGE(fmt, args...) { LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno)); err_handler(); }
extern
char
*
argv0
;
/* For changing process name */
extern
char
*
argv0
;
/* For changing process name */
extern
char
*
applet
[];
extern
char
*
applet
[];
extern
int
(
*
applet_main
[])
(
int
,
char
*
[]);
extern
int
(
*
applet_main
[])
(
int
,
char
*
[]);
int
create_links
(
const
char
*
bin
,
const
char
*
path
);
// Multi-call entrypoints
// Multi-call entrypoints
int
magiskhide_main
(
int
argc
,
char
*
argv
[]);
int
magiskhide_main
(
int
argc
,
char
*
argv
[]);
int
magiskpolicy_main
(
int
argc
,
char
*
argv
[]);
int
magiskpolicy_main
(
int
argc
,
char
*
argv
[]);
...
...
jni/include/utils.h
View file @
1816ca6b
...
@@ -78,7 +78,6 @@ int vector_to_file(const char* filename, struct vector *v);
...
@@ -78,7 +78,6 @@ int vector_to_file(const char* filename, struct vector *v);
ssize_t
fdgets
(
char
*
buf
,
size_t
size
,
int
fd
);
ssize_t
fdgets
(
char
*
buf
,
size_t
size
,
int
fd
);
void
ps
(
void
(
*
func
)(
int
));
void
ps
(
void
(
*
func
)(
int
));
void
ps_filter_proc_name
(
const
char
*
filter
,
void
(
*
func
)(
int
));
void
ps_filter_proc_name
(
const
char
*
filter
,
void
(
*
func
)(
int
));
int
create_links
(
const
char
*
bin
,
const
char
*
path
);
void
unlock_blocks
();
void
unlock_blocks
();
void
setup_sighandlers
(
void
(
*
handler
)(
int
));
void
setup_sighandlers
(
void
(
*
handler
)(
int
));
int
exec_command
(
int
err
,
int
*
fd
,
void
(
*
setupenv
)(
struct
vector
*
),
const
char
*
argv0
,
...);
int
exec_command
(
int
err
,
int
*
fd
,
void
(
*
setupenv
)(
struct
vector
*
),
const
char
*
argv0
,
...);
...
...
jni/magiskboot/magisk.h
deleted
100644 → 0
View file @
7394ff93
/* magisk.h - Let MagiskBoot use the same error handling API as main magisk program
*/
#ifndef _MAGISK_H_
#define _MAGISK_H_
#define LOGE(err, ...) { fprintf(stderr, __VA_ARGS__); exit(err); }
#define PLOGE(fmt, args...) { fprintf(stderr, fmt " failed with %d: %s\n\n", ##args, errno, strerror(errno)); exit(1); }
#endif
jni/magiskboot/magiskboot.h
View file @
1816ca6b
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
#include "bootimg.h"
#include "bootimg.h"
#include "sha1.h"
#include "sha1.h"
#include "
magisk
.h"
#include "
logging
.h"
#include "utils.h"
#include "utils.h"
#include "magic.h"
#include "magic.h"
...
...
jni/utils/misc.c
View file @
1816ca6b
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include <selinux/selinux.h>
#include <selinux/selinux.h>
#include "
magisk
.h"
#include "
logging
.h"
#include "utils.h"
#include "utils.h"
int
quit_signals
[]
=
{
SIGALRM
,
SIGABRT
,
SIGHUP
,
SIGPIPE
,
SIGQUIT
,
SIGTERM
,
SIGINT
,
0
};
int
quit_signals
[]
=
{
SIGALRM
,
SIGABRT
,
SIGHUP
,
SIGPIPE
,
SIGQUIT
,
SIGTERM
,
SIGINT
,
0
};
...
@@ -167,21 +167,6 @@ void ps_filter_proc_name(const char *pattern, void (*func)(int)) {
...
@@ -167,21 +167,6 @@ void ps_filter_proc_name(const char *pattern, void (*func)(int)) {
ps
(
proc_name_filter
);
ps
(
proc_name_filter
);
}
}
int
create_links
(
const
char
*
bin
,
const
char
*
path
)
{
char
self
[
PATH_MAX
],
linkpath
[
PATH_MAX
];
if
(
bin
==
NULL
)
{
xreadlink
(
"/proc/self/exe"
,
self
,
sizeof
(
self
));
bin
=
self
;
}
int
ret
=
0
;
for
(
int
i
=
0
;
applet
[
i
];
++
i
)
{
snprintf
(
linkpath
,
sizeof
(
linkpath
),
"%s/%s"
,
path
,
applet
[
i
]);
unlink
(
linkpath
);
ret
|=
symlink
(
bin
,
linkpath
);
}
return
ret
;
}
#define DEV_BLOCK "/dev/block"
#define DEV_BLOCK "/dev/block"
void
unlock_blocks
()
{
void
unlock_blocks
()
{
...
...
jni/utils/xwrap.c
View file @
1816ca6b
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#include <sys/mman.h>
#include <sys/mman.h>
#include <sys/sendfile.h>
#include <sys/sendfile.h>
#include "
magisk
.h"
#include "
logging
.h"
#include "utils.h"
#include "utils.h"
FILE
*
xfopen
(
const
char
*
pathname
,
const
char
*
mode
)
{
FILE
*
xfopen
(
const
char
*
pathname
,
const
char
*
mode
)
{
...
...
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