diff --git a/src/aiori-POSIX.c b/src/aiori-POSIX.c index 99a68f1..b57601a 100755 --- a/src/aiori-POSIX.c +++ b/src/aiori-POSIX.c @@ -436,19 +436,15 @@ void *POSIX_Create(char *testFileName, IOR_param_t * param) /* * Creat a file through mknod interface. */ -void *POSIX_Mknod(char *testFileName) +int POSIX_Mknod(char *testFileName) { - int *fd; + int ret; - fd = (int *)malloc(sizeof(int)); - if (fd == NULL) - ERR("Unable to malloc file descriptor"); + ret = mknod(testFileName, S_IFREG | S_IRUSR, 0); + if (ret < 0) + ERR("mknod failed"); - *fd = mknod(testFileName, S_IFREG | S_IRUSR, 0); - if (*fd < 0) - ERR("mknod failed"); - - return ((void *)fd); + return ret; } /* diff --git a/src/aiori.h b/src/aiori.h index da93a1a..3fc9f06 100755 --- a/src/aiori.h +++ b/src/aiori.h @@ -68,7 +68,7 @@ typedef struct ior_aiori { char *name; char *name_legacy; void *(*create)(char *, IOR_param_t *); - void *(*mknod)(char *); + int (*mknod)(char *); void *(*open)(char *, IOR_param_t *); IOR_offset_t (*xfer)(int, void *, IOR_size_t *, IOR_offset_t, IOR_param_t *); @@ -131,7 +131,7 @@ int aiori_posix_access (const char *path, int mode, IOR_param_t * param); int aiori_posix_stat (const char *path, struct stat *buf, IOR_param_t * param); void *POSIX_Create(char *testFileName, IOR_param_t * param); -void *POSIX_Mknod(char *testFileName); +int POSIX_Mknod(char *testFileName); void *POSIX_Open(char *testFileName, IOR_param_t * param); IOR_offset_t POSIX_GetFileSize(IOR_param_t * test, MPI_Comm testComm, char *testFileName); void POSIX_Delete(char *testFileName, IOR_param_t * param); diff --git a/src/mdtest.c b/src/mdtest.c index fe9c153..05e8a44 100644 --- a/src/mdtest.c +++ b/src/mdtest.c @@ -345,7 +345,7 @@ static void remove_file (const char *path, uint64_t itemNum) { static void create_file (const char *path, uint64_t itemNum) { char curr_item[MAX_PATHLEN]; - void *aiori_fh; + void *aiori_fh = NULL; if ( (itemNum % ITEM_COUNT==0 && (itemNum != 0))) { VERBOSE(3,5,"create file: "LLU"", itemNum); @@ -355,36 +355,36 @@ static void create_file (const char *path, uint64_t itemNum) { sprintf(curr_item, "%s/file.%s"LLU"", path, mk_name, itemNum); VERBOSE(3,5,"create_remove_items_helper (non-dirs create): curr_item is '%s'", curr_item); - if (collective_creates) { - param.openFlags = IOR_WRONLY; + param.openFlags = IOR_WRONLY; + if (make_node) { + int ret; + VERBOSE(3,5,"create_remove_items_helper : mknod..." ); + + ret = backend->mknod (curr_item); + if (ret != 0) + FAIL("unable to mknode file %s", curr_item); + + return; + } else if (collective_creates) { VERBOSE(3,5,"create_remove_items_helper (collective): open..." ); - if (make_node) - aiori_fh = backend->mknod (curr_item); - else - aiori_fh = backend->open (curr_item, ¶m); - if (NULL == aiori_fh) { + aiori_fh = backend->open (curr_item, ¶m); + if (NULL == aiori_fh) FAIL("unable to open file %s", curr_item); - } /* * !collective_creates */ } else { - param.openFlags = IOR_CREAT | IOR_WRONLY; + param.openFlags |= IOR_CREAT; param.filePerProc = !shared_file; - param.mode = FILEMODE; - + param.mode = FILEMODE; VERBOSE(3,5,"create_remove_items_helper (non-collective, shared): open..." ); - if (make_node) - aiori_fh = backend->mknod (curr_item); - else - aiori_fh = backend->create (curr_item, ¶m); - if (NULL == aiori_fh) { + aiori_fh = backend->create (curr_item, ¶m); + if (NULL == aiori_fh) FAIL("unable to create file %s", curr_item); - } } if (write_bytes > 0) { @@ -402,9 +402,7 @@ static void create_file (const char *path, uint64_t itemNum) { } VERBOSE(3,5,"create_remove_items_helper: close..." ); - - if (!make_node) - backend->close (aiori_fh, ¶m); + backend->close (aiori_fh, ¶m); } /* helper for creating/removing items */