more like samba offline test
[tridge/junkcode.git] / fsid.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <sys/vfs.h>
5 #include <sys/statvfs.h>
6
7 int main(int argc, const char *argv[])
8 {
9         struct statfs s1;
10         struct statvfs s2;
11         const char *path;
12         unsigned char buf[sizeof(fsid_t)];
13         int i;
14
15         if (argc != 2) {
16                 printf("Usage: fsid <path>\n");
17                 exit(1);
18         }
19
20         path = argv[1];
21         
22         if (statfs(path, &s1) != 0) {
23                 perror("statfs");
24                 exit(1);
25         }
26
27         memcpy(buf, &s1.f_fsid, sizeof(fsid_t));
28
29         printf("statfs  ");
30         for (i=0;i<sizeof(buf);i++) {
31                 printf("%02x", buf[i]);
32         }
33         printf("\n");
34
35         if (statvfs(path, &s2) != 0) {
36                 perror("statvfs");
37                 exit(1);
38         }
39
40         printf("statvfs %llx\n", (unsigned long long)s2.f_fsid);
41
42         return 0;       
43 }