Permalink
Browse files

Add dump-stat script

  • Loading branch information...
EtiennePerot committed Oct 19, 2013
1 parent abceefc commit 3ff0014252f2d43449cf69cafdd9387c1364403a
Showing with 44 additions and 0 deletions.
  1. +1 −0 res/.gitignore
  2. +8 −0 res/dump-stat
  3. +35 −0 res/dump-stat.c
View
@@ -0,0 +1 @@
dump-stat.bin
View
@@ -0,0 +1,8 @@
#!/bin/bash
set -e
scriptDir=$(dirname "$BASH_SOURCE")
gcc -o "$scriptDir/dump-stat.bin" "$scriptDir/dump-stat.c"
exec "$scriptDir/dump-stat.bin" "$@"
View
@@ -0,0 +1,35 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
struct stat sb;
size_t i;
char *c;
if (argc != 2) {
fprintf(stderr, "Usage: %s <pathname>\n", argv[0]);
exit(EXIT_FAILURE);
}
if (stat(argv[1], &sb) == -1) {
perror("stat");
exit(EXIT_FAILURE);
}
c = (char *) &sb;
for (i = 0; i < sizeof(struct stat); i++) {
printf("%02x ", *c++ & 0xff);
if(i % 4 == 3)
{
printf(" ");
}
if(i % 16 == 15)
{
printf(" [%d]\n", i + 1);
}
}
printf("\n");
}

0 comments on commit 3ff0014

Please sign in to comment.