diff --git a/modules/csync_owncloud.c b/modules/csync_owncloud.c index 56e5d2ad26..0b07b47a19 100644 --- a/modules/csync_owncloud.c +++ b/modules/csync_owncloud.c @@ -898,7 +898,9 @@ static char*_lastDir = NULL; * bool atomar_copy_support */ -static csync_vio_capabilities_t _owncloud_capabilities = { true }; +static struct csync_vio_capabilities_s _owncloud_capabilities = { + .atomar_copy_support = true, +}; static csync_vio_capabilities_t *owncloud_get_capabilities(void) { diff --git a/src/vio/csync_vio.c b/src/vio/csync_vio.c index 2ed21e6982..0b4ca533c7 100644 --- a/src/vio/csync_vio.c +++ b/src/vio/csync_vio.c @@ -29,6 +29,7 @@ #include /* dlopen(), dlclose(), dlsym() ... */ #include "csync_private.h" +#include "csync_util.h" #include "vio/csync_vio.h" #include "vio/csync_vio_handle_private.h" #include "vio/csync_vio_local.h" @@ -152,6 +153,9 @@ int csync_vio_init(CSYNC *ctx, const char *module, const char *args) { /* Useful defaults to the module capabilities */ ctx->module.capabilities.atomar_copy_support = false; + ctx->module.capabilities.put_support = false; + ctx->module.capabilities.get_support = false; + /* Load the module capabilities from the module if it implements the it. */ if( VIO_METHOD_HAS_FUNC(m, get_capabilities)) { ctx->module.capabilities = *(m->get_capabilities()); @@ -257,6 +261,67 @@ int csync_vio_close(CSYNC *ctx, csync_vio_handle_t *fhandle) { return rc; } +int csync_vio_getfd(CSYNC *ctx, csync_vio_handle_t *fhandle) { + int fd = -1; + (void) ctx; + + if (fhandle == NULL) { + errno = EBADF; + return -1; + } + + fd = csync_vio_local_getfd( fhandle ); + // Return the correct handle here. + return fd; + +} + +int csync_vio_put(CSYNC *ctx, + csync_vio_handle_t *flocal, + csync_vio_handle_t *fremote, + csync_file_stat_t *st) { + int rc = 0; + csync_vio_file_stat_t *vfs = csync_vio_convert_file_stat(st); + + if (flocal == NULL) { + rc = -1; + } + if (vfs == NULL) { + rc = -1; + } + + if (rc == 0) { + rc = ctx->module.method->put(flocal->method_handle, + fremote->method_handle, + vfs); + } + csync_vio_file_stat_destroy(vfs); + return rc; +} + +int csync_vio_get(CSYNC *ctx, + csync_vio_handle_t *flocal, + csync_vio_handle_t *fremote, + csync_file_stat_t *st) { + int rc = 0; + csync_vio_file_stat_t *vfs = csync_vio_convert_file_stat(st); + + if (flocal == NULL) { + rc = -1; + } + if (vfs == NULL) { + rc = -1; + } + + if (rc == 0) { + rc = ctx->module.method->get(flocal->method_handle, + fremote->method_handle, + vfs); + } + csync_vio_file_stat_destroy(vfs); + return rc; +} + ssize_t csync_vio_read(CSYNC *ctx, csync_vio_handle_t *fhandle, void *buf, size_t count) { ssize_t rs = 0; diff --git a/src/vio/csync_vio.h b/src/vio/csync_vio.h index dfad69e289..2e7cbd4271 100644 --- a/src/vio/csync_vio.h +++ b/src/vio/csync_vio.h @@ -32,7 +32,6 @@ int csync_vio_init(CSYNC *ctx, const char *module, const char *args); void csync_vio_shutdown(CSYNC *ctx); - csync_vio_handle_t *csync_vio_open(CSYNC *ctx, const char *uri, int flags, mode_t mode); csync_vio_handle_t *csync_vio_creat(CSYNC *ctx, const char *uri, mode_t mode); int csync_vio_close(CSYNC *ctx, csync_vio_handle_t *handle); @@ -40,6 +39,11 @@ ssize_t csync_vio_read(CSYNC *ctx, csync_vio_handle_t *fhandle, void *buf, size_ ssize_t csync_vio_write(CSYNC *ctx, csync_vio_handle_t *fhandle, const void *buf, size_t count); off_t csync_vio_lseek(CSYNC *ctx, csync_vio_handle_t *fhandle, off_t offset, int whence); +int csync_vio_put(CSYNC *ctx, csync_vio_handle_t *flocal, csync_vio_handle_t *fremote, csync_file_stat_t *st); +int csync_vio_get(CSYNC *ctx, csync_vio_handle_t *flocal, csync_vio_handle_t *fremote, csync_file_stat_t *st); + +int csync_vio_getfd(CSYNC *ctx, csync_vio_handle_t *hnd); + csync_vio_handle_t *csync_vio_opendir(CSYNC *ctx, const char *name); int csync_vio_closedir(CSYNC *ctx, csync_vio_handle_t *dhandle); csync_vio_file_stat_t *csync_vio_readdir(CSYNC *ctx, csync_vio_handle_t *dhandle); diff --git a/src/vio/csync_vio_method.h b/src/vio/csync_vio_method.h index dc0b7f4582..0fe0ead010 100644 --- a/src/vio/csync_vio_method.h +++ b/src/vio/csync_vio_method.h @@ -37,6 +37,8 @@ typedef struct csync_vio_method_s csync_vio_method_t; struct csync_vio_capabilities_s { bool atomar_copy_support; + bool get_support; + bool put_support; }; typedef struct csync_vio_capabilities_s csync_vio_capabilities_t; @@ -76,6 +78,13 @@ typedef char* (*csync_method_get_error_string_fn)(); typedef int (*csync_method_commit_fn)(); +typedef int (*csync_method_get_fn)(csync_vio_method_handle_t *flocal, + csync_vio_method_handle_t *fremote, + csync_vio_file_stat_t *st); +typedef int (*csync_method_put_fn)(csync_vio_method_handle_t *flocal, + csync_vio_method_handle_t *fremote, + csync_vio_file_stat_t *st); + struct csync_vio_method_s { size_t method_table_size; /* Used for versioning */ csync_method_get_capabilities_fn get_capabilities; @@ -99,6 +108,8 @@ struct csync_vio_method_s { csync_method_set_property_fn set_property; csync_method_get_error_string_fn get_error_string; csync_method_commit_fn commit; + csync_method_put_fn put; + csync_method_get_fn get; }; #endif /* _CSYNC_VIO_H */