Skip to content

Add a Write/Read Test That uses plfs API to check Offset Writes and Reads #23

@atorrez

Description

@atorrez

The code should mimic the following sequence:

include

include

include "plfs.h"

include

include

include

int main()
{
int ret_value;
char* filename = "/home/kmehta/plfs/trunk/mount_point/test.out";
char write_buf1[] = "Testing";
char write_buf2[] = "PLFSRW";
char *read_buf = (char *) malloc(sizeof(write_buf1)+sizeof(write_buf2));

Plfs_fd * pfd = NULL;

if(0>(plfs_open(&pfd, filename, O_CREAT|O_TRUNC|O_RDWR, 99, 0666, NULL)))
{
perror("Error opening file");
exit(-1);
}

if(6 != (ret_value = plfs_write(pfd, write_buf1, 6, 0, 99))) //6 bytes at offset 0
{
perror("Error in first write");
printf("ret_value: %d\n", ret_value);
exit(-1);
}

if(5 != (ret_value = plfs_write(pfd, write_buf2, 5, 6, 99))) //5 bytes at offset 6
{
perror("Error in first write");
printf("ret_value: %d\n", ret_value);
exit(-1);
}

if(0>(plfs_close(pfd, 99, 99, O_CREAT|O_TRUNC|O_RDWR, NULL)))
{
perror("Error closing file");
exit(-1);
}

pfd = NULL;
if(0>(plfs_open(&pfd, filename, O_RDWR, 99, 0666, NULL)))
{
perror("Error during re-open");
exit(-1);
}

if(11 != (ret_value = plfs_read(pfd, read_buf, 11, 0)))
{
perror("Error during read");
printf("ret_value: %d\n", ret_value);
}

if(0>(plfs_close(pfd, 99, 1, O_RDWR, NULL)))
{
perror("Error re-closing file");
exit(-1);
}

free(read_buf);
return 0;

}

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions