smbd: fix creation of BUILTIN\{Administrators,Users} when "tdbsam:map builtin = false"
[Samba/wip.git] / examples / libsmbclient / testfstatvfs.c
blob512563f3e6200dd5193560bde3cc532d0304b020
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 fd;
15 int ret;
16 int debug = 0;
17 char * p;
18 char path[2048];
19 struct stat statbuf;
20 struct statvfs statvfsbuf;
22 smbc_init(get_auth_data_fn, debug);
24 for (;;)
26 fprintf(stdout, "Path: ");
27 *path = '\0';
28 fgets(path, sizeof(path) - 1, stdin);
29 if (strlen(path) == 0)
31 return 0;
34 p = path + strlen(path) - 1;
35 if (*p == '\n')
37 *p = '\0';
40 /* Determine if it's a file or a folder */
41 if (smbc_stat(path, &statbuf) < 0)
43 perror("smbc_stat");
44 continue;
47 if (S_ISREG(statbuf.st_mode))
49 if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
51 perror("smbc_open");
52 continue;
55 else
57 if ((fd = smbc_opendir(path)) < 0)
59 perror("smbc_opendir");
60 continue;
64 ret = smbc_fstatvfs(fd, &statvfsbuf);
66 smbc_close(fd);
68 if (ret < 0)
70 perror("fstatvfs");
72 else
74 printf("\n");
75 printf("Block Size: %lu\n", statvfsbuf.f_bsize);
76 printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
77 printf("Blocks: %llu\n",
78 (unsigned long long) statvfsbuf.f_blocks);
79 printf("Free Blocks: %llu\n",
80 (unsigned long long) statvfsbuf.f_bfree);
81 printf("Available Blocks: %llu\n",
82 (unsigned long long) statvfsbuf.f_bavail);
83 printf("Files : %llu\n",
84 (unsigned long long) statvfsbuf.f_files);
85 printf("Free Files: %llu\n",
86 (unsigned long long) statvfsbuf.f_ffree);
87 printf("Available Files: %llu\n",
88 (unsigned long long) statvfsbuf.f_favail);
89 #ifdef HAVE_FSID_INT
90 printf("File System ID: %lu\n",
91 (unsigned long) statvfsbuf.f_fsid);
92 #endif
93 printf("\n");
95 printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
96 printf("Extended Features: ");
98 if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
100 printf("NO_UNIXCIFS ");
102 else
104 printf("unixcifs ");
107 if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
109 printf("CASE_INSENSITIVE ");
111 else
113 printf("case_sensitive ");
116 if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
118 printf("DFS ");
120 else
122 printf("no_dfs ");
125 printf("\n");
129 return 0;