diff options
author | midipix <writeonce@midipix.org> | 2016-10-23 23:51:20 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-11 00:22:49 -0500 |
commit | 51430e224464219f5b0bb94465eb9a3e2930cabd (patch) | |
tree | 22ff7d5dfc4c1a3527eeaa3e4b95f2d794c0e42d | |
parent | 62fec76c0ad272943d16867c4084134f82f9157a (diff) | |
download | mdso-51430e224464219f5b0bb94465eb9a3e2930cabd.tar.bz2 mdso-51430e224464219f5b0bb94465eb9a3e2930cabd.tar.xz |
mdso_map_input(): added error trace support.
-rw-r--r-- | include/mdso/mdso.h | 2 | ||||
-rw-r--r-- | src/driver/mdso_unit_ctx.c | 4 | ||||
-rw-r--r-- | src/logic/mdso_map_input.c | 18 |
3 files changed, 14 insertions, 10 deletions
diff --git a/include/mdso/mdso.h b/include/mdso/mdso.h index 4d770de..bd5c29f 100644 --- a/include/mdso/mdso.h +++ b/include/mdso/mdso.h @@ -107,7 +107,7 @@ mdso_api void mdso_free_driver_ctx (struct mdso_driver_ctx *); mdso_api int mdso_get_unit_ctx (const struct mdso_driver_ctx *, const char * path, struct mdso_unit_ctx **); mdso_api void mdso_free_unit_ctx (struct mdso_unit_ctx *); -mdso_api int mdso_map_input (int fd, const char * path, int prot, struct mdso_input *); +mdso_api int mdso_map_input (const struct mdso_driver_ctx *, int fd, const char * path, int prot, struct mdso_input *); mdso_api int mdso_unmap_input (struct mdso_input *); /* utility api */ diff --git a/src/driver/mdso_unit_ctx.c b/src/driver/mdso_unit_ctx.c index 7181982..1ab77ff 100644 --- a/src/driver/mdso_unit_ctx.c +++ b/src/driver/mdso_unit_ctx.c @@ -190,9 +190,9 @@ int mdso_get_unit_ctx( else fclose(ftmp); - if (mdso_map_input(fd,path,PROT_READ,&ctx->map)) + if (mdso_map_input(dctx,fd,path,PROT_READ,&ctx->map)) return mdso_free_unit_ctx_impl( - ctx,MDSO_SYSTEM_ERROR(dctx)); + ctx,MDSO_NESTED_ERROR(dctx)); if (fd > 0) close(fd); diff --git a/src/logic/mdso_map_input.c b/src/logic/mdso_map_input.c index e29b8e7..0cb290d 100644 --- a/src/logic/mdso_map_input.c +++ b/src/logic/mdso_map_input.c @@ -13,12 +13,14 @@ #include <sys/stat.h> #include <mdso/mdso.h> +#include "mdso_errinfo_impl.h" int mdso_map_input( - int fd, - const char * path, - int prot, - struct mdso_input * map) + const struct mdso_driver_ctx * dctx, + int fd, + const char * path, + int prot, + struct mdso_input * map) { struct stat st; bool fnew; @@ -28,13 +30,13 @@ int mdso_map_input( fd = open(path,O_RDONLY | O_CLOEXEC); if (fd < 0) - return -1; + return MDSO_SYSTEM_ERROR(dctx); if ((ret = fstat(fd,&st) < 0) && fnew) close(fd); if (ret < 0) - return -1; + return MDSO_SYSTEM_ERROR(dctx); map->size = st.st_size; map->addr = mmap(0,map->size,prot,MAP_PRIVATE,fd,0); @@ -42,7 +44,9 @@ int mdso_map_input( if (fnew) close(fd); - return (map->addr == MAP_FAILED) ? -1 : 0; + return (map->addr == MAP_FAILED) + ? MDSO_SYSTEM_ERROR(dctx) + : 0; } int mdso_unmap_input(struct mdso_input * map) |