[SCM] Samba Shared Repository - branch v3-3-test updated -
release-3-2-0pre2-4943-g0697cff
Derrell Lipman
derrell at samba.org
Thu Feb 12 14:18:24 GMT 2009
The branch, v3-3-test has been updated
via 0697cffe211a922c816b6c75230c4186328498ed (commit)
from a8a7040d7dbffe7b1c2bccb8b46e08fb996786ac (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test
- Log -----------------------------------------------------------------
commit 0697cffe211a922c816b6c75230c4186328498ed
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date: Thu Feb 12 09:16:48 2009 -0500
[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
-----------------------------------------------------------------------
Summary of changes:
examples/libsmbclient/Makefile | 5 ++
examples/libsmbclient/testfstatvfs.c | 6 +-
.../libsmbclient/{testfstatvfs.c => teststatvfs.c} | 34 ++-----------
source/include/libsmb_internal.h | 7 +++
source/include/libsmbclient.h | 31 +++++++++++-
source/libsmb/libsmb_compat.c | 7 +++
source/libsmb/libsmb_context.c | 1 +
source/libsmb/libsmb_setget.c | 12 ++++
source/libsmb/libsmb_stat.c | 56 +++++++++++++++++++-
9 files changed, 123 insertions(+), 36 deletions(-)
copy examples/libsmbclient/{testfstatvfs.c => teststatvfs.c} (74%)
Changeset truncated at 500 lines:
diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile
index 7ad28dc..728dbe0 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 f8a6870..b4dafef 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/testfstatvfs.c b/examples/libsmbclient/teststatvfs.c
similarity index 74%
copy from examples/libsmbclient/testfstatvfs.c
copy to examples/libsmbclient/teststatvfs.c
index f8a6870..8812002 100644
--- a/examples/libsmbclient/testfstatvfs.c
+++ b/examples/libsmbclient/teststatvfs.c
@@ -38,33 +38,7 @@ int main(int argc, char * argv[])
*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);
+ ret = smbc_statvfs(path, &statvfsbuf);
if (ret < 0)
{
@@ -105,13 +79,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/source/include/libsmb_internal.h b/source/include/libsmb_internal.h
index edf3a6e..166685c 100644
--- a/source/include/libsmb_internal.h
+++ b/source/include/libsmb_internal.h
@@ -197,6 +197,7 @@ struct SMBC_internal_data {
smbc_stat_fn stat_fn;
smbc_fstat_fn fstat_fn;
#endif
+ smbc_statvfs_fn statvfs_fn;
smbc_fstatvfs_fn fstatvfs_fn;
smbc_ftruncate_fn ftruncate_fn;
#if 0 /* Left in libsmbclient.h for backward compatibility */
@@ -503,6 +504,12 @@ SMBC_fstat_ctx(SMBCCTX *context,
int
+SMBC_statvfs_ctx(SMBCCTX *context,
+ char *path,
+ struct statvfs *st);
+
+
+int
SMBC_fstatvfs_ctx(SMBCCTX *context,
SMBCFILE *file,
struct statvfs *st);
diff --git a/source/include/libsmbclient.h b/source/include/libsmbclient.h
index ec7e742..67010a5 100644
--- a/source/include/libsmbclient.h
+++ b/source/include/libsmbclient.h
@@ -185,7 +185,7 @@ typedef enum smbc_vfs_feature
SMBC_VFS_FEATURE_RDONLY = (1 << 0),
/* Specific to libsmbclient (high-order bits) */
- SMBC_VFS_FEATURE_NO_DFS = (1 << 29),
+ SMBC_VFS_FEATURE_DFS = (1 << 29),
SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 30),
SMBC_VFS_FEATURE_NO_UNIXCIFS = (1 << 31)
} smbc_vfs_feature;
@@ -869,6 +869,12 @@ typedef int (*smbc_fstat_fn)(SMBCCTX *c,
smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
+typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
+ char *path,
+ struct statvfs *st);
+smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
+void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
+
typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
SMBCFILE *file,
struct statvfs *st);
@@ -1614,6 +1620,28 @@ int smbc_fstat(int fd, struct stat *st);
/**@ingroup attribute
+ * Get file system information for a specified path.
+ *
+ * @param url The smb url to get information for
+ *
+ * @param st pointer to a buffer that will be filled with
+ * standard Unix struct statvfs information.
+ *
+ * @return EBADF filedes is bad.
+ * - EACCES Permission denied.
+ * - EBADF fd is not a valid file descriptor
+ * - EINVAL Problems occurred in the underlying routines
+ * or smbc_init not called.
+ * - ENOMEM Out of memory
+ *
+ * @see Unix fstatvfs()
+ *
+ */
+int
+smbc_statvfs(char *url,
+ struct statvfs *st);
+
+/**@ingroup attribute
* Get file system information via an file descriptor.
*
* @param fd Open file handle from smbc_open(), smbc_creat(),
@@ -1636,6 +1664,7 @@ int
smbc_fstatvfs(int fd,
struct statvfs *st);
+
/**@ingroup attribute
* Truncate a file given a file descriptor
*
diff --git a/source/libsmb/libsmb_compat.c b/source/libsmb/libsmb_compat.c
index 5bebc5e..56d113f 100644
--- a/source/libsmb/libsmb_compat.c
+++ b/source/libsmb/libsmb_compat.c
@@ -330,6 +330,13 @@ smbc_fstat(int fd,
}
int
+smbc_statvfs(char *path,
+ struct statvfs *st)
+{
+ return smbc_getFunctionStatVFS(statcont)(statcont, path, st);
+}
+
+int
smbc_fstatvfs(int fd,
struct statvfs *st)
{
diff --git a/source/libsmb/libsmb_context.c b/source/libsmb/libsmb_context.c
index fa0de24..3f8e0c5 100644
--- a/source/libsmb/libsmb_context.c
+++ b/source/libsmb/libsmb_context.c
@@ -94,6 +94,7 @@ smbc_new_context(void)
smbc_setFunctionLseek(context, SMBC_lseek_ctx);
smbc_setFunctionFtruncate(context, SMBC_ftruncate_ctx);
smbc_setFunctionStat(context, SMBC_stat_ctx);
+ smbc_setFunctionStatVFS(context, SMBC_statvfs_ctx);
smbc_setFunctionFstatVFS(context, SMBC_fstatvfs_ctx);
smbc_setFunctionFstat(context, SMBC_fstat_ctx);
smbc_setFunctionOpendir(context, SMBC_opendir_ctx);
diff --git a/source/libsmb/libsmb_setget.c b/source/libsmb/libsmb_setget.c
index 9fb608b..3493e4f 100644
--- a/source/libsmb/libsmb_setget.c
+++ b/source/libsmb/libsmb_setget.c
@@ -659,6 +659,18 @@ smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn)
c->fstat = fn;
}
+smbc_statvfs_fn
+smbc_getFunctionStatVFS(SMBCCTX *c)
+{
+ return c->internal->posix_emu.statvfs_fn;
+}
+
+void
+smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn)
+{
+ c->internal->posix_emu.statvfs_fn = fn;
+}
+
smbc_fstatvfs_fn
smbc_getFunctionFstatVFS(SMBCCTX *c)
{
diff --git a/source/libsmb/libsmb_stat.c b/source/libsmb/libsmb_stat.c
index 02088c3..bfcacdc 100644
--- a/source/libsmb/libsmb_stat.c
+++ b/source/libsmb/libsmb_stat.c
@@ -301,6 +301,58 @@ SMBC_fstat_ctx(SMBCCTX *context,
}
+
+/*
+ * Routine to obtain file system information given a path
+ */
+int
+SMBC_statvfs_ctx(SMBCCTX *context,
+ char *path,
+ struct statvfs *st)
+{
+ int ret;
+ bool bIsDir;
+ struct stat statbuf;
+ SMBCFILE * pFile;
+
+ /* Determine if the provided path is a file or a folder */
+ if (SMBC_stat_ctx(context, path, &statbuf) < 0) {
+ return -1;
+ }
+
+ /* Is it a file or a directory? */
+ if (S_ISDIR(statbuf.st_mode)) {
+ /* It's a directory. */
+ if ((pFile = SMBC_opendir_ctx(context, path)) < 0) {
+ return -1;
+ }
+ bIsDir = true;
+ } else if (S_ISREG(statbuf.st_mode)) {
+ /* It's a file. */
+ if ((pFile = SMBC_open_ctx(context, path, O_RDONLY, 0)) < 0) {
+ return -1;
+ }
+ bIsDir = false;
+ } else {
+ /* It's neither a file nor a directory. Not supported. */
+ errno = ENOSYS;
+ return -1;
+ }
+
+ /* Now we have an open file handle, so just use SMBC_fstatvfs */
+ ret = SMBC_fstatvfs_ctx(context, pFile, st);
+
+ /* Close the file or directory */
+ if (bIsDir) {
+ SMBC_closedir_ctx(context, pFile);
+ } else {
+ SMBC_close_ctx(context, pFile);
+ }
+
+ return ret;
+}
+
+
/*
* Routine to obtain file system information given an fd
*/
@@ -411,8 +463,8 @@ SMBC_fstatvfs_ctx(SMBCCTX *context,
}
/* See if DFS is supported */
- if (! (cli->capabilities & CAP_DFS) || ! cli->dfsroot) {
- st->f_flag |= SMBC_VFS_FEATURE_NO_DFS;
+ if ((cli->capabilities & CAP_DFS) && cli->dfsroot) {
+ st->f_flag |= SMBC_VFS_FEATURE_DFS;
}
return 0;
--
Samba Shared Repository
More information about the samba-cvs
mailing list