From aaaccf9d87604644ee84bd97a8c37aa8202f245b Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Sun, 13 Jul 2014 16:23:27 +0200 Subject: [PATCH] native: enable reboot with tap partially fixes #787 --- cpu/native/native_cpu.c | 11 +++++++++++ cpu/native/net/tap.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cpu/native/native_cpu.c b/cpu/native/native_cpu.c index 6d38fc8e9d..dfde2e3715 100644 --- a/cpu/native/native_cpu.c +++ b/cpu/native/native_cpu.c @@ -48,6 +48,9 @@ #include "cpu.h" #include "cpu-conf.h" +#ifdef MODULE_NATIVENET +#include "tap.h" +#endif #include "native_internal.h" @@ -68,6 +71,14 @@ int reboot_arch(int mode) (void) mode; printf("\n\n\t\t!! REBOOT !!\n\n"); +#ifdef MODULE_UART0 + /* TODO: close stdio fds */ +#endif +#ifdef MODULE_NATIVENET + if (_native_tap_fd != -1) { + real_close(_native_tap_fd); + } +#endif if (real_execve(_native_argv[0], _native_argv, NULL) == -1) { err(EXIT_FAILURE, "reboot: execve"); diff --git a/cpu/native/net/tap.c b/cpu/native/net/tap.c index 6acc0db076..ab734ea686 100644 --- a/cpu/native/net/tap.c +++ b/cpu/native/net/tap.c @@ -60,7 +60,7 @@ #define TAP_BUFFER_LENGTH (ETHER_MAX_LEN) int _native_marshall_ethernet(uint8_t *framebuf, radio_packet_t *packet); -int _native_tap_fd; +int _native_tap_fd = -1; unsigned char _native_tap_mac[ETHER_ADDR_LEN]; #ifdef __MACH__