Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Aug 2001 16:55:17 +0400
From:      "Andrey A. Chernov" <ache@nagual.pp.ru>
To:        Joseph Koshy <jkoshy@FreeBSD.ORG>
Cc:        arch@FreeBSD.ORG
Subject:   Re: CFR: fseek<0 + feof error (with fix)
Message-ID:  <20010813165517.A76432@nagual.pp.ru>
In-Reply-To: <20010813112848.ABF4437B406@hub.freebsd.org>
References:  <20010813145956.A75227@nagual.pp.ru> <20010813112848.ABF4437B406@hub.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Aug 13, 2001 at 04:28:48 -0700, Joseph Koshy wrote:
> 
> I think I didn't explain my point clearly: `fseek(3)' ultimately invokes
> `lseek(2)'.  From my reading of the code in "libc/stdio/fseek.c", we don't

We must stop fseek() far before lseek(2) call because of its bad effect
on ungetc() and feof().

Fixing lseek() per POSIX is out of my scope at this moment.

> handle character device files specially and just pass the arguments through
> to `lseek()'.  

Yes, there is a problem, we can't stop fseek() in 100% cases, in complex
cases only for files with fstat() possible.

> So, if you are planning to disallow negative offsets to
> `fseek()', you will need to special-case character special files to allow
> negative offsets there.

We don't need. No negative offsets allowed for fseek(), in all cases, read
my POSIX quote. Remember fseek() is not lseek(), POSIX treat them
differently. fseek() is stdio and have some documented side effects which
turns to nightmare with negative seeks, thats why POSIX disallow negative
ofsets for fseek() completely (but not for lseek()).

> Allowing negative file offsets for character special files is not actually
> prohibited by the standards, IIRC, since this behaviour is termed
> 'implementation dependent'.  Perhaps someone with more standards expertise
> than I have could clarify.

Yes, but for lseek() only, not for fseek().

-- 
Andrey A. Chernov
http://ache.pp.ru/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010813165517.A76432>