[comp.unix.questions] directory reading

bglenden@mandrill.cv.nrao.edu (Brian Glendenning) (08/15/90)

I'm converting some old directory reading code to get it to work on
the latest version of Convex OS (8.1). The old code contained:
   struct direct *dp;
[...]
            if (dp->d_ino == 0)
               continue;
Presumably because the reading routines could return non-null pointers
that contained invalid (deleted or whatever) directory entries. It
looks like modern readdir(3)'s only return pointers to valid entries,
and NULL at the end, so a test of this type is no longer required.
True?

Thanks!

Brian
--
       Brian Glendenning - National Radio Astronomy Observatory
bglenden@nrao.edu          bglenden@nrao.bitnet          (804) 296-0286

gwyn@smoke.BRL.MIL (Doug Gwyn) (08/15/90)

In article <BGLENDEN.90Aug14202150@mandrill.cv.nrao.edu> bglenden@mandrill.cv.nrao.edu (Brian Glendenning) writes:
>            if (dp->d_ino == 0)
>               continue;
>It looks like modern readdir(3)'s only return pointers to valid entries,
>and NULL at the end, so a test of this type is no longer required.

Yes, all versions of readdir() are expected to filter out "deleted" entries
so there is no need to test for that in the application.