Merge pull request #2015 from LudwigOrtmann/native_real-accept
native: add missing syscall declarations
This commit is contained in:
commit
d4e651ad8b
@ -106,24 +106,24 @@ int init_tcp_socket(char *tcpport)
|
|||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_flags = AI_PASSIVE;
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
if ((i = getaddrinfo(NULL, tcpport, &hints, &info)) != 0) {
|
if ((i = real_getaddrinfo(NULL, tcpport, &hints, &info)) != 0) {
|
||||||
errx(EXIT_FAILURE,
|
errx(EXIT_FAILURE,
|
||||||
"init_uart_socket: getaddrinfo: %s", gai_strerror(i));
|
"init_uart_socket: getaddrinfo: %s", real_gai_strerror(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (p = info; p != NULL; p = p->ai_next) {
|
for (p = info; p != NULL; p = p->ai_next) {
|
||||||
if ((s = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
|
if ((s = real_socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
|
||||||
warn("init_uart_socket: socket");
|
warn("init_uart_socket: socket");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 1;
|
i = 1;
|
||||||
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(int)) == -1) {
|
if (real_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(int)) == -1) {
|
||||||
err(EXIT_FAILURE, "init_uart_socket: setsockopt");
|
err(EXIT_FAILURE, "init_uart_socket: setsockopt");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (real_bind(s, p->ai_addr, p->ai_addrlen) == -1) {
|
if (real_bind(s, p->ai_addr, p->ai_addrlen) == -1) {
|
||||||
close(s);
|
real_close(s);
|
||||||
warn("init_uart_socket: bind");
|
warn("init_uart_socket: bind");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ int init_tcp_socket(char *tcpport)
|
|||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
errx(EXIT_FAILURE, "init_uart_socket: failed to bind\n");
|
errx(EXIT_FAILURE, "init_uart_socket: failed to bind\n");
|
||||||
}
|
}
|
||||||
freeaddrinfo(info);
|
real_freeaddrinfo(info);
|
||||||
|
|
||||||
if (real_listen(s, 1) == -1) {
|
if (real_listen(s, 1) == -1) {
|
||||||
err(EXIT_FAILURE, "init_uart_socket: listen");
|
err(EXIT_FAILURE, "init_uart_socket: listen");
|
||||||
@ -147,7 +147,7 @@ int init_unix_socket(void)
|
|||||||
int s;
|
int s;
|
||||||
struct sockaddr_un sa;
|
struct sockaddr_un sa;
|
||||||
|
|
||||||
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
|
if ((s = real_socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
|
||||||
err(EXIT_FAILURE, "init_unix_socket: socket");
|
err(EXIT_FAILURE, "init_unix_socket: socket");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ void handle_uart_sock(void)
|
|||||||
t = sizeof(remote);
|
t = sizeof(remote);
|
||||||
|
|
||||||
_native_syscall_enter();
|
_native_syscall_enter();
|
||||||
if ((s = accept(_native_uart_sock, &remote, &t)) == -1) {
|
if ((s = real_accept(_native_uart_sock, &remote, &t)) == -1) {
|
||||||
err(EXIT_FAILURE, "handle_uart_sock: accept");
|
err(EXIT_FAILURE, "handle_uart_sock: accept");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -43,6 +43,7 @@
|
|||||||
#include <ucontext.h>
|
#include <ucontext.h>
|
||||||
#endif
|
#endif
|
||||||
#endif // BSD/Linux
|
#endif // BSD/Linux
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
#include "kernel_types.h"
|
#include "kernel_types.h"
|
||||||
|
|
||||||
@ -77,6 +78,9 @@ extern void (*real_free)(void *ptr);
|
|||||||
extern void* (*real_calloc)(size_t nmemb, size_t size);
|
extern void* (*real_calloc)(size_t nmemb, size_t size);
|
||||||
extern void* (*real_malloc)(size_t size);
|
extern void* (*real_malloc)(size_t size);
|
||||||
extern void* (*real_realloc)(void *ptr, size_t size);
|
extern void* (*real_realloc)(void *ptr, size_t size);
|
||||||
|
extern void (*real_freeaddrinfo)(struct addrinfo *res);
|
||||||
|
/* The ... is a hack to save includes: */
|
||||||
|
extern int (*real_accept)(int socket, ...);
|
||||||
/* The ... is a hack to save includes: */
|
/* The ... is a hack to save includes: */
|
||||||
extern int (*real_bind)(int socket, ...);
|
extern int (*real_bind)(int socket, ...);
|
||||||
extern int (*real_close)(int);
|
extern int (*real_close)(int);
|
||||||
@ -85,12 +89,17 @@ extern int (*real_execve)(const char *, char *const[], char *const[]);
|
|||||||
extern int (*real_feof)(FILE *stream);
|
extern int (*real_feof)(FILE *stream);
|
||||||
extern int (*real_ferror)(FILE *stream);
|
extern int (*real_ferror)(FILE *stream);
|
||||||
extern int (*real_fork)(void);
|
extern int (*real_fork)(void);
|
||||||
|
/* The ... is a hack to save includes: */
|
||||||
|
extern int (*real_getaddrinfo)(const char *node, ...);
|
||||||
extern int (*real_getpid)(void);
|
extern int (*real_getpid)(void);
|
||||||
extern int (*real_listen)(int socket, int backlog);
|
extern int (*real_listen)(int socket, int backlog);
|
||||||
extern int (*real_pause)(void);
|
extern int (*real_pause)(void);
|
||||||
extern int (*real_pipe)(int[2]);
|
extern int (*real_pipe)(int[2]);
|
||||||
|
extern int (*real_setsockopt)(int socket, ...);
|
||||||
|
extern int (*real_socket)(int domain, int type, int protocol);
|
||||||
extern int (*real_printf)(const char *format, ...);
|
extern int (*real_printf)(const char *format, ...);
|
||||||
extern int (*real_unlink)(const char *);
|
extern int (*real_unlink)(const char *);
|
||||||
|
extern const char* (*real_gai_strerror)(int errcode);
|
||||||
extern FILE* (*real_fopen)(const char *path, const char *mode);
|
extern FILE* (*real_fopen)(const char *path, const char *mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -421,7 +421,7 @@ int unregister_interrupt(int sig)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown(int sig, siginfo_t *info, void *context)
|
static void native_shutdown(int sig, siginfo_t *info, void *context)
|
||||||
{
|
{
|
||||||
(void)sig;
|
(void)sig;
|
||||||
(void)info;
|
(void)info;
|
||||||
@ -510,8 +510,8 @@ void native_interrupt_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allow for ctrl+c to shut down gracefully always */
|
/* allow for ctrl+c to shut down gracefully always */
|
||||||
//register_interrupt(SIGINT, shutdown);
|
//register_interrupt(SIGINT, native_shutdown);
|
||||||
sa.sa_sigaction = shutdown;
|
sa.sa_sigaction = native_shutdown;
|
||||||
if (sigdelset(&_native_sig_set, SIGINT) == -1) {
|
if (sigdelset(&_native_sig_set, SIGINT) == -1) {
|
||||||
err(EXIT_FAILURE, "native_interrupt_init: sigdelset");
|
err(EXIT_FAILURE, "native_interrupt_init: sigdelset");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,10 +55,12 @@ void (*real_free)(void *ptr);
|
|||||||
void* (*real_malloc)(size_t size);
|
void* (*real_malloc)(size_t size);
|
||||||
void* (*real_calloc)(size_t nmemb, size_t size);
|
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);
|
||||||
|
void (*real_freeaddrinfo)(struct addrinfo *res);
|
||||||
|
int (*real_accept)(int socket, ...);
|
||||||
int (*real_bind)(int socket, ...);
|
int (*real_bind)(int socket, ...);
|
||||||
int (*real_printf)(const char *format, ...);
|
int (*real_printf)(const char *format, ...);
|
||||||
|
int (*real_getaddrinfo)(const char *node, ...);
|
||||||
int (*real_getpid)(void);
|
int (*real_getpid)(void);
|
||||||
int (*real_pipe)(int[2]);
|
|
||||||
int (*real_close)(int);
|
int (*real_close)(int);
|
||||||
int (*real_dup2)(int, int);
|
int (*real_dup2)(int, int);
|
||||||
int (*real_execve)(const char *, char *const[], char *const[]);
|
int (*real_execve)(const char *, char *const[], char *const[]);
|
||||||
@ -67,7 +69,11 @@ int (*real_feof)(FILE *stream);
|
|||||||
int (*real_ferror)(FILE *stream);
|
int (*real_ferror)(FILE *stream);
|
||||||
int (*real_listen)(int socket, int backlog);
|
int (*real_listen)(int socket, int backlog);
|
||||||
int (*real_pause)(void);
|
int (*real_pause)(void);
|
||||||
|
int (*real_pipe)(int[2]);
|
||||||
|
int (*real_setsockopt)(int socket, ...);
|
||||||
|
int (*real_socket)(int domain, int type, int protocol);
|
||||||
int (*real_unlink)(const char *);
|
int (*real_unlink)(const char *);
|
||||||
|
const char* (*real_gai_strerror)(int errcode);
|
||||||
FILE* (*real_fopen)(const char *path, const char *mode);
|
FILE* (*real_fopen)(const char *path, const char *mode);
|
||||||
|
|
||||||
void _native_syscall_enter(void)
|
void _native_syscall_enter(void)
|
||||||
@ -355,13 +361,19 @@ void _native_init_syscalls(void)
|
|||||||
*(void **)(&real_malloc) = dlsym(RTLD_NEXT, "malloc");
|
*(void **)(&real_malloc) = dlsym(RTLD_NEXT, "malloc");
|
||||||
*(void **)(&real_realloc) = dlsym(RTLD_NEXT, "realloc");
|
*(void **)(&real_realloc) = dlsym(RTLD_NEXT, "realloc");
|
||||||
*(void **)(&real_free) = dlsym(RTLD_NEXT, "free");
|
*(void **)(&real_free) = dlsym(RTLD_NEXT, "free");
|
||||||
|
*(void **)(&real_freeaddrinfo) = dlsym(RTLD_NEXT, "freeaddrinfo");
|
||||||
|
*(void **)(&real_accept) = dlsym(RTLD_NEXT, "accept");
|
||||||
*(void **)(&real_bind) = dlsym(RTLD_NEXT, "bind");
|
*(void **)(&real_bind) = dlsym(RTLD_NEXT, "bind");
|
||||||
*(void **)(&real_printf) = dlsym(RTLD_NEXT, "printf");
|
*(void **)(&real_printf) = dlsym(RTLD_NEXT, "printf");
|
||||||
|
*(void **)(&real_gai_strerror) = dlsym(RTLD_NEXT, "gai_strerror");
|
||||||
|
*(void **)(&real_getaddrinfo) = dlsym(RTLD_NEXT, "getaddrinfo");
|
||||||
*(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_fork) = dlsym(RTLD_NEXT, "fork");
|
||||||
*(void **)(&real_dup2) = dlsym(RTLD_NEXT, "dup2");
|
*(void **)(&real_dup2) = dlsym(RTLD_NEXT, "dup2");
|
||||||
|
*(void **)(&real_setsockopt) = dlsym(RTLD_NEXT, "setsockopt");
|
||||||
|
*(void **)(&real_socket) = dlsym(RTLD_NEXT, "socket");
|
||||||
*(void **)(&real_unlink) = dlsym(RTLD_NEXT, "unlink");
|
*(void **)(&real_unlink) = dlsym(RTLD_NEXT, "unlink");
|
||||||
*(void **)(&real_execve) = dlsym(RTLD_NEXT, "execve");
|
*(void **)(&real_execve) = dlsym(RTLD_NEXT, "execve");
|
||||||
*(void **)(&real_listen) = dlsym(RTLD_NEXT, "listen");
|
*(void **)(&real_listen) = dlsym(RTLD_NEXT, "listen");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user