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
151
daemon/upcall.c
151
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;
|
||||
}
|
||||
|
||||
status = op->marshall(buffer, &length, upcall);
|
||||
if (status) {
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue