From owner-freebsd-arch Mon Aug 13 4:28:52 2001 Delivered-To: freebsd-arch@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 729) id ABF4437B406; Mon, 13 Aug 2001 04:28:48 -0700 (PDT) X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0 To: "Andrey A. Chernov" Cc: arch@freebsd.org Subject: Re: CFR: fseek<0 + feof error (with fix) In-Reply-To: Your message of "Mon, 13 Aug 2001 14:59:59 +0400." <20010813145956.A75227@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain Message-Id: <20010813112848.ABF4437B406@hub.freebsd.org> Date: Mon, 13 Aug 2001 04:28:48 -0700 (PDT) From: jkoshy@FreeBSD.ORG (Joseph Koshy) Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message