docs: Avoid mentioning a possibly misleading option.
[obnox/samba/samba-obnox.git] / examples / libsmbclient / teststatvfs.c
1 #include <sys/types.h>
2 #include <sys/statvfs.h>
3 #include <stdio.h> 
4 #include <unistd.h>
5 #include <string.h> 
6 #include <time.h> 
7 #include <errno.h>
8 #include <libsmbclient.h> 
9 #include "get_auth_data_fn.h"
10
11
12 int main(int argc, char * argv[]) 
13
14     int             ret;
15     int             debug = 0;
16     char *          p;
17     char            path[2048];
18     struct statvfs  statvfsbuf;
19     
20     smbc_init(get_auth_data_fn, debug); 
21     
22     for (;;)
23     {
24         fprintf(stdout, "Path: ");
25         *path = '\0';
26         fgets(path, sizeof(path) - 1, stdin);
27         if (strlen(path) == 0)
28         {
29             return 0;
30         }
31
32         p = path + strlen(path) - 1;
33         if (*p == '\n')
34         {
35             *p = '\0';
36         }
37     
38         ret = smbc_statvfs(path, &statvfsbuf);
39
40         if (ret < 0)
41         {
42             perror("fstatvfs");
43         }
44         else
45         {
46             printf("\n");
47             printf("Block Size: %lu\n", statvfsbuf.f_bsize);
48             printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
49             printf("Blocks: %llu\n",
50                    (unsigned long long) statvfsbuf.f_blocks);
51             printf("Free Blocks: %llu\n",
52                    (unsigned long long) statvfsbuf.f_bfree);
53             printf("Available Blocks: %llu\n",
54                    (unsigned long long) statvfsbuf.f_bavail);
55             printf("Files : %llu\n",
56                    (unsigned long long) statvfsbuf.f_files);
57             printf("Free Files: %llu\n",
58                    (unsigned long long) statvfsbuf.f_ffree);
59             printf("Available Files: %llu\n",
60                    (unsigned long long) statvfsbuf.f_favail);
61 #ifdef HAVE_FSID_INT
62             printf("File System ID: %lu\n",
63                    (unsigned long) statvfsbuf.f_fsid);
64 #endif
65             printf("\n");
66
67             printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
68             printf("Extended Features: ");
69
70             if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
71             {
72                 printf("NO_UNIXCIFS ");
73             }
74             else
75             {
76                 printf("unixcifs ");
77             }
78
79             if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
80             {
81                 printf("CASE_INSENSITIVE ");
82             }
83             else
84             {
85                 printf("case_sensitive ");
86             }
87
88             if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
89             {
90                 printf("DFS ");
91             }
92             else
93             {
94                 printf("no_dfs ");
95             }
96
97             printf("\n");
98         }
99     }
100
101     return 0; 
102 }