I have this code:

/*DIR.c */
#include <sys/types.h>
#include <sys/dir.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#define MAXPATH 255

void Error(char* msg)
{
perror(msg);
exit(0);
}

main(int argc,char** argv)
{
DIR *dhandle
struct direct *entry
struct stat inode;
char path[MAXPATH];

if (argc !=2) {Error("syntax: DIR directoryName"); }
dhandle=opendir(argv[1]);
if (dhandle==0) {Error("Open: "); }
printf("Listing of directory: %s\n inode name\n",argv[1]);

while ((entry=readdir(dhandle))!=0)

{

sprintf(path,"%s/%s",argv[1],entry->d_name);
if (stat(path,&inode)==-1) {Error("Getting inode: "); }

printf("%16u %-24s", entry->d_ino, entry->d_name);

if (S_ISREG(inode.st_mode)) printf("\tFile \n");

else

if (S_ISDIR(inode.st_mode)) printf("\tDirectory \n");

else printf("\tOther \n");

}

closedir(dhandle);

}

Now I'm trying to amend it from dir.c to dird.c so that the command dird pathname will print the total number of files in pathname, total number of blocks allocated and total number of bytes they consume. Any help please?

Thanks