From owner-freebsd-doc@FreeBSD.ORG Tue Nov 22 22:00:14 2011 Return-Path: Delivered-To: freebsd-doc@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5EB5F1065688 for ; Tue, 22 Nov 2011 22:00:14 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 24E3C8FC08 for ; Tue, 22 Nov 2011 22:00:14 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id pAMM0EQN024293 for ; Tue, 22 Nov 2011 22:00:14 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id pAMM0DAo024292; Tue, 22 Nov 2011 22:00:13 GMT (envelope-from gnats) Date: Tue, 22 Nov 2011 22:00:13 GMT Message-Id: <201111222200.pAMM0DAo024292@freefall.freebsd.org> To: freebsd-doc@FreeBSD.org From: Alexander Best Cc: Subject: Re: kern/162765: [patch] lseek(2) may return successful although no seek operation was actually performed X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Alexander Best List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2011 22:00:14 -0000 The following reply was made to PR kern/162765; it has been noted by GNATS. From: Alexander Best To: bug-followup@freebsd.org Cc: Subject: Re: kern/162765: [patch] lseek(2) may return successful although no seek operation was actually performed Date: Tue, 22 Nov 2011 21:52:56 +0000 --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline here's a revised patch (comma removed after "confirm"), as suggested by warren block. thanks. :) cheers. alex --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="lseek.2.diff3" diff --git a/lib/libc/sys/lseek.2 b/lib/libc/sys/lseek.2 index 874c523..1db5891 100644 --- a/lib/libc/sys/lseek.2 +++ b/lib/libc/sys/lseek.2 @@ -28,7 +28,7 @@ .\" @(#)lseek.2 8.3 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd April 5, 2007 +.Dd November 21, 2011 .Dt LSEEK 2 .Os .Sh NAME @@ -113,10 +113,9 @@ of the existing end-of-file of the file. If data is later written at this point, subsequent reads of the data in the gap return bytes of zeros (until data is actually written into the gap). -.Pp -Some devices are incapable of seeking. -The value of the pointer -associated with such a device is undefined. +However, the +.Fn lseek +system call does not, by itself, extend the size of a file. .Pp A .Qq hole @@ -197,13 +196,43 @@ is associated with a pipe, socket, or FIFO. The .Fn lseek system call is expected to conform to -.St -p1003.1-90 . +.St -p1003.1-2008 . +.Pp +The +.Dv SEEK_HOLE +and +.Dv SEEK_DATA +directives, along with the +.Er ENXIO +error, are extensions to that specification. .Sh HISTORY The .Fn lseek function appeared in .At v7 . .Sh BUGS +If the +.Fn lseek +system call is operating on a device which is incapable of seeking, +it will request the seek operation and return successfully, +even though no seek was performed. +Because the +.Ar offset +argument will be stored unconditionally in the file descriptor of that device, +there is no way to confirm if the seek operation succeeded or not +(e.g. using the +.Fn ftell +function). +Device types which are known to be incapable of seeking include +tape drives. +.Pp +The +.Fn lseek +system call will not detect whether media are present in changeable +media devices such as DVD or Blu-ray devices. +A requested seek operation will therefore return sucessfully when no +medium is present. +.Pp This document's use of .Fa whence is incorrect English, but is maintained for historical reasons. --fdj2RfSjLxBAspz7--