[374] | 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 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;
|
---|
| 22 |
|
---|
| 23 | smbc_init(get_auth_data_fn, debug);
|
---|
| 24 |
|
---|
| 25 | for (;;)
|
---|
| 26 | {
|
---|
| 27 | fprintf(stdout, "Path: ");
|
---|
| 28 | *path = '\0';
|
---|
| 29 | fgets(path, sizeof(path) - 1, stdin);
|
---|
| 30 | if (strlen(path) == 0)
|
---|
| 31 | {
|
---|
| 32 | return 0;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | p = path + strlen(path) - 1;
|
---|
| 36 | if (*p == '\n')
|
---|
| 37 | {
|
---|
| 38 | *p = '\0';
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | ret = smbc_statvfs(path, &statvfsbuf);
|
---|
| 42 |
|
---|
| 43 | if (ret < 0)
|
---|
| 44 | {
|
---|
| 45 | perror("fstatvfs");
|
---|
| 46 | }
|
---|
| 47 | else
|
---|
| 48 | {
|
---|
| 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", statvfsbuf.f_blocks);
|
---|
| 53 | printf("Free Blocks: %llu\n", statvfsbuf.f_bfree);
|
---|
| 54 | printf("Available Blocks: %llu\n", statvfsbuf.f_bavail);
|
---|
| 55 | printf("Files : %llu\n", statvfsbuf.f_files);
|
---|
| 56 | printf("Free Files: %llu\n", statvfsbuf.f_ffree);
|
---|
| 57 | printf("Available Files: %llu\n", statvfsbuf.f_favail);
|
---|
| 58 | printf("File System ID: %lu\n", statvfsbuf.f_fsid);
|
---|
| 59 | printf("\n");
|
---|
| 60 |
|
---|
| 61 | printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
|
---|
| 62 | printf("Extended Features: ");
|
---|
| 63 |
|
---|
| 64 | if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
|
---|
| 65 | {
|
---|
| 66 | printf("NO_UNIXCIFS ");
|
---|
| 67 | }
|
---|
| 68 | else
|
---|
| 69 | {
|
---|
| 70 | printf("unixcifs ");
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
|
---|
| 74 | {
|
---|
| 75 | printf("CASE_INSENSITIVE ");
|
---|
| 76 | }
|
---|
| 77 | else
|
---|
| 78 | {
|
---|
| 79 | printf("case_sensitive ");
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
|
---|
| 83 | {
|
---|
| 84 | printf("DFS ");
|
---|
| 85 | }
|
---|
| 86 | else
|
---|
| 87 | {
|
---|
| 88 | printf("no_dfs ");
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | printf("\n");
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | return 0;
|
---|
| 96 | }
|
---|