X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ffailtest%2Ffailtest.c;fp=ccan%2Ffailtest%2Ffailtest.c;h=1dad0864aa372fa3b7ead07a081f9e125f192bbc;hp=be5234f7a90453ac8ec313a287b3dd4594667431;hb=e43dc84fe91f64d8761aeda6338a1afbf701b7f5;hpb=3d99c9334fe3067c88772547b9c06acec21616ea diff --git a/ccan/failtest/failtest.c b/ccan/failtest/failtest.c index be5234f7..1dad0864 100644 --- a/ccan/failtest/failtest.c +++ b/ccan/failtest/failtest.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -96,7 +97,7 @@ static unsigned int lock_num = 0; static pid_t orig_pid; -static const char info_to_arg[] = "mceoxprwf"; +static const char info_to_arg[] = "mceoxprwfa"; /* Dummy call used for failtest_undo wrappers. */ static struct failtest_call unrecorded_call; @@ -860,6 +861,30 @@ int failtest_open(const char *pathname, return p->u.open.ret; } +void *failtest_mmap(void *addr, size_t length, int prot, int flags, + int fd, off_t offset, const char *file, unsigned line) +{ + struct failtest_call *p; + struct mmap_call call; + + call.addr = addr; + call.length = length; + call.prot = prot; + call.flags = flags; + call.offset = offset; + call.fd = fd; + + p = add_history(FAILTEST_MMAP, file, line, &call); + if (should_fail(p)) { + p->u.mmap.ret = MAP_FAILED; + p->error = ENOMEM; + } else { + p->u.mmap.ret = mmap(addr, length, prot, flags, fd, offset); + } + errno = p->error; + return p->u.mmap.ret; +} + static void cleanup_pipe(struct pipe_call *call) { if (!call->closed[0])