Bug 23300

Summary: make assumes readdir returns '.' and '..' for the first two calls.
Product: Base System Reporter: Jim.Pirzyk <Jim.Pirzyk>
Component: binAssignee: Will Andrews <will>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Jim.Pirzyk 2000-12-05 19:20:02 UTC
	The readdir on a specific NFS dir will not return '.' and '..' 
	as the first entries.  Make assumes that the first two calls to
	readdir will return those.  The make fails because it cannot find
	the file 'S' (which is returned second, see below)

How-To-Repeat: 
	Running this short C program shows that '.' and '..' are not the
	first two entries returned by readdir.


--- listdir.c ---

#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

void main (int argc, char *argv[]) {
	int i;

	for (i = 1; i < argc; i++) {
		(void)list_files (argv[i]);
	}
}

void list_files (char *dir) {
	DIR *d = opendir (dir);
	struct dirent *dp;

	if ( d ) {
		while (dp=readdir(d)) {
			printf ("%s\n", dp->d_name);
		}
	} else {
		printf ("Could not open %s\n", dir);
	}

	closedir(dir);
}

--- output from listdir (run by ./listdir /usr/src/contrib/groff/devX100 ) ---

.
S
..
CB
CI
CR
HB
HI
HR
NB
NI
NR
TB
TI
TR
CBI
HBI
NBI
TBI
DESC
Comment 1 Chris D.Faulhaber freebsd_committer freebsd_triage 2000-12-06 11:52:44 UTC
Responsible Changed
From-To: freebsd-bugs->will

Over to maintainer
Comment 2 Will Andrews freebsd_committer freebsd_triage 2000-12-26 07:36:19 UTC
State Changed
From-To: open->suspended

Merged into -CURRENT, where it will sit out for at least six weeks, since 
I don't have access to an environment like the one you describe (and thus 
your listdir program doesn't work the same way).  I accepted your patch, 
however, because it appears to work correctly.
Comment 3 Will Andrews freebsd_committer freebsd_triage 2001-02-25 10:11:25 UTC
State Changed
From-To: suspended->closed

Hmm, thought I closed this PR.  Anyway, the fixed was MFC'd to RELENG_4 
and RELENG_3 almost two weeks ago.