#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
-static void nfs_mount_10_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_mount_10_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
struct nfs_context *nfs = data->nfs;
FSINFO3res *res = command_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
/* Dont want any more callbacks even if the socket is closed */
rpc->connect_cb = NULL;
struct nfs_context *nfs = data->nfs;
mountres3 *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
/* Dont want any more callbacks even if the socket is closed */
rpc->connect_cb = NULL;
struct nfs_context *nfs = data->nfs;
uint32_t mount_port;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
/* Dont want any more callbacks even if the socket is closed */
rpc->connect_cb = NULL;
* Functions to first look up a path, component by component, and then finally call a specific function once
* the filehandle for the final component is found.
*/
-static void nfs_lookup_path_1_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_lookup_path_1_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
LOOKUP3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async stat()
*/
-static void nfs_stat_1_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_stat_1_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
GETATTR3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
struct stat st;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async open()
*/
-static void nfs_open_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_open_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
ACCESS3res *res;
struct nfs_cb_data *data = private_data;
struct nfsfh *nfsfh;
unsigned int nfsmode = 0;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async pread()
*/
-static void nfs_pread_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_pread_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
READ3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
free_nfs_cb_data(data);
}
-static void nfs_pread_mcb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_pread_mcb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_mcb_data *mdata = private_data;
struct nfs_cb_data *data = mdata->data;
struct nfs_context *nfs = data->nfs;
READ3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
data->num_calls--;
if (status == RPC_STATUS_ERROR) {
/*
* Async pwrite()
*/
-static void nfs_pwrite_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_pwrite_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
WRITE3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
free_nfs_cb_data(data);
}
-static void nfs_pwrite_mcb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_pwrite_mcb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_mcb_data *mdata = private_data;
struct nfs_cb_data *data = mdata->data;
struct nfs_context *nfs = data->nfs;
WRITE3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
data->num_calls--;
if (status == RPC_STATUS_ERROR) {
/*
* Async fsync()
*/
-static void nfs_fsync_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_fsync_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
COMMIT3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async ftruncate()
*/
-static void nfs_ftruncate_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_ftruncate_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
SETATTR3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async mkdir()
*/
-static void nfs_mkdir_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_mkdir_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
MKDIR3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
char *str = data->continue_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
str = &str[strlen(str) + 1];
if (status == RPC_STATUS_ERROR) {
/*
* Async rmdir()
*/
-static void nfs_rmdir_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_rmdir_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
RMDIR3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
char *str = data->continue_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
str = &str[strlen(str) + 1];
if (status == RPC_STATUS_ERROR) {
/*
* Async creat()
*/
-static void nfs_create_2_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_create_2_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
LOOKUP3res *res;
struct nfs_cb_data *data = private_data;
struct nfsfh *nfsfh;
char *str = data->continue_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
-static void nfs_creat_1_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_creat_1_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
CREATE3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
char *str = data->continue_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async unlink()
*/
-static void nfs_unlink_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_unlink_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
REMOVE3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
char *str = data->continue_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
str = &str[strlen(str) + 1];
if (status == RPC_STATUS_ERROR) {
free(data);
}
-static void nfs_mknod_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_mknod_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
MKNOD3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
char *str = data->continue_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
str = &str[strlen(str) + 1];
if (status == RPC_STATUS_ERROR) {
};
/* Workaround for servers lacking READDIRPLUS, use READDIR instead and a GETATTR-loop */
-static void nfs_opendir3_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_opendir3_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
LOOKUP3res *res = command_data;
struct rdpe_lookup_cb_data *rdpe_lookup_cb_data = private_data;
struct nfs_context *nfs = data->nfs;
struct nfsdirent *nfsdirent = rdpe_lookup_cb_data->nfsdirent;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
free(rdpe_lookup_cb_data);
rdpe_cb_data->getattrcount--;
}
}
-static void nfs_opendir2_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_opendir2_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
READDIR3res *res = command_data;
struct nfs_cb_data *data = private_data;
uint64_t cookie;
struct rdpe_cb_data *rdpe_cb_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
nfs_free_nfsdir(nfsdir);
}
-static void nfs_opendir_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_opendir_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
READDIRPLUS3res *res = command_data;
struct nfs_cb_data *data = private_data;
struct entryplus3 *entry;
uint64_t cookie;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
if (status == RPC_STATUS_ERROR || (status == RPC_STATUS_SUCCESS && res->status == NFS3ERR_NOTSUPP) ){
cookieverf3 cv;
void *private_data;
};
-static void nfs_lseek_1_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_lseek_1_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
GETATTR3res *res;
struct lseek_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free(data);
/*
* Async statvfs()
*/
-static void nfs_statvfs_1_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_statvfs_1_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
FSSTAT3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
struct statvfs svfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async readlink()
*/
-static void nfs_readlink_1_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_readlink_1_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
READLINK3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async chmod()
*/
-static void nfs_chmod_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_chmod_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
SETATTR3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async chown()
*/
-static void nfs_chown_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_chown_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
SETATTR3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async utimes()
*/
-static void nfs_utimes_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_utimes_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
SETATTR3res *res;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
/*
* Async access()
*/
-static void nfs_access_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_access_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
ACCESS3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
unsigned int nfsmode = 0;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
free(data);
}
-static void nfs_symlink_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_symlink_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
SYMLINK3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
struct nfs_symlink_data *symlink_data = data->continue_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
free(data);
}
-static void nfs_rename_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_rename_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
RENAME3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
struct nfs_rename_data *rename_data = data->continue_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
free(data);
}
-static void nfs_link_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data)
+static void nfs_link_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
{
LINK3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
struct nfs_link_data *link_data = data->continue_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
{
struct mount_cb_data *data = private_data;
- if (status == RPC_STATUS_ERROR) {
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
+ if (status == RPC_STATUS_ERROR) {
data->cb(rpc, -EFAULT, command_data, data->private_data);
free_mount_cb_data(data);
return;
{
struct mount_cb_data *data = private_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
/* Dont want any more callbacks even if the socket is closed */
rpc->connect_cb = NULL;
struct mount_cb_data *data = private_data;
uint32_t mount_port;
- if (status == RPC_STATUS_ERROR) {
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
+ if (status == RPC_STATUS_ERROR) {
data->cb(rpc, -EFAULT, command_data, data->private_data);
free_mount_cb_data(data);
return;
{
struct mount_cb_data *data = private_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
if (status == RPC_STATUS_ERROR) {
data->cb(rpc, -EFAULT, command_data, data->private_data);
free_mount_cb_data(data);
{
struct mount_cb_data *data = private_data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
/* Dont want any more callbacks even if the socket is closed */
rpc->connect_cb = NULL;
{
struct mount_cb_data *data;
+ assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
data = malloc(sizeof(struct mount_cb_data));
if (data == NULL) {
return -1;
struct rpc_context *nfs_get_rpc_context(struct nfs_context *nfs)
{
+ assert(nfs->rpc->magic == RPC_CONTEXT_MAGIC);
return nfs->rpc;
}