From owner-freebsd-hackers@FreeBSD.ORG Thu Nov 17 21:13:44 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 204D3106566B; Thu, 17 Nov 2011 21:13:44 +0000 (UTC) (envelope-from nox@jelal.kn-bremen.de) Received: from smtp.kn-bremen.de (gelbbaer.kn-bremen.de [78.46.108.116]) by mx1.freebsd.org (Postfix) with ESMTP id D37F28FC19; Thu, 17 Nov 2011 21:13:43 +0000 (UTC) Received: by smtp.kn-bremen.de (Postfix, from userid 10) id E8C7B1E00233; Thu, 17 Nov 2011 21:57:55 +0100 (CET) Received: from triton8.kn-bremen.de (noident@localhost [127.0.0.1]) by triton8.kn-bremen.de (8.14.4/8.14.3) with ESMTP id pAHKtaGm061119; Thu, 17 Nov 2011 21:55:36 +0100 (CET) (envelope-from nox@triton8.kn-bremen.de) Received: (from nox@localhost) by triton8.kn-bremen.de (8.14.4/8.14.3/Submit) id pAHKtZso061118; Thu, 17 Nov 2011 21:55:35 +0100 (CET) (envelope-from nox) Date: Thu, 17 Nov 2011 21:55:35 +0100 (CET) From: Juergen Lock Message-Id: <201111172055.pAHKtZso061118@triton8.kn-bremen.de> To: tim@kientzle.com X-Newsgroups: local.list.freebsd.hackers In-Reply-To: References: <20111115202450.GA73512@freebsd.org> <20111116102239.GA2687@britannica.bec.de> <20111116131428.GA40723@freebsd.org> <20111116232152.GC21793@britannica.bec.de> <20111117002438.GA55931@freebsd.org> Organization: X-Mailman-Approved-At: Thu, 17 Nov 2011 22:33:30 +0000 Cc: Alexander Best , freebsd-hackers@freebsd.org Subject: Re: easy way to determine if a stream or fd is seekable 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: Thu, 17 Nov 2011 21:13:44 -0000 In article you write: >On Nov 16, 2011, at 4:24 PM, Alexander Best wrote: > >> On Thu Nov 17 11, Joerg Sonnenberger wrote: >>> On Wed, Nov 16, 2011 at 01:14:28PM +0000, Alexander Best wrote: >>>> On Wed Nov 16 11, Joerg Sonnenberger wrote: >>>>> On Tue, Nov 15, 2011 at 08:24:50PM +0000, Alexander Best wrote: >>>>>> one of the things i'm missing is an easy way to determine, whether a stream or >>>>>> fd is seekable. i checked the dd(1) and hd(1) sources and those tools are >>>>>> performing so much stuff just to find out if this is the case, and they still >>>>>> are doing a very poor job. >>>>> >>>>> Isn't the primary issue that FreeBSD doesn't properly report errors for >>>>> lseek(2)? I think you should start from that and not hack around the >>>>> fallout... >>>> >>>> what do you mean? lseek(2) returns -1, when the file descriptor is not >>>> seekable. i fired lseek(2) at all sorts of file types (dir, sockets, ...) >>>> and it always returned the correct result. >>> >>> If that were the case, you wouldn't need your flag to detect seek >>> support. But e.g. some devices silently ignore seek requests without >>> reporting errors. At least that is what I remember from the last time >>> this has brought up. >> >> this is the first time i hear about problems with seek requests. would be nice >> to see some examples cases. was this discussed on the mailinglists? or >> submitted as a problem report? > >There was a version of bsdtar that made the mistake of assuming >lseek() would return an error. > >lseek() on a tape drive does not return an error, nor does it >actually do anything. > >After a few experiments, bsdtar stopped using lseek() on >FreeBSD for anything other than regular files and block >devices. I believe there are other things that do support >seeking, but I don't believe there is an accurate mechanism >for determining whether lseek() is correctly supported. Ah is that the reason why my patch never made it into FreeBSD 9? I'm talking about this thread, where I also commented on seeking on tape: http://docs.freebsd.org/cgi/mid.cgi?20100220101724.GA26604 (Re: "tar tfv /dev/cd0" speedup patch) entire thread here: http://markmail.org/message/nfznipqik3tuhbqp Cheers, Juergen (who would still like to see a faster "tar tfv /dev/cd0"... :)