s3: Add a fallback for missing open&x support in OS/X Lion
[Samba.git] / examples / libsmbclient / teststatvfs.c
blobb7e6b5159e1ddaeb5f20d929723f13c4d69f353d
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 i;
15 int fd;
16 int ret;
17 int debug = 0;
18 char * p;
19 char path[2048];
20 struct stat statbuf;
21 struct statvfs statvfsbuf;
23 smbc_init(get_auth_data_fn, debug);
25 for (;;)
27 fprintf(stdout, "Path: ");
28 *path = '\0';
29 fgets(path, sizeof(path) - 1, stdin);
30 if (strlen(path) == 0)
32 return 0;
35 p = path + strlen(path) - 1;
36 if (*p == '\n')
38 *p = '\0';
41 ret = smbc_statvfs(path, &statvfsbuf);
43 if (ret < 0)
45 perror("fstatvfs");
47 else
49 printf("\n");
50 printf("Block Size: %lu\n", statvfsbuf.f_bsize);
51 printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
52 printf("Blocks: %llu\n",
53 (unsigned long long) statvfsbuf.f_blocks);
54 printf("Free Blocks: %llu\n",
55 (unsigned long long) statvfsbuf.f_bfree);
56 printf("Available Blocks: %llu\n",
57 (unsigned long long) statvfsbuf.f_bavail);
58 printf("Files : %llu\n",
59 (unsigned long long) statvfsbuf.f_files);
60 printf("Free Files: %llu\n",
61 (unsigned long long) statvfsbuf.f_ffree);
62 printf("Available Files: %llu\n",
63 (unsigned long long) statvfsbuf.f_favail);
64 printf("File System ID: %lu\n",
65 (unsigned long) statvfsbuf.f_fsid);
66 printf("\n");
68 printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
69 printf("Extended Features: ");
71 if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
73 printf("NO_UNIXCIFS ");
75 else
77 printf("unixcifs ");
80 if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
82 printf("CASE_INSENSITIVE ");
84 else
86 printf("case_sensitive ");
89 if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
91 printf("DFS ");
93 else
95 printf("no_dfs ");
98 printf("\n");
102 return 0;