[Ocfs2-test-devel] [PATCH 1/1] Ocfs2-test: Teach 'create_and_open' to be aware of working directory.
Tristan Ye
tristan.ye at oracle.com
Sat Jun 12 00:59:10 PDT 2010
Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
programs/create_and_open/create_and_open.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/programs/create_and_open/create_and_open.c b/programs/create_and_open/create_and_open.c
index 00680e1..84146c1 100644
--- a/programs/create_and_open/create_and_open.c
+++ b/programs/create_and_open/create_and_open.c
@@ -35,12 +35,20 @@
int create_files(int writefd);
int open_files(int readfd);
+char *workplace;
+
int main(int argc, char **argv)
{
int status = 0;
int comm[2];
int pid, readfd, writefd;
+ if ((argc < 2) || (strcmp(argv[1], "-h") == 0)) {
+ fprintf(stderr, "Usage: create_and_open <workdir>\n");
+ return 1;
+ }
+
+ workplace = argv[1];
status = pipe(comm);
if (status < 0) {
@@ -74,7 +82,7 @@ int create_files(int writefd)
for(i = 0; i < NUMFILES; i++) {
memset(buff, 0, NMMX);
- snprintf(buff, NMMX-1, "testfile%d", i);
+ snprintf(buff, NMMX-1, "%s/testfile%d", workplace, i);
status = mknod(buff, S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
0);
@@ -95,7 +103,6 @@ int create_files(int writefd)
printf("Could not write buff to pipe, %d\n", status);
goto bail;
}
-// printf("created \"%s\"\n", buff);
}
status = 0;
@@ -130,7 +137,6 @@ int open_files(int readfd)
printf("Could not open file \"%s\", %d", buff, tmpfd);
goto bail;
}
-// printf("opened \"%s\"\n", buff);
}
bail:
--
1.5.5
More information about the Ocfs2-test-devel
mailing list