travis-ci: Add py3 jobs to match new jobs in autobuild.py
[Samba.git] / examples / libsmbclient / teststatvfs.c
blob9a8e5392763501b2b576825eb6aea8c4eea42250
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"
12 int main(int argc, char * argv[])
14 int ret;
15 int debug = 0;
16 char * p;
17 char path[2048];
18 struct statvfs statvfsbuf;
20 smbc_init(get_auth_data_fn, debug);
22 for (;;)
24 fprintf(stdout, "Path: ");
25 *path = '\0';
26 p = fgets(path, sizeof(path) - 1, stdin);
27 if (p == NULL) {
28 fprintf(stderr, "failed to read from stdin\n");
29 return 1;
31 if (strlen(path) == 0)
33 return 0;
36 p = path + strlen(path) - 1;
37 if (*p == '\n')
39 *p = '\0';
42 ret = smbc_statvfs(path, &statvfsbuf);
44 if (ret < 0)
46 perror("fstatvfs");
48 else
50 printf("\n");
51 printf("Block Size: %lu\n", statvfsbuf.f_bsize);
52 printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
53 printf("Blocks: %llu\n",
54 (unsigned long long) statvfsbuf.f_blocks);
55 printf("Free Blocks: %llu\n",
56 (unsigned long long) statvfsbuf.f_bfree);
57 printf("Available Blocks: %llu\n",
58 (unsigned long long) statvfsbuf.f_bavail);
59 printf("Files : %llu\n",
60 (unsigned long long) statvfsbuf.f_files);
61 printf("Free Files: %llu\n",
62 (unsigned long long) statvfsbuf.f_ffree);
63 printf("Available Files: %llu\n",
64 (unsigned long long) statvfsbuf.f_favail);
65 #ifdef HAVE_FSID_INT
66 printf("File System ID: %lu\n",
67 (unsigned long) statvfsbuf.f_fsid);
68 #endif
69 printf("\n");
71 printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
72 printf("Extended Features: ");
74 if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
76 printf("NO_UNIXCIFS ");
78 else
80 printf("unixcifs ");
83 if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
85 printf("CASE_INSENSITIVE ");
87 else
89 printf("case_sensitive ");
92 if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
94 printf("DFS ");
96 else
98 printf("no_dfs ");
101 printf("\n");
105 return 0;