summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-25 22:59:07 -0400
committermidipix <writeonce@midipix.org>2016-10-25 22:59:07 -0400
commit47a21b92c285ac4d5f4b1b9faf757311269725fd (patch)
tree74b84ae94928be35bb1557bf10615ee6edce8192
parentd413d68bcd714151b5bd064896e4ea61707b9833 (diff)
downloadsofort-47a21b92c285ac4d5f4b1b9faf757311269725fd.tar.bz2
sofort-47a21b92c285ac4d5f4b1b9faf757311269725fd.tar.xz
sfrt_map_input(): added error trace support.
-rw-r--r--include/sofort/sofort.h2
-rw-r--r--src/driver/sfrt_unit_ctx.c2
-rw-r--r--src/logic/sfrt_map_input.c18
3 files changed, 13 insertions, 9 deletions
diff --git a/include/sofort/sofort.h b/include/sofort/sofort.h
index 76b8b70..c5f278a 100644
--- a/include/sofort/sofort.h
+++ b/include/sofort/sofort.h
@@ -119,7 +119,7 @@ sfrt_api void sfrt_free_driver_ctx (struct sfrt_driver_ctx *);
sfrt_api int sfrt_get_unit_ctx (const struct sfrt_driver_ctx *, const char * path, struct sfrt_unit_ctx **);
sfrt_api void sfrt_free_unit_ctx (struct sfrt_unit_ctx *);
-sfrt_api int sfrt_map_input (int fd, const char * path, int prot, struct sfrt_input *);
+sfrt_api int sfrt_map_input (const struct sfrt_driver_ctx *, int fd, const char * path, int prot, struct sfrt_input *);
sfrt_api int sfrt_unmap_input (struct sfrt_input *);
/* utility api */
diff --git a/src/driver/sfrt_unit_ctx.c b/src/driver/sfrt_unit_ctx.c
index 672c323..a17d78d 100644
--- a/src/driver/sfrt_unit_ctx.c
+++ b/src/driver/sfrt_unit_ctx.c
@@ -27,7 +27,7 @@ int sfrt_get_unit_ctx(
if (!dctx || !(ctx = calloc(1,sizeof(*ctx))))
return -1;
- if (sfrt_map_input(-1,path,PROT_READ,&ctx->map))
+ if (sfrt_map_input(dctx,-1,path,PROT_READ,&ctx->map))
return sfrt_free_unit_ctx_impl(ctx,-1);
memcpy(&ctx->cctx,dctx->cctx,
diff --git a/src/logic/sfrt_map_input.c b/src/logic/sfrt_map_input.c
index abcedab..77cc40e 100644
--- a/src/logic/sfrt_map_input.c
+++ b/src/logic/sfrt_map_input.c
@@ -7,12 +7,14 @@
#include <sys/stat.h>
#include <sofort/sofort.h>
+#include "sofort_errinfo_impl.h"
int sfrt_map_input(
- int fd,
- const char * path,
- int prot,
- struct sfrt_input * map)
+ const struct sfrt_driver_ctx * dctx,
+ int fd,
+ const char * path,
+ int prot,
+ struct sfrt_input * map)
{
struct stat st;
bool fnew;
@@ -22,13 +24,13 @@ int sfrt_map_input(
fd = open(path,O_RDONLY | O_CLOEXEC);
if (fd < 0)
- return -1;
+ return SFRT_SYSTEM_ERROR(dctx);
if ((ret = fstat(fd,&st) < 0) && fnew)
close(fd);
if (ret < 0)
- return -1;
+ return SFRT_SYSTEM_ERROR(dctx);
map->size = st.st_size;
map->addr = mmap(0,map->size,prot,MAP_PRIVATE,fd,0);
@@ -36,7 +38,9 @@ int sfrt_map_input(
if (fnew)
close(fd);
- return (map->addr == MAP_FAILED) ? -1 : 0;
+ return (map->addr == MAP_FAILED)
+ ? SFRT_SYSTEM_ERROR(dctx)
+ : 0;
}
int sfrt_unmap_input(struct sfrt_input * map)