summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-26 20:59:01 -0400
committermidipix <writeonce@midipix.org>2016-10-26 22:10:27 -0400
commitbb5e477926b1aa1732c862b34e3b515406b18bc5 (patch)
treefe4a42d5701f3409478ee9a111da50dcc98fce7d /src/logic
parentbbcd7d3ba187f5b2f4ecec766436d36514a34ce4 (diff)
downloadapimagic-bb5e477926b1aa1732c862b34e3b515406b18bc5.tar.bz2
apimagic-bb5e477926b1aa1732c862b34e3b515406b18bc5.tar.xz
amgc_map_input(): added error trace support.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/amgc_map_input.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/logic/amgc_map_input.c b/src/logic/amgc_map_input.c
index 5d2f08d..b4e07ea 100644
--- a/src/logic/amgc_map_input.c
+++ b/src/logic/amgc_map_input.c
@@ -13,12 +13,14 @@
#include <sys/stat.h>
#include <apimagic/apimagic.h>
+#include "apimagic_errinfo_impl.h"
int amgc_map_input(
- int fd,
- const char * path,
- int prot,
- struct amgc_input * map)
+ const struct amgc_driver_ctx * dctx,
+ int fd,
+ const char * path,
+ int prot,
+ struct amgc_input * map)
{
struct stat st;
bool fnew;
@@ -28,13 +30,13 @@ int amgc_map_input(
fd = open(path,O_RDONLY | O_CLOEXEC);
if (fd < 0)
- return -1;
+ return AMGC_SYSTEM_ERROR(dctx);
if ((ret = fstat(fd,&st) < 0) && fnew)
close(fd);
if (ret < 0)
- return -1;
+ return AMGC_SYSTEM_ERROR(dctx);
map->size = st.st_size;
map->addr = mmap(0,map->size,prot,MAP_PRIVATE,fd,0);
@@ -42,7 +44,9 @@ int amgc_map_input(
if (fnew)
close(fd);
- return (map->addr == MAP_FAILED) ? -1 : 0;
+ return (map->addr == MAP_FAILED)
+ ? AMGC_SYSTEM_ERROR(dctx)
+ : 0;
}
int amgc_unmap_input(struct amgc_input * map)