From 522bacb1f06eb8a7df317277981b3ee5911579b4 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 11 May 2019 11:59:26 +1000 Subject: [PATCH] [c-host] linux: remove extra shm device name validation This is now validated by the option validator callback --- VERSION | 2 +- c-host/platform/Linux/src/platform.c | 71 +++++++++------------------- 2 files changed, 24 insertions(+), 49 deletions(-) diff --git a/VERSION b/VERSION index 22cdcc4b..4a4d8b2a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -a12-176-g823164a924+1 \ No newline at end of file +a12-177-gcf030f6f0c+1 \ No newline at end of file diff --git a/c-host/platform/Linux/src/platform.c b/c-host/platform/Linux/src/platform.c index 397a7f39..86de7f48 100644 --- a/c-host/platform/Linux/src/platform.c +++ b/c-host/platform/Linux/src/platform.c @@ -200,62 +200,37 @@ bool app_init() { const char * shmDevice = option_get_string("os", "shmDevice"); - // check the deice name - { - char * name = uioGetName(shmDevice); - if (!name) - { - DEBUG_ERROR("Failed to read the shmDevice name for: %s", shmDevice); - DEBUG_ERROR("Did you remmeber to modprobe the kvmfr module?"); - return false; - } - - if (strcmp(name, "KVMFR") != 0) - { - free(name); - DEBUG_ERROR("Device is not a KVMFR device \"%s\" reports as: %s", shmDevice, name); - return false; - } - - free(name); - } - // get the device size + int fd = uioOpenFile(shmDevice, "maps/map0/size"); + if (fd < 0) { - int fd = uioOpenFile(shmDevice, "maps/map0/size"); - if (fd < 0) - { - DEBUG_ERROR("Failed to open %s/size", shmDevice); - DEBUG_ERROR("Did you remmeber to modprobe the kvmfr module?"); - return false; - } - - char size[32]; - int len = read(fd, size, sizeof(size) - 1); - if (len <= 0) - { - DEBUG_ERROR("Failed to read the device size"); - close(fd); - return false; - } - size[len] = '\0'; - close(fd); - - app.shmSize = strtoul(size, NULL, 16); + DEBUG_ERROR("Failed to open %s/size", shmDevice); + DEBUG_ERROR("Did you remmeber to modprobe the kvmfr module?"); + return false; } + char size[32]; + int len = read(fd, size, sizeof(size) - 1); + if (len <= 0) + { + DEBUG_ERROR("Failed to read the device size"); + close(fd); + return false; + } + size[len] = '\0'; + close(fd); + + app.shmSize = strtoul(size, NULL, 16); + // open the device - { - app.shmFD = shmOpenDev(shmDevice); - app.shmMap = MAP_FAILED; - if (app.shmFD < 0) - return false; + app.shmFD = shmOpenDev(shmDevice); + app.shmMap = MAP_FAILED; + if (app.shmFD < 0) + return false; - DEBUG_INFO("KVMFR Device : %s", shmDevice); - } + DEBUG_INFO("KVMFR Device : %s", shmDevice); signal(SIGINT, sigHandler); - return true; }