Ignore fadvise if it return ENOSYS

This happens in ARM platform because fadvise is
differently implemented by the kernel and glibc
may not support it yet.
This commit is contained in:
Andrea Mazzoleni 2016-10-23 22:03:02 +02:00
parent 72c558b104
commit 20e9f7de41
2 changed files with 22 additions and 0 deletions

View file

@ -47,11 +47,16 @@ STREAM* sopen_read(const char* file)
#if HAVE_POSIX_FADVISE
/* advise sequential access */
ret = posix_fadvise(s->handle[0].f, 0, 0, POSIX_FADV_SEQUENTIAL);
if (ret == ENOSYS) {
/* call is not supported, like in armhf, see posix_fadvise manpage */
ret = 0;
}
if (ret != 0) {
/* LCOV_EXCL_START */
close(s->handle[0].f);
free(s->handle);
free(s);
errno = ret; /* posix_fadvise return the error code */
return 0;
/* LCOV_EXCL_STOP */
}
@ -116,9 +121,14 @@ int sopen_multi_file(STREAM* s, unsigned i, const char* file)
#if HAVE_POSIX_FADVISE
/* advise sequential access */
ret = posix_fadvise(f, 0, 0, POSIX_FADV_SEQUENTIAL);
if (ret == ENOSYS) {
/* call is not supported, like in armhf, see posix_fadvise manpage */
ret = 0;
}
if (ret != 0) {
/* LCOV_EXCL_START */
close(f);
errno = ret; /* posix_fadvise return the error code */
return -1;
/* LCOV_EXCL_STOP */
}