From owner-freebsd-current@FreeBSD.ORG Thu Aug 4 08:25:34 2005 Return-Path: X-Original-To: current@FreeBSD.ORG Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 62C8616A41F for ; Thu, 4 Aug 2005 08:25:34 +0000 (GMT) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (nagual.pp.ru [194.87.13.69]) by mx1.FreeBSD.org (Postfix) with ESMTP id ABF8643D48 for ; Thu, 4 Aug 2005 08:25:33 +0000 (GMT) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.13.4/8.13.4) with ESMTP id j748PSfN023307; Thu, 4 Aug 2005 12:25:28 +0400 (MSD) (envelope-from ache@nagual.pp.ru) Received: (from ache@localhost) by nagual.pp.ru (8.13.4/8.13.4/Submit) id j748PSRZ023306; Thu, 4 Aug 2005 12:25:28 +0400 (MSD) (envelope-from ache) Date: Thu, 4 Aug 2005 12:25:28 +0400 From: Andrey Chernov To: Peter Jeremy Message-ID: <20050804082527.GA22992@nagual.pp.ru> Mail-Followup-To: Andrey Chernov , Peter Jeremy , Maxim.Sobolev@portaone.com, Dan Nelson , "current@freebsd.org" References: <42F0CCD5.9090200@portaone.com> <20050803150117.GD93405@dan.emsphone.com> <42F0E9B2.9080208@portaone.com> <20050804060251.GA21228@nagual.pp.ru> <20050804063908.GA21871@nagual.pp.ru> <20050804075711.GB271@cirb503493.alcatel.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050804075711.GB271@cirb503493.alcatel.com.au> User-Agent: Mutt/1.5.9i Cc: Maxim.Sobolev@portaone.com, Dan Nelson , "current@freebsd.org" Subject: Re: Sub-optimal libc's read-ahead buffering behaviour X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2005 08:25:34 -0000 On Thu, Aug 04, 2005 at 05:57:11PM +1000, Peter Jeremy wrote: > >In case SEEK_CUR still uses > >the buffer, it probably should not for character device. As I look at the fseek code now, _any_ non-regular file seek is not optimized, which is right things (and BSD traditional). > I can't see any reason for the current stdio behaviour: > - If you're accessing a device with "magic" behaviour then it's not safe > to read(2) 4KB (or whatever) when userland asks to fread(3) 512 bytes. It is safe to read more. You may hit EOF, but it handles by stdio internally. It is not safe to read again from the buffer. In that case fseek to needed position helps to re-read. > - If the device doesn't have "magic" behaviour then you can just seek > within the stdio buffer. > > That said, I've seen similar behaviour on other systems so it could be > a subtle side-effect of POSIX. It is traditional BSD behaviour. Compare this place with less touched NetBSD fseeko.c f.e. -- http://ache.pp.ru/