Skip to content

Instantly share code, notes, and snippets.

@Qix-
Created April 29, 2016 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Qix-/fa6053522ecc0a2e171b80f5c2e2dc81 to your computer and use it in GitHub Desktop.
Save Qix-/fa6053522ecc0a2e171b80f5c2e2dc81 to your computer and use it in GitHub Desktop.
dstat - developer stat
#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