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


main(argc, argv)
	int argc;
	char *argv[];
{
	int fd;
	int i;
	char buf[1024], *d;

	fd = open(argv[1], 0);
	while ((i = getdents(fd, buf, 256)) > 0) {
		for (d=buf; d<buf+i; d += ((struct dirent *)d)->d_reclen)
			if (((struct dirent *)d)->d_ino)
				printf("getdents : %d, %d -> \"%s\"\n",
					i,
					((struct dirent *)d)->d_reclen,
					((struct dirent *)d)->d_name);
	}

	if (i < 0)
		perror("getdents");
}
