Ported to samba 3.2 with a compatibility header for Samba 3.0. Version 20080626… | |
git clone git://git.codemadness.org/susmb | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 1e80c5eb0c78bc1824bcdb92010b6a3d25b0fa32 | |
parent bd037226cf4a14330a38b1370ed42b33618edb5c | |
Author: Geoff Johnstone <[email protected]> | |
Date: Thu, 26 Jun 2008 21:25:38 +0100 | |
Ported to samba 3.2 with a compatibility header for Samba 3.0. | |
Version 20080626; downgraded to beta given the above. | |
Minor whitespace cleanups. | |
Diffstat: | |
A .hgignore | 1 + | |
M Makefile | 6 +++--- | |
M README | 7 +++++-- | |
M conffile.c | 2 +- | |
M options.c | 4 ++-- | |
M password.c | 2 +- | |
A samba30-compat.h | 266 +++++++++++++++++++++++++++++… | |
M usmb.c | 9 +++++---- | |
M usmb.conf | 4 ++-- | |
M usmb_dir.c | 21 ++++++++++++--------- | |
M usmb_file.c | 62 ++++++++++++++++-------------… | |
M version.h | 4 ++-- | |
12 files changed, 333 insertions(+), 55 deletions(-) | |
--- | |
diff --git a/.hgignore b/.hgignore | |
@@ -0,0 +1 @@ | |
+config.rng.h | |
diff --git a/Makefile b/Makefile | |
@@ -100,9 +100,9 @@ conffile.o: conffile.c password.h utils.h xml.h config.rng.h | |
options.o: options.c options.h utils.h version.h | |
password.o: password.c password.h utils.h | |
usmb.o: usmb.c conffile.h options.h usmb.h usmb_dir.h usmb_file.h utils.h \ | |
- version.h | |
-usmb_dir.o: usmb_dir.c usmb_dir.h usmb.h utils.h | |
-usmb_file.o: usmb_file.c usmb_file.h usmb.h utils.h | |
+ version.h samba30-compat.h | |
+usmb_dir.o: samba30-compat.h usmb_dir.c usmb_dir.h usmb.h utils.h | |
+usmb_file.o: samba30-compat.h usmb_file.c usmb_file.h usmb.h utils.h | |
utils.o: utils.c utils.h | |
version.o: version.c version.h | |
xml.o: xml.c xml.h utils.h | |
diff --git a/README b/README | |
@@ -4,12 +4,15 @@ usmb - Unprivileged mounting of SMB/CIFS shares via FUSE | |
Acknowledgements | |
---------------- | |
-Jonathan Schultz (Email firstname at imatix.com) provided a patch | |
+Jonathan Schultz (Email <firstname> at imatix.com) provided a patch | |
to fix the display of file modification times. | |
-Stijn Hoop (Email firstname at sandcat.nl) provided a patch to fix | |
+Stijn Hoop (Email <firstname> at sandcat.nl) provided a patch to fix | |
a compilation problem on 64-bit platforms. | |
+Nigel Smith (Email me at <firstname>.<surname>.name) contributed the | |
+port to Samba 3.2. | |
+ | |
Introduction | |
------------ | |
diff --git a/conffile.c b/conffile.c | |
@@ -100,7 +100,7 @@ static bool conffile_read (const char *filename, | |
xmlFreeDoc (*doc); | |
return false; | |
} | |
- | |
+ | |
return true; | |
} | |
diff --git a/options.c b/options.c | |
@@ -144,13 +144,13 @@ void build_fuse_args (const char *options, const char *mo… | |
if (debug) | |
argv[argc++] = "-d"; | |
- | |
+ | |
// force -f in debug mode | |
#ifndef DEBUGON | |
if (nofork) | |
#endif | |
argv[argc++] = "-f"; | |
- | |
+ | |
argv[argc++] = "-o"; | |
argv[argc++] = "max_read=32768"; | |
diff --git a/password.c b/password.c | |
@@ -70,7 +70,7 @@ bool password_read (char **out) | |
if ((0 < len) && ('\n' == buff[len - 1])) | |
buff[len - 1] = '\0'; | |
} | |
- | |
+ | |
*out = xstrdup (buff); | |
DEBUG (fprintf (stderr, "Password: %s\n", *out)); | |
diff --git a/samba30-compat.h b/samba30-compat.h | |
@@ -0,0 +1,266 @@ | |
+/* usmb - mount SMB shares via FUSE and Samba | |
+ * Copyright (C) 2006-2008 Geoff Johnstone | |
+ * | |
+ * Portions of this file are taken from Samba 3.2's libsmbclient.h: | |
+ * Copyright (C) Andrew Tridgell 1998 | |
+ * Copyright (C) Richard Sharpe 2000 | |
+ * Copyright (C) John Terpsra 2000 | |
+ * Copyright (C) Tom Jansen (Ninja ISD) 2002 | |
+ * Copyright (C) Derrell Lipman 2003-2008 | |
+ * | |
+ * This program is free software; you can redistribute it and/or modify | |
+ * it under the terms of the GNU General Public License as published by the | |
+ * Free Software Foundation; either version 3 of the License, or (at your | |
+ * option) any later version. | |
+ * | |
+ * This program is distributed in the hope that it will be useful, | |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
+ * GNU General Public License for more details. | |
+ * | |
+ * You should have received a copy of the GNU General Public License | |
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
+ */ | |
+ | |
+#ifndef SAMBA_30_COMPAT_H | |
+ #define SAMBA_30_COMPAT_H | |
+ | |
+ #include <libsmbclient.h> | |
+ | |
+ #ifndef DEPRECATED_SMBC_INTERFACE | |
+ | |
+ typedef int (*smbc_chmod_fn) (SMBCCTX *c, const char *fname, mode_t mode); | |
+ | |
+ static inline smbc_chmod_fn smbc_getFunctionChmod (SMBCCTX *c) | |
+ { | |
+ return c->chmod; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_close_fn) (SMBCCTX *c, SMBCFILE *file); | |
+ | |
+ static inline smbc_close_fn smbc_getFunctionClose (SMBCCTX *c) | |
+ { | |
+ return c->close_fn; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_closedir_fn) (SMBCCTX *c, SMBCFILE *dir); | |
+ | |
+ static inline smbc_closedir_fn smbc_getFunctionClosedir (SMBCCTX *c) | |
+ { | |
+ return c->closedir; | |
+ } | |
+ | |
+ | |
+ typedef SMBCFILE * (*smbc_creat_fn) (SMBCCTX *c, | |
+ const char *path, | |
+ mode_t mode); | |
+ | |
+ static inline smbc_creat_fn smbc_getFunctionCreat (SMBCCTX *c) | |
+ { | |
+ return c->creat; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_fstat_fn) (SMBCCTX *c, SMBCFILE *file, struct stat *st); | |
+ | |
+ static inline smbc_fstat_fn smbc_getFunctionFstat (SMBCCTX *c) | |
+ { | |
+ return c->fstat; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_getxattr_fn) (SMBCCTX *context, | |
+ const char *fname, | |
+ const char *name, | |
+ const void *value, | |
+ size_t size); | |
+ | |
+ static inline smbc_getxattr_fn smbc_getFunctionGetxattr (SMBCCTX *c) | |
+ { | |
+ return c->getxattr; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_listxattr_fn) (SMBCCTX *context, | |
+ const char *fname, | |
+ char *list, | |
+ size_t size); | |
+ | |
+ static inline smbc_listxattr_fn smbc_getFunctionListxattr (SMBCCTX *c) | |
+ { | |
+ return c->listxattr; | |
+ } | |
+ | |
+ | |
+ typedef off_t (*smbc_lseek_fn) (SMBCCTX *c, | |
+ SMBCFILE *file, | |
+ off_t offset, | |
+ int whence); | |
+ | |
+ static inline smbc_lseek_fn smbc_getFunctionLseek (SMBCCTX *c) | |
+ { | |
+ return c->lseek; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_mkdir_fn) (SMBCCTX *c, const char *fname, mode_t mode); | |
+ | |
+ static inline smbc_mkdir_fn smbc_getFunctionMkdir (SMBCCTX *c) | |
+ { | |
+ return c->mkdir; | |
+ } | |
+ | |
+ | |
+ typedef SMBCFILE * (*smbc_open_fn) (SMBCCTX *c, | |
+ const char *fname, | |
+ int flags, | |
+ mode_t mode); | |
+ | |
+ static inline smbc_open_fn smbc_getFunctionOpen (SMBCCTX *c) | |
+ { | |
+ return c->open; | |
+ } | |
+ | |
+ | |
+ typedef SMBCFILE * (*smbc_opendir_fn) (SMBCCTX *c, const char *fname); | |
+ | |
+ static inline smbc_opendir_fn smbc_getFunctionOpendir (SMBCCTX *c) | |
+ { | |
+ return c->opendir; | |
+ } | |
+ | |
+ | |
+ typedef ssize_t (*smbc_read_fn) (SMBCCTX *c, | |
+ SMBCFILE *file, | |
+ void *buf, | |
+ size_t count); | |
+ | |
+ static inline smbc_read_fn smbc_getFunctionRead (SMBCCTX *c) | |
+ { | |
+ return c->read; | |
+ } | |
+ | |
+ | |
+ typedef struct smbc_dirent * (*smbc_readdir_fn) (SMBCCTX *c, SMBCFILE *dir… | |
+ | |
+ static inline smbc_readdir_fn smbc_getFunctionReaddir (SMBCCTX *c) | |
+ { | |
+ return c->readdir; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_removexattr_fn) (SMBCCTX *context, | |
+ const char *fname, | |
+ const char *name); | |
+ | |
+ static inline smbc_removexattr_fn smbc_getFunctionRemovexattr (SMBCCTX *c) | |
+ { | |
+ return c->removexattr; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_rename_fn) (SMBCCTX *ocontext, | |
+ const char *oname, | |
+ SMBCCTX *ncontext, | |
+ const char *nname); | |
+ | |
+ static inline smbc_rename_fn smbc_getFunctionRename (SMBCCTX *c) | |
+ { | |
+ return c->rename; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_rmdir_fn) (SMBCCTX *c, const char *fname); | |
+ | |
+ static inline smbc_rmdir_fn smbc_getFunctionRmdir (SMBCCTX *c) | |
+ { | |
+ return c->rmdir; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_setxattr_fn) (SMBCCTX *context, | |
+ const char *fname, | |
+ const char *name, | |
+ const void *value, | |
+ size_t size, | |
+ int flags); | |
+ | |
+ static inline smbc_setxattr_fn smbc_getFunctionSetxattr (SMBCCTX *c) | |
+ { | |
+ return c->setxattr; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_stat_fn) (SMBCCTX *c, const char *fname, struct stat *s… | |
+ | |
+ static inline smbc_stat_fn smbc_getFunctionStat (SMBCCTX *c) | |
+ { | |
+ return c->stat; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_unlink_fn) (SMBCCTX *c, const char *fname); | |
+ | |
+ static inline smbc_unlink_fn smbc_getFunctionUnlink (SMBCCTX *c) | |
+ { | |
+ return c->unlink; | |
+ } | |
+ | |
+ | |
+ typedef int (*smbc_utimes_fn) (SMBCCTX *c, | |
+ const char *fname, | |
+ struct timeval *tbuf); | |
+ | |
+ static inline smbc_utimes_fn smbc_getFunctionUtimes (SMBCCTX *c) | |
+ { | |
+ return c->utimes; | |
+ } | |
+ | |
+ | |
+ typedef ssize_t (*smbc_write_fn) (SMBCCTX *c, | |
+ SMBCFILE *file, | |
+ void *buf, | |
+ size_t count); | |
+ | |
+ static inline smbc_write_fn smbc_getFunctionWrite (SMBCCTX *c) | |
+ { | |
+ return c->write; | |
+ } | |
+ | |
+ | |
+ typedef void (*smbc_get_auth_fn) (const char *srv, | |
+ const char *shr, | |
+ char *wg, int wglen, | |
+ char *un, int unlen, | |
+ char *pw, int pwlen); | |
+ | |
+ static inline void smbc_setFunctionAuthData (SMBCCTX *c, | |
+ smbc_get_auth_data_fn fn) | |
+ { | |
+ c->callbacks.auth_fn = fn; | |
+ } | |
+ | |
+ | |
+ static inline void smbc_setTimeout (SMBCCTX *c, int timeout) | |
+ { | |
+ c->timeout = timeout; | |
+ } | |
+ | |
+ | |
+ static inline void smbc_setUser (SMBCCTX *c, char *user) | |
+ { | |
+ c->user = user; | |
+ } | |
+ | |
+ | |
+ static inline void smbc_setWorkgroup (SMBCCTX *c, char *workgroup) | |
+ { | |
+ c->workgroup = workgroup; | |
+ } | |
+ | |
+ #endif | |
+ | |
+#endif | |
+ | |
diff --git a/usmb.c b/usmb.c | |
@@ -17,6 +17,7 @@ | |
#include <sys/time.h> // struct timeval needed by libsmbclient.h | |
#include <unistd.h> | |
#include <libsmbclient.h> | |
+#include "samba30-compat.h" | |
#include <fuse.h> | |
#include <assert.h> | |
#include <stdarg.h> | |
@@ -83,10 +84,10 @@ static bool create_smb_context (char *domain, char *usernam… | |
return false; | |
} | |
- (*pctx)->workgroup = domain; | |
- (*pctx)->user = username; | |
- (*pctx)->timeout = 5000; | |
- (*pctx)->callbacks.auth_fn = auth_fn; | |
+ smbc_setWorkgroup (*pctx, domain); | |
+ smbc_setUser (*pctx, username); | |
+ smbc_setTimeout (*pctx, 5000); | |
+ smbc_setFunctionAuthData (*pctx, auth_fn); | |
if (NULL == smbc_init_context (*pctx)) | |
{ | |
diff --git a/usmb.conf b/usmb.conf | |
@@ -1,6 +1,6 @@ | |
<?xml version="1.0" encoding="ISO-8859-1"?> | |
-<!-- | |
+<!-- | |
Example usmb.conf | |
================= | |
@@ -56,4 +56,4 @@ | |
</mount> | |
</usmbconfig> | |
- | |
+ | |
diff --git a/usmb_dir.c b/usmb_dir.c | |
@@ -16,6 +16,7 @@ | |
#include <sys/time.h> // struct timeval needed by libsmbclient.h | |
#include <libsmbclient.h> | |
+#include "samba30-compat.h" | |
#include <fuse.h> | |
#include <dirent.h> | |
#include <errno.h> | |
@@ -36,7 +37,7 @@ int usmb_mkdir (const char *dirname, mode_t mode) | |
return -ENOMEM; | |
DEBUG (fprintf (stderr, "mkdir (%s)\n", url)); | |
- int ret = ctx->mkdir (ctx, url, mode) ? -errno : 0; | |
+ int ret = smbc_getFunctionMkdir (ctx) (ctx, url, mode) ? -errno : 0; | |
free (url); | |
return ret; | |
} | |
@@ -49,7 +50,7 @@ int usmb_rmdir (const char *dirname) | |
return -ENOMEM; | |
DEBUG (fprintf (stderr, "rmdir (%s)\n", url)); | |
- int ret = ctx->rmdir (ctx, url) ? -errno : 0; | |
+ int ret = smbc_getFunctionRmdir (ctx) (ctx, url) ? -errno : 0; | |
free (url); | |
return ret; | |
} | |
@@ -62,7 +63,7 @@ int usmb_opendir (const char *dirname, struct fuse_file_info … | |
return -ENOMEM; | |
DEBUG (fprintf (stderr, "opendir (%s)", url)); | |
- SMBCFILE *file = ctx->opendir (ctx, url); | |
+ SMBCFILE *file = smbc_getFunctionOpendir (ctx) (ctx, url); | |
DEBUG (fprintf (stderr, " = %p\n", (void *)file)); | |
int ret = (NULL == file) ? -errno : 0; | |
@@ -82,7 +83,7 @@ int usmb_readdir (const char *path UNUSED, void *h, fuse_fill… | |
DEBUG (fprintf (stderr, "readdir (%s, %p)\n", path, (void *)file)); | |
- while (NULL != (dirent = ctx->readdir (ctx, file))) | |
+ while (NULL != (dirent = smbc_getFunctionReaddir (ctx) (ctx, file))) | |
{ | |
struct stat stbuf; | |
@@ -116,7 +117,7 @@ int usmb_releasedir (const char *path UNUSED, struct fuse_f… | |
{ | |
SMBCFILE *file = fd_to_smbcfile (fi->fh); | |
DEBUG (fprintf (stderr, "releasedir (%s, %p)\n", path, (void *)file)); | |
- return (0 > ctx->closedir (ctx, file)) ? -errno : 0; | |
+ return (0 > smbc_getFunctionClosedir (ctx) (ctx, file)) ? -errno : 0; | |
} | |
@@ -129,7 +130,8 @@ int usmb_setxattr (const char *path, const char *name, cons… | |
DEBUG (fprintf (stderr, "setxattr (%s, %s, %p, %u, %x)\n", | |
path, url, value, size, flags)); | |
- int ret = ctx->setxattr (ctx, url, name, value, size, flags) ? -errno : 0; | |
+ int ret = smbc_getFunctionSetxattr (ctx) (ctx, url, name, | |
+ value, size, flags) ? -errno : 0; | |
free (url); | |
return ret; | |
} | |
@@ -143,7 +145,8 @@ int usmb_getxattr (const char *path, const char *name, char… | |
DEBUG (fprintf (stderr, "getxattr (%s, %s, %p, %u)\n", | |
path, url, value, size)); | |
- int ret = ctx->getxattr (ctx, url, name, value, size) ? -errno : 0; | |
+ int ret = smbc_getFunctionGetxattr (ctx) (ctx, url, name, | |
+ value, size) ? -errno : 0; | |
free (url); | |
return ret; | |
} | |
@@ -156,7 +159,7 @@ int usmb_listxattr (const char *path, char *list, size_t si… | |
return -ENOMEM; | |
DEBUG (fprintf (stderr, "listxattr (%s, %p, %u)\n", url, list, size)); | |
- int ret = ctx->listxattr (ctx, url, list, size) ? -errno : 0; | |
+ int ret = smbc_getFunctionListxattr (ctx) (ctx, url, list, size) ? -errno : … | |
free (url); | |
return ret; | |
} | |
@@ -169,7 +172,7 @@ int usmb_removexattr (const char *path, const char *name) | |
return -ENOMEM; | |
DEBUG (fprintf (stderr, "removexattr (%s, %s)\n", url, name)); | |
- int ret = ctx->removexattr (ctx, url, name) ? -errno : 0; | |
+ int ret = smbc_getFunctionRemovexattr (ctx) (ctx, url, name) ? -errno : 0; | |
free (url); | |
return ret; | |
} | |
diff --git a/usmb_file.c b/usmb_file.c | |
@@ -16,6 +16,7 @@ | |
#include <sys/time.h> // struct timeval needed by libsmbclient.h | |
#include <libsmbclient.h> | |
+#include "samba30-compat.h" | |
#include <limits.h> | |
#include <assert.h> | |
#include <fuse.h> | |
@@ -39,7 +40,7 @@ static bool fix_nlink (const char *url, struct stat *st) | |
if (!S_ISDIR (st->st_mode)) | |
return true; | |
- SMBCFILE *file = ctx->opendir (ctx, url); | |
+ SMBCFILE *file = smbc_getFunctionOpendir (ctx) (ctx, url); | |
if (NULL == file) | |
return false; | |
@@ -48,15 +49,15 @@ static bool fix_nlink (const char *url, struct stat *st) | |
struct smbc_dirent *dirent; | |
- while (NULL != (dirent = ctx->readdir (ctx, file))) | |
+ while (NULL != (dirent = smbc_getFunctionReaddir (ctx) (ctx, file))) | |
if (SMBC_DIR == dirent->smbc_type) | |
if (INT_MAX == st->st_nlink++) | |
break; | |
- (void)ctx->closedir (ctx, file); | |
+ (void)smbc_getFunctionClosedir (ctx) (ctx, file); | |
return (NULL == dirent); | |
} | |
- | |
+ | |
int usmb_getattr (const char *filename, struct stat *st) | |
{ | |
@@ -66,7 +67,7 @@ int usmb_getattr (const char *filename, struct stat *st) | |
DEBUG (fprintf (stderr, "stat (%s)\n", url)); | |
- int ret = ctx->stat (ctx, url, st); | |
+ int ret = smbc_getFunctionStat (ctx) (ctx, url, st); | |
if ((0 > ret) || !fix_nlink (url, st)) | |
ret = -errno; | |
@@ -82,7 +83,7 @@ int usmb_fgetattr (const char *filename UNUSED, struct stat *… | |
SMBCFILE *file = fd_to_smbcfile (fi->fh); | |
DEBUG (fprintf (stderr, "fgetattr (%s, %p)\n", filename, (void *)file)); | |
- if (0 > ctx->fstat (ctx, file, st)) | |
+ if (0 > smbc_getFunctionFstat (ctx) (ctx, file, st)) | |
return -errno; | |
if (S_ISDIR (st->st_mode)) | |
@@ -109,7 +110,7 @@ int usmb_unlink (const char *filename) | |
return -ENOMEM; | |
DEBUG (fprintf (stderr, "unlink (%s)\n", url)); | |
- int ret = (0 > ctx->unlink (ctx, url)) ? -errno : 0; | |
+ int ret = (0 > smbc_getFunctionUnlink (ctx) (ctx, url)) ? -errno : 0; | |
free (url); | |
return ret; | |
} | |
@@ -122,7 +123,7 @@ int usmb_open (const char *filename, struct fuse_file_info … | |
return -ENOMEM; | |
DEBUG (fprintf (stderr, "open (%s, %d)", url, fi->flags)); | |
- SMBCFILE *file = ctx->open (ctx, url, fi->flags, 0); | |
+ SMBCFILE *file = smbc_getFunctionOpen (ctx) (ctx, url, fi->flags, 0); | |
DEBUG (fprintf (stderr, " = %p\n", (void *)file)); | |
int ret = (NULL == file) ? -errno : 0; | |
@@ -137,26 +138,26 @@ int usmb_release (const char *filename UNUSED, struct fus… | |
{ | |
SMBCFILE *file = fd_to_smbcfile (fi->fh); | |
DEBUG (fprintf (stderr, "release (%s, %p)\n", filename, (void *)file)); | |
- return (0 > ctx->close_fn (ctx, file)) ? -errno : 0; | |
+ return (0 > smbc_getFunctionClose (ctx) (ctx, file)) ? -errno : 0; | |
} | |
int usmb_read (const char *filename UNUSED, char *buff, size_t len, off_t off, | |
struct fuse_file_info *fi) | |
{ | |
- assert (len <= 32768); | |
+ assert (32768 >= len); | |
SMBCFILE *file = fd_to_smbcfile (fi->fh); | |
DEBUG (fprintf (stderr, "read (%p, %p, %u, %lld) ", | |
(void *)file, buff, len, off)); | |
- if (0 > ctx->lseek (ctx, file, off, SEEK_SET)) | |
+ if (0 > smbc_getFunctionLseek (ctx) (ctx, file, off, SEEK_SET)) | |
{ | |
fprintf (stderr, "- seek failed: %d\n", -errno); | |
return -errno; | |
} | |
- int bytes = ctx->read (ctx, file, buff, len); | |
+ int bytes = smbc_getFunctionRead (ctx) (ctx, file, buff, len); | |
DEBUG (fprintf (stderr, "= %d\n", bytes)); | |
return (0 > bytes) ? -errno : (int)bytes; | |
} | |
@@ -169,20 +170,20 @@ int usmb_write (const char *filename UNUSED, const char *… | |
DEBUG (fprintf (stderr, "write (%p, %p, len=%u, off=%lld) ", | |
(void *)file, buff, len, off)); | |
- if (0 > ctx->lseek (ctx, file, off, SEEK_SET)) | |
- { | |
- fprintf (stderr, "- seek failed: %d\n", -errno); | |
+ if (0 > smbc_getFunctionLseek (ctx) (ctx, file, off, SEEK_SET)) | |
return -errno; | |
- } | |
size_t written = 0; | |
int bytes = 0; | |
// No idea whether Windows servers don't like > 32768 byte writes | |
// (cf. usmb_read), but taking no chances... | |
+ | |
+ const smbc_write_fn write_fn = smbc_getFunctionWrite (ctx); | |
+ | |
while (written < len) | |
{ | |
- bytes = ctx->write (ctx, file, (char *)buff, (len > 32768) ? 32768 : len); | |
+ bytes = write_fn (ctx, file, (char *)buff, (len > 32768) ? 32768 : len); | |
if (0 > bytes) | |
break; | |
@@ -207,11 +208,11 @@ int usmb_create (const char *filename, mode_t mode, struc… | |
DEBUG (fprintf (stderr, "creat (%s)", url)); | |
- SMBCFILE *file = ctx->creat (ctx, url, mode); | |
+ SMBCFILE *file = smbc_getFunctionCreat (ctx) (ctx, url, mode); | |
DEBUG (fprintf (stderr, " = %p\n", (void *)file)); | |
int ret = (NULL == file) ? -errno : 0; | |
fi->fh = smbcfile_to_fd (file); | |
- | |
+ | |
free (url); | |
return ret; | |
} | |
@@ -231,7 +232,8 @@ int usmb_rename (const char *from, const char *to) | |
} | |
DEBUG (fprintf (stderr, "rename (%s, %s)\n", fromurl, tourl)); | |
- int ret = (0 > ctx->rename (ctx, fromurl, ctx, tourl)) ? -errno : 0; | |
+ int ret = | |
+ (0 > smbc_getFunctionRename (ctx) (ctx, fromurl, ctx, tourl)) ? -errno : 0; | |
free (tourl); | |
free (fromurl); | |
return ret; | |
@@ -270,7 +272,7 @@ int usmb_utime (const char *filename, struct utimbuf *utb) | |
}; | |
DEBUG (fprintf (stderr, "utime (%s)\n", url)); | |
- int ret = (0 > ctx->utimes (ctx, url, tv)) ? -errno : 0; | |
+ int ret = (0 > smbc_getFunctionUtimes (ctx) (ctx, url, tv)) ? -errno : 0; | |
free (url); | |
return ret; | |
} | |
@@ -310,15 +312,16 @@ int usmb_truncate (const char *filename, off_t offset) | |
char *url = make_url (filename); | |
if (NULL == url) | |
return -ENOMEM; | |
- | |
- SMBCFILE *file = ctx->open (ctx, url, O_WRONLY | O_TRUNC, 0); | |
+ | |
+ SMBCFILE *file = smbc_getFunctionOpen (ctx) (ctx, url, | |
+ O_WRONLY | O_TRUNC, 0); | |
if (NULL == file) | |
{ | |
free_errno (url); | |
return -errno; | |
} | |
- | |
- ctx->close_fn (ctx, file); | |
+ | |
+ smbc_getFunctionClose (ctx) (ctx, file); | |
free (url); | |
return 0; | |
@@ -339,9 +342,9 @@ int usmb_chmod (const char *filename, mode_t mode) | |
char *url = make_url (filename); | |
if (NULL == url) | |
return -ENOMEM; | |
- | |
+ | |
DEBUG (fprintf (stderr, "chmod (%s, %u)\n", url, mode)); | |
- int ret = (0 > ctx->chmod (ctx, url, mode)) ? -errno : 0; | |
+ int ret = (0 > smbc_getFunctionChmod (ctx) (ctx, url, mode)) ? -errno : 0; | |
free (url); | |
return ret; | |
} | |
@@ -354,9 +357,10 @@ int usmb_chown (const char *filename, uid_t owner, uid_t g… | |
char *url = make_url (filename); | |
if (NULL == url) | |
return -ENOMEM; | |
- | |
+ | |
DEBUG (fprintf (stderr, "chown (%s, %d, %d)\n", url, owner, group)); | |
- int ret = (ctx->chown (ctx, url, owner, group) < 0) ? -errno : 0; | |
+ int ret = | |
+ (0 > smbc_getFunctionChown (ctx) (ctx, url, owner, group)) ? -errno : 0; | |
free (url); | |
return ret; | |
} | |
diff --git a/version.h b/version.h | |
@@ -19,10 +19,10 @@ | |
#include <stdio.h> | |
- #define USMB_VERSION 0x20080625 | |
+ #define USMB_VERSION 0x20080626 | |
// a - alpha, b - beta, p - pre-release, s - stable | |
- #define USMB_VERSION_STATUS 's' | |
+ #define USMB_VERSION_STATUS 'b' | |
void show_about (FILE *fp); | |
void show_version (FILE *fp); |