diff options
author | Derrell Lipman <derrell.lipman@unwireduniverse.com> | 2009-02-09 22:46:29 -0500 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2009-02-16 09:56:59 +0100 |
commit | 47d16e7e7ffde80bf244225ea74e985e570ea1ab (patch) | |
tree | 1e34d723e9f5bee1a2717e7fed6c43bac43447d0 /examples | |
parent | 37b0e87076cf0836e01f7b74e21a457bcb02a719 (diff) | |
download | samba-47d16e7e7ffde80bf244225ea74e985e570ea1ab.tar.gz |
[Bug 6069] Add a fstatvfs function for libsmbclient
- Complete the implementation of the f_flag field. We now return a flag
indicatin UNIX CIFS, CASE SENSITIVE, and/or DFS support.
Derrell
(cherry picked from commit df15e8f84d108f8e9df1408155b0f9ccc44da3fe)
Diffstat (limited to 'examples')
-rw-r--r-- | examples/libsmbclient/testfstatvfs.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/examples/libsmbclient/testfstatvfs.c b/examples/libsmbclient/testfstatvfs.c new file mode 100644 index 00000000000..9db70cf476a --- /dev/null +++ b/examples/libsmbclient/testfstatvfs.c @@ -0,0 +1,101 @@ +#include <sys/types.h> +#include <sys/statvfs.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <time.h> +#include <errno.h> +#include <libsmbclient.h> +#include "get_auth_data_fn.h" + + +int main(int argc, char * argv[]) +{ + int i; + int fd; + int ret; + int debug = 0; + char * p; + char path[2048]; + struct stat statbuf; + struct statvfs statvfsbuf; + + smbc_init(get_auth_data_fn, debug); + + for (;;) + { + fprintf(stdout, "Path: "); + *path = '\0'; + fgets(path, sizeof(path) - 1, stdin); + if (strlen(path) == 0) + { + return 0; + } + + p = path + strlen(path) - 1; + if (*p == '\n') + { + *p = '\0'; + } + + /* Determine if it's a file or a folder */ + if (smbc_stat(path, &statbuf) < 0) + { + perror("smbc_stat"); + continue; + } + + if (S_ISREG(statbuf.st_mode)) + { + if ((fd = smbc_open(path, O_RDONLY, 0)) < 0) + { + perror("smbc_open"); + continue; + } + } + else + { + if ((fd = smbc_opendir(path)) < 0) + { + perror("smbc_opendir"); + continue; + } + } + + ret = smbc_fstatvfs(fd, &statvfsbuf); + + smbc_close(fd); + + if (ret < 0) + { + perror("fstatvfs"); + } + else if (statvfsbuf.f_flag == 0) + { + printf("No capabilities found\n"); + } + else + { + printf("Capabilities: "); + + if (statvfsbuf.f_flag & SMBC_VFS_CAP_UNIXCIFS) + { + printf("UNIXCIFS "); + } + + if (statvfsbuf.f_flag & SMBC_VFS_CAP_CASE_SENSITIVE) + { + printf("CASE_SENSITIVE "); + } + + if (statvfsbuf.f_flag & SMBC_VFS_CAP_DFS) + { + printf("DFS "); + } + + printf("\n"); + } + } + + return 0; +} |