upcall: added upcall_cleanup() to interface
added call to upcall_cleanup() after both upcall_marshall() and upcall_cancel() individual upcall operations define their nfs41_upcall_op structs locally, instead of putting tons of function prototypes in upcall.c made the upcall_marshall() function optional; most marshall functions are noops Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
parent
7e7f73766d
commit
ae4c67c21e
12 changed files with 189 additions and 166 deletions
|
|
@ -57,7 +57,8 @@ int nfs41_cached_getattr(
|
|||
return status;
|
||||
}
|
||||
|
||||
int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
/* NFS41_FILE_QUERY */
|
||||
static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
getattr_upcall_args *args = &upcall->args.getattr;
|
||||
|
|
@ -78,7 +79,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_getattr(nfs41_upcall *upcall)
|
||||
static int handle_getattr(nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
getattr_upcall_args *args = &upcall->args.getattr;
|
||||
|
|
@ -122,7 +123,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int marshall_getattr(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
static int marshall_getattr(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
getattr_upcall_args *args = &upcall->args.getattr;
|
||||
|
|
@ -158,3 +159,10 @@ int marshall_getattr(unsigned char *buffer, uint32_t *length, nfs41_upcall *upca
|
|||
out:
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
const nfs41_upcall_op nfs41_op_getattr = {
|
||||
parse_getattr,
|
||||
handle_getattr,
|
||||
marshall_getattr
|
||||
};
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ static void update_last_lock_state(
|
|||
|
||||
|
||||
/* NFS41_LOCK */
|
||||
int parse_lock(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
static int parse_lock(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
lock_upcall_args *args = &upcall->args.lock;
|
||||
|
|
@ -120,7 +120,7 @@ static __inline uint32_t get_lock_type(BOOLEAN exclusive, BOOLEAN blocking)
|
|||
: ( exclusive == 0 ? READW_LT : WRITEW_LT );
|
||||
}
|
||||
|
||||
int handle_lock(nfs41_upcall *upcall)
|
||||
static int handle_lock(nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
lock_upcall_args *args = &upcall->args.lock;
|
||||
|
|
@ -144,12 +144,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int marshall_lock(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int cancel_lock(IN nfs41_upcall *upcall)
|
||||
static void cancel_lock(IN nfs41_upcall *upcall)
|
||||
{
|
||||
int status = NO_ERROR;
|
||||
lock_upcall_args *args = &upcall->args.lock;
|
||||
|
|
@ -175,12 +170,11 @@ int cancel_lock(IN nfs41_upcall *upcall)
|
|||
update_last_lock_state(&state->last_lock, &stateid);
|
||||
out:
|
||||
dprintf(1, "<-- cancel_lock() returning %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* NFS41_UNLOCK */
|
||||
int parse_unlock(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
static int parse_unlock(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
unlock_upcall_args *args = &upcall->args.unlock;
|
||||
|
|
@ -201,7 +195,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_unlock(nfs41_upcall *upcall)
|
||||
static int handle_unlock(nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
unlock_upcall_args *args = &upcall->args.unlock;
|
||||
|
|
@ -242,7 +236,14 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int marshall_unlock(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
const nfs41_upcall_op nfs41_op_lock = {
|
||||
parse_lock,
|
||||
handle_lock,
|
||||
NULL,
|
||||
cancel_lock
|
||||
};
|
||||
const nfs41_upcall_op nfs41_op_unlock = {
|
||||
parse_unlock,
|
||||
handle_unlock
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@
|
|||
#include "upcall.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/* NFS41_MOUNT */
|
||||
int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
static int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
mount_upcall_args *args = &upcall->args.mount;
|
||||
|
|
@ -47,7 +48,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_mount(nfs41_upcall *upcall)
|
||||
static int handle_mount(nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
mount_upcall_args *args = &upcall->args.mount;
|
||||
|
|
@ -103,16 +104,22 @@ out_err:
|
|||
goto out;
|
||||
}
|
||||
|
||||
int marshall_mount(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
static int marshall_mount(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
mount_upcall_args *args = &upcall->args.mount;
|
||||
dprintf(2, "NFS41_MOUNT: writing pointer to nfs41_root %p\n", args->root);
|
||||
return safe_write(&buffer, length, &args->root, sizeof(args->root));
|
||||
}
|
||||
|
||||
const nfs41_upcall_op nfs41_op_mount = {
|
||||
parse_mount,
|
||||
handle_mount,
|
||||
marshall_mount
|
||||
};
|
||||
|
||||
|
||||
/* NFS41_UNMOUNT */
|
||||
int parse_unmount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
static int parse_unmount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
unmount_upcall_args *args = &upcall->args.unmount;
|
||||
|
|
@ -125,7 +132,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_unmount(nfs41_upcall *upcall)
|
||||
static int handle_unmount(nfs41_upcall *upcall)
|
||||
{
|
||||
int status = NO_ERROR;
|
||||
unmount_upcall_args *args = &upcall->args.unmount;
|
||||
|
|
@ -133,7 +140,7 @@ int handle_unmount(nfs41_upcall *upcall)
|
|||
return status;
|
||||
}
|
||||
|
||||
int marshall_unmount(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
return NO_ERROR;
|
||||
}
|
||||
const nfs41_upcall_op nfs41_op_unmount = {
|
||||
parse_unmount,
|
||||
handle_unmount
|
||||
};
|
||||
|
|
|
|||
|
|
@ -125,9 +125,9 @@ write_downcall:
|
|||
if (!status) {
|
||||
eprintf("IOCTL_NFS41_WRITE failed with %d xid=%d opcode=%s\n",
|
||||
GetLastError(), upcall.xid, opcode2string(upcall.opcode));
|
||||
status = upcall_cancel(&upcall);
|
||||
continue;
|
||||
upcall_cancel(&upcall);
|
||||
}
|
||||
upcall_cleanup(&upcall);
|
||||
}
|
||||
CloseHandle(pipe);
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ static void free_open_state(
|
|||
|
||||
|
||||
/* NFS41_OPEN */
|
||||
int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
static int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
open_upcall_args *args = &upcall->args.open;
|
||||
|
|
@ -212,7 +212,7 @@ static int check_execute_access(nfs41_open_state *state)
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_open(nfs41_upcall *upcall)
|
||||
static int handle_open(nfs41_upcall *upcall)
|
||||
{
|
||||
int status = 0;
|
||||
open_upcall_args *args = &upcall->args.open;
|
||||
|
|
@ -402,7 +402,7 @@ out_free_state:
|
|||
goto out;
|
||||
}
|
||||
|
||||
int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
open_upcall_args *args = &upcall->args.open;
|
||||
|
|
@ -437,7 +437,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int cancel_open(IN nfs41_upcall *upcall)
|
||||
static void cancel_open(IN nfs41_upcall *upcall)
|
||||
{
|
||||
int status = NFS4_OK;
|
||||
open_upcall_args *args = &upcall->args.open;
|
||||
|
|
@ -465,12 +465,11 @@ int cancel_open(IN nfs41_upcall *upcall)
|
|||
out:
|
||||
status = nfs_to_windows_error(status, ERROR_INTERNAL_ERROR);
|
||||
dprintf(1, "<-- cancel_open() returning %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* NFS41_CLOSE */
|
||||
int parse_close(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
static int parse_close(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
close_upcall_args *args = &upcall->args.close;
|
||||
|
|
@ -496,7 +495,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_close(nfs41_upcall *upcall)
|
||||
static int handle_close(nfs41_upcall *upcall)
|
||||
{
|
||||
int status = NFS4_OK, rm_status = NFS4_OK;
|
||||
close_upcall_args *args = &upcall->args.close;
|
||||
|
|
@ -539,7 +538,14 @@ int handle_close(nfs41_upcall *upcall)
|
|||
return rm_status;
|
||||
}
|
||||
|
||||
int marshall_close(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
const nfs41_upcall_op nfs41_op_open = {
|
||||
parse_open,
|
||||
handle_open,
|
||||
marshall_open,
|
||||
cancel_open
|
||||
};
|
||||
const nfs41_upcall_op nfs41_op_close = {
|
||||
parse_close,
|
||||
handle_close
|
||||
};
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ typedef union _FILE_DIR_INFO_UNION {
|
|||
|
||||
|
||||
/* NFS41_DIR_QUERY */
|
||||
int parse_readdir(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
static int parse_readdir(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
readdir_upcall_args *args = &upcall->args.readdir;
|
||||
|
|
@ -372,7 +372,7 @@ out:
|
|||
#define COOKIE_DOT ((uint64_t)-2)
|
||||
#define COOKIE_DOTDOT ((uint64_t)-1)
|
||||
|
||||
int readdir_add_dots(
|
||||
static int readdir_add_dots(
|
||||
IN readdir_upcall_args *args,
|
||||
IN OUT unsigned char *entry_buf,
|
||||
IN uint32_t entry_buf_len,
|
||||
|
|
@ -453,7 +453,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_readdir(nfs41_upcall *upcall)
|
||||
static int handle_readdir(nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
readdir_upcall_args *args = &upcall->args.readdir;
|
||||
|
|
@ -649,7 +649,7 @@ out_free_cookie:
|
|||
goto out_free_entry;
|
||||
}
|
||||
|
||||
int marshall_readdir(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
static int marshall_readdir(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
readdir_upcall_args *args = &upcall->args.readdir;
|
||||
|
|
@ -661,3 +661,10 @@ out:
|
|||
free(args->buf);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
const nfs41_upcall_op nfs41_op_readdir = {
|
||||
parse_readdir,
|
||||
handle_readdir,
|
||||
marshall_readdir
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,10 +30,11 @@
|
|||
#include "daemon_debug.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
stateid4 special_read_stateid = {0xffffffff,
|
||||
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
|
||||
|
||||
int parse_rw(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
static int parse_rw(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
readwrite_upcall_args *args = &upcall->args.rw;
|
||||
|
|
@ -144,7 +145,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_read(nfs41_upcall *upcall)
|
||||
static int handle_read(nfs41_upcall *upcall)
|
||||
{
|
||||
stateid4 stateid, *pstateid;
|
||||
readwrite_upcall_args *args = &upcall->args.rw;
|
||||
|
|
@ -181,6 +182,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* NFS41_WRITE */
|
||||
static int write_to_mds(
|
||||
IN nfs41_session *session,
|
||||
|
|
@ -267,7 +269,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_write(nfs41_upcall *upcall)
|
||||
static int handle_write(nfs41_upcall *upcall)
|
||||
{
|
||||
stateid4 stateid, *pstateid = NULL;
|
||||
readwrite_upcall_args *args = &upcall->args.rw;
|
||||
|
|
@ -304,8 +306,20 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int marshall_rw(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
static int marshall_rw(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
readwrite_upcall_args *args = &upcall->args.rw;
|
||||
return safe_write(&buffer, length, &args->out_len, sizeof(args->out_len));
|
||||
}
|
||||
|
||||
|
||||
const nfs41_upcall_op nfs41_op_read = {
|
||||
parse_rw,
|
||||
handle_read,
|
||||
marshall_rw
|
||||
};
|
||||
const nfs41_upcall_op nfs41_op_write = {
|
||||
parse_rw,
|
||||
handle_write,
|
||||
marshall_rw
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@
|
|||
#include "daemon_debug.h"
|
||||
|
||||
|
||||
int parse_setattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
/* NFS41_FILE_SET */
|
||||
static int parse_setattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
setattr_upcall_args *args = &upcall->args.setattr;
|
||||
|
|
@ -339,7 +340,7 @@ static int handle_nfs41_set_size(setattr_upcall_args *args)
|
|||
return status = nfs_to_windows_error(status, ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
int handle_nfs41_link(setattr_upcall_args *args)
|
||||
static int handle_nfs41_link(setattr_upcall_args *args)
|
||||
{
|
||||
nfs41_open_state *state = args->state;
|
||||
PFILE_LINK_INFORMATION link = (PFILE_LINK_INFORMATION)args->buf;
|
||||
|
|
@ -432,7 +433,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_setattr(nfs41_upcall *upcall)
|
||||
static int handle_setattr(nfs41_upcall *upcall)
|
||||
{
|
||||
setattr_upcall_args *args = &upcall->args.setattr;
|
||||
nfs41_open_state *state = args->state;
|
||||
|
|
@ -489,12 +490,9 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int marshall_setattr(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int parse_setexattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
/* NFS41_EA_SET */
|
||||
static int parse_setexattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
setexattr_upcall_args *args = &upcall->args.setexattr;
|
||||
|
|
@ -512,7 +510,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_setexattr(nfs41_upcall *upcall)
|
||||
static int handle_setexattr(nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
setexattr_upcall_args *args = &upcall->args.setexattr;
|
||||
|
|
@ -539,7 +537,12 @@ int handle_setexattr(nfs41_upcall *upcall)
|
|||
return nfs_to_windows_error(status, ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
int marshall_setexattr(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
const nfs41_upcall_op nfs41_op_setattr = {
|
||||
parse_setattr,
|
||||
handle_setattr
|
||||
};
|
||||
const nfs41_upcall_op nfs41_op_setexattr = {
|
||||
parse_setexattr,
|
||||
handle_setexattr
|
||||
};
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ out:
|
|||
|
||||
|
||||
/* NFS41_SYMLINK */
|
||||
int parse_symlink(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
static int parse_symlink(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
symlink_upcall_args *args = &upcall->args.symlink;
|
||||
int status;
|
||||
|
|
@ -226,7 +226,7 @@ static int map_symlink_errors(int status)
|
|||
}
|
||||
}
|
||||
|
||||
int handle_symlink(nfs41_upcall *upcall)
|
||||
static int handle_symlink(nfs41_upcall *upcall)
|
||||
{
|
||||
symlink_upcall_args *args = &upcall->args.symlink;
|
||||
nfs41_open_state *state = args->state;
|
||||
|
|
@ -274,7 +274,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int marshall_symlink(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
static int marshall_symlink(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
symlink_upcall_args *args = &upcall->args.symlink;
|
||||
unsigned short len = (args->target_get.len + 1) * sizeof(WCHAR);
|
||||
|
|
@ -295,3 +295,10 @@ int marshall_symlink(unsigned char *buffer, uint32_t *length, nfs41_upcall *upca
|
|||
out:
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
const nfs41_upcall_op nfs41_op_symlink = {
|
||||
parse_symlink,
|
||||
handle_symlink,
|
||||
marshall_symlink
|
||||
};
|
||||
|
|
|
|||
143
daemon/upcall.c
143
daemon/upcall.c
|
|
@ -29,78 +29,38 @@
|
|||
#include "util.h"
|
||||
|
||||
|
||||
int parse_mount(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_mount(nfs41_upcall*);
|
||||
int marshall_mount(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
extern const nfs41_upcall_op nfs41_op_mount;
|
||||
extern const nfs41_upcall_op nfs41_op_unmount;
|
||||
extern const nfs41_upcall_op nfs41_op_open;
|
||||
extern const nfs41_upcall_op nfs41_op_close;
|
||||
extern const nfs41_upcall_op nfs41_op_read;
|
||||
extern const nfs41_upcall_op nfs41_op_write;
|
||||
extern const nfs41_upcall_op nfs41_op_lock;
|
||||
extern const nfs41_upcall_op nfs41_op_unlock;
|
||||
extern const nfs41_upcall_op nfs41_op_readdir;
|
||||
extern const nfs41_upcall_op nfs41_op_getattr;
|
||||
extern const nfs41_upcall_op nfs41_op_setattr;
|
||||
extern const nfs41_upcall_op nfs41_op_setexattr;
|
||||
extern const nfs41_upcall_op nfs41_op_symlink;
|
||||
extern const nfs41_upcall_op nfs41_op_volume;
|
||||
|
||||
int parse_unmount(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_unmount(nfs41_upcall*);
|
||||
int marshall_unmount(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
int parse_open(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_open(nfs41_upcall*);
|
||||
int marshall_open(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
int cancel_open(nfs41_upcall*);
|
||||
|
||||
int parse_close(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_close(nfs41_upcall*);
|
||||
int marshall_close(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
int parse_rw(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_read(nfs41_upcall*);
|
||||
int handle_write(nfs41_upcall*);
|
||||
int marshall_rw(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
int parse_lock(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_lock(nfs41_upcall*);
|
||||
int marshall_lock(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
int cancel_lock(nfs41_upcall*);
|
||||
|
||||
int parse_unlock(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_unlock(nfs41_upcall*);
|
||||
int marshall_unlock(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
int parse_readdir(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_readdir(nfs41_upcall*);
|
||||
int marshall_readdir(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
int parse_getattr(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_getattr(nfs41_upcall*);
|
||||
int marshall_getattr(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
int parse_setattr(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_setattr(nfs41_upcall*);
|
||||
int marshall_setattr(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
int parse_setexattr(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_setexattr(nfs41_upcall*);
|
||||
int marshall_setexattr(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
int parse_symlink(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_symlink(nfs41_upcall*);
|
||||
int marshall_symlink(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
int parse_volume(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
int handle_volume(nfs41_upcall*);
|
||||
int marshall_volume(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
|
||||
static const nfs41_upcall_op g_upcall_op_table[] = {
|
||||
{ parse_mount, handle_mount, marshall_mount, NULL },
|
||||
{ parse_unmount, handle_unmount, marshall_unmount, NULL },
|
||||
{ parse_open, handle_open, marshall_open, cancel_open },
|
||||
{ parse_close, handle_close, marshall_close, NULL },
|
||||
{ parse_rw, handle_read, marshall_rw, NULL },
|
||||
{ parse_rw, handle_write, marshall_rw, NULL },
|
||||
{ parse_lock, handle_lock, marshall_lock, cancel_lock },
|
||||
{ parse_unlock, handle_unlock, marshall_unlock, NULL },
|
||||
{ parse_readdir, handle_readdir, marshall_readdir, NULL },
|
||||
{ parse_getattr, handle_getattr, marshall_getattr, NULL },
|
||||
{ parse_setattr, handle_setattr, marshall_setattr, NULL },
|
||||
{ parse_setexattr, handle_setexattr, marshall_setexattr, NULL },
|
||||
{ parse_symlink, handle_symlink, marshall_symlink, NULL },
|
||||
{ parse_volume, handle_volume, marshall_volume, NULL },
|
||||
{ NULL, NULL, NULL, NULL }, /* NFS41_SHUTDOWN */
|
||||
{ NULL, NULL, NULL, NULL }, /* INVALID_OPCODE */
|
||||
static const nfs41_upcall_op *g_upcall_op_table[] = {
|
||||
&nfs41_op_mount,
|
||||
&nfs41_op_unmount,
|
||||
&nfs41_op_open,
|
||||
&nfs41_op_close,
|
||||
&nfs41_op_read,
|
||||
&nfs41_op_write,
|
||||
&nfs41_op_lock,
|
||||
&nfs41_op_unlock,
|
||||
&nfs41_op_readdir,
|
||||
&nfs41_op_getattr,
|
||||
&nfs41_op_setattr,
|
||||
&nfs41_op_setexattr,
|
||||
&nfs41_op_symlink,
|
||||
&nfs41_op_volume,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
static const uint32_t g_upcall_op_table_size = ARRAYSIZE(g_upcall_op_table);
|
||||
|
||||
|
|
@ -138,8 +98,8 @@ int upcall_parse(
|
|||
}
|
||||
|
||||
/* parse the operation's arguments */
|
||||
op = &g_upcall_op_table[upcall->opcode];
|
||||
if (op->parse) {
|
||||
op = g_upcall_op_table[upcall->opcode];
|
||||
if (op && op->parse) {
|
||||
status = op->parse(buffer, length, upcall);
|
||||
if (status) {
|
||||
eprintf("parsing of upcall '%s' failed with %d.\n",
|
||||
|
|
@ -157,8 +117,8 @@ int upcall_handle(
|
|||
int status = NO_ERROR;
|
||||
const nfs41_upcall_op *op;
|
||||
|
||||
op = &g_upcall_op_table[upcall->opcode];
|
||||
if (op->handle == NULL) {
|
||||
op = g_upcall_op_table[upcall->opcode];
|
||||
if (op == NULL || op->handle == NULL) {
|
||||
status = ERROR_NOT_SUPPORTED;
|
||||
eprintf("upcall '%s' missing handle function!\n",
|
||||
opcode2string(upcall->opcode));
|
||||
|
|
@ -194,34 +154,31 @@ write_downcall:
|
|||
goto out;
|
||||
|
||||
/* marshall the operation's results */
|
||||
op = &g_upcall_op_table[upcall->opcode];
|
||||
if (op->marshall == NULL) {
|
||||
status = ERROR_NOT_SUPPORTED;
|
||||
eprintf("upcall '%s' missing marshall function!\n",
|
||||
opcode2string(upcall->opcode));
|
||||
upcall->status = status;
|
||||
goto write_downcall;
|
||||
}
|
||||
|
||||
op = g_upcall_op_table[upcall->opcode];
|
||||
if (op && op->marshall) {
|
||||
status = op->marshall(buffer, &length, upcall);
|
||||
if (status) {
|
||||
upcall->status = status;
|
||||
goto write_downcall;
|
||||
}
|
||||
}
|
||||
out:
|
||||
*length_out = total - length;
|
||||
return status;
|
||||
}
|
||||
|
||||
int upcall_cancel(
|
||||
void upcall_cancel(
|
||||
IN nfs41_upcall *upcall)
|
||||
{
|
||||
int status = NO_ERROR;
|
||||
const nfs41_upcall_op *op;
|
||||
|
||||
op = &g_upcall_op_table[upcall->opcode];
|
||||
if (op->cancel)
|
||||
status = op->cancel(upcall);
|
||||
|
||||
return status;
|
||||
const nfs41_upcall_op *op = g_upcall_op_table[upcall->opcode];
|
||||
if (op && op->cancel)
|
||||
op->cancel(upcall);
|
||||
}
|
||||
|
||||
void upcall_cleanup(
|
||||
IN nfs41_upcall *upcall)
|
||||
{
|
||||
const nfs41_upcall_op *op = g_upcall_op_table[upcall->opcode];
|
||||
if (op && op->cleanup)
|
||||
op->cleanup(upcall);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,13 +183,15 @@ typedef struct __nfs41_upcall {
|
|||
typedef int (*upcall_parse_proc)(unsigned char*, uint32_t, nfs41_upcall*);
|
||||
typedef int (*upcall_handle_proc)(nfs41_upcall*);
|
||||
typedef int (*upcall_marshall_proc)(unsigned char*, uint32_t*, nfs41_upcall*);
|
||||
typedef int (*upcall_cancel_proc)(nfs41_upcall*);
|
||||
typedef void (*upcall_cancel_proc)(nfs41_upcall*);
|
||||
typedef void (*upcall_cleanup_proc)(nfs41_upcall*);
|
||||
|
||||
typedef struct __nfs41_upcall_op {
|
||||
upcall_parse_proc parse;
|
||||
upcall_handle_proc handle;
|
||||
upcall_marshall_proc marshall;
|
||||
upcall_cancel_proc cancel;
|
||||
upcall_cleanup_proc cleanup;
|
||||
} nfs41_upcall_op;
|
||||
|
||||
|
||||
|
|
@ -208,7 +210,10 @@ int upcall_marshall(
|
|||
IN uint32_t length,
|
||||
OUT uint32_t *length_out);
|
||||
|
||||
int upcall_cancel(
|
||||
void upcall_cancel(
|
||||
IN nfs41_upcall *upcall);
|
||||
|
||||
void upcall_cleanup(
|
||||
IN nfs41_upcall *upcall);
|
||||
|
||||
#endif /* !__NFS41_DAEMON_UPCALL_H__ */
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@
|
|||
#define TO_UNITS(bytes) (bytes / BYTES_PER_UNIT)
|
||||
|
||||
|
||||
int parse_volume(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
/* NFS41_VOLUME_QUERY */
|
||||
static int parse_volume(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
volume_upcall_args *args = &upcall->args.volume;
|
||||
|
|
@ -127,7 +128,7 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
int handle_volume(nfs41_upcall *upcall)
|
||||
static int handle_volume(nfs41_upcall *upcall)
|
||||
{
|
||||
volume_upcall_args *args = &upcall->args.volume;
|
||||
nfs41_session *session = nfs41_root_session(args->root);
|
||||
|
|
@ -168,7 +169,7 @@ int handle_volume(nfs41_upcall *upcall)
|
|||
return status;
|
||||
}
|
||||
|
||||
int marshall_volume(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
static int marshall_volume(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
|
||||
{
|
||||
int status;
|
||||
volume_upcall_args *args = &upcall->args.volume;
|
||||
|
|
@ -179,3 +180,10 @@ int marshall_volume(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcal
|
|||
out:
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
const nfs41_upcall_op nfs41_op_volume = {
|
||||
parse_volume,
|
||||
handle_volume,
|
||||
marshall_volume
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue