From owner-freebsd-hackers Fri Dec 1 04:38:52 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id EAA21128 for hackers-outgoing; Fri, 1 Dec 1995 04:38:52 -0800 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id EAA21120 for ; Fri, 1 Dec 1995 04:38:39 -0800 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id XAA16391; Fri, 1 Dec 1995 23:29:53 +1100 Date: Fri, 1 Dec 1995 23:29:53 +1100 From: Bruce Evans Message-Id: <199512011229.XAA16391@godzilla.zeta.org.au> To: julian@ref.tfs.com, terry@lambert.org Subject: Re: seekdir broken.. Cc: hackers@FreeBSD.org Sender: owner-hackers@FreeBSD.org Precedence: bulk >Terry, look at what you just quoted.... >> >> Man page says: >> ========================================================================== >>... >> pointer, dirp, from which they are derived. If the directory is closed >> and then reopened, the telldir() value may be invalidated due to unde- >> tected directory compaction. It is safe to use a previous telldir() val- > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> ue immediately after a call to opendir() and before any calls to > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> readdir(). > ^^^^^^^^^ >> ========================================================================== >This is exactly what is failing..... Do you have cvs access? :-) The log for telldir says: revision 1.2 date: 1995/01/27 13:51:18; author: dfr; state: Exp; lines: +29 -0 Reclaim memory used for telldir cookies on closedir. I.e., extra work is done to break the underlined documentation. >> It is bogus to open and close the directory and expect the token to >> live past the life of the open. >In some ways I agree, exept that it is known to work on all other >systems and it seems to be commonly done It wastes a lot of memory. Consider a recursive traversal of "/". The original code allocates a telldir cookie for each telldir() call and frees it only for the corresponding seekdir() call. After closedir() there is unlikely to be a matching seekdir() call (unless the application is depending on the cookies living across closedir() and/or knows about the undocumented (#ifdef SINGLEUSE) way of freeing the cookies). Bruce