native: remove some warnings about undef functions
This PR implements `real_X` for `X in (fork, dup2, unlink, execve)`. These function caused warnings while making the default example.
This commit is contained in:
parent
80ecdaca17
commit
2f871ca885
@ -156,7 +156,7 @@ int init_unix_socket(void)
|
|||||||
else {
|
else {
|
||||||
snprintf(sa.sun_path, sizeof(sa.sun_path), "/tmp/riot.tty.%d", _native_pid);
|
snprintf(sa.sun_path, sizeof(sa.sun_path), "/tmp/riot.tty.%d", _native_pid);
|
||||||
}
|
}
|
||||||
unlink(sa.sun_path); /* remove stale socket */
|
real_unlink(sa.sun_path); /* remove stale socket */
|
||||||
if (bind(s, (struct sockaddr *)&sa, SUN_LEN(&sa)) == -1) {
|
if (bind(s, (struct sockaddr *)&sa, SUN_LEN(&sa)) == -1) {
|
||||||
err(EXIT_FAILURE, "init_unix_socket: bind");
|
err(EXIT_FAILURE, "init_unix_socket: bind");
|
||||||
}
|
}
|
||||||
@ -183,11 +183,11 @@ void handle_uart_in(void)
|
|||||||
/* end of file / socket closed */
|
/* end of file / socket closed */
|
||||||
if (_native_uart_conn != 0) {
|
if (_native_uart_conn != 0) {
|
||||||
if (_native_null_out_file != -1) {
|
if (_native_null_out_file != -1) {
|
||||||
if (dup2(_native_null_out_file, STDOUT_FILENO) == -1) {
|
if (real_dup2(_native_null_out_file, STDOUT_FILENO) == -1) {
|
||||||
err(EXIT_FAILURE, "handle_uart_in: dup2(STDOUT_FILENO)");
|
err(EXIT_FAILURE, "handle_uart_in: dup2(STDOUT_FILENO)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dup2(_native_null_in_pipe[0], STDIN_FILENO) == -1) {
|
if (real_dup2(_native_null_in_pipe[0], STDIN_FILENO) == -1) {
|
||||||
err(EXIT_FAILURE, "handle_uart_in: dup2(STDIN_FILENO)");
|
err(EXIT_FAILURE, "handle_uart_in: dup2(STDIN_FILENO)");
|
||||||
}
|
}
|
||||||
_native_uart_conn = 0;
|
_native_uart_conn = 0;
|
||||||
@ -221,10 +221,10 @@ void handle_uart_sock(void)
|
|||||||
warnx("handle_uart_sock: successfully accepted socket");
|
warnx("handle_uart_sock: successfully accepted socket");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dup2(s, STDOUT_FILENO) == -1) {
|
if (real_dup2(s, STDOUT_FILENO) == -1) {
|
||||||
err(EXIT_FAILURE, "handle_uart_sock: dup2()");
|
err(EXIT_FAILURE, "handle_uart_sock: dup2()");
|
||||||
}
|
}
|
||||||
if (dup2(s, STDIN_FILENO) == -1) {
|
if (real_dup2(s, STDIN_FILENO) == -1) {
|
||||||
err(EXIT_FAILURE, "handle_uart_sock: dup2()");
|
err(EXIT_FAILURE, "handle_uart_sock: dup2()");
|
||||||
}
|
}
|
||||||
_native_syscall_leave();
|
_native_syscall_leave();
|
||||||
|
|||||||
@ -61,6 +61,10 @@ extern void* (*real_realloc)(void *ptr, size_t size);
|
|||||||
extern int (*real_getpid)(void);
|
extern int (*real_getpid)(void);
|
||||||
extern int (*real_pipe)(int[2]);
|
extern int (*real_pipe)(int[2]);
|
||||||
extern int (*real_close)(int);
|
extern int (*real_close)(int);
|
||||||
|
extern int (*real_fork)(void);
|
||||||
|
extern int (*real_dup2)(int, int);
|
||||||
|
extern int (*real_unlink)(const char *);
|
||||||
|
extern int (*real_execve)(const char *, char *const[], char *const[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* data structures
|
* data structures
|
||||||
|
|||||||
@ -69,7 +69,7 @@ int reboot_arch(int mode)
|
|||||||
|
|
||||||
printf("\n\n\t\t!! REBOOT !!\n\n");
|
printf("\n\n\t\t!! REBOOT !!\n\n");
|
||||||
|
|
||||||
if (execve(_native_argv[0], _native_argv, NULL) == -1) {
|
if (real_execve(_native_argv[0], _native_argv, NULL) == -1) {
|
||||||
err(EXIT_FAILURE, "reboot: execve");
|
err(EXIT_FAILURE, "reboot: execve");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -153,7 +153,7 @@ void sigio_child()
|
|||||||
{
|
{
|
||||||
pid_t parent = _native_pid;
|
pid_t parent = _native_pid;
|
||||||
|
|
||||||
if ((sigio_child_pid = fork()) == -1) {
|
if ((sigio_child_pid = real_fork()) == -1) {
|
||||||
err(EXIT_FAILURE, "sigio_child: fork");
|
err(EXIT_FAILURE, "sigio_child: fork");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ void _native_null_in(char *stdiotype)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dup2(_native_null_in_pipe[0], STDIN_FILENO) == -1) {
|
if (real_dup2(_native_null_in_pipe[0], STDIN_FILENO) == -1) {
|
||||||
err(EXIT_FAILURE, "_native_null_in: dup2(STDIN_FILENO)");
|
err(EXIT_FAILURE, "_native_null_in: dup2(STDIN_FILENO)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ void _native_log_stdout(char *stdouttype)
|
|||||||
errx(EXIT_FAILURE, "_native_log_stdout: unknown log type");
|
errx(EXIT_FAILURE, "_native_log_stdout: unknown log type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dup2(stdout_outfile, STDOUT_FILENO) == -1) {
|
if (real_dup2(stdout_outfile, STDOUT_FILENO) == -1) {
|
||||||
err(EXIT_FAILURE, "_native_log_stdout: dup2(STDOUT_FILENO)");
|
err(EXIT_FAILURE, "_native_log_stdout: dup2(STDOUT_FILENO)");
|
||||||
}
|
}
|
||||||
_native_null_out_file = stdout_outfile;
|
_native_null_out_file = stdout_outfile;
|
||||||
@ -132,14 +132,14 @@ void _native_log_stderr(char *stderrtype)
|
|||||||
errx(EXIT_FAILURE, "_native_log_stderr: unknown log type");
|
errx(EXIT_FAILURE, "_native_log_stderr: unknown log type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dup2(stderr_outfile, STDERR_FILENO) == -1) {
|
if (real_dup2(stderr_outfile, STDERR_FILENO) == -1) {
|
||||||
err(EXIT_FAILURE, "_native_log_stderr: dup2(STDERR_FILENO)");
|
err(EXIT_FAILURE, "_native_log_stderr: dup2(STDERR_FILENO)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void daemonize(void)
|
void daemonize(void)
|
||||||
{
|
{
|
||||||
if ((_native_pid = fork()) == -1) {
|
if ((_native_pid = real_fork()) == -1) {
|
||||||
err(EXIT_FAILURE, "daemonize: fork");
|
err(EXIT_FAILURE, "daemonize: fork");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,6 +201,10 @@ __attribute__((constructor)) static void startup(int argc, char **argv)
|
|||||||
*(void **)(&real_getpid) = dlsym(RTLD_NEXT, "getpid");
|
*(void **)(&real_getpid) = dlsym(RTLD_NEXT, "getpid");
|
||||||
*(void **)(&real_pipe) = dlsym(RTLD_NEXT, "pipe");
|
*(void **)(&real_pipe) = dlsym(RTLD_NEXT, "pipe");
|
||||||
*(void **)(&real_close) = dlsym(RTLD_NEXT, "close");
|
*(void **)(&real_close) = dlsym(RTLD_NEXT, "close");
|
||||||
|
*(void **)(&real_fork) = dlsym(RTLD_NEXT, "fork");
|
||||||
|
*(void **)(&real_dup2) = dlsym(RTLD_NEXT, "dup2");
|
||||||
|
*(void **)(&real_unlink) = dlsym(RTLD_NEXT, "unlink");
|
||||||
|
*(void **)(&real_execve) = dlsym(RTLD_NEXT, "execve");
|
||||||
|
|
||||||
_native_argv = argv;
|
_native_argv = argv;
|
||||||
_progname = argv[0];
|
_progname = argv[0];
|
||||||
|
|||||||
@ -56,6 +56,10 @@ void* (*real_calloc)(size_t nmemb, size_t size);
|
|||||||
void* (*real_realloc)(void *ptr, size_t size);
|
void* (*real_realloc)(void *ptr, size_t size);
|
||||||
int (*real_pipe)(int[2]);
|
int (*real_pipe)(int[2]);
|
||||||
int (*real_close)(int);
|
int (*real_close)(int);
|
||||||
|
int (*real_fork)(void);
|
||||||
|
int (*real_dup2)(int, int);
|
||||||
|
int (*real_unlink)(const char *);
|
||||||
|
int (*real_execve)(const char *, char *const[], char *const[]);
|
||||||
|
|
||||||
void _native_syscall_enter(void)
|
void _native_syscall_enter(void)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user