When running the harness on a filesystem such as a tmpfs, which do not
support O_DIRECT, fallback to calls without the flag.
Signed-off-by: Guillem Jover <guillem@hadrons.org>
Gbp-Pq: Name 0004-harness-Add-fallback-code-for-filesystems-not-suppor.patch
unlink(filename);
fd = open(filename, O_CREAT | O_RDWR | O_DIRECT, 0644);
+ if (fd < 0 && errno == EINVAL)
+ fd = open(filename, O_CREAT | O_RDWR, 0644);
assert(fd >= 0);
ret = ftruncate(fd, max_ios * io_size);
assert(buffer != NULL);
fd = open(FILENAME, O_DIRECT|O_RDONLY);
+ if (fd < 0 && errno == EINVAL)
+ fd = open(FILENAME, O_RDONLY);
assert(fd >= 0);
for (i = 0; i < 1000; i++) {
strncpy(template, TEMPLATE, sizeof(template));
fd = mkostemp(template, O_DIRECT);
+ if (fd < 0 && errno == EINVAL) {
+ strncpy(template, TEMPLATE, sizeof(template));
+ fd = mkstemp(template);
+ }
if (fd < 0) {
perror("mkstemp");
exit(1);
*/
flags = fcntl(fd, F_GETFL);
ret = fcntl(fd, F_SETFL, flags | O_DIRECT);
- if (ret != 0) {
+ if (ret != 0 && errno != EINVAL) {
perror("fcntl");
return 1;
}