Skip to content

Commit

Permalink
Merge pull request #208 from jyvet/mknod
Browse files Browse the repository at this point in the history
Fix confusing output of mknod
  • Loading branch information
glennklockwood authored Dec 16, 2019
2 parents e87f46f + 9da36ab commit 7a2d307
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
16 changes: 6 additions & 10 deletions src/aiori-POSIX.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down
4 changes: 2 additions & 2 deletions src/aiori.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down Expand Up @@ -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);
Expand Down
40 changes: 19 additions & 21 deletions src/mdtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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, &param);
if (NULL == aiori_fh) {
aiori_fh = backend->open (curr_item, &param);
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, &param);
if (NULL == aiori_fh) {
aiori_fh = backend->create (curr_item, &param);
if (NULL == aiori_fh)
FAIL("unable to create file %s", curr_item);
}
}

if (write_bytes > 0) {
Expand All @@ -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, &param);
backend->close (aiori_fh, &param);
}

/* helper for creating/removing items */
Expand Down

0 comments on commit 7a2d307

Please sign in to comment.