From owner-freebsd-hackers@FreeBSD.ORG Sat Jul 2 18:04:21 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41EDC106566B for ; Sat, 2 Jul 2011 18:04:21 +0000 (UTC) (envelope-from artemb@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id B9B758FC17 for ; Sat, 2 Jul 2011 18:04:20 +0000 (UTC) Received: by wwe6 with SMTP id 6so3960064wwe.31 for ; Sat, 02 Jul 2011 11:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=oGcVPVDlKdIkj8zxVUW/EnCwAO7kKqVah/KgZGJ6mC4=; b=Aph1xoAJv+XEQ7kp5QG+8uUn+RJ0mFVWS7buqd966WGlahpegM+1lhB/84JCU1asqR FRmR+nHaJ7BidQESr7nPSIlFAB8ecEGj45lxcmxH1dlNN/SHmTokqgkMxarSXS2yd9Lb PcVzcJgt45gtktktYFmSAmiPsNhBdm5jrzMtA= MIME-Version: 1.0 Received: by 10.216.63.2 with SMTP id z2mr2183857wec.11.1309629859555; Sat, 02 Jul 2011 11:04:19 -0700 (PDT) Sender: artemb@gmail.com Received: by 10.216.135.169 with HTTP; Sat, 2 Jul 2011 11:04:19 -0700 (PDT) In-Reply-To: References: Date: Sat, 2 Jul 2011 11:04:19 -0700 X-Google-Sender-Auth: ANNBD5-wxBLvsts_qzlygMnwn6w Message-ID: From: Artem Belevich To: =?ISO-8859-1?Q?Martin_M=F6ller?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "freebsd-hackers@freebsd.org" Subject: Re: Question about lseek/fseek X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jul 2011 18:04:21 -0000 On Sat, Jul 2, 2011 at 6:57 AM, Martin M=F6ller wrote: > Hi Hackers, > > why does these function allow seeking beyond the EOF of a file in > O_RDONLY/=B2rb=B2 mode ? Perhaps because the standard explicitly says that it's allowed: http://pubs.opengroup.org/onlinepubs/009695399/functions/lseek.html > How does these function then signal the EOF correctly ? It does not. It only sets offset for a given file descriptor. It's read's job to signal EOF. > Seeking beyond the EOF makes sense for me in write-mode but not in read-o= nly > mode ! Given that lseek does not change file size (I.e. it does not ever modify the file), there's no reason to prohibit seek beyond end of file even in read-only mode. Now, if you would try to read after seeking beyond EOF, then the read() should complain that there's no data. --Artem > > With Regards, > Martin > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org= " >