susmb

mounting of SMB/CIFS shares via FUSE
git clone git://git.codemadness.org/susmb
Log | Files | Refs | README | LICENSE

commit 4d264f7c2b0312f4c3b80ce77d957b3fac55ac24
parent a31e37f5b54869feccc5e2337d240a942221afe4
Author: Geoff Johnstone <qwerty@acm.org>
Date:   Fri, 10 Apr 2009 20:22:31 +0100

Critical fixes for Samba 3.0 and 3.2.

Diffstat:
MMakefile.in | 6+++---
Mconfigure.ac | 2+-
Msamba30_compat.c | 8+++++++-
Msamba32_compat.c | 51+++++----------------------------------------------
Msamba3x-compat.h | 11+++++++++++
5 files changed, 27 insertions(+), 51 deletions(-)

diff --git a/Makefile.in b/Makefile.in @@ -55,11 +55,11 @@ clean: distclean: clean $(RM) -r core usmb-*.tar.bz2 usmb-*.tar.gz doc/*.mdzip.bak config.rng.h \ - autom4te.cache config.h.in~ config.status config.log - + autom4te.cache config.h.in~ config.status config.log config.h \ + Makefile allclean: distclean - $(RM) Makefile configure config.h config.h.in autom4te.cache + $(RM) configure config.h.in autom4te.cache install-strip: STRIPFLAGS = -s diff --git a/configure.ac b/configure.ac @@ -44,7 +44,7 @@ AC_DEFINE([MUSTCHECK], [MUSTCHECK_], AC_CHECK_LIB([smbclient], [smbc_init], [], [AC_MSG_ERROR(Cannot find libsmbclient.)]) -AC_CHECK_LIB([smbclient], [smbc_getFunctionFtruncate], +AC_CHECK_LIB([smbclient], [smbc_getFunctionStatVFS], [AC_DEFINE([HAVE_SAMBA33], [], [Whether we have Samba 3.3 or later]) SAMBA_VERSION=33]) diff --git a/samba30_compat.c b/samba30_compat.c @@ -15,8 +15,14 @@ */ #include "config.h" +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include "samba3x-compat.h" +#include "usmb.h" #include "usmb_file.h" +#include "utils.h" int usmb_statfs (const char *path UNUSED, struct statvfs *vfs UNUSED) @@ -27,7 +33,7 @@ int usmb_statfs (const char *path UNUSED, struct statvfs *vfs UNUSED) } -int compat_truncate (const char *path UNUSED, SMBCFILE *file, off_t size) +int compat_truncate (const char *path UNUSED, SMBCFILE *file UNUSED, off_t size) { /* Windows doesn't support truncation so we implement a limited version: * 0 == size => create a new file for writing. diff --git a/samba32_compat.c b/samba32_compat.c @@ -26,56 +26,15 @@ int usmb_statfs (const char *path, struct statvfs *vfs) { - if ((NULL == path) || (NULL == vfs)) - return -EINVAL; - - char *url = make_url (path); - if (NULL == url) - return -ENOMEM; - - DEBUG (fprintf (stderr, "statfs (%s, %p)\n", url, (void *)vfs)); - memset (vfs, 0, sizeof (*vfs)); - - int ret = (0 > smbc_getFunctionStatVFS (ctx) (ctx, url, vfs)) ? -errno : 0; - free (url); - return ret; + (void)path; + (void)vfs; + return -ENOSYS; } + int compat_truncate (const char *path UNUSED, SMBCFILE *file, off_t size) { - /* Windows doesn't support truncation so we implement a limited version: - * 0 == size => create a new file for writing. - * current size == size => succeed. - * else return -ENOSYS. - */ - - if (0 == size) - { - char *url = make_url (path); - if (NULL == url) - return -ENOMEM; - - SMBCFILE *file_ = smbc_getFunctionOpen (ctx) (ctx, url, - O_WRONLY | O_TRUNC, 0); - if (NULL == file_) - { - free_errno (url); - return -errno; - } - - smbc_getFunctionClose (ctx) (ctx, file_); - free (url); - - return 0; - } - - struct stat st; - int ret = usmb_getattr (path, &st); - - if (0 != ret) - return ret; - - return (size == st.st_size) ? 0 : -ENOSYS; + return (0 > smbc_getFunctionFtruncate (ctx) (ctx, file, size)) ? -errno : 0; } diff --git a/samba3x-compat.h b/samba3x-compat.h @@ -27,6 +27,7 @@ #include "config.h" #include <libsmbclient.h> + #include <sys/statvfs.h> int usmb_statfs (const char *path UNUSED, struct statvfs *vfs UNUSED); @@ -186,6 +187,16 @@ } + typedef int (*smbc_lseekdir_fn)(SMBCCTX *c, + SMBCFILE *dir, + off_t offset); + + static inline smbc_lseekdir_fn smbc_getFunctionLseekdir (SMBCCTX *c) + { + return c->lseekdir; + } + + typedef int (*smbc_setxattr_fn) (SMBCCTX *context, const char *fname, const char *name,