Start system call
#include <stdio.h> #include <sys/stat.h> #include <stdlib.h> #include <time.h> int main(int argc, char* argv[]) { struct stat file; int n; if (argc != 2) { printf("Usage: ./a.out <filename>\n"); exit(-1); } // Checking if file statistics can be obtained if ((n = stat(argv[1], &file)) == -1) { perror(argv[1]); exit(-1); } // Printing file information printf("User id: %d\n", file.st_uid); printf("Group id: %d\n", file.st_gid); printf("Block size: %ld\n", file.st_blksize); printf("Blocks allocated: %ld\n", file.st_blocks); printf("Inode no.: %ld\n", file.st_ino); printf("Last accessed: %s", ctime(&(file.st_atime))); printf("Last m...
Comments
Post a Comment