Created
April 29, 2016 06:51
-
-
Save Qix-/fa6053522ecc0a2e171b80f5c2e2dc81 to your computer and use it in GitHub Desktop.
dstat - developer stat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/stat.h> | |
#include <stdio.h> | |
int main(int argc, char **argv) { | |
if (argc != 2) { | |
fprintf(stderr, "error: must specify (only) one file\n"); | |
return -1; | |
} | |
struct stat attr; | |
if (stat(argv[1], &attr)) { | |
perror("could not stat file"); | |
return -2; | |
} | |
#define S(delim, name) printf(#name ":\x1b[30G%" #delim "\n", attr.st_##name); | |
S(ud, dev); | |
S(llud, ino); | |
S(oo, mode); | |
S(dd, nlink); | |
S(dd, uid); | |
S(dd, gid); | |
S(ud, rdev); | |
S(llud, size); | |
S(llud, blocks); | |
S(dd, blksize); | |
S(ud, flags); | |
S(ud, gen); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment