intelmetool: Print strerror() results for mmap errors

These are more human readable for folks not familiar with errno values.

Change-Id: I21352a00b583163472ccd3302a83adf1f8396c61
Signed-off-by: Paul Wise <pabs3@bonedaddy.net>
Reviewed-on: https://review.coreboot.org/19560
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
This commit is contained in:
Paul Wise 2017-05-04 14:12:21 +08:00 committed by Martin Roth
parent 730fc6c7d8
commit 3c02699dd7
1 changed files with 5 additions and 4 deletions

View File

@ -15,6 +15,7 @@
#include "mmap.h" #include "mmap.h"
#include <errno.h> #include <errno.h>
#include <string.h>
#ifndef __DARWIN__ #ifndef __DARWIN__
int fd_mem; int fd_mem;
@ -28,8 +29,8 @@ void *map_physical_exact(off_t phys_addr, void *mapto, size_t len) {
if (virt_addr == MAP_FAILED) { if (virt_addr == MAP_FAILED) {
err = errno; err = errno;
printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d\n", printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d %s\n",
(intmax_t)phys_addr, len, err); (intmax_t)phys_addr, len, err, strerror(err));
return NULL; return NULL;
} }
@ -44,8 +45,8 @@ void *map_physical(off_t phys_addr, size_t len) {
if (virt_addr == MAP_FAILED) { if (virt_addr == MAP_FAILED) {
err = errno; err = errno;
printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d\n", printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d %s\n",
(intmax_t)phys_addr, len, err); (intmax_t)phys_addr, len, err, strerror(err));
return NULL; return NULL;
} }