diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/compatfd.c | 2 | ||||
-rw-r--r-- | util/drm.c | 19 | ||||
-rw-r--r-- | util/oslib-posix.c | 20 | ||||
-rw-r--r-- | util/qemu-openpty.c | 2 |
4 files changed, 36 insertions, 7 deletions
diff --git a/util/compatfd.c b/util/compatfd.c index c296f55..ee47dd8 100644 --- a/util/compatfd.c +++ b/util/compatfd.c @@ -16,7 +16,9 @@ #include "qemu/osdep.h" #include "qemu/thread.h" +#if defined(CONFIG_SIGNALFD) #include <sys/syscall.h> +#endif struct sigfd_compat_info { @@ -24,7 +24,8 @@ int qemu_drm_rendernode_open(const char *rendernode) { DIR *dir; struct dirent *e; - int r, fd; + struct stat st; + int r, fd, ret; char *p; if (rendernode) { @@ -38,10 +39,6 @@ int qemu_drm_rendernode_open(const char *rendernode) fd = -1; while ((e = readdir(dir))) { - if (e->d_type != DT_CHR) { - continue; - } - if (strncmp(e->d_name, "renderD", 7)) { continue; } @@ -53,6 +50,18 @@ int qemu_drm_rendernode_open(const char *rendernode) g_free(p); continue; } + + /* + * prefer fstat() over checking e->d_type == DT_CHR for + * portability reasons + */ + ret = fstat(r, &st); + if (ret < 0 || (st.st_mode & S_IFMT) != S_IFCHR) { + close(r); + g_free(p); + continue; + } + fd = r; g_free(p); break; diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 39ddc77..72907d4 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -38,7 +38,6 @@ #include "qemu/sockets.h" #include "qemu/thread.h" #include <libgen.h> -#include <sys/signal.h> #include "qemu/cutils.h" #ifdef CONFIG_LINUX @@ -61,6 +60,10 @@ #include <mach-o/dyld.h> #endif +#ifdef __HAIKU__ +#include <kernel/image.h> +#endif + #include "qemu/mmap-alloc.h" #ifdef CONFIG_DEBUG_STACK_USAGE @@ -390,6 +393,21 @@ void qemu_init_exec_dir(const char *argv0) } } } +#elif defined(__HAIKU__) + { + image_info ii; + int32_t c = 0; + + *buf = '\0'; + while (get_next_image_info(0, &c, &ii) == B_OK) { + if (ii.type == B_APP_IMAGE) { + strncpy(buf, ii.name, sizeof(buf)); + buf[sizeof(buf) - 1] = 0; + p = buf; + break; + } + } + } #endif /* If we don't have any way of figuring out the actual executable location then try argv[0]. */ diff --git a/util/qemu-openpty.c b/util/qemu-openpty.c index 4b8df96..eb17f5b 100644 --- a/util/qemu-openpty.c +++ b/util/qemu-openpty.c @@ -35,7 +35,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#if defined(__GLIBC__) +#if defined HAVE_PTY_H # include <pty.h> #elif defined CONFIG_BSD # include <termios.h> |