Subject: Re: readdir()/getdents() portability -- "."/".." always first?
To: Jaromir Dolecek <jdolecek@NetBSD.org>
From: Greywolf <greywolf@starwolf.com>
List: current-users
Date: 09/04/2003 10:08:30
Thus spake Jaromir Dolecek ("JD> ") sometime Today...

JD> Currently, all our filesystems do return '.' and '..' as first two
JD> entries for getdent(). Perhaps it would be good if coda_readdir()
JD> would make sure to do the same.

Are you *sure* about this?

What about a filesystem whose '.' or '..' gets trashed?  I've seen it
happen, and another entry could possibly take its place (which I've
also seen happen).

The first entry is nearly 100% guaranteed to be '.', much closer to 100%
than the second being guaranteed to be '..' (in a case where '..' gets
unlinked; obviously, this is not the case for a sane directory!).

...then Matthias Drochner ("MD> ") asked:

MD> Can we _really_ rely on "." and ".." to be the first 2 entries,
MD> whatever filesystem we use (or whatever system we compile our
MD> "make" on)?

I would say "it's not entirely a safe bet".  The remnants of the
error-prone days where this was more possible than it is now still
haunt me, and as a programmer, I'd tend to want not to assume this.

[right now, short of fsdb (and a subsequent reboot and some recovery),
 I don't have a means of testing this...]

				--*greywolf;
--
NetBSD:  You choose the hardware, we'll bring the OS.