Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Aug 2001 04:28:48 -0700 (PDT)
From:      jkoshy@FreeBSD.ORG (Joseph Koshy)
To:        "Andrey A. Chernov" <ache@nagual.pp.ru>
Cc:        arch@freebsd.org
Subject:   Re: CFR: fseek<0 + feof error (with fix) 
Message-ID:  <20010813112848.ABF4437B406@hub.freebsd.org>
In-Reply-To: Your message of "Mon, 13 Aug 2001 14:59:59 %2B0400." <20010813145956.A75227@nagual.pp.ru> 

next in thread | previous in thread | raw e-mail | index | archive | help


jk> FreeBSD's implementation of `lseek()' allows negative offsets --- these
jk> seem to be required to allow reading of /dev/[k]mem.  See PR kern/6184.


ac> We talk here about _fseek_, not about _lseek_. For lseek POSIX word are
ac> different:

ac> [EINVAL] The whence argument is not a proper value, or the resulting file
ac> offset would be negative for a regular file, block special file, or
ac> directory.

ac> I.e. no negative offset allowed for fseek at all while it allowed for
ac> lseek expecting regular, block special or directory file.

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
handle character device files specially and just pass the arguments through
to `lseek()'.  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.

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.

Koshy
<jkoshy@freebsd.org>


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?20010813112848.ABF4437B406>