summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDerrell Lipman <derrell.lipman@unwireduniverse.com>2009-02-12 09:16:48 -0500
committerKarolin Seeger <kseeger@samba.org>2009-02-16 09:57:02 +0100
commit6e4efa3a31567a1f136e4ba4537b25e55765535a (patch)
treed207287ba06c9174537c1580e13308d208c5a16b /examples
parent962acaf800014913794cbbc1df381f619f63a6ca (diff)
downloadsamba-6e4efa3a31567a1f136e4ba4537b25e55765535a.tar.gz
[Bug 6069] Add a fstatvfs function for libsmbclient
- DFS is not a POSIX feature, so the state of that bit should be zero if DFS is *not* supported. Bit feature reversed. - Added smbc_statvfs function Derrell (cherry picked from commit 0697cffe211a922c816b6c75230c4186328498ed)
Diffstat (limited to 'examples')
-rw-r--r--examples/libsmbclient/Makefile5
-rw-r--r--examples/libsmbclient/testfstatvfs.c6
-rw-r--r--examples/libsmbclient/teststatvfs.c96
3 files changed, 104 insertions, 3 deletions
diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile
index 7ad28dcea0f..728dbe0edbc 100644
--- a/examples/libsmbclient/Makefile
+++ b/examples/libsmbclient/Makefile
@@ -24,6 +24,7 @@ TESTS= testsmbc \
teststat \
teststat2 \
teststat3 \
+ teststatvfs \
testfstatvfs \
testtruncate \
testchmod \
@@ -75,6 +76,10 @@ teststat3: teststat3.o
@echo Linking teststat3
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+teststatvfs: teststatvfs.o
+ @echo Linking teststatvfs
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+
testfstatvfs: testfstatvfs.o
@echo Linking testfstatvfs
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
diff --git a/examples/libsmbclient/testfstatvfs.c b/examples/libsmbclient/testfstatvfs.c
index f8a6870a921..b4dafefff60 100644
--- a/examples/libsmbclient/testfstatvfs.c
+++ b/examples/libsmbclient/testfstatvfs.c
@@ -105,13 +105,13 @@ int main(int argc, char * argv[])
printf("case_sensitive ");
}
- if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_DFS)
+ if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
{
- printf("NO_DFS ");
+ printf("DFS ");
}
else
{
- printf("dfs ");
+ printf("no_dfs ");
}
printf("\n");
diff --git a/examples/libsmbclient/teststatvfs.c b/examples/libsmbclient/teststatvfs.c
new file mode 100644
index 00000000000..8812002d5ce
--- /dev/null
+++ b/examples/libsmbclient/teststatvfs.c
@@ -0,0 +1,96 @@
+#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';
+ }
+
+ ret = smbc_statvfs(path, &statvfsbuf);
+
+ if (ret < 0)
+ {
+ perror("fstatvfs");
+ }
+ else
+ {
+ printf("\n");
+ printf("Block Size: %lu\n", statvfsbuf.f_bsize);
+ printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
+ printf("Blocks: %llu\n", statvfsbuf.f_blocks);
+ printf("Free Blocks: %llu\n", statvfsbuf.f_bfree);
+ printf("Available Blocks: %llu\n", statvfsbuf.f_bavail);
+ printf("Files : %llu\n", statvfsbuf.f_files);
+ printf("Free Files: %llu\n", statvfsbuf.f_ffree);
+ printf("Available Files: %llu\n", statvfsbuf.f_favail);
+ printf("File System ID: %lu\n", statvfsbuf.f_fsid);
+ printf("\n");
+
+ printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
+ printf("Extended Features: ");
+
+ if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
+ {
+ printf("NO_UNIXCIFS ");
+ }
+ else
+ {
+ printf("unixcifs ");
+ }
+
+ if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
+ {
+ printf("CASE_INSENSITIVE ");
+ }
+ else
+ {
+ printf("case_sensitive ");
+ }
+
+ if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
+ {
+ printf("DFS ");
+ }
+ else
+ {
+ printf("no_dfs ");
+ }
+
+ printf("\n");
+ }
+ }
+
+ return 0;
+}