Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Branch HEAD
[fs/lustre-release.git]
/
lustre
/
tests
/
openfile.c
diff --git
a/lustre/tests/openfile.c
b/lustre/tests/openfile.c
index
1cb36ea
..
6cba76b
100644
(file)
--- a/
lustre/tests/openfile.c
+++ b/
lustre/tests/openfile.c
@@
-7,7
+7,9
@@
#endif
/* for O_DIRECTORY and O_DIRECT */
#endif
/* for O_DIRECTORY and O_DIRECT */
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <stdio.h>
#include <sys/types.h>
#include <stdio.h>
#include <sys/types.h>
@@
-36,7
+38,9
@@
FLAG_MAPPING flag_table[] = {
{"O_NONBLOCK", O_NONBLOCK},
{"O_NDELAY", O_NDELAY},
{"O_SYNC", O_SYNC},
{"O_NONBLOCK", O_NONBLOCK},
{"O_NDELAY", O_NDELAY},
{"O_SYNC", O_SYNC},
+#ifdef O_DIRECT
{"O_DIRECT", O_DIRECT},
{"O_DIRECT", O_DIRECT},
+#endif
{"O_LARGEFILE", O_LARGEFILE},
{"O_DIRECTORY", O_DIRECTORY},
{"O_NOFOLLOW", O_NOFOLLOW},
{"O_LARGEFILE", O_LARGEFILE},
{"O_DIRECTORY", O_DIRECTORY},
{"O_NOFOLLOW", O_NOFOLLOW},
@@
-60,7
+64,8
@@
int main(int argc, char** argv)
int mode_set=0;
int flag_set=0;
int file_set=0;
int mode_set=0;
int flag_set=0;
int file_set=0;
- char c;
+ int c;
+ int save_errno;
char* cloned_flags = NULL;
if (argc == 1)
char* cloned_flags = NULL;
if (argc == 1)
@@
-78,7
+83,7
@@
int main(int argc, char** argv)
}
strncpy(cloned_flags, optarg, strlen(optarg)+1);
}
strncpy(cloned_flags, optarg, strlen(optarg)+1);
- for (tmp = strtok(
optarg
, ":|"); tmp;
+ for (tmp = strtok(
cloned_flags
, ":|"); tmp;
tmp = strtok(NULL, ":|")) {
int i = 0;
#ifdef DEBUG
tmp = strtok(NULL, ":|")) {
int i = 0;
#ifdef DEBUG
@@
-98,6
+103,7
@@
int main(int argc, char** argv)
exit(-1);
}
}
exit(-1);
}
}
+ free(cloned_flags);
#ifdef DEBUG
printf("flags = %x\n", flags);
#endif
#ifdef DEBUG
printf("flags = %x\n", flags);
#endif
@@
-138,6
+144,8
@@
int main(int argc, char** argv)
else
fd = open(fname, flags);
else
fd = open(fname, flags);
+ save_errno = errno;
+
if (fd != -1) {
printf("Succeed in opening file \"%s\"(flags=%s",
fname, cloned_flags);
if (fd != -1) {
printf("Succeed in opening file \"%s\"(flags=%s",
fname, cloned_flags);
@@
-153,7
+161,7
@@
int main(int argc, char** argv)
fname, cloned_flags);
if (mode_set)
fprintf(stderr, ", mode=%o", mode);
fname, cloned_flags);
if (mode_set)
fprintf(stderr, ", mode=%o", mode);
- fprintf(stderr, ") %d: %s\n",
errno, strerror(
errno));
+ fprintf(stderr, ") %d: %s\n",
save_errno, strerror(save_
errno));
- return errno;
+ return
save_
errno;
}
}