mkswap, readahead: stop using fdlength, it is reported to be unreliable

This commit is contained in:
Denis Vlasenko
2008-01-27 23:41:34 +00:00
parent da42bd5bbe
commit b5c60fc787
3 changed files with 15 additions and 4 deletions

View File

@ -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;
}