From 6650e58a4a401263c606b056ab78140ce7e2d08a Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 12 Oct 2020 17:48:31 +1100 Subject: [PATCH] [common] linux: print reason for failure to open the shm file/device --- common/src/platform/linux/ivshmem.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/src/platform/linux/ivshmem.c b/common/src/platform/linux/ivshmem.c index dc982cfd..dea25137 100644 --- a/common/src/platform/linux/ivshmem.c +++ b/common/src/platform/linux/ivshmem.c @@ -27,6 +27,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include +#include #include "common/debug.h" #include "common/option.h" @@ -196,6 +197,7 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) if (len <= 0) { DEBUG_ERROR("Failed to read the device size"); + DEBUG_ERROR("%s", strerror(errno)); close(fd); return false; } @@ -207,7 +209,7 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) if (devFD < 0) { DEBUG_ERROR("Failed to open: %s", shmDevice); - DEBUG_ERROR("Do you have permission to access the device?"); + DEBUG_ERROR("%s", strerror(errno)); return false; } } @@ -217,6 +219,7 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) if (stat(shmDevice, &st) != 0) { DEBUG_ERROR("Failed to stat: %s", shmDevice); + DEBUG_ERROR("%s", strerror(errno)); return false; } @@ -225,6 +228,7 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) if (devFD < 0) { DEBUG_ERROR("Failed to open: %s", shmDevice); + DEBUG_ERROR("%s", strerror(errno)); return false; } } @@ -233,6 +237,7 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) if (map == MAP_FAILED) { DEBUG_ERROR("Failed to map the shared memory device: %s", shmDevice); + DEBUG_ERROR("%s", strerror(errno)); return false; } @@ -264,4 +269,4 @@ void ivshmemClose(struct IVSHMEM * dev) dev->mem = NULL; dev->size = 0; dev->opaque = NULL; -} \ No newline at end of file +}