Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
atorrez opened this issue Mar 18, 2013 · 0 comments
Open
Assignees

Comments

@atorrez
Copy link
Contributor

atorrez commented Mar 18, 2013

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;

}

@ghost ghost assigned atorrez Mar 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant