From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 18 05:37:12 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9480837B401 for ; Fri, 18 Jul 2003 05:37:12 -0700 (PDT) Received: from mail.auriga.ru (mail.auriga.ru [80.240.102.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8611043FA3 for ; Fri, 18 Jul 2003 05:37:11 -0700 (PDT) (envelope-from alex.neyman@auriga.ru) Received: from mail.loopback.interface ([127.0.0.1] helo=vagabond.auriga.ru) by mail.auriga.ru with esmtp (Exim 4.14) id 19dUaN-00089b-Qt; Fri, 18 Jul 2003 16:43:43 +0400 From: Alexey Neyman Organization: Auriga, Inc. To: Dan Nelson , Jp Calderone Date: Fri, 18 Jul 2003 16:37:50 +0400 User-Agent: KMail/1.5.1 References: <20030708192342.GA4899@intarweb.us> <20030708203026.GM87950@dan.emsphone.com> In-Reply-To: <20030708203026.GM87950@dan.emsphone.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200307181637.50764.alex.neyman@auriga.ru> cc: hackers@freebsd.org Subject: Re: telldir()/seekdir() confusion X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jul 2003 12:37:12 -0000 hi, there! On Wednesday 09 July 2003 00:30, Dan Nelson wrote: DN> > pos = telldir(dirp); DN> > ent = readdir(dirp); DN> > seekdir(dirp, pos); DN> > printf("First telldir:%d\nSecond telldir:%d\n", pos, telldir(dirp)); DN> I don't think there's any pstandard that says that telldir has to DN> return a seekable file offset, or that consecutive calls on the same DN> position must return the same value. Think about a filesystem that It seems you're wrong; what follows is a quote from the SUSv3: "If the most recent operation on the directory stream was a seekdir(), the directory position returned from the telldir() shall be the same as that supplied as a loc argument for seekdir()." which is clearly violated in this case. Also, if I'm not misreading the code, the 'ddloc' structure is freed after a successful seekdir() call was made. That said, a value returned by the telldir() is rendered invalid after the seekdir() on it, and if the seekdir() is called more than once, the 2nd and the following calls won't change the stream position. However, I couldn't find anything in standard forbidding calling seekdir() twice on the same position; the only requirements are using valid position (obtained via telldir()) and no calls to rewinddir between telldir() and seekdir(). Regards, Alexey. -- A quoi ca sert d'etre sur la terre Si c'est pour faire nos vies a genoux?