#include #include #include #include #include #include void err_sys(char* message) { perror(message); exit(EXIT_FAILURE); } void stat_file(char *fname) { struct stat buff; char* type = "Unknown"; if(lstat(fname, &buff) < 0) { err_sys("lstat"); } if(S_ISREG(buff.st_mode)) { type = "Regular file"; } else if(S_ISDIR(buff.st_mode)) { type = "Directory"; } else if(S_ISCHR(buff.st_mode)) { type = "Character special file"; } else if(S_ISBLK(buff.st_mode)) { type = "Block special file"; } else if(S_ISFIFO(buff.st_mode)) { type = "Pipe or FIFO"; } else if(S_ISLNK(buff.st_mode)) { type = "Symbolic link"; } else if(S_ISSOCK(buff.st_mode)) { type = "Socket"; } printf("%-30s %10ld Bytes %s\n", fname, buff.st_size,type); } int main(int argc, char *argv[]) { int i; for(i=1; i