Subject: Re: lib/14340: scandir aborts with Segmentation fault (core dumped)
To: None <netbsd-bugs@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: netbsd-bugs
Date: 10/25/2001 02:56:03
In article <20011024212335.DBB6111112@www.netbsd.org>,
<cwlh@nortelnetworks.com> wrote:
Your program is wrong, use:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/param.h>
#include <stddef.h>
int main();
int main()
{
int n;
char cwd[MAXPATHLEN+1];
struct dirent **namelist;
// get our current working directory
// to use as an example directory
getcwd(cwd,MAXPATHLEN);
printf("cwd = <%s>\n",cwd);
// then go to get the contents
// of that directory
printf("Starting scandir\n");
n = scandir(cwd,&namelist,NULL,NULL);
printf("Back from scandir\n");
printf("There were %d entries\n",n);
return 0;
}