From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 22 16:22:52 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 31BCA10656A8; Tue, 22 Feb 2011 16:22:52 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-ew0-f54.google.com (mail-ew0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 8FDF08FC1F; Tue, 22 Feb 2011 16:22:51 +0000 (UTC) Received: by ewy28 with SMTP id 28so233197ewy.13 for ; Tue, 22 Feb 2011 08:22:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=72Fchf63K0A0hh9n+ZfUbboH9RFLRjTHMRKB84EStKg=; b=pDLfICN3Cj6VwJPN3nY3LWE7oP4W0y3cK9RJtpPNTpHnebWM9w23ljIu/WCgx982KR 2wj2NSv+Xdj4WgYzPQC9yXNnlHYiUGvk1ZLWMd2AR+K+wdn8iWs+aFYDyXY+0GW48B0O yKAEWOCCu0okPPreXkXwhLl2+AXtNR0reKP10= DomainKey-Signature: a=rsa-sha1; c=nofws; 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; b=Fvr0DgZtc5L4q0A8w/gC4iTs+GfwTBy3/m6pAqU/FM1Oa8lwSs+btYf3tvwRxYx8bJ ctVTgOyMxRb7ADLS464HTL+I5dmX+t0D1+LrcdKi+0XKgdiegXqrY6FYQUpcroSsZ+4q +QGvEeQtMD94psSHKZQTlmmHZyrIcFgmvhKGY= MIME-Version: 1.0 Received: by 10.216.144.205 with SMTP id n55mr3505238wej.5.1298391770223; Tue, 22 Feb 2011 08:22:50 -0800 (PST) Sender: yanegomi@gmail.com Received: by 10.216.15.74 with HTTP; Tue, 22 Feb 2011 08:22:50 -0800 (PST) In-Reply-To: <20110222141112.GA98964@freebsd.org> References: <20110222141112.GA98964@freebsd.org> Date: Tue, 22 Feb 2011 08:22:50 -0800 X-Google-Sender-Auth: AAgEUGLVFxnCs_42-m4V5WtjKCA Message-ID: From: Garrett Cooper To: Alexander Best Content-Type: text/plain; charset=ISO-8859-1 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:22:52 -0000 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 wanted > 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 the 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 "ordinary" > files. right now only reading from /dev/zero will seek into the file. writing > 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 example: 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 last. 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