From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Galibert Subject: Re: [PATCH 10/11] readahead: dont do start-of-file readahead after lseek() Date: Tue, 2 Feb 2010 19:48:31 +0100 Message-ID: <20100202184831.GD75577@dspnet.fr.eu.org> References: <20100202152835.683907822@intel.com> <20100202153317.644170708@intel.com> <20100202181321.GB75577@dspnet.fr.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Wu Fengguang , Andrew Morton , Jens Axboe , Peter Zijlstra , Linux Memory Management List , linux-fsdevel@vger.kernel.org, LKML To: Linus Torvalds Return-path: Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org 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, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org