Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jul 2003 16:37:50 +0400
From:      Alexey Neyman <alex.neyman@auriga.ru>
To:        Dan Nelson <dnelson@allantgroup.com>, Jp Calderone <exarkun@intarweb.us>
Cc:        hackers@freebsd.org
Subject:   Re: telldir()/seekdir() confusion
Message-ID:  <200307181637.50764.alex.neyman@auriga.ru>
In-Reply-To: <20030708203026.GM87950@dan.emsphone.com>
References:  <20030708192342.GA4899@intarweb.us> <20030708203026.GM87950@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307181637.50764.alex.neyman>