summaryrefslogtreecommitdiffstats
path: root/src/strings.c
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2017-03-27 16:33:52 +0200
committerUlf Hermann <[email protected]>2017-05-04 16:12:05 +0000
commit5e738a2deec976ffac6c313327f407d7e4760076 (patch)
tree443eb2e8617f8198ea21e085e099d9104f71de4a /src/strings.c
parent741248144e6361548359ad7d9e394144a0312ecf (diff)
Skip fchown, fchmod, fadvise, fallocate if functions are unavailable
If fchmod or fchown are unavailable, then the file permission model is likely to be different from what we expect there. posix_fallocate is a rather fragile affair already on linux, and not guaranteed to do anything useful. If it's not available, the result will be the same as when it's available and unreliable. fadvise is an optimization. Change-Id: I28a77e976a0198cf80397b45eb1bc8cfb30664f5 Reviewed-by: Christian Kandeler <[email protected]>
Diffstat (limited to 'src/strings.c')
-rw-r--r--src/strings.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/strings.c b/src/strings.c
index 22cbfaca..46b23560 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -574,9 +574,11 @@ read_block (int fd, const char *fname, off_t fdlen, off_t from, off_t to)
elfmap_off = from & ~(ps - 1);
elfmap_base = elfmap = map_file (fd, elfmap_off, fdlen, &elfmap_size);
+#if HAVE_DECL_POSIX_FADVISE
if (unlikely (elfmap == MAP_FAILED))
/* Let the kernel know we are going to read everything in sequence. */
(void) posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+#endif
}
if (unlikely (elfmap == MAP_FAILED))