Re: [PATCH 10/11] readahead: dont do start-of-file readahead after lseek()

From: Olivier Galibert
Date: Tue Feb 02 2010 - 13:48:40 EST


On Tue, Feb 02, 2010 at 10:40:41AM -0800, Linus Torvalds wrote:
> IOW, if you start off with a SEEK_END, I think it's reasonable to expect
> it to _not_ read the whole thing.

I've seen a lot of:
int fd = open(...);
size = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);

data = malloc(size);
read(fd, data, size);
close(fd);

Why not fstat? I don't know. Perhaps a case of cargo culting,
perhaps a case of "other unixes suck for portability"[1]. But it's
probably still there a lot in real code.

OG.

[1] In the hpux, dgux, sunos, etc sense. Not to be taken as a comment
on modern BSDs.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/