#include #include #include int main(int argc, char * argv[]) { printf("ino_t size %d, time_t size %d\n", sizeof(ino_t), sizeof(time_t)); time_t now = time(NULL); printf("time %lld, year %lld\n", now, now / 31536000 + 1970); struct tm * t = localtime(& now); printf("%d %d %d %d %d %d %d %d\n", t->tm_year, t->tm_mon, t->tm_mday, t->tm_wday, t->tm_hour, t->tm_min, t->tm_sec); DIR * d = opendir("weaths"); if (d == NULL) fprintf(stderr, "Can't open directory\n"); else { while (1) { struct dirent * de = readdir(d); if (de == NULL) break; printf("name %s, inode %lld, type %d\n", de->d_name, de->d_fileno, de->d_type); } closedir(d); } int i; for (i = 1; i < argc; i += 1) { printf("\n%s:\n", argv[i]); struct stat s; int n = stat(argv[i], & s); if (n < 0) perror(" stat failed"); else { printf(" device: %d\n", s.st_dev); printf(" inode: %lld\n", s.st_ino); printf(" nlinks: %d\n", s.st_nlink); printf(" size: %lld\n", s.st_size); printf(" mode: %o\n", s.st_mode); printf(" uid: %d\n", s.st_uid); printf(" gid: %d\n", s.st_gid); printf(" ctime: %lld\n", s.st_ctime); printf(" mtime: %lld\n", s.st_mtime); printf(" atime: %lld\n", s.st_atime); printf(" ctim: %d.%09d\n", s.st_ctim.tv_sec, s.st_ctim.tv_nsec); printf(" mtim: %d.%09d\n", s.st_mtim.tv_sec, s.st_mtim.tv_nsec); printf(" atim: %d.%09d\n", s.st_atim.tv_sec, s.st_atim.tv_nsec); printf(" birthtim: %d.%09d\n", s.st_birthtim.tv_sec, s.st_birthtim.tv_nsec); } } }