Commit 12e09b0f authored by Philip Carns's avatar Philip Carns
Browse files

wrappers for mkostemp and unlink

parent e51eb269
......@@ -99,7 +99,8 @@ int main(int argc, char **argv)
}
else
{
assert(0);
ret = ABT_nosnoozer_xstream_create(io_es_count, &io_pool, io_xstreams);
assert(ret == 0);
}
/* initialize abt_io */
......@@ -179,12 +180,14 @@ static void worker_ult(void *_arg)
if(arg->opt_abt_io)
{
#if 0
ret = abt_io_pwrite(arg->aid, arg->fd, buffer, arg->size, my_offset);
assert(ret == arg->size);
#endif
fd = abt_io_mkostemp(arg->aid, template, O_DIRECT|O_SYNC);
assert(fd >= 0);
assert(0);
ret = abt_io_pwrite(arg->aid, fd, buffer, arg->opt_unit_size, 0);
assert(ret == arg->opt_unit_size);
ret = abt_io_unlink(arg->aid, template);
assert(ret == 0);
}
else
{
......
......@@ -13,6 +13,7 @@ extern "C" {
#include <abt.h>
#include <sys/types.h>
#include <stdlib.h>
struct abt_io_instance;
typedef struct abt_io_instance* abt_io_instance_id;
......@@ -43,6 +44,16 @@ int abt_io_open(abt_io_instance_id aid, const char* pathname, int flags, mode_t
ssize_t abt_io_pwrite(abt_io_instance_id aid, int fd, const void *buf, size_t count,
off_t offset);
/**
* wrapper for mkostemp()
*/
int abt_io_mkostemp(abt_io_instance_id aid, char *template, int flags);
/**
* wrapper for unlink()
*/
int abt_io_unlink(abt_io_instance_id aid, const char *pathname);
#ifdef __cplusplus
}
#endif
......
......@@ -5,6 +5,8 @@
* See COPYRIGHT in top-level directory.
*/
#define _GNU_SOURCE
#include <assert.h>
#include <unistd.h>
#include <errno.h>
......@@ -134,3 +136,85 @@ ssize_t abt_io_pwrite(abt_io_instance_id aid, int fd, const void *buf,
return(state.ret);
}
struct abt_io_mkostemp_state
{
int ret;
char *template;
int flags;
};
static void abt_io_mkostemp_fn(void *foo)
{
struct abt_io_mkostemp_state *state = foo;
state->ret = mkostemp(state->template, state->flags);
if(state->ret < 0)
state->ret = -errno;
return;
}
int abt_io_mkostemp(abt_io_instance_id aid, char *template, int flags)
{
struct abt_io_mkostemp_state state;
int ret;
ABT_thread tid;
state.ret = -ENOSYS;
state.template = template;
state.flags = flags;
ret = ABT_thread_create(aid->progress_pool, abt_io_mkostemp_fn, &state,
ABT_THREAD_ATTR_NULL, &tid);
if(ret != 0)
{
return(-EINVAL);
}
ABT_thread_join(tid);
ABT_thread_free(&tid);
return(state.ret);
}
struct abt_io_unlink_state
{
int ret;
const char *pathname;
};
static void abt_io_unlink_fn(void *foo)
{
struct abt_io_unlink_state *state = foo;
state->ret = unlink(state->pathname);
if(state->ret < 0)
state->ret = -errno;
return;
}
int abt_io_unlink(abt_io_instance_id aid, const char *pathname)
{
struct abt_io_unlink_state state;
int ret;
ABT_thread tid;
state.ret = -ENOSYS;
state.pathname = pathname;
ret = ABT_thread_create(aid->progress_pool, abt_io_unlink_fn, &state,
ABT_THREAD_ATTR_NULL, &tid);
if(ret != 0)
{
return(-EINVAL);
}
ABT_thread_join(tid);
ABT_thread_free(&tid);
return(state.ret);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment