From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 22 16:35:46 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 6AF10106564A for ; Tue, 22 Feb 2011 16:35:46 +0000 (UTC) (envelope-from aduane@juniper.net) Received: from exprod7og108.obsmtp.com (exprod7og108.obsmtp.com [64.18.2.169]) by mx1.freebsd.org (Postfix) with ESMTP id DBC1E8FC14 for ; Tue, 22 Feb 2011 16:35:45 +0000 (UTC) Received: from source ([66.129.224.36]) (using TLSv1) by exprod7ob108.postini.com ([64.18.6.12]) with SMTP ID DSNKTWPl4Yhshs3HUW9YkOLtafaui/ZX3gtl@postini.com; Tue, 22 Feb 2011 08:35:46 PST Received: from p-emfe02-wf.jnpr.net (172.28.145.25) by P-EMHUB01-HQ.jnpr.net (172.24.192.35) with Microsoft SMTP Server (TLS) id 8.2.254.0; Tue, 22 Feb 2011 08:32:54 -0800 Received: from EMBX01-WF.jnpr.net ([fe80::1914:3299:33d9:e43b]) by p-emfe02-wf.jnpr.net ([fe80::c126:c633:d2dc:8090%11]) with mapi; Tue, 22 Feb 2011 11:33:27 -0500 From: Andrew Duane To: Garrett Cooper , Alexander Best Date: Tue, 22 Feb 2011 11:31:12 -0500 Thread-Topic: seeking into /dev/{null,zero} Thread-Index: AcvSrOTLLWLRlbw0TeyBbYAA+7OlhwAAQZ5n Message-ID: References: <20110222141112.GA98964@freebsd.org>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "freebsd-hackers@freebsd.org" Subject: RE: seeking into /dev/{null,zero} 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: Tue, 22 Feb 2011 16:35:46 -0000 I thought seeking past EOF was valid; writing something creates a file with= a hole in it. I always assumed that was standard semantics. As for /dev/zero and /dev/null, you could easily ask "who cares about the f= ile position?" But I think some programs might want to seek around and chec= k values, and those shouldn't change behaviour if someone uses /dev/null as= a test file. It seems pretty trivial to update it, so why not make it beha= ve the same. -- Andrew Duane Juniper Networks 978-589-0551 10 Technology Park Dr aduane@juniper.net Westford, MA 01886-3418 ________________________________________ From: owner-freebsd-hackers@freebsd.org [owner-freebsd-hackers@freebsd.org]= On Behalf Of Garrett Cooper [gcooper@freebsd.org] Sent: Tuesday, February 22, 2011 11:22 AM To: Alexander Best Cc: freebsd-hackers@freebsd.org Subject: Re: seeking into /dev/{null,zero} On Tue, Feb 22, 2011 at 6:11 AM, Alexander Best wrote= : > hi there, > > there's a PR [1] regarding seeking into /dev/null and /dev/zero. i just w= anted > to ask what the overall opinion is on this matter. technically it's quite= easy > to seek into those files upon fwrite(3) and fread(3). the point is, if th= e file > position should be repositioned according the the amount of bytes read or > written. > > the zero(4) and null(4) manual pages claim that both devices act as "ordi= nary" > files. right now only reading from /dev/zero will seek into the file. wri= ting > to /dev/zero and reading/writing to /dev/null will *not* adjust the file > position. lseek on CURRENT (and its assorted functions) is funky. Try this as an exam= ple: 1. Create a zero character file. 2. lseek with SEEK_SET to byte 1. 2. will always return 1. My Fedora Linux 13 VM on the other hand actually reports the error when you try and seek outside the bounds of the file descriptor (this makes more sense IMO because it accurately reflects reality). This is an extension to the POSIX spec though as the spec doesn't say whether or not seeking past the bounds of the descriptor is legal or illegal. So what I'm trying to say is that the seek family functions in general don't report helpful data except with success. Found this when trying to write testcases for lseek(2) the night before las= t. I'll get back to you about the POSIXness of those /dev's in the most recent spec once I get access back to the OpenGroup download section -_-... Thanks, -Garrett _______________________________________________ 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"