summaryrefslogtreecommitdiff
path: root/miscutils/readahead.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-01-27 23:41:34 +0000
committerDenis Vlasenko2008-01-27 23:41:34 +0000
commitb5c60fc7870a66d89de571e96596b0745edcd6d9 (patch)
tree29b3595303de8e526b9f64d3a2d2456f783efe2a /miscutils/readahead.c
parentda42bd5bbe6fdda12133e7305b1a3e7cee506cc8 (diff)
downloadbusybox-b5c60fc7870a66d89de571e96596b0745edcd6d9.zip
busybox-b5c60fc7870a66d89de571e96596b0745edcd6d9.tar.gz
mkswap, readahead: stop using fdlength, it is reported to be unreliable
Diffstat (limited to 'miscutils/readahead.c')
-rw-r--r--miscutils/readahead.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/miscutils/readahead.c b/miscutils/readahead.c
index 7b375cf..fb71ce8 100644
--- a/miscutils/readahead.c
+++ b/miscutils/readahead.c
@@ -22,9 +22,16 @@ int readahead_main(int argc, char **argv)
while (*++argv) {
int fd = open_or_warn(*argv, O_RDONLY);
if (fd >= 0) {
- int r = readahead(fd, 0, fdlength(fd));
+ off_t len;
+ int r;
+
+ /* fdlength was reported to be unreliable - use seek */
+ len = xlseek(fd, 0, SEEK_END);
+ xlseek(fd, 0, SEEK_SET);
+ r = readahead(fd, 0, len);
close(fd);
- if (r >= 0) continue;
+ if (r >= 0)
+ continue;
}
retval = EXIT_FAILURE;
}