ZDR: New builtin replacement for RPC/XDR called ZDR
This patch switches libnfs over to use precompiled rpcgen files and using ZDR. ZDR is a trivial reimplementation of XDR that is built in into libnfs. This removes the dependencies of rpc/xdr completely and allow us to build on any system, even systems where rpcgen and librpc/libxdr are not generally available.libnfs-4.0.0-vitalif
parent
061d3f1f99
commit
763cd6e3e2
|
@ -35,6 +35,7 @@
|
|||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-raw-mount.h"
|
||||
|
|
|
@ -30,8 +30,10 @@
|
|||
#include <sys/time.h>
|
||||
#include <net/if.h>
|
||||
#include <netdb.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
#include "libnfs-raw-mount.h"
|
||||
#include "libnfs-raw-portmap.h"
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-raw-mount.h"
|
||||
|
|
|
@ -48,8 +48,8 @@ WSADATA wsaData;
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include <rpc/rpc.h> /* for authunix_create() */
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-raw-mount.h"
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <rpc/xdr.h>
|
||||
#include <rpc/auth.h>
|
||||
#include <sys/socket.h> /* struct sockaddr_storage */
|
||||
|
||||
#include "libnfs-zdr.h"
|
||||
|
||||
struct rpc_fragment {
|
||||
struct rpc_fragment *next;
|
||||
|
@ -64,7 +65,7 @@ struct rpc_pdu {
|
|||
struct rpc_pdu *next;
|
||||
|
||||
unsigned long xid;
|
||||
XDR xdr;
|
||||
ZDR zdr;
|
||||
|
||||
int written;
|
||||
struct rpc_data outdata;
|
||||
|
@ -72,13 +73,13 @@ struct rpc_pdu {
|
|||
rpc_cb cb;
|
||||
void *private_data;
|
||||
|
||||
/* function to decode the xdr reply data and buffer to decode into */
|
||||
xdrproc_t xdr_decode_fn;
|
||||
caddr_t xdr_decode_buf;
|
||||
int xdr_decode_bufsize;
|
||||
/* function to decode the zdr reply data and buffer to decode into */
|
||||
zdrproc_t zdr_decode_fn;
|
||||
caddr_t zdr_decode_buf;
|
||||
int zdr_decode_bufsize;
|
||||
};
|
||||
|
||||
struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int version, int procedure, rpc_cb cb, void *private_data, xdrproc_t xdr_decode_fn, int xdr_bufsize);
|
||||
struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int version, int procedure, rpc_cb cb, void *private_data, zdrproc_t zdr_decode_fn, int zdr_bufsize);
|
||||
void rpc_free_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu);
|
||||
int rpc_queue_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu);
|
||||
int rpc_get_pdu_size(char *buf);
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
* protocol as well as the XDR encoded/decoded structures.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/auth.h>
|
||||
|
||||
struct rpc_data {
|
||||
int size;
|
||||
|
|
|
@ -0,0 +1,281 @@
|
|||
/*
|
||||
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
* This file contains definitions for the built in ZDR implementation.
|
||||
* This is a very limited ZDR subset that can only marshal to/from a momory buffer,
|
||||
* i.e. zdrmem_create() buffers.
|
||||
* It aims to be compatible with normal rpcgen generated functions.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef _LIBNFS_ZDR_H_
|
||||
#define _LIBNFS_ZDR_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define _RPC_RPC_H 1
|
||||
#define _RPC_ZDR_H 1
|
||||
#define _RPC_AUTH_H 1
|
||||
|
||||
/* we dont need these */
|
||||
typedef void CLIENT;
|
||||
struct svc_req {
|
||||
};
|
||||
typedef void SVCXPRT;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define ZDR_INLINE(...) NULL
|
||||
#define IZDR_PUT_U_LONG(...) assert(0)
|
||||
#define IZDR_GET_U_LONG(...) (assert(0), 0)
|
||||
#define IZDR_PUT_LONG(...) assert(0)
|
||||
#define IZDR_GET_LONG(...) (assert(0), 0)
|
||||
#define IZDR_PUT_BOOL(...) assert(0)
|
||||
#define IZDR_GET_BOOL(...) (assert(0), 0)
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
enum zdr_op {
|
||||
ZDR_ENCODE = 0,
|
||||
ZDR_DECODE = 1
|
||||
};
|
||||
|
||||
struct zdr_mem {
|
||||
struct zdr_mem *next;
|
||||
caddr_t buf;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct ZDR {
|
||||
enum zdr_op x_op;
|
||||
caddr_t buf;
|
||||
int size;
|
||||
int pos;
|
||||
struct zdr_mem *mem;
|
||||
};
|
||||
typedef struct ZDR ZDR;
|
||||
|
||||
|
||||
typedef uint32_t u_int;
|
||||
typedef uint32_t enum_t;
|
||||
typedef uint32_t bool_t;
|
||||
|
||||
typedef int (*zdrproc_t) (ZDR *, void *,...);
|
||||
|
||||
/* XXX find out what we can get rid of */
|
||||
|
||||
#define AUTH_NONE 0
|
||||
#define AUTH_NULL 0
|
||||
#define AUTH_UNIX 1
|
||||
struct opaque_auth {
|
||||
uint32_t oa_flavor;
|
||||
caddr_t oa_base;
|
||||
uint32_t oa_length;
|
||||
};
|
||||
extern struct opaque_auth _null_auth;
|
||||
|
||||
|
||||
typedef struct {
|
||||
struct opaque_auth ah_cred;
|
||||
struct opaque_auth ah_verf;
|
||||
caddr_t ah_private;
|
||||
} AUTH;
|
||||
|
||||
enum msg_type {
|
||||
CALL=0,
|
||||
REPLY=1
|
||||
};
|
||||
|
||||
#define RPC_MSG_VERSION 2
|
||||
|
||||
struct call_body {
|
||||
uint32_t cb_rpcvers;
|
||||
uint32_t cb_prog;
|
||||
uint32_t cb_vers;
|
||||
uint32_t cb_proc;
|
||||
struct opaque_auth cb_cred;
|
||||
struct opaque_auth cb_verf;
|
||||
};
|
||||
|
||||
enum accept_stat {
|
||||
SUCCESS=0,
|
||||
PROG_UNAVAIL=1,
|
||||
PROG_MISMATCH=2,
|
||||
PROC_UNAVAIL=3,
|
||||
GARBAGE_ARGS=4,
|
||||
SYSTEM_ERR=5
|
||||
};
|
||||
|
||||
struct accepted_reply {
|
||||
struct opaque_auth ar_verf;
|
||||
uint32_t ar_stat;
|
||||
union {
|
||||
struct {
|
||||
uint32_t low;
|
||||
uint32_t high;
|
||||
} AR_versions;
|
||||
struct {
|
||||
caddr_t where;
|
||||
zdrproc_t proc;
|
||||
} AR_results;
|
||||
/* and many other null cases */
|
||||
} ru;
|
||||
#define ar_results ru.AR_results
|
||||
#define ar_vers ru.AR_versions
|
||||
};
|
||||
|
||||
enum reject_stat {
|
||||
RPC_MISMATCH=0,
|
||||
AUTH_ERROR=1
|
||||
};
|
||||
|
||||
enum auth_stat {
|
||||
AUTH_OK=0,
|
||||
/*
|
||||
* failed at remote end
|
||||
*/
|
||||
AUTH_BADCRED=1, /* bogus credentials (seal broken) */
|
||||
AUTH_REJECTEDCRED=2, /* client should begin new session */
|
||||
AUTH_BADVERF=3, /* bogus verifier (seal broken) */
|
||||
AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
|
||||
AUTH_TOOWEAK=5, /* rejected due to security reasons */
|
||||
/*
|
||||
* failed locally
|
||||
*/
|
||||
AUTH_INVALIDRESP=6, /* bogus response verifier */
|
||||
AUTH_FAILED=7 /* some unknown reason */
|
||||
};
|
||||
|
||||
struct rejected_reply {
|
||||
enum reject_stat rj_stat;
|
||||
union {
|
||||
struct {
|
||||
u_long low;
|
||||
u_long high;
|
||||
} RJ_versions;
|
||||
enum auth_stat RJ_why; /* why authentication did not work */
|
||||
} ru;
|
||||
#define rj_vers ru.RJ_versions
|
||||
#define rj_why ru.RJ_why
|
||||
};
|
||||
|
||||
#define MSG_ACCEPTED 0
|
||||
#define MSG_DENIED 1
|
||||
|
||||
struct reply_body {
|
||||
uint32_t rp_stat;
|
||||
union {
|
||||
struct accepted_reply RP_ar;
|
||||
struct rejected_reply RP_dr;
|
||||
} ru;
|
||||
#define rp_acpt ru.RP_ar
|
||||
#define rp_rjct ru.RP_dr
|
||||
};
|
||||
|
||||
struct rpc_msg {
|
||||
uint32_t rm_xid;
|
||||
|
||||
uint32_t rm_direction;
|
||||
union {
|
||||
struct call_body RM_cmb;
|
||||
struct reply_body RM_rmb;
|
||||
} ru;
|
||||
#define rm_call ru.RM_cmb
|
||||
#define rm_reply ru.RM_rmb
|
||||
};
|
||||
#define acpted_rply ru.RM_rmb.ru.RP_ar
|
||||
#define rjcted_rply ru.RM_rmb.ru.RP_dr
|
||||
|
||||
|
||||
|
||||
#define zdrmem_create libnfs_zdrmem_create
|
||||
void libnfs_zdrmem_create(ZDR *zdrs, const caddr_t addr, uint32_t size, enum zdr_op xop);
|
||||
|
||||
#define zdr_destroy libnfs_zdr_destroy
|
||||
void libnfs_zdr_destroy(ZDR *zdrs);
|
||||
|
||||
#define zdr_bytes libnfs_zdr_bytes
|
||||
bool_t libnfs_zdr_bytes(ZDR *zdrs, char **bufp, uint32_t *size, uint32_t maxsize);
|
||||
|
||||
#define zdr_u_int libnfs_zdr_u_int
|
||||
bool_t libnfs_zdr_u_int(ZDR *zdrs, uint32_t *u);
|
||||
|
||||
#define zdr_int libnfs_zdr_int
|
||||
bool_t libnfs_zdr_int(ZDR *zdrs, int32_t *i);
|
||||
|
||||
#define zdr_u_quad_t libnfs_zdr_u_quad_t
|
||||
bool_t libnfs_zdr_u_quad_t(ZDR *zdrs, uint64_t *u);
|
||||
|
||||
#define zdr_quad_t libnfs_zdr_quad_t
|
||||
bool_t libnfs_zdr_quad_t(ZDR *zdrs, int64_t *i);
|
||||
|
||||
#define zdr_enum libnfs_zdr_enum
|
||||
bool_t libnfs_zdr_enum(ZDR *zdrs, int32_t *e);
|
||||
|
||||
#define zdr_bool libnfs_zdr_bool
|
||||
bool_t libnfs_zdr_bool(ZDR *zdrs, bool_t *b);
|
||||
|
||||
#define zdr_void libnfs_zdr_void
|
||||
bool_t libnfs_zdr_void(void);
|
||||
|
||||
#define zdr_pointer libnfs_zdr_pointer
|
||||
bool_t libnfs_zdr_pointer(ZDR *zdrs, char **objp, uint32_t size, zdrproc_t proc);
|
||||
|
||||
#define zdr_opaque libnfs_zdr_opaque
|
||||
bool_t libnfs_zdr_opaque(ZDR *zdrs, char *objp, uint32_t size);
|
||||
|
||||
#define zdr_string libnfs_zdr_string
|
||||
bool_t libnfs_zdr_string(ZDR *zdrs, char **strp, uint32_t maxsize);
|
||||
|
||||
#define zdr_array libnfs_zdr_array
|
||||
bool_t libnfs_zdr_array(ZDR *zdrs, char **arrp, uint32_t *size, uint32_t maxsize, uint32_t elsize, zdrproc_t proc);
|
||||
|
||||
#define zdr_setpos libnfs_zdr_setpos
|
||||
bool_t libnfs_zdr_setpos(ZDR *zdrs, uint32_t pos);
|
||||
|
||||
#define zdr_getpos libnfs_zdr_getpos
|
||||
uint32_t libnfs_zdr_getpos(ZDR *zdrs);
|
||||
|
||||
#define zdr_free libnfs_zdr_free
|
||||
void libnfs_zdr_free(zdrproc_t proc, char *objp);
|
||||
|
||||
#define zdr_callmsg libnfs_zdr_callmsg
|
||||
bool_t libnfs_zdr_callmsg(ZDR *zdrs, struct rpc_msg *msg);
|
||||
|
||||
#define zdr_replymsg libnfs_zdr_replymsg
|
||||
bool_t libnfs_zdr_replymsg(ZDR *zdrs, struct rpc_msg *msg);
|
||||
|
||||
#define authnone_create libnfs_authnone_create
|
||||
AUTH *libnfs_authnone_create(void);
|
||||
|
||||
#define authunix_create libnfs_authunix_create
|
||||
AUTH *libnfs_authunix_create(char *host, uint32_t uid, uint32_t gid, uint32_t len, uint32_t *groups);
|
||||
|
||||
#define authunix_create_default libnfs_authunix_create_default
|
||||
AUTH *libnfs_authunix_create_default(void);
|
||||
|
||||
#define auth_destroy libnfs_auth_destroy
|
||||
void libnfs_auth_destroy(AUTH *auth);
|
||||
|
||||
#endif
|
|
@ -18,8 +18,6 @@
|
|||
* This is the highlevel interface to access NFS resources using a posix-like interface
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/auth.h>
|
||||
|
||||
struct nfs_context;
|
||||
struct rpc_context;
|
||||
|
|
|
@ -12,6 +12,7 @@ libnfs_la_SOURCES = \
|
|||
init.c \
|
||||
libnfs.c \
|
||||
libnfs-sync.c \
|
||||
libnfs-zdr.c \
|
||||
pdu.c \
|
||||
socket.c
|
||||
|
||||
|
|
|
@ -24,9 +24,8 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include "slist.h"
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-raw-mount.h"
|
||||
|
|
|
@ -0,0 +1,482 @@
|
|||
/*
|
||||
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
* This file contains definitions for the built in ZDR implementation.
|
||||
* This is a very limited ZDR subset that can only marshal to/from a momory buffer,
|
||||
* i.e. zdrmem_create() buffers.
|
||||
* It aims to be compatible with normal rpcgen generated functions.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "libnfs-zdr.h"
|
||||
|
||||
struct opaque_auth _null_auth;
|
||||
|
||||
bool_t libnfs_zdr_setpos(ZDR *zdrs, uint32_t pos)
|
||||
{
|
||||
zdrs->pos = pos;
|
||||
}
|
||||
|
||||
uint32_t libnfs_zdr_getpos(ZDR *zdrs)
|
||||
{
|
||||
return zdrs->pos;
|
||||
}
|
||||
|
||||
void libnfs_zdrmem_create(ZDR *zdrs, const caddr_t addr, uint32_t size, enum zdr_op xop)
|
||||
{
|
||||
zdrs->x_op = xop;
|
||||
zdrs->buf = addr;
|
||||
zdrs->size = size;
|
||||
zdrs->pos = 0;
|
||||
zdrs->mem = NULL;
|
||||
}
|
||||
|
||||
static void *zdr_malloc(ZDR *zdrs, uint32_t size)
|
||||
{
|
||||
struct zdr_mem *mem;
|
||||
|
||||
mem = malloc(sizeof(struct zdr_mem));
|
||||
mem->next = zdrs->mem;
|
||||
mem->size = size;
|
||||
mem->buf = malloc(mem->size);
|
||||
zdrs->mem = mem;
|
||||
|
||||
return mem->buf;
|
||||
}
|
||||
|
||||
void libnfs_zdr_destroy(ZDR *zdrs)
|
||||
{
|
||||
while (zdrs->mem != NULL) {
|
||||
struct zdr_mem *mem = zdrs->mem->next;
|
||||
free(zdrs->mem->buf);
|
||||
free(zdrs->mem);
|
||||
zdrs->mem = mem;
|
||||
}
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_u_int(ZDR *zdrs, uint32_t *u)
|
||||
{
|
||||
if (zdrs->pos + 4 > zdrs->size) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (zdrs->x_op) {
|
||||
case ZDR_ENCODE:
|
||||
*(uint32_t *)&zdrs->buf[zdrs->pos] = htonl(*u);
|
||||
zdrs->pos += 4;
|
||||
return TRUE;
|
||||
break;
|
||||
case ZDR_DECODE:
|
||||
*u = ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
|
||||
zdrs->pos += 4;
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_int(ZDR *zdrs, int32_t *i)
|
||||
{
|
||||
return libnfs_zdr_u_int(zdrs, (uint32_t *)i);
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_u_quad_t(ZDR *zdrs, uint64_t *u)
|
||||
{
|
||||
if (zdrs->pos + 8 > zdrs->size) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (zdrs->x_op) {
|
||||
case ZDR_ENCODE:
|
||||
*(uint32_t *)&zdrs->buf[zdrs->pos] = htonl((*u >> 32));
|
||||
zdrs->pos += 4;
|
||||
*(uint32_t *)&zdrs->buf[zdrs->pos] = htonl((*u & 0xffffffff));
|
||||
zdrs->pos += 4;
|
||||
return TRUE;
|
||||
break;
|
||||
case ZDR_DECODE:
|
||||
*u = ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
|
||||
zdrs->pos += 4;
|
||||
*u <<= 32;
|
||||
*u |= ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
|
||||
zdrs->pos += 4;
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_quad_t(ZDR *zdrs, int64_t *i)
|
||||
{
|
||||
return libnfs_zdr_u_quad_t(zdrs, (uint64_t *)i);
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_bytes(ZDR *zdrs, char **bufp, uint32_t *size, uint32_t maxsize)
|
||||
{
|
||||
if (!libnfs_zdr_u_int(zdrs, size)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (zdrs->pos + *size > zdrs->size) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (zdrs->x_op) {
|
||||
case ZDR_ENCODE:
|
||||
memcpy(&zdrs->buf[zdrs->pos], *bufp, *size);
|
||||
zdrs->pos += *size;
|
||||
zdrs->pos = (zdrs->pos + 3) & ~3;
|
||||
return TRUE;
|
||||
case ZDR_DECODE:
|
||||
if (*bufp == NULL) {
|
||||
*bufp = zdr_malloc(zdrs, *size);
|
||||
}
|
||||
memcpy(*bufp, &zdrs->buf[zdrs->pos], *size);
|
||||
zdrs->pos += *size;
|
||||
zdrs->pos = (zdrs->pos + 3) & ~3;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
bool_t libnfs_zdr_enum(ZDR *zdrs, int32_t *e)
|
||||
{
|
||||
return libnfs_zdr_u_int(zdrs, (uint32_t *)e);
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_bool(ZDR *zdrs, bool_t *b)
|
||||
{
|
||||
return libnfs_zdr_u_int(zdrs, (uint32_t *)b);
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_void(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_pointer(ZDR *zdrs, char **objp, uint32_t size, zdrproc_t proc)
|
||||
{
|
||||
bool_t more_data;
|
||||
|
||||
more_data = (*objp != NULL);
|
||||
|
||||
if (!libnfs_zdr_bool(zdrs, &more_data)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (more_data == 0) {
|
||||
*objp = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (zdrs->x_op == ZDR_DECODE) {
|
||||
*objp = zdr_malloc(zdrs, size);
|
||||
if (*objp == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
memset(*objp, 0, size);
|
||||
}
|
||||
return proc(zdrs, *objp);
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_opaque(ZDR *zdrs, char *objp, uint32_t size)
|
||||
{
|
||||
switch (zdrs->x_op) {
|
||||
case ZDR_ENCODE:
|
||||
memcpy(&zdrs->buf[zdrs->pos], objp, size);
|
||||
zdrs->pos += size;
|
||||
zdrs->pos = (zdrs->pos + 3) & ~3;
|
||||
return TRUE;
|
||||
case ZDR_DECODE:
|
||||
memcpy(objp, &zdrs->buf[zdrs->pos], size);
|
||||
zdrs->pos += size;
|
||||
zdrs->pos = (zdrs->pos + 3) & ~3;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_string(ZDR *zdrs, char **strp, uint32_t maxsize)
|
||||
{
|
||||
uint32_t size;
|
||||
|
||||
if (zdrs->x_op == ZDR_ENCODE) {
|
||||
size = strlen(*strp);
|
||||
}
|
||||
|
||||
if (!libnfs_zdr_u_int(zdrs, &size)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (zdrs->pos + size > zdrs->size) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (zdrs->x_op) {
|
||||
case ZDR_ENCODE:
|
||||
return libnfs_zdr_opaque(zdrs, *strp, size);
|
||||
case ZDR_DECODE:
|
||||
*strp = zdr_malloc(zdrs, size + 1);
|
||||
if (*strp == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
(*strp)[size] = 0;
|
||||
return libnfs_zdr_opaque(zdrs, *strp, size);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_array(ZDR *zdrs, char **arrp, uint32_t *size, uint32_t maxsize, uint32_t elsize, zdrproc_t proc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!libnfs_zdr_u_int(zdrs, size)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (zdrs->pos + *size * elsize > zdrs->size) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (zdrs->x_op == ZDR_DECODE) {
|
||||
*arrp = zdr_malloc(zdrs, *size * elsize);
|
||||
if (*arrp == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
memset(*arrp, 0, *size * elsize);
|
||||
}
|
||||
|
||||
for (i = 0; i < *size; i++) {
|
||||
if (proc(zdrs, *arrp + i * elsize)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void libnfs_zdr_free(zdrproc_t proc, char *objp)
|
||||
{
|
||||
}
|
||||
|
||||
static bool_t libnfs_opaque_auth(ZDR *zdrs, struct opaque_auth *auth)
|
||||
{
|
||||
if (!libnfs_zdr_u_int(zdrs, &auth->oa_flavor)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!libnfs_zdr_bytes(zdrs, &auth->oa_base, &auth->oa_length, &auth->oa_length)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t libnfs_rpc_call_body(ZDR *zdrs, struct call_body *cmb)
|
||||
{
|
||||
if (!libnfs_zdr_u_int(zdrs, &cmb->cb_rpcvers)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!libnfs_zdr_u_int(zdrs, &cmb->cb_prog)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!libnfs_zdr_u_int(zdrs, &cmb->cb_vers)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!libnfs_zdr_u_int(zdrs, &cmb->cb_proc)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!libnfs_opaque_auth(zdrs, &cmb->cb_cred)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!libnfs_opaque_auth(zdrs, &cmb->cb_verf)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static bool_t libnfs_accepted_reply(ZDR *zdrs, struct accepted_reply *ar)
|
||||
{
|
||||
if (!libnfs_opaque_auth(zdrs, &ar->ar_verf)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!libnfs_zdr_u_int(zdrs, &ar->ar_stat)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (ar->ar_stat) {
|
||||
case SUCCESS:
|
||||
if (!ar->ar_results.proc(zdrs, ar->ar_results.where)) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
case PROG_MISMATCH:
|
||||
if (!libnfs_zdr_u_int(zdrs, &ar->ar_vers.low)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (!libnfs_zdr_u_int(zdrs, &ar->ar_vers.high)) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool_t libnfs_rejected_reply(ZDR *zdrs, struct rejected_reply *RP_dr)
|
||||
{
|
||||
printf("rejected reply\n");
|
||||
exit(10);
|
||||
}
|
||||
|
||||
static bool_t libnfs_rpc_reply_body(ZDR *zdrs, struct reply_body *rmb)
|
||||
{
|
||||
if (!libnfs_zdr_u_int(zdrs, &rmb->rp_stat)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (rmb->rp_stat) {
|
||||
case MSG_ACCEPTED:
|
||||
if (!libnfs_accepted_reply(zdrs, &rmb->rp_acpt)) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
case MSG_DENIED:
|
||||
if (!libnfs_rejected_reply(zdrs, &rmb->rp_rjct)) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool_t libnfs_rpc_msg(ZDR *zdrs, struct rpc_msg *msg)
|
||||
{
|
||||
if (!libnfs_zdr_u_int(zdrs, &msg->rm_xid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!libnfs_zdr_u_int(zdrs, &msg->rm_direction)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (msg->rm_direction) {
|
||||
case CALL:
|
||||
return libnfs_rpc_call_body(zdrs, &msg->ru.RM_cmb);
|
||||
break;
|
||||
case REPLY:
|
||||
return libnfs_rpc_reply_body(zdrs, &msg->ru.RM_rmb);
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_callmsg(ZDR *zdrs, struct rpc_msg *msg)
|
||||
{
|
||||
return libnfs_rpc_msg(zdrs, msg);
|
||||
}
|
||||
|
||||
bool_t libnfs_zdr_replymsg(ZDR *zdrs, struct rpc_msg *msg)
|
||||
{
|
||||
return libnfs_rpc_msg(zdrs, msg);
|
||||
}
|
||||
|
||||
AUTH *authnone_create(void)
|
||||
{
|
||||
AUTH *auth;
|
||||
|
||||
auth = malloc(sizeof(AUTH));
|
||||
|
||||
auth->ah_cred.oa_flavor = AUTH_NONE;
|
||||
auth->ah_cred.oa_length = 0;
|
||||
auth->ah_cred.oa_base = NULL;
|
||||
|
||||
auth->ah_verf.oa_flavor = AUTH_NONE;
|
||||
auth->ah_verf.oa_length = 0;
|
||||
auth->ah_verf.oa_base = NULL;
|
||||
|
||||
auth->ah_private = NULL;
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
AUTH *libnfs_authunix_create(char *host, uint32_t uid, uint32_t gid, uint32_t len, uint32_t *groups)
|
||||
{
|
||||
AUTH *auth;
|
||||
int size;
|
||||
uint32_t *buf;
|
||||
int idx;
|
||||
|
||||
size = 4 + 4 + ((strlen(host) + 3) & ~3) + 4 + 4 + 4 + len * 4;
|
||||
auth = malloc(sizeof(AUTH));
|
||||
auth->ah_cred.oa_flavor = AUTH_UNIX;
|
||||
auth->ah_cred.oa_length = size;
|
||||
auth->ah_cred.oa_base = malloc(size);
|
||||
|
||||
buf = auth->ah_cred.oa_base;
|
||||
idx = 0;
|
||||
buf[idx++] = htonl(time(NULL));
|
||||
buf[idx++] = htonl(strlen(host));
|
||||
memcpy(&buf[2], host, strlen(host));
|
||||
|
||||
idx += (strlen(host) + 3) >> 2;
|
||||
buf[idx++] = htonl(uid);
|
||||
buf[idx++] = htonl(gid);
|
||||
buf[idx++] = htonl(len);
|
||||
while (len-- > 0) {
|
||||
buf[idx++] = htonl(*groups++);
|
||||
}
|
||||
|
||||
auth->ah_verf.oa_flavor = AUTH_NONE;
|
||||
auth->ah_verf.oa_length = 0;
|
||||
auth->ah_verf.oa_base = NULL;
|
||||
|
||||
auth->ah_private = NULL;
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
AUTH *libnfs_authunix_create_default(void)
|
||||
{
|
||||
return libnfs_authunix_create("libnfs", getuid(), -1, 0, NULL);
|
||||
}
|
||||
|
||||
void libnfs_auth_destroy(AUTH *auth)
|
||||
{
|
||||
if (auth->ah_cred.oa_base) {
|
||||
free(auth->ah_cred.oa_base);
|
||||
}
|
||||
if (auth->ah_verf.oa_base) {
|
||||
free(auth->ah_verf.oa_base);
|
||||
}
|
||||
free(auth);
|
||||
}
|
||||
|
|
@ -37,6 +37,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-raw-mount.h"
|
||||
|
@ -3341,7 +3343,7 @@ uint64_t nfs_get_readmax(struct nfs_context *nfs)
|
|||
*/
|
||||
uint64_t nfs_get_writemax(struct nfs_context *nfs)
|
||||
{
|
||||
/* Some XDR libraries can not marshall PDUs bigger than this */
|
||||
/* Some ZDR libraries can not marshall PDUs bigger than this */
|
||||
if (nfs->writemax < 32768) {
|
||||
return nfs->writemax;
|
||||
}
|
||||
|
|
108
lib/pdu.c
108
lib/pdu.c
|
@ -25,16 +25,17 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <errno.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <rpc/rpc_msg.h>
|
||||
#include "slist.h"
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
|
||||
struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int version, int procedure, rpc_cb cb, void *private_data, xdrproc_t xdr_decode_fn, int xdr_decode_bufsize)
|
||||
struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int version, int procedure, rpc_cb cb, void *private_data, zdrproc_t zdr_decode_fn, int zdr_decode_bufsize)
|
||||
{
|
||||
struct rpc_pdu *pdu;
|
||||
struct rpc_msg msg;
|
||||
|
@ -52,12 +53,12 @@ struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int versi
|
|||
pdu->xid = rpc->xid++;
|
||||
pdu->cb = cb;
|
||||
pdu->private_data = private_data;
|
||||
pdu->xdr_decode_fn = xdr_decode_fn;
|
||||
pdu->xdr_decode_bufsize = xdr_decode_bufsize;
|
||||
pdu->zdr_decode_fn = zdr_decode_fn;
|
||||
pdu->zdr_decode_bufsize = zdr_decode_bufsize;
|
||||
|
||||
xdrmem_create(&pdu->xdr, rpc->encodebuf, rpc->encodebuflen, XDR_ENCODE);
|
||||
zdrmem_create(&pdu->zdr, rpc->encodebuf, rpc->encodebuflen, ZDR_ENCODE);
|
||||
if (rpc->is_udp == 0) {
|
||||
xdr_setpos(&pdu->xdr, 4); /* skip past the record marker */
|
||||
zdr_setpos(&pdu->zdr, 4); /* skip past the record marker */
|
||||
}
|
||||
|
||||
memset(&msg, 0, sizeof(struct rpc_msg));
|
||||
|
@ -70,9 +71,9 @@ struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int versi
|
|||
msg.rm_call.cb_cred = rpc->auth->ah_cred;
|
||||
msg.rm_call.cb_verf = rpc->auth->ah_verf;
|
||||
|
||||
if (xdr_callmsg(&pdu->xdr, &msg) == 0) {
|
||||
rpc_set_error(rpc, "xdr_callmsg failed");
|
||||
xdr_destroy(&pdu->xdr);
|
||||
if (zdr_callmsg(&pdu->zdr, &msg) == 0) {
|
||||
rpc_set_error(rpc, "zdr_callmsg failed");
|
||||
zdr_destroy(&pdu->zdr);
|
||||
free(pdu);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -87,13 +88,13 @@ void rpc_free_pdu(struct rpc_context *rpc _U_, struct rpc_pdu *pdu)
|
|||
pdu->outdata.data = NULL;
|
||||
}
|
||||
|
||||
if (pdu->xdr_decode_buf != NULL) {
|
||||
xdr_free(pdu->xdr_decode_fn, pdu->xdr_decode_buf);
|
||||
free(pdu->xdr_decode_buf);
|
||||
pdu->xdr_decode_buf = NULL;
|
||||
if (pdu->zdr_decode_buf != NULL) {
|
||||
zdr_free(pdu->zdr_decode_fn, pdu->zdr_decode_buf);
|
||||
free(pdu->zdr_decode_buf);
|
||||
pdu->zdr_decode_buf = NULL;
|
||||
}
|
||||
|
||||
xdr_destroy(&pdu->xdr);
|
||||
zdr_destroy(&pdu->zdr);
|
||||
|
||||
free(pdu);
|
||||
}
|
||||
|
@ -103,10 +104,11 @@ int rpc_queue_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu)
|
|||
{
|
||||
int size, recordmarker;
|
||||
|
||||
size = xdr_getpos(&pdu->xdr);
|
||||
size = zdr_getpos(&pdu->zdr);
|
||||
|
||||
/* for udp we dont queue, we just send it straight away */
|
||||
if (rpc->is_udp != 0) {
|
||||
// XXX add a rpc->udp_dest_sock_size and get rid of sys/socket.h and netinet/in.h
|
||||
if (sendto(rpc->fd, rpc->encodebuf, size, MSG_DONTWAIT, rpc->udp_dest, sizeof(struct sockaddr_in)) < 0) {
|
||||
rpc_set_error(rpc, "Sendto failed with errno %s", strerror(errno));
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
|
@ -117,9 +119,9 @@ int rpc_queue_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu)
|
|||
}
|
||||
|
||||
/* write recordmarker */
|
||||
xdr_setpos(&pdu->xdr, 0);
|
||||
zdr_setpos(&pdu->zdr, 0);
|
||||
recordmarker = (size - 4) | 0x80000000;
|
||||
xdr_int(&pdu->xdr, &recordmarker);
|
||||
zdr_int(&pdu->zdr, &recordmarker);
|
||||
|
||||
pdu->outdata.size = size;
|
||||
pdu->outdata.data = malloc(pdu->outdata.size);
|
||||
|
@ -144,33 +146,33 @@ int rpc_get_pdu_size(char *buf)
|
|||
return (size & 0x7fffffff) + 4;
|
||||
}
|
||||
|
||||
static int rpc_process_reply(struct rpc_context *rpc, struct rpc_pdu *pdu, XDR *xdr)
|
||||
static int rpc_process_reply(struct rpc_context *rpc, struct rpc_pdu *pdu, ZDR *zdr)
|
||||
{
|
||||
struct rpc_msg msg;
|
||||
|
||||
memset(&msg, 0, sizeof(struct rpc_msg));
|
||||
msg.acpted_rply.ar_verf = _null_auth;
|
||||
if (pdu->xdr_decode_bufsize > 0) {
|
||||
if (pdu->xdr_decode_buf != NULL) {
|
||||
free(pdu->xdr_decode_buf);
|
||||
if (pdu->zdr_decode_bufsize > 0) {
|
||||
if (pdu->zdr_decode_buf != NULL) {
|
||||
free(pdu->zdr_decode_buf);
|
||||
}
|
||||
pdu->xdr_decode_buf = malloc(pdu->xdr_decode_bufsize);
|
||||
if (pdu->xdr_decode_buf == NULL) {
|
||||
rpc_set_error(rpc, "xdr_replymsg failed in portmap_getport_reply");
|
||||
pdu->cb(rpc, RPC_STATUS_ERROR, "Failed to allocate buffer for decoding of XDR reply", pdu->private_data);
|
||||
pdu->zdr_decode_buf = malloc(pdu->zdr_decode_bufsize);
|
||||
if (pdu->zdr_decode_buf == NULL) {
|
||||
rpc_set_error(rpc, "zdr_replymsg failed in portmap_getport_reply");
|
||||
pdu->cb(rpc, RPC_STATUS_ERROR, "Failed to allocate buffer for decoding of ZDR reply", pdu->private_data);
|
||||
return 0;
|
||||
}
|
||||
memset(pdu->xdr_decode_buf, 0, pdu->xdr_decode_bufsize);
|
||||
memset(pdu->zdr_decode_buf, 0, pdu->zdr_decode_bufsize);
|
||||
}
|
||||
msg.acpted_rply.ar_results.where = pdu->xdr_decode_buf;
|
||||
msg.acpted_rply.ar_results.proc = pdu->xdr_decode_fn;
|
||||
msg.acpted_rply.ar_results.where = pdu->zdr_decode_buf;
|
||||
msg.acpted_rply.ar_results.proc = pdu->zdr_decode_fn;
|
||||
|
||||
if (xdr_replymsg(xdr, &msg) == 0) {
|
||||
rpc_set_error(rpc, "xdr_replymsg failed in portmap_getport_reply");
|
||||
if (zdr_replymsg(zdr, &msg) == 0) {
|
||||
rpc_set_error(rpc, "zdr_replymsg failed in portmap_getport_reply");
|
||||
pdu->cb(rpc, RPC_STATUS_ERROR, "Message rejected by server", pdu->private_data);
|
||||
if (pdu->xdr_decode_buf != NULL) {
|
||||
free(pdu->xdr_decode_buf);
|
||||
pdu->xdr_decode_buf = NULL;
|
||||
if (pdu->zdr_decode_buf != NULL) {
|
||||
free(pdu->zdr_decode_buf);
|
||||
pdu->zdr_decode_buf = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -180,7 +182,7 @@ static int rpc_process_reply(struct rpc_context *rpc, struct rpc_pdu *pdu, XDR *
|
|||
}
|
||||
switch (msg.rm_reply.rp_acpt.ar_stat) {
|
||||
case SUCCESS:
|
||||
pdu->cb(rpc, RPC_STATUS_SUCCESS, pdu->xdr_decode_buf, pdu->private_data);
|
||||
pdu->cb(rpc, RPC_STATUS_SUCCESS, pdu->zdr_decode_buf, pdu->private_data);
|
||||
break;
|
||||
case PROG_UNAVAIL:
|
||||
pdu->cb(rpc, RPC_STATUS_ERROR, "Server responded: Program not available", pdu->private_data);
|
||||
|
@ -208,22 +210,22 @@ static int rpc_process_reply(struct rpc_context *rpc, struct rpc_pdu *pdu, XDR *
|
|||
int rpc_process_pdu(struct rpc_context *rpc, char *buf, int size)
|
||||
{
|
||||
struct rpc_pdu *pdu;
|
||||
XDR xdr;
|
||||
ZDR zdr;
|
||||
int pos, recordmarker = 0;
|
||||
unsigned int xid;
|
||||
char *reasbuf = NULL;
|
||||
|
||||
memset(&xdr, 0, sizeof(XDR));
|
||||
memset(&zdr, 0, sizeof(ZDR));
|
||||
|
||||
xdrmem_create(&xdr, buf, size, XDR_DECODE);
|
||||
zdrmem_create(&zdr, buf, size, ZDR_DECODE);
|
||||
if (rpc->is_udp == 0) {
|
||||
if (xdr_int(&xdr, &recordmarker) == 0) {
|
||||
rpc_set_error(rpc, "xdr_int reading recordmarker failed");
|
||||
xdr_destroy(&xdr);
|
||||
if (zdr_int(&zdr, &recordmarker) == 0) {
|
||||
rpc_set_error(rpc, "zdr_int reading recordmarker failed");
|
||||
zdr_destroy(&zdr);
|
||||
return -1;
|
||||
}
|
||||
if (!(recordmarker&0x80000000)) {
|
||||
xdr_destroy(&xdr);
|
||||
zdr_destroy(&zdr);
|
||||
if (rpc_add_fragment(rpc, buf+4, size-4) != 0) {
|
||||
rpc_set_error(rpc, "Failed to queue fragment for reassembly.");
|
||||
return -1;
|
||||
|
@ -238,7 +240,7 @@ int rpc_process_pdu(struct rpc_context *rpc, char *buf, int size)
|
|||
uint64_t total = size - 4;
|
||||
char *ptr;
|
||||
|
||||
xdr_destroy(&xdr);
|
||||
zdr_destroy(&zdr);
|
||||
for (fragment = rpc->fragments; fragment; fragment = fragment->next) {
|
||||
total += fragment->size;
|
||||
}
|
||||
|
@ -255,20 +257,20 @@ int rpc_process_pdu(struct rpc_context *rpc, char *buf, int size)
|
|||
ptr += fragment->size;
|
||||
}
|
||||
memcpy(ptr, buf + 4, size - 4);
|
||||
xdrmem_create(&xdr, reasbuf, total, XDR_DECODE);
|
||||
zdrmem_create(&zdr, reasbuf, total, ZDR_DECODE);
|
||||
rpc_free_all_fragments(rpc);
|
||||
}
|
||||
|
||||
pos = xdr_getpos(&xdr);
|
||||
if (xdr_int(&xdr, (int *)&xid) == 0) {
|
||||
rpc_set_error(rpc, "xdr_int reading xid failed");
|
||||
xdr_destroy(&xdr);
|
||||
pos = zdr_getpos(&zdr);
|
||||
if (zdr_int(&zdr, (int *)&xid) == 0) {
|
||||
rpc_set_error(rpc, "zdr_int reading xid failed");
|
||||
zdr_destroy(&zdr);
|
||||
if (reasbuf != NULL) {
|
||||
free(reasbuf);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
xdr_setpos(&xdr, pos);
|
||||
zdr_setpos(&zdr, pos);
|
||||
|
||||
for (pdu=rpc->waitpdu; pdu; pdu=pdu->next) {
|
||||
if (pdu->xid != xid) {
|
||||
|
@ -277,10 +279,10 @@ int rpc_process_pdu(struct rpc_context *rpc, char *buf, int size)
|
|||
if (rpc->is_udp == 0 || rpc->is_broadcast == 0) {
|
||||
SLIST_REMOVE(&rpc->waitpdu, pdu);
|
||||
}
|
||||
if (rpc_process_reply(rpc, pdu, &xdr) != 0) {
|
||||
if (rpc_process_reply(rpc, pdu, &zdr) != 0) {
|
||||
rpc_set_error(rpc, "rpc_procdess_reply failed");
|
||||
}
|
||||
xdr_destroy(&xdr);
|
||||
zdr_destroy(&zdr);
|
||||
if (rpc->is_udp == 0 || rpc->is_broadcast == 0) {
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
}
|
||||
|
@ -290,7 +292,7 @@ int rpc_process_pdu(struct rpc_context *rpc, char *buf, int size)
|
|||
return 0;
|
||||
}
|
||||
rpc_set_error(rpc, "No matching pdu found for xid:%d", xid);
|
||||
xdr_destroy(&xdr);
|
||||
zdr_destroy(&zdr);
|
||||
if (reasbuf != NULL) {
|
||||
free(reasbuf);
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#ifdef HAVE_SYS_FILIO_H
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
@ -42,6 +40,7 @@
|
|||
#include <sys/sockio.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
noinst_LTLIBRARIES = libmount.la
|
||||
|
||||
mount_SOURCES_GENERATED = libnfs-raw-mount.c
|
||||
mount_HEADERS_GENERATED = libnfs-raw-mount.h
|
||||
mount_SOURCES_GENERATED =
|
||||
mount_HEADERS_GENERATED =
|
||||
mount_GENERATED = $(mount_SOURCES_GENERATED) $(mount_HEADERS_GENERATED)
|
||||
|
||||
CLEANFILES = $(mount_GENERATED) mount-stamp
|
||||
|
@ -9,12 +9,13 @@ CLEANFILES = $(mount_GENERATED) mount-stamp
|
|||
libmount_la_CPPFLAGS = -I$(abs_top_srcdir)/include
|
||||
libmount_la_SOURCES = \
|
||||
$(mount_SOURCES_GENERATED) \
|
||||
mount.c
|
||||
mount.c libnfs-raw-mount.c
|
||||
|
||||
$(mount_GENERATED) : mount-stamp
|
||||
mount-stamp : mount.x
|
||||
rm -f $(mount_GENERATED)
|
||||
rpcgen -h @RPCGENFLAGS@ $< > libnfs-raw-mount.h
|
||||
rpcgen -c @RPCGENFLAGS@ $< | sed -e "s/#include \".*mount.h\"/#include \"libnfs-raw-mount.h\"/" > libnfs-raw-mount.c
|
||||
touch mount-stamp
|
||||
|
||||
|
||||
compile_rpc:
|
||||
rpcgen -h @RPCGENFLAGS@ mount.x | sed -e "s/#include <rpc\/rpc.h>//" | sed -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-mount.h
|
||||
rpcgen -c @RPCGENFLAGS@ mount.x | sed -e "s/#include \".*mount.h\"/#include \"libnfs-xdr.h\"\n#include \"libnfs-raw-mount.h\"/" -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-mount.c
|
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs-raw-mount.h"
|
||||
|
||||
bool_t
|
||||
zdr_fhandle3 (ZDR *zdrs, fhandle3 *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_bytes (zdrs, (char **)&objp->fhandle3_val, (u_int *) &objp->fhandle3_len, FHSIZE3))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_dirpath (ZDR *zdrs, dirpath *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_string (zdrs, objp, MNTPATHLEN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_name (ZDR *zdrs, name *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_string (zdrs, objp, MNTNAMLEN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_mountstat3 (ZDR *zdrs, mountstat3 *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_enum (zdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_mountlist (ZDR *zdrs, mountlist *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_pointer (zdrs, (char **)objp, sizeof (struct mountbody), (zdrproc_t) zdr_mountbody))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_mountbody (ZDR *zdrs, mountbody *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_name (zdrs, &objp->ml_hostname))
|
||||
return FALSE;
|
||||
if (!zdr_dirpath (zdrs, &objp->ml_directory))
|
||||
return FALSE;
|
||||
if (!zdr_mountlist (zdrs, &objp->ml_next))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_groups (ZDR *zdrs, groups *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_pointer (zdrs, (char **)objp, sizeof (struct groupnode), (zdrproc_t) zdr_groupnode))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_groupnode (ZDR *zdrs, groupnode *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_name (zdrs, &objp->gr_name))
|
||||
return FALSE;
|
||||
if (!zdr_groups (zdrs, &objp->gr_next))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_exports (ZDR *zdrs, exports *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_pointer (zdrs, (char **)objp, sizeof (struct exportnode), (zdrproc_t) zdr_exportnode))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_exportnode (ZDR *zdrs, exportnode *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_dirpath (zdrs, &objp->ex_dir))
|
||||
return FALSE;
|
||||
if (!zdr_groups (zdrs, &objp->ex_groups))
|
||||
return FALSE;
|
||||
if (!zdr_exports (zdrs, &objp->ex_next))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_mountres3_ok (ZDR *zdrs, mountres3_ok *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_fhandle3 (zdrs, &objp->fhandle))
|
||||
return FALSE;
|
||||
if (!zdr_array (zdrs, (char **)&objp->auth_flavors.auth_flavors_val, (u_int *) &objp->auth_flavors.auth_flavors_len, ~0,
|
||||
sizeof (int), (zdrproc_t) zdr_int))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_mountres3 (ZDR *zdrs, mountres3 *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_mountstat3 (zdrs, &objp->fhs_status))
|
||||
return FALSE;
|
||||
switch (objp->fhs_status) {
|
||||
case MNT3_OK:
|
||||
if (!zdr_mountres3_ok (zdrs, &objp->mountres3_u.mountinfo))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_mountstat1 (ZDR *zdrs, mountstat1 *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_enum (zdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_fhandle1 (ZDR *zdrs, fhandle1 objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_opaque (zdrs, objp, FHSIZE))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_mountres1_ok (ZDR *zdrs, mountres1_ok *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_fhandle1 (zdrs, objp->fhandle))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_mountres1 (ZDR *zdrs, mountres1 *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_mountstat1 (zdrs, &objp->fhs_status))
|
||||
return FALSE;
|
||||
switch (objp->fhs_status) {
|
||||
case MNT1_OK:
|
||||
if (!zdr_mountres1_ok (zdrs, &objp->mountres1_u.mountinfo))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,250 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#ifndef _MOUNT_H_RPCGEN
|
||||
#define _MOUNT_H_RPCGEN
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MNTPATHLEN 1024
|
||||
#define MNTNAMLEN 255
|
||||
#define FHSIZE3 64
|
||||
|
||||
typedef struct {
|
||||
u_int fhandle3_len;
|
||||
char *fhandle3_val;
|
||||
} fhandle3;
|
||||
|
||||
typedef char *dirpath;
|
||||
|
||||
typedef char *name;
|
||||
|
||||
enum mountstat3 {
|
||||
MNT3_OK = 0,
|
||||
MNT3ERR_PERM = 1,
|
||||
MNT3ERR_NOENT = 2,
|
||||
MNT3ERR_IO = 5,
|
||||
MNT3ERR_ACCES = 13,
|
||||
MNT3ERR_NOTDIR = 20,
|
||||
MNT3ERR_INVAL = 22,
|
||||
MNT3ERR_NAMETOOLONG = 63,
|
||||
MNT3ERR_NOTSUPP = 10004,
|
||||
MNT3ERR_SERVERFAULT = 10006,
|
||||
};
|
||||
typedef enum mountstat3 mountstat3;
|
||||
|
||||
typedef struct mountbody *mountlist;
|
||||
|
||||
struct mountbody {
|
||||
name ml_hostname;
|
||||
dirpath ml_directory;
|
||||
mountlist ml_next;
|
||||
};
|
||||
typedef struct mountbody mountbody;
|
||||
|
||||
typedef struct groupnode *groups;
|
||||
|
||||
struct groupnode {
|
||||
name gr_name;
|
||||
groups gr_next;
|
||||
};
|
||||
typedef struct groupnode groupnode;
|
||||
|
||||
typedef struct exportnode *exports;
|
||||
|
||||
struct exportnode {
|
||||
dirpath ex_dir;
|
||||
groups ex_groups;
|
||||
exports ex_next;
|
||||
};
|
||||
typedef struct exportnode exportnode;
|
||||
|
||||
struct mountres3_ok {
|
||||
fhandle3 fhandle;
|
||||
struct {
|
||||
u_int auth_flavors_len;
|
||||
int *auth_flavors_val;
|
||||
} auth_flavors;
|
||||
};
|
||||
typedef struct mountres3_ok mountres3_ok;
|
||||
|
||||
struct mountres3 {
|
||||
mountstat3 fhs_status;
|
||||
union {
|
||||
mountres3_ok mountinfo;
|
||||
} mountres3_u;
|
||||
};
|
||||
typedef struct mountres3 mountres3;
|
||||
|
||||
enum mountstat1 {
|
||||
MNT1_OK = 0,
|
||||
MNT1ERR_PERM = 1,
|
||||
MNT1ERR_NOENT = 2,
|
||||
MNT1ERR_IO = 5,
|
||||
MNT1ERR_ACCES = 13,
|
||||
MNT1ERR_NOTDIR = 20,
|
||||
MNT1ERR_INVAL = 22,
|
||||
MNT1ERR_NAMETOOLONG = 63,
|
||||
MNT1ERR_NOTSUPP = 10004,
|
||||
MNT1ERR_SERVERFAULT = 10006,
|
||||
};
|
||||
typedef enum mountstat1 mountstat1;
|
||||
#define FHSIZE 32
|
||||
|
||||
typedef char fhandle1[FHSIZE];
|
||||
|
||||
struct mountres1_ok {
|
||||
fhandle1 fhandle;
|
||||
};
|
||||
typedef struct mountres1_ok mountres1_ok;
|
||||
|
||||
struct mountres1 {
|
||||
mountstat1 fhs_status;
|
||||
union {
|
||||
mountres1_ok mountinfo;
|
||||
} mountres1_u;
|
||||
};
|
||||
typedef struct mountres1 mountres1;
|
||||
|
||||
#define MOUNT_PROGRAM 100005
|
||||
#define MOUNT_V1 1
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define MOUNT1_NULL 0
|
||||
extern void * mount1_null_1(void *, CLIENT *);
|
||||
extern void * mount1_null_1_svc(void *, struct svc_req *);
|
||||
#define MOUNT1_MNT 1
|
||||
extern mountres1 * mount1_mnt_1(dirpath *, CLIENT *);
|
||||
extern mountres1 * mount1_mnt_1_svc(dirpath *, struct svc_req *);
|
||||
#define MOUNT1_DUMP 2
|
||||
extern mountlist * mount1_dump_1(void *, CLIENT *);
|
||||
extern mountlist * mount1_dump_1_svc(void *, struct svc_req *);
|
||||
#define MOUNT1_UMNT 3
|
||||
extern void * mount1_umnt_1(dirpath *, CLIENT *);
|
||||
extern void * mount1_umnt_1_svc(dirpath *, struct svc_req *);
|
||||
#define MOUNT1_UMNTALL 4
|
||||
extern void * mount1_umntall_1(void *, CLIENT *);
|
||||
extern void * mount1_umntall_1_svc(void *, struct svc_req *);
|
||||
#define MOUNT1_EXPORT 5
|
||||
extern exports * mount1_export_1(void *, CLIENT *);
|
||||
extern exports * mount1_export_1_svc(void *, struct svc_req *);
|
||||
extern int mount_program_1_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
|
||||
|
||||
#else /* K&R C */
|
||||
#define MOUNT1_NULL 0
|
||||
extern void * mount1_null_1();
|
||||
extern void * mount1_null_1_svc();
|
||||
#define MOUNT1_MNT 1
|
||||
extern mountres1 * mount1_mnt_1();
|
||||
extern mountres1 * mount1_mnt_1_svc();
|
||||
#define MOUNT1_DUMP 2
|
||||
extern mountlist * mount1_dump_1();
|
||||
extern mountlist * mount1_dump_1_svc();
|
||||
#define MOUNT1_UMNT 3
|
||||
extern void * mount1_umnt_1();
|
||||
extern void * mount1_umnt_1_svc();
|
||||
#define MOUNT1_UMNTALL 4
|
||||
extern void * mount1_umntall_1();
|
||||
extern void * mount1_umntall_1_svc();
|
||||
#define MOUNT1_EXPORT 5
|
||||
extern exports * mount1_export_1();
|
||||
extern exports * mount1_export_1_svc();
|
||||
extern int mount_program_1_freeresult ();
|
||||
#endif /* K&R C */
|
||||
#define MOUNT_V3 3
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define MOUNT3_NULL 0
|
||||
extern void * mount3_null_3(void *, CLIENT *);
|
||||
extern void * mount3_null_3_svc(void *, struct svc_req *);
|
||||
#define MOUNT3_MNT 1
|
||||
extern mountres3 * mount3_mnt_3(dirpath *, CLIENT *);
|
||||
extern mountres3 * mount3_mnt_3_svc(dirpath *, struct svc_req *);
|
||||
#define MOUNT3_DUMP 2
|
||||
extern mountlist * mount3_dump_3(void *, CLIENT *);
|
||||
extern mountlist * mount3_dump_3_svc(void *, struct svc_req *);
|
||||
#define MOUNT3_UMNT 3
|
||||
extern void * mount3_umnt_3(dirpath *, CLIENT *);
|
||||
extern void * mount3_umnt_3_svc(dirpath *, struct svc_req *);
|
||||
#define MOUNT3_UMNTALL 4
|
||||
extern void * mount3_umntall_3(void *, CLIENT *);
|
||||
extern void * mount3_umntall_3_svc(void *, struct svc_req *);
|
||||
#define MOUNT3_EXPORT 5
|
||||
extern exports * mount3_export_3(void *, CLIENT *);
|
||||
extern exports * mount3_export_3_svc(void *, struct svc_req *);
|
||||
extern int mount_program_3_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
|
||||
|
||||
#else /* K&R C */
|
||||
#define MOUNT3_NULL 0
|
||||
extern void * mount3_null_3();
|
||||
extern void * mount3_null_3_svc();
|
||||
#define MOUNT3_MNT 1
|
||||
extern mountres3 * mount3_mnt_3();
|
||||
extern mountres3 * mount3_mnt_3_svc();
|
||||
#define MOUNT3_DUMP 2
|
||||
extern mountlist * mount3_dump_3();
|
||||
extern mountlist * mount3_dump_3_svc();
|
||||
#define MOUNT3_UMNT 3
|
||||
extern void * mount3_umnt_3();
|
||||
extern void * mount3_umnt_3_svc();
|
||||
#define MOUNT3_UMNTALL 4
|
||||
extern void * mount3_umntall_3();
|
||||
extern void * mount3_umntall_3_svc();
|
||||
#define MOUNT3_EXPORT 5
|
||||
extern exports * mount3_export_3();
|
||||
extern exports * mount3_export_3_svc();
|
||||
extern int mount_program_3_freeresult ();
|
||||
#endif /* K&R C */
|
||||
|
||||
/* the zdr functions */
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
extern bool_t zdr_fhandle3 (ZDR *, fhandle3*);
|
||||
extern bool_t zdr_dirpath (ZDR *, dirpath*);
|
||||
extern bool_t zdr_name (ZDR *, name*);
|
||||
extern bool_t zdr_mountstat3 (ZDR *, mountstat3*);
|
||||
extern bool_t zdr_mountlist (ZDR *, mountlist*);
|
||||
extern bool_t zdr_mountbody (ZDR *, mountbody*);
|
||||
extern bool_t zdr_groups (ZDR *, groups*);
|
||||
extern bool_t zdr_groupnode (ZDR *, groupnode*);
|
||||
extern bool_t zdr_exports (ZDR *, exports*);
|
||||
extern bool_t zdr_exportnode (ZDR *, exportnode*);
|
||||
extern bool_t zdr_mountres3_ok (ZDR *, mountres3_ok*);
|
||||
extern bool_t zdr_mountres3 (ZDR *, mountres3*);
|
||||
extern bool_t zdr_mountstat1 (ZDR *, mountstat1*);
|
||||
extern bool_t zdr_fhandle1 (ZDR *, fhandle1);
|
||||
extern bool_t zdr_mountres1_ok (ZDR *, mountres1_ok*);
|
||||
extern bool_t zdr_mountres1 (ZDR *, mountres1*);
|
||||
|
||||
#else /* K&R C */
|
||||
extern bool_t zdr_fhandle3 ();
|
||||
extern bool_t zdr_dirpath ();
|
||||
extern bool_t zdr_name ();
|
||||
extern bool_t zdr_mountstat3 ();
|
||||
extern bool_t zdr_mountlist ();
|
||||
extern bool_t zdr_mountbody ();
|
||||
extern bool_t zdr_groups ();
|
||||
extern bool_t zdr_groupnode ();
|
||||
extern bool_t zdr_exports ();
|
||||
extern bool_t zdr_exportnode ();
|
||||
extern bool_t zdr_mountres3_ok ();
|
||||
extern bool_t zdr_mountres3 ();
|
||||
extern bool_t zdr_mountstat1 ();
|
||||
extern bool_t zdr_fhandle1 ();
|
||||
extern bool_t zdr_mountres1_ok ();
|
||||
extern bool_t zdr_mountres1 ();
|
||||
|
||||
#endif /* K&R C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_MOUNT_H_RPCGEN */
|
|
@ -21,8 +21,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
|
@ -32,7 +31,7 @@ int rpc_mount_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_NULL, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for mount/null call");
|
||||
return -1;
|
||||
|
@ -51,14 +50,14 @@ int rpc_mount_mnt_async(struct rpc_context *rpc, rpc_cb cb, char *export, void *
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_MNT, cb, private_data, (xdrproc_t)xdr_mountres3, sizeof(mountres3));
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_MNT, cb, private_data, (zdrproc_t)zdr_mountres3, sizeof(mountres3));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for mount/mnt call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_dirpath(&pdu->xdr, &export) == 0) {
|
||||
rpc_set_error(rpc, "XDR error. Failed to encode mount/mnt call");
|
||||
if (zdr_dirpath(&pdu->zdr, &export) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error. Failed to encode mount/mnt call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -1;
|
||||
}
|
||||
|
@ -76,7 +75,7 @@ int rpc_mount_dump_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_DUMP, cb, private_data, (xdrproc_t)xdr_mountlist, sizeof(mountlist));
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_DUMP, cb, private_data, (zdrproc_t)zdr_mountlist, sizeof(mountlist));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Failed to allocate pdu for mount/dump");
|
||||
return -1;
|
||||
|
@ -95,13 +94,13 @@ int rpc_mount_umnt_async(struct rpc_context *rpc, rpc_cb cb, char *export, void
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_UMNT, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_UMNT, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Failed to allocate pdu for mount/umnt");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_dirpath(&pdu->xdr, &export) == 0) {
|
||||
if (zdr_dirpath(&pdu->zdr, &export) == 0) {
|
||||
rpc_set_error(rpc, "failed to encode dirpath for mount/umnt");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -1;
|
||||
|
@ -120,7 +119,7 @@ int rpc_mount_umntall_async(struct rpc_context *rpc, rpc_cb cb, void *private_da
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_UMNTALL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_UMNTALL, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Failed to allocate pdu for mount/umntall");
|
||||
return -1;
|
||||
|
@ -139,7 +138,7 @@ int rpc_mount_export_async(struct rpc_context *rpc, rpc_cb cb, void *private_dat
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_EXPORT, cb, private_data, (xdrproc_t)xdr_exports, sizeof(exports));
|
||||
pdu = rpc_allocate_pdu(rpc, MOUNT_PROGRAM, MOUNT_V3, MOUNT3_EXPORT, cb, private_data, (zdrproc_t)zdr_exports, sizeof(exports));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Failed to allocate pdu for mount/export");
|
||||
return -1;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
noinst_LTLIBRARIES = libnfs.la
|
||||
|
||||
nfs_SOURCES_GENERATED = libnfs-raw-nfs.c
|
||||
nfs_HEADERS_GENERATED = libnfs-raw-nfs.h
|
||||
nfs_SOURCES_GENERATED =
|
||||
nfs_HEADERS_GENERATED =
|
||||
nfs_GENERATED = $(nfs_SOURCES_GENERATED) $(nfs_HEADERS_GENERATED)
|
||||
|
||||
CLEANFILES = $(nfs_GENERATED) nfs-stamp
|
||||
|
@ -9,12 +9,13 @@ CLEANFILES = $(nfs_GENERATED) nfs-stamp
|
|||
libnfs_la_CPPFLAGS = -I$(abs_top_srcdir)/include
|
||||
libnfs_la_SOURCES = \
|
||||
$(nfs_SOURCES_GENERATED) \
|
||||
nfs.c nfsacl.c
|
||||
nfs.c nfsacl.c libnfs-raw-nfs.c
|
||||
|
||||
$(nfs_GENERATED) : nfs-stamp
|
||||
nfs-stamp : nfs.x
|
||||
rm -f $(nfs_GENERATED)
|
||||
rpcgen -h @RPCGENFLAGS@ $< > libnfs-raw-nfs.h
|
||||
rpcgen -c @RPCGENFLAGS@ $< | sed -e "s/#include \".*nfs.h\"/#include \"libnfs-raw-nfs.h\"/" > libnfs-raw-nfs.c
|
||||
touch nfs-stamp
|
||||
|
||||
|
||||
compile_rpc:
|
||||
rpcgen -h @RPCGENFLAGS@ nfs.x | sed -e "s/#include <rpc\/rpc.h>//" | sed -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-nfs.h
|
||||
rpcgen -c @RPCGENFLAGS@ nfs.x | sed -e "s/#include \".*nfs.h\"/#include \"libnfs-xdr.h\"\n#include \"libnfs-raw-nfs.h\"/" -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-nfs.c
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
125
nfs/nfs.c
125
nfs/nfs.c
|
@ -24,8 +24,7 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
|
@ -108,7 +107,7 @@ int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_NULL, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/null call");
|
||||
return -1;
|
||||
|
@ -128,7 +127,7 @@ int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh
|
|||
struct rpc_pdu *pdu;
|
||||
GETATTR3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_GETATTR, cb, private_data, (xdrproc_t)xdr_GETATTR3res, sizeof(GETATTR3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_GETATTR, cb, private_data, (zdrproc_t)zdr_GETATTR3res, sizeof(GETATTR3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/null call");
|
||||
return -1;
|
||||
|
@ -137,8 +136,8 @@ int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh
|
|||
args.object.data.data_len = fh->data.data_len;
|
||||
args.object.data.data_val = fh->data.data_val;
|
||||
|
||||
if (xdr_GETATTR3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode GETATTR3args");
|
||||
if (zdr_GETATTR3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode GETATTR3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -157,7 +156,7 @@ int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
struct rpc_pdu *pdu;
|
||||
LOOKUP3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LOOKUP, cb, private_data, (xdrproc_t)xdr_LOOKUP3res, sizeof(LOOKUP3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LOOKUP, cb, private_data, (zdrproc_t)zdr_LOOKUP3res, sizeof(LOOKUP3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/lookup call");
|
||||
return -1;
|
||||
|
@ -167,8 +166,8 @@ int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
args.what.dir.data.data_val = fh->data.data_val;
|
||||
args.what.name = name;
|
||||
|
||||
if (xdr_LOOKUP3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode LOOKUP3args");
|
||||
if (zdr_LOOKUP3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode LOOKUP3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -188,7 +187,7 @@ int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
struct rpc_pdu *pdu;
|
||||
ACCESS3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_ACCESS, cb, private_data, (xdrproc_t)xdr_ACCESS3res, sizeof(ACCESS3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_ACCESS, cb, private_data, (zdrproc_t)zdr_ACCESS3res, sizeof(ACCESS3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/access call");
|
||||
return -1;
|
||||
|
@ -198,8 +197,8 @@ int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
args.object.data.data_val = fh->data.data_val;
|
||||
args.access = access;
|
||||
|
||||
if (xdr_ACCESS3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode ACCESS3args");
|
||||
if (zdr_ACCESS3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode ACCESS3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -220,7 +219,7 @@ int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, u
|
|||
struct rpc_pdu *pdu;
|
||||
READ3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READ, cb, private_data, (xdrproc_t)xdr_READ3res, sizeof(READ3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READ, cb, private_data, (zdrproc_t)zdr_READ3res, sizeof(READ3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/read call");
|
||||
return -1;
|
||||
|
@ -231,8 +230,8 @@ int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, u
|
|||
args.offset = offset;
|
||||
args.count = count;
|
||||
|
||||
if (xdr_READ3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode READ3args");
|
||||
if (zdr_READ3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode READ3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -252,7 +251,7 @@ int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
struct rpc_pdu *pdu;
|
||||
WRITE3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_WRITE, cb, private_data, (xdrproc_t)xdr_WRITE3res, sizeof(WRITE3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_WRITE, cb, private_data, (zdrproc_t)zdr_WRITE3res, sizeof(WRITE3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/write call");
|
||||
return -1;
|
||||
|
@ -266,8 +265,8 @@ int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
args.data.data_len = count;
|
||||
args.data.data_val = buf;
|
||||
|
||||
if (xdr_WRITE3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode WRITE3args");
|
||||
if (zdr_WRITE3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode WRITE3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -288,7 +287,7 @@ int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
struct rpc_pdu *pdu;
|
||||
COMMIT3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_COMMIT, cb, private_data, (xdrproc_t)xdr_COMMIT3res, sizeof(COMMIT3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_COMMIT, cb, private_data, (zdrproc_t)zdr_COMMIT3res, sizeof(COMMIT3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/commit call");
|
||||
return -1;
|
||||
|
@ -299,8 +298,8 @@ int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
args.offset = 0;
|
||||
args.count = 0;
|
||||
|
||||
if (xdr_COMMIT3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode WRITE3args");
|
||||
if (zdr_COMMIT3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode WRITE3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -319,14 +318,14 @@ int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SETATTR, cb, private_data, (xdrproc_t)xdr_SETATTR3res, sizeof(SETATTR3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SETATTR, cb, private_data, (zdrproc_t)zdr_SETATTR3res, sizeof(SETATTR3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/setattr call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_SETATTR3args(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode SETATTR3args");
|
||||
if (zdr_SETATTR3args(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode SETATTR3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -346,14 +345,14 @@ int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, vo
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKDIR, cb, private_data, (xdrproc_t)xdr_MKDIR3res, sizeof(MKDIR3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKDIR, cb, private_data, (zdrproc_t)zdr_MKDIR3res, sizeof(MKDIR3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/setattr call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_MKDIR3args(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode MKDIR3args");
|
||||
if (zdr_MKDIR3args(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode MKDIR3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -375,7 +374,7 @@ int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
struct rpc_pdu *pdu;
|
||||
RMDIR3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RMDIR, cb, private_data, (xdrproc_t)xdr_RMDIR3res, sizeof(RMDIR3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RMDIR, cb, private_data, (zdrproc_t)zdr_RMDIR3res, sizeof(RMDIR3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/rmdir call");
|
||||
return -1;
|
||||
|
@ -386,8 +385,8 @@ int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
args.object.dir.data.data_val = fh->data.data_val;
|
||||
args.object.name = dir;
|
||||
|
||||
if (xdr_RMDIR3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode RMDIR3args");
|
||||
if (zdr_RMDIR3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode RMDIR3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -407,14 +406,14 @@ int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args,
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_CREATE, cb, private_data, (xdrproc_t)xdr_CREATE3res, sizeof(CREATE3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_CREATE, cb, private_data, (zdrproc_t)zdr_CREATE3res, sizeof(CREATE3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/create call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_CREATE3args(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode CREATE3args");
|
||||
if (zdr_CREATE3args(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode CREATE3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -435,7 +434,7 @@ int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
struct rpc_pdu *pdu;
|
||||
MKNOD3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKNOD, cb, private_data, (xdrproc_t)xdr_MKNOD3res, sizeof(MKNOD3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKNOD, cb, private_data, (zdrproc_t)zdr_MKNOD3res, sizeof(MKNOD3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/mknod call");
|
||||
return -1;
|
||||
|
@ -475,8 +474,8 @@ int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_MKNOD3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode MKNOD3args");
|
||||
if (zdr_MKNOD3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode MKNOD3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -496,7 +495,7 @@ int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
struct rpc_pdu *pdu;
|
||||
REMOVE3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_REMOVE, cb, private_data, (xdrproc_t)xdr_REMOVE3res, sizeof(REMOVE3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_REMOVE, cb, private_data, (zdrproc_t)zdr_REMOVE3res, sizeof(REMOVE3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/remove call");
|
||||
return -1;
|
||||
|
@ -507,8 +506,8 @@ int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
args.object.dir.data.data_val = fh->data.data_val;
|
||||
args.object.name = file;
|
||||
|
||||
if (xdr_REMOVE3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode REMOVE3args");
|
||||
if (zdr_REMOVE3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode REMOVE3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -527,7 +526,7 @@ int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh
|
|||
struct rpc_pdu *pdu;
|
||||
READDIR3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIR, cb, private_data, (xdrproc_t)xdr_READDIR3res, sizeof(READDIR3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIR, cb, private_data, (zdrproc_t)zdr_READDIR3res, sizeof(READDIR3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/readdir call");
|
||||
return -1;
|
||||
|
@ -540,8 +539,8 @@ int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh
|
|||
memcpy(&args.cookieverf, cookieverf, sizeof(cookieverf3));
|
||||
args.count = count;
|
||||
|
||||
if (xdr_READDIR3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode READDIR3args");
|
||||
if (zdr_READDIR3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode READDIR3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -560,7 +559,7 @@ int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3
|
|||
struct rpc_pdu *pdu;
|
||||
READDIRPLUS3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIRPLUS, cb, private_data, (xdrproc_t)xdr_READDIRPLUS3res, sizeof(READDIRPLUS3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIRPLUS, cb, private_data, (zdrproc_t)zdr_READDIRPLUS3res, sizeof(READDIRPLUS3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/readdirplus call");
|
||||
return -1;
|
||||
|
@ -574,8 +573,8 @@ int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3
|
|||
args.dircount = count;
|
||||
args.maxcount = count;
|
||||
|
||||
if (xdr_READDIRPLUS3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode READDIRPLUS3args");
|
||||
if (zdr_READDIRPLUS3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode READDIRPLUS3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -594,7 +593,7 @@ int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
struct rpc_pdu *pdu;
|
||||
FSSTAT3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSSTAT, cb, private_data, (xdrproc_t)xdr_FSSTAT3res, sizeof(FSSTAT3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSSTAT, cb, private_data, (zdrproc_t)zdr_FSSTAT3res, sizeof(FSSTAT3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/fsstat call");
|
||||
return -1;
|
||||
|
@ -603,8 +602,8 @@ int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
args.fsroot.data.data_len = fh->data.data_len;
|
||||
args.fsroot.data.data_val = fh->data.data_val;
|
||||
|
||||
if (xdr_FSSTAT3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode FSSTAT3args");
|
||||
if (zdr_FSSTAT3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode FSSTAT3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -623,7 +622,7 @@ int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
struct rpc_pdu *pdu;
|
||||
FSINFO3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSINFO, cb, private_data, (xdrproc_t)xdr_FSINFO3res, sizeof(FSINFO3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSINFO, cb, private_data, (zdrproc_t)zdr_FSINFO3res, sizeof(FSINFO3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/fsinfo call");
|
||||
return -1;
|
||||
|
@ -632,8 +631,8 @@ int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
|
|||
args.fsroot.data.data_len = fh->data.data_len;
|
||||
args.fsroot.data.data_val = fh->data.data_val;
|
||||
|
||||
if (xdr_FSINFO3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode FSINFO3args");
|
||||
if (zdr_FSINFO3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode FSINFO3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -651,14 +650,14 @@ int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK3args *ar
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READLINK, cb, private_data, (xdrproc_t)xdr_READLINK3res, sizeof(READLINK3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READLINK, cb, private_data, (zdrproc_t)zdr_READLINK3res, sizeof(READLINK3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/readlink call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_READLINK3args(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode READLINK3args");
|
||||
if (zdr_READLINK3args(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode READLINK3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -677,14 +676,14 @@ int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK3args *args
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SYMLINK, cb, private_data, (xdrproc_t)xdr_SYMLINK3res, sizeof(SYMLINK3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SYMLINK, cb, private_data, (zdrproc_t)zdr_SYMLINK3res, sizeof(SYMLINK3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/symlink call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_SYMLINK3args(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode SYMLINK3args");
|
||||
if (zdr_SYMLINK3args(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode SYMLINK3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -706,7 +705,7 @@ int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *old
|
|||
struct rpc_pdu *pdu;
|
||||
RENAME3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RENAME, cb, private_data, (xdrproc_t)xdr_RENAME3res, sizeof(RENAME3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RENAME, cb, private_data, (zdrproc_t)zdr_RENAME3res, sizeof(RENAME3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/rename call");
|
||||
return -1;
|
||||
|
@ -720,8 +719,8 @@ int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *old
|
|||
args.to.dir.data.data_val = newdir->data.data_val;
|
||||
args.to.name = newname;
|
||||
|
||||
if (xdr_RENAME3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode RENAME3args");
|
||||
if (zdr_RENAME3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode RENAME3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -743,7 +742,7 @@ int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file,
|
|||
struct rpc_pdu *pdu;
|
||||
LINK3args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LINK, cb, private_data, (xdrproc_t)xdr_LINK3res, sizeof(LINK3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LINK, cb, private_data, (zdrproc_t)zdr_LINK3res, sizeof(LINK3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/link call");
|
||||
return -1;
|
||||
|
@ -756,8 +755,8 @@ int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file,
|
|||
args.link.dir.data.data_val = newdir->data.data_val;
|
||||
args.link.name = newname;
|
||||
|
||||
if (xdr_LINK3args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode LINK3args");
|
||||
if (zdr_LINK3args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode LINK3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
|
108
nfs/nfs.x
108
nfs/nfs.x
|
@ -39,44 +39,40 @@ enum ftype3 {
|
|||
NF3FIFO = 7
|
||||
};
|
||||
|
||||
typedef unsigned long uint32;
|
||||
typedef unsigned int mode3;
|
||||
|
||||
typedef long int32;
|
||||
typedef unsigned int uid3;
|
||||
|
||||
typedef uint32 mode3;
|
||||
|
||||
typedef uint32 uid3;
|
||||
|
||||
typedef uint32 gid3;
|
||||
typedef unsigned int gid3;
|
||||
|
||||
typedef uint64 size3;
|
||||
|
||||
typedef uint64 fileid3;
|
||||
|
||||
struct specdata3 {
|
||||
uint32 specdata1;
|
||||
uint32 specdata2;
|
||||
unsigned int specdata1;
|
||||
unsigned int specdata2;
|
||||
};
|
||||
|
||||
struct nfstime3 {
|
||||
uint32 seconds;
|
||||
uint32 nseconds;
|
||||
unsigned int seconds;
|
||||
unsigned int nseconds;
|
||||
};
|
||||
|
||||
struct fattr3 {
|
||||
ftype3 type;
|
||||
mode3 mode;
|
||||
uint32 nlink;
|
||||
uid3 uid;
|
||||
gid3 gid;
|
||||
size3 size;
|
||||
size3 used;
|
||||
specdata3 rdev;
|
||||
uint64 fsid;
|
||||
fileid3 fileid;
|
||||
nfstime3 atime;
|
||||
nfstime3 mtime;
|
||||
nfstime3 ctime;
|
||||
ftype3 type;
|
||||
mode3 mode;
|
||||
unsigned int nlink;
|
||||
uid3 uid;
|
||||
gid3 gid;
|
||||
size3 size;
|
||||
size3 used;
|
||||
specdata3 rdev;
|
||||
uint64 fsid;
|
||||
fileid3 fileid;
|
||||
nfstime3 atime;
|
||||
nfstime3 mtime;
|
||||
nfstime3 ctime;
|
||||
};
|
||||
|
||||
union post_op_attr switch (bool attributes_follow) {
|
||||
|
@ -127,7 +123,7 @@ enum stable_how {
|
|||
|
||||
typedef uint64 offset3;
|
||||
|
||||
typedef uint32 count3;
|
||||
typedef unsigned int count3;
|
||||
|
||||
struct wcc_attr {
|
||||
size3 size;
|
||||
|
@ -228,13 +224,13 @@ const ACCESS3_DELETE = 0x0010;
|
|||
const ACCESS3_EXECUTE = 0x0020;
|
||||
|
||||
struct ACCESS3args {
|
||||
nfs_fh3 object;
|
||||
uint32 access;
|
||||
nfs_fh3 object;
|
||||
unsigned int access;
|
||||
};
|
||||
|
||||
struct ACCESS3resok {
|
||||
post_op_attr obj_attributes;
|
||||
uint32 access;
|
||||
post_op_attr obj_attributes;
|
||||
unsigned int access;
|
||||
};
|
||||
|
||||
struct ACCESS3resfail {
|
||||
|
@ -424,16 +420,16 @@ struct FSINFO3args {
|
|||
|
||||
struct FSINFO3resok {
|
||||
post_op_attr obj_attributes;
|
||||
uint32 rtmax;
|
||||
uint32 rtpref;
|
||||
uint32 rtmult;
|
||||
uint32 wtmax;
|
||||
uint32 wtpref;
|
||||
uint32 wtmult;
|
||||
uint32 dtpref;
|
||||
unsigned int rtmax;
|
||||
unsigned int rtpref;
|
||||
unsigned int rtmult;
|
||||
unsigned int wtmax;
|
||||
unsigned int wtpref;
|
||||
unsigned int wtmult;
|
||||
unsigned int dtpref;
|
||||
size3 maxfilesize;
|
||||
nfstime3 time_delta;
|
||||
uint32 properties;
|
||||
unsigned int properties;
|
||||
};
|
||||
|
||||
struct FSINFO3resfail {
|
||||
|
@ -460,7 +456,7 @@ struct FSSTAT3resok {
|
|||
size3 tfiles;
|
||||
size3 ffiles;
|
||||
size3 afiles;
|
||||
uint32 invarsec;
|
||||
unsigned int invarsec;
|
||||
};
|
||||
|
||||
struct FSSTAT3resfail {
|
||||
|
@ -480,8 +476,8 @@ struct PATHCONF3args {
|
|||
|
||||
struct PATHCONF3resok {
|
||||
post_op_attr obj_attributes;
|
||||
uint32 linkmax;
|
||||
uint32 name_max;
|
||||
unsigned int linkmax;
|
||||
unsigned int name_max;
|
||||
bool no_trunc;
|
||||
bool chown_restricted;
|
||||
bool case_insensitive;
|
||||
|
@ -878,8 +874,8 @@ const NFSACL_PERM_EXEC = 0x01;
|
|||
|
||||
struct nfsacl_ace {
|
||||
enum nfsacl_type type;
|
||||
uint32_t id;
|
||||
uint32_t perm;
|
||||
unsigned int id;
|
||||
unsigned int perm;
|
||||
};
|
||||
|
||||
const NFSACL_MASK_ACL_ENTRY = 0x0001;
|
||||
|
@ -888,17 +884,17 @@ const NFSACL_MASK_ACL_DEFAULT_ENTRY = 0x0004;
|
|||
const NFSACL_MASK_ACL_DEFAULT_COUNT = 0x0008;
|
||||
|
||||
struct GETACL3args {
|
||||
nfs_fh3 dir;
|
||||
uint32 mask;
|
||||
nfs_fh3 dir;
|
||||
unsigned int mask;
|
||||
};
|
||||
|
||||
struct GETACL3resok {
|
||||
post_op_attr attr;
|
||||
uint32_t mask;
|
||||
uint32_t ace_count;
|
||||
struct nfsacl_ace ace<>;
|
||||
uint32_t default_ace_count;
|
||||
struct nfsacl_ace default_ace<>;
|
||||
post_op_attr attr;
|
||||
unsigned int mask;
|
||||
unsigned int ace_count;
|
||||
struct nfsacl_ace ace<>;
|
||||
unsigned int default_ace_count;
|
||||
struct nfsacl_ace default_ace<>;
|
||||
};
|
||||
|
||||
union GETACL3res switch (nfsstat3 status) {
|
||||
|
@ -909,12 +905,12 @@ default:
|
|||
};
|
||||
|
||||
struct SETACL3args {
|
||||
nfs_fh3 dir;
|
||||
uint32_t mask;
|
||||
uint32_t ace_count;
|
||||
struct nfsacl_ace ace<>;
|
||||
uint32_t default_ace_count;
|
||||
struct nfsacl_ace default_ace<>;
|
||||
nfs_fh3 dir;
|
||||
unsigned int mask;
|
||||
unsigned int ace_count;
|
||||
struct nfsacl_ace ace<>;
|
||||
unsigned int default_ace_count;
|
||||
struct nfsacl_ace default_ace<>;
|
||||
};
|
||||
|
||||
struct SETACL3resok {
|
||||
|
|
17
nfs/nfsacl.c
17
nfs/nfsacl.c
|
@ -23,8 +23,7 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
|
@ -35,7 +34,7 @@ int rpc_nfsacl_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_NULL, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfsacl/null call");
|
||||
return -1;
|
||||
|
@ -55,14 +54,14 @@ int rpc_nfsacl_getacl_async(struct rpc_context *rpc, rpc_cb cb, struct GETACL3ar
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_GETACL, cb, private_data, (xdrproc_t)xdr_GETACL3res, sizeof(GETACL3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_GETACL, cb, private_data, (zdrproc_t)zdr_GETACL3res, sizeof(GETACL3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfsacl/getacl call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_GETACL3args(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode GETACL3args");
|
||||
if (zdr_GETACL3args(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode GETACL3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -80,14 +79,14 @@ int rpc_nfsacl_setacl_async(struct rpc_context *rpc, rpc_cb cb, struct SETACL3ar
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_SETACL, cb, private_data, (xdrproc_t)xdr_SETACL3res, sizeof(SETACL3res));
|
||||
pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_SETACL, cb, private_data, (zdrproc_t)zdr_SETACL3res, sizeof(SETACL3res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfsacl/setacl call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_SETACL3args(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode SETACL3args");
|
||||
if (zdr_SETACL3args(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode SETACL3args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
noinst_LTLIBRARIES = libnlm.la
|
||||
|
||||
nlm_SOURCES_GENERATED = libnfs-raw-nlm.c
|
||||
nlm_HEADERS_GENERATED = libnfs-raw-nlm.h
|
||||
nlm_SOURCES_GENERATED =
|
||||
nlm_HEADERS_GENERATED =
|
||||
nlm_GENERATED = $(nlm_SOURCES_GENERATED) $(nlm_HEADERS_GENERATED)
|
||||
|
||||
CLEANFILES = $(nlm_GENERATED) nlm-stamp
|
||||
|
@ -9,12 +9,13 @@ CLEANFILES = $(nlm_GENERATED) nlm-stamp
|
|||
libnlm_la_CPPFLAGS = -I$(abs_top_srcdir)/include
|
||||
libnlm_la_SOURCES = \
|
||||
$(nlm_SOURCES_GENERATED) \
|
||||
nlm.c
|
||||
nlm.c libnfs-raw-nlm.c
|
||||
|
||||
$(nlm_GENERATED) : nlm-stamp
|
||||
nlm-stamp : nlm.x
|
||||
rm -f $(nlm_GENERATED)
|
||||
rpcgen -h @RPCGENFLAGS@ $< > libnfs-raw-nlm.h
|
||||
rpcgen -c @RPCGENFLAGS@ $< | sed -e "s/#include \".*nlm.h\"/#include \"libnfs-raw-nlm.h\"/" > libnfs-raw-nlm.c
|
||||
touch nlm-stamp
|
||||
|
||||
|
||||
compile_rpc:
|
||||
rpcgen -h @RPCGENFLAGS@ nlm.x | sed -e "s/#include <rpc\/rpc.h>//" | sed -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-nlm.h
|
||||
rpcgen -c @RPCGENFLAGS@ nlm.x | sed -e "s/#include \".*nlm.h\"/#include \"libnfs-xdr.h\"\n#include \"libnfs-raw-nlm.h\"/" -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-nlm.c
|
||||
|
|
|
@ -0,0 +1,267 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs-raw-nlm.h"
|
||||
|
||||
bool_t
|
||||
zdr_nlm_fh4 (ZDR *zdrs, nlm_fh4 *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_bytes (zdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_nlm4_oh (ZDR *zdrs, nlm4_oh *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_string (zdrs, objp, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_nlm_cookie (ZDR *zdrs, nlm_cookie *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_bytes (zdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_nlmstat4 (ZDR *zdrs, nlmstat4 *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_enum (zdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_nlm4_holder (ZDR *zdrs, nlm4_holder *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_bool (zdrs, &objp->exclusive))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->svid))
|
||||
return FALSE;
|
||||
if (!zdr_nlm4_oh (zdrs, &objp->oh))
|
||||
return FALSE;
|
||||
if (!zdr_u_quad_t (zdrs, &objp->l_offset))
|
||||
return FALSE;
|
||||
if (!zdr_u_quad_t (zdrs, &objp->l_len))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_nlm4_lock (ZDR *zdrs, nlm4_lock *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_string (zdrs, &objp->caller_name, NLM_MAXNAME))
|
||||
return FALSE;
|
||||
if (!zdr_nlm_fh4 (zdrs, &objp->fh))
|
||||
return FALSE;
|
||||
if (!zdr_nlm4_oh (zdrs, &objp->oh))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->svid))
|
||||
return FALSE;
|
||||
if (!zdr_u_quad_t (zdrs, &objp->l_offset))
|
||||
return FALSE;
|
||||
if (!zdr_u_quad_t (zdrs, &objp->l_len))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_nlm4_share (ZDR *zdrs, nlm4_share *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_string (zdrs, &objp->caller_name, NLM_MAXNAME))
|
||||
return FALSE;
|
||||
if (!zdr_nlm_fh4 (zdrs, &objp->fh))
|
||||
return FALSE;
|
||||
if (!zdr_nlm4_oh (zdrs, &objp->oh))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->mode))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->access))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_nlm4_testres_denied (ZDR *zdrs, nlm4_testres_denied *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm4_holder (zdrs, &objp->holder))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_nlm4_testreply (ZDR *zdrs, nlm4_testreply *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlmstat4 (zdrs, &objp->status))
|
||||
return FALSE;
|
||||
switch (objp->status) {
|
||||
case NLM4_DENIED:
|
||||
if (!zdr_nlm4_testres_denied (zdrs, &objp->nlm4_testreply_u.lock))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_TESTres (ZDR *zdrs, NLM4_TESTres *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_nlm4_testreply (zdrs, &objp->reply))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_TESTargs (ZDR *zdrs, NLM4_TESTargs *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_bool (zdrs, &objp->exclusive))
|
||||
return FALSE;
|
||||
if (!zdr_nlm4_lock (zdrs, &objp->lock))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_CANCres (ZDR *zdrs, NLM4_CANCres *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_nlmstat4 (zdrs, &objp->status))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_CANCargs (ZDR *zdrs, NLM4_CANCargs *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_bool (zdrs, &objp->block))
|
||||
return FALSE;
|
||||
if (!zdr_bool (zdrs, &objp->exclusive))
|
||||
return FALSE;
|
||||
if (!zdr_nlm4_lock (zdrs, &objp->lock))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_UNLOCKres (ZDR *zdrs, NLM4_UNLOCKres *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_nlmstat4 (zdrs, &objp->status))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_UNLOCKargs (ZDR *zdrs, NLM4_UNLOCKargs *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_nlm4_lock (zdrs, &objp->lock))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_LOCKres (ZDR *zdrs, NLM4_LOCKres *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_nlmstat4 (zdrs, &objp->status))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_LOCKargs (ZDR *zdrs, NLM4_LOCKargs *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_bool (zdrs, &objp->block))
|
||||
return FALSE;
|
||||
if (!zdr_bool (zdrs, &objp->exclusive))
|
||||
return FALSE;
|
||||
if (!zdr_nlm4_lock (zdrs, &objp->lock))
|
||||
return FALSE;
|
||||
if (!zdr_bool (zdrs, &objp->reclaim))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->state))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_GRANTEDargs (ZDR *zdrs, NLM4_GRANTEDargs *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_bool (zdrs, &objp->exclusive))
|
||||
return FALSE;
|
||||
if (!zdr_nlm4_lock (zdrs, &objp->lock))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_NLM4_GRANTEDres (ZDR *zdrs, NLM4_GRANTEDres *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_nlm_cookie (zdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
if (!zdr_nlmstat4 (zdrs, &objp->status))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,315 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#ifndef _NLM_H_RPCGEN
|
||||
#define _NLM_H_RPCGEN
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct nlm_fh4 {
|
||||
struct {
|
||||
u_int data_len;
|
||||
char *data_val;
|
||||
} data;
|
||||
};
|
||||
typedef struct nlm_fh4 nlm_fh4;
|
||||
|
||||
typedef char *nlm4_oh;
|
||||
|
||||
struct nlm_cookie {
|
||||
struct {
|
||||
u_int data_len;
|
||||
char *data_val;
|
||||
} data;
|
||||
};
|
||||
typedef struct nlm_cookie nlm_cookie;
|
||||
|
||||
enum nlmstat4 {
|
||||
NLM4_GRANTED = 0,
|
||||
NLM4_DENIED = 1,
|
||||
NLM4_DENIED_NOLOCKS = 2,
|
||||
NLM4_BLOCKED = 3,
|
||||
NLM4_DENIED_GRACE_PERIOD = 4,
|
||||
NLM4_DEADLCK = 5,
|
||||
NLM4_ROFS = 6,
|
||||
NLM4_STALE_FH = 7,
|
||||
NLM4_FBIG = 8,
|
||||
NLM4_FAILED = 9,
|
||||
};
|
||||
typedef enum nlmstat4 nlmstat4;
|
||||
|
||||
struct nlm4_holder {
|
||||
bool_t exclusive;
|
||||
u_int svid;
|
||||
nlm4_oh oh;
|
||||
u_quad_t l_offset;
|
||||
u_quad_t l_len;
|
||||
};
|
||||
typedef struct nlm4_holder nlm4_holder;
|
||||
#define NLM_MAXNAME 256
|
||||
|
||||
struct nlm4_lock {
|
||||
char *caller_name;
|
||||
struct nlm_fh4 fh;
|
||||
nlm4_oh oh;
|
||||
u_int svid;
|
||||
u_quad_t l_offset;
|
||||
u_quad_t l_len;
|
||||
};
|
||||
typedef struct nlm4_lock nlm4_lock;
|
||||
|
||||
struct nlm4_share {
|
||||
char *caller_name;
|
||||
struct nlm_fh4 fh;
|
||||
nlm4_oh oh;
|
||||
u_int mode;
|
||||
u_int access;
|
||||
};
|
||||
typedef struct nlm4_share nlm4_share;
|
||||
|
||||
struct nlm4_testres_denied {
|
||||
nlm4_holder holder;
|
||||
};
|
||||
typedef struct nlm4_testres_denied nlm4_testres_denied;
|
||||
|
||||
struct nlm4_testreply {
|
||||
nlmstat4 status;
|
||||
union {
|
||||
nlm4_testres_denied lock;
|
||||
} nlm4_testreply_u;
|
||||
};
|
||||
typedef struct nlm4_testreply nlm4_testreply;
|
||||
|
||||
struct NLM4_TESTres {
|
||||
nlm_cookie cookie;
|
||||
nlm4_testreply reply;
|
||||
};
|
||||
typedef struct NLM4_TESTres NLM4_TESTres;
|
||||
|
||||
struct NLM4_TESTargs {
|
||||
nlm_cookie cookie;
|
||||
bool_t exclusive;
|
||||
nlm4_lock lock;
|
||||
};
|
||||
typedef struct NLM4_TESTargs NLM4_TESTargs;
|
||||
|
||||
struct NLM4_CANCres {
|
||||
nlm_cookie cookie;
|
||||
nlmstat4 status;
|
||||
};
|
||||
typedef struct NLM4_CANCres NLM4_CANCres;
|
||||
|
||||
struct NLM4_CANCargs {
|
||||
nlm_cookie cookie;
|
||||
bool_t block;
|
||||
bool_t exclusive;
|
||||
nlm4_lock lock;
|
||||
};
|
||||
typedef struct NLM4_CANCargs NLM4_CANCargs;
|
||||
|
||||
struct NLM4_UNLOCKres {
|
||||
nlm_cookie cookie;
|
||||
nlmstat4 status;
|
||||
};
|
||||
typedef struct NLM4_UNLOCKres NLM4_UNLOCKres;
|
||||
|
||||
struct NLM4_UNLOCKargs {
|
||||
nlm_cookie cookie;
|
||||
nlm4_lock lock;
|
||||
};
|
||||
typedef struct NLM4_UNLOCKargs NLM4_UNLOCKargs;
|
||||
|
||||
struct NLM4_LOCKres {
|
||||
nlm_cookie cookie;
|
||||
nlmstat4 status;
|
||||
};
|
||||
typedef struct NLM4_LOCKres NLM4_LOCKres;
|
||||
|
||||
struct NLM4_LOCKargs {
|
||||
nlm_cookie cookie;
|
||||
bool_t block;
|
||||
bool_t exclusive;
|
||||
nlm4_lock lock;
|
||||
bool_t reclaim;
|
||||
int state;
|
||||
};
|
||||
typedef struct NLM4_LOCKargs NLM4_LOCKargs;
|
||||
|
||||
struct NLM4_GRANTEDargs {
|
||||
nlm_cookie cookie;
|
||||
bool_t exclusive;
|
||||
nlm4_lock lock;
|
||||
};
|
||||
typedef struct NLM4_GRANTEDargs NLM4_GRANTEDargs;
|
||||
|
||||
struct NLM4_GRANTEDres {
|
||||
nlm_cookie cookie;
|
||||
nlmstat4 status;
|
||||
};
|
||||
typedef struct NLM4_GRANTEDres NLM4_GRANTEDres;
|
||||
|
||||
#define NLM_PROGRAM 100021
|
||||
#define NLM_V4 4
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define NLM4_NULL 0
|
||||
extern void * nlm4_null_4(void *, CLIENT *);
|
||||
extern void * nlm4_null_4_svc(void *, struct svc_req *);
|
||||
#define NLM4_TEST 1
|
||||
extern NLM4_TESTres * nlm4_test_4(NLM4_TESTargs *, CLIENT *);
|
||||
extern NLM4_TESTres * nlm4_test_4_svc(NLM4_TESTargs *, struct svc_req *);
|
||||
#define NLM4_LOCK 2
|
||||
extern NLM4_LOCKres * nlm4_lock_4(NLM4_LOCKargs *, CLIENT *);
|
||||
extern NLM4_LOCKres * nlm4_lock_4_svc(NLM4_LOCKargs *, struct svc_req *);
|
||||
#define NLM4_CANCEL 3
|
||||
extern NLM4_CANCres * nlm4_cancel_4(NLM4_CANCargs *, CLIENT *);
|
||||
extern NLM4_CANCres * nlm4_cancel_4_svc(NLM4_CANCargs *, struct svc_req *);
|
||||
#define NLM4_UNLOCK 4
|
||||
extern NLM4_UNLOCKres * nlm4_unlock_4(NLM4_UNLOCKargs *, CLIENT *);
|
||||
extern NLM4_UNLOCKres * nlm4_unlock_4_svc(NLM4_UNLOCKargs *, struct svc_req *);
|
||||
#define NLM4_GRANT 5
|
||||
extern NLM4_GRANTEDres * nlm4_grant_4(NLM4_GRANTEDargs *, CLIENT *);
|
||||
extern NLM4_GRANTEDres * nlm4_grant_4_svc(NLM4_GRANTEDargs *, struct svc_req *);
|
||||
#define NLM4_TEST_MSG 6
|
||||
extern void * nlm4_test_msg_4(NLM4_TESTargs *, CLIENT *);
|
||||
extern void * nlm4_test_msg_4_svc(NLM4_TESTargs *, struct svc_req *);
|
||||
#define NLM4_LOCK_MSG 7
|
||||
extern void * nlm4_lock_msg_4(NLM4_LOCKargs *, CLIENT *);
|
||||
extern void * nlm4_lock_msg_4_svc(NLM4_LOCKargs *, struct svc_req *);
|
||||
#define NLM4_CANCEL_MSG 8
|
||||
extern void * nlm4_cancel_msg_4(NLM4_CANCargs *, CLIENT *);
|
||||
extern void * nlm4_cancel_msg_4_svc(NLM4_CANCargs *, struct svc_req *);
|
||||
#define NLM4_UNLOCK_MSG 9
|
||||
extern void * nlm4_unlock_msg_4(NLM4_UNLOCKargs *, CLIENT *);
|
||||
extern void * nlm4_unlock_msg_4_svc(NLM4_UNLOCKargs *, struct svc_req *);
|
||||
#define NLM4_GRANT_MSG 10
|
||||
extern void * nlm4_grant_msg_4(NLM4_GRANTEDargs *, CLIENT *);
|
||||
extern void * nlm4_grant_msg_4_svc(NLM4_GRANTEDargs *, struct svc_req *);
|
||||
#define NLM4_TEST_RES 11
|
||||
extern void * nlm4_test_res_4(NLM4_TESTres *, CLIENT *);
|
||||
extern void * nlm4_test_res_4_svc(NLM4_TESTres *, struct svc_req *);
|
||||
#define NLM4_LOCK_RES 12
|
||||
extern void * nlm4_lock_res_4(NLM4_LOCKres *, CLIENT *);
|
||||
extern void * nlm4_lock_res_4_svc(NLM4_LOCKres *, struct svc_req *);
|
||||
#define NLM4_CANCEL_RES 13
|
||||
extern void * nlm4_cancel_res_4(NLM4_CANCres *, CLIENT *);
|
||||
extern void * nlm4_cancel_res_4_svc(NLM4_CANCres *, struct svc_req *);
|
||||
#define NLM4_UNLOCK_RES 14
|
||||
extern void * nlm4_unlock_res_4(NLM4_UNLOCKres *, CLIENT *);
|
||||
extern void * nlm4_unlock_res_4_svc(NLM4_UNLOCKres *, struct svc_req *);
|
||||
#define NLM4_GRANT_RES 15
|
||||
extern void * nlm4_grant_res_4(NLM4_GRANTEDres *, CLIENT *);
|
||||
extern void * nlm4_grant_res_4_svc(NLM4_GRANTEDres *, struct svc_req *);
|
||||
extern int nlm_program_4_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
|
||||
|
||||
#else /* K&R C */
|
||||
#define NLM4_NULL 0
|
||||
extern void * nlm4_null_4();
|
||||
extern void * nlm4_null_4_svc();
|
||||
#define NLM4_TEST 1
|
||||
extern NLM4_TESTres * nlm4_test_4();
|
||||
extern NLM4_TESTres * nlm4_test_4_svc();
|
||||
#define NLM4_LOCK 2
|
||||
extern NLM4_LOCKres * nlm4_lock_4();
|
||||
extern NLM4_LOCKres * nlm4_lock_4_svc();
|
||||
#define NLM4_CANCEL 3
|
||||
extern NLM4_CANCres * nlm4_cancel_4();
|
||||
extern NLM4_CANCres * nlm4_cancel_4_svc();
|
||||
#define NLM4_UNLOCK 4
|
||||
extern NLM4_UNLOCKres * nlm4_unlock_4();
|
||||
extern NLM4_UNLOCKres * nlm4_unlock_4_svc();
|
||||
#define NLM4_GRANT 5
|
||||
extern NLM4_GRANTEDres * nlm4_grant_4();
|
||||
extern NLM4_GRANTEDres * nlm4_grant_4_svc();
|
||||
#define NLM4_TEST_MSG 6
|
||||
extern void * nlm4_test_msg_4();
|
||||
extern void * nlm4_test_msg_4_svc();
|
||||
#define NLM4_LOCK_MSG 7
|
||||
extern void * nlm4_lock_msg_4();
|
||||
extern void * nlm4_lock_msg_4_svc();
|
||||
#define NLM4_CANCEL_MSG 8
|
||||
extern void * nlm4_cancel_msg_4();
|
||||
extern void * nlm4_cancel_msg_4_svc();
|
||||
#define NLM4_UNLOCK_MSG 9
|
||||
extern void * nlm4_unlock_msg_4();
|
||||
extern void * nlm4_unlock_msg_4_svc();
|
||||
#define NLM4_GRANT_MSG 10
|
||||
extern void * nlm4_grant_msg_4();
|
||||
extern void * nlm4_grant_msg_4_svc();
|
||||
#define NLM4_TEST_RES 11
|
||||
extern void * nlm4_test_res_4();
|
||||
extern void * nlm4_test_res_4_svc();
|
||||
#define NLM4_LOCK_RES 12
|
||||
extern void * nlm4_lock_res_4();
|
||||
extern void * nlm4_lock_res_4_svc();
|
||||
#define NLM4_CANCEL_RES 13
|
||||
extern void * nlm4_cancel_res_4();
|
||||
extern void * nlm4_cancel_res_4_svc();
|
||||
#define NLM4_UNLOCK_RES 14
|
||||
extern void * nlm4_unlock_res_4();
|
||||
extern void * nlm4_unlock_res_4_svc();
|
||||
#define NLM4_GRANT_RES 15
|
||||
extern void * nlm4_grant_res_4();
|
||||
extern void * nlm4_grant_res_4_svc();
|
||||
extern int nlm_program_4_freeresult ();
|
||||
#endif /* K&R C */
|
||||
|
||||
/* the zdr functions */
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
extern bool_t zdr_nlm_fh4 (ZDR *, nlm_fh4*);
|
||||
extern bool_t zdr_nlm4_oh (ZDR *, nlm4_oh*);
|
||||
extern bool_t zdr_nlm_cookie (ZDR *, nlm_cookie*);
|
||||
extern bool_t zdr_nlmstat4 (ZDR *, nlmstat4*);
|
||||
extern bool_t zdr_nlm4_holder (ZDR *, nlm4_holder*);
|
||||
extern bool_t zdr_nlm4_lock (ZDR *, nlm4_lock*);
|
||||
extern bool_t zdr_nlm4_share (ZDR *, nlm4_share*);
|
||||
extern bool_t zdr_nlm4_testres_denied (ZDR *, nlm4_testres_denied*);
|
||||
extern bool_t zdr_nlm4_testreply (ZDR *, nlm4_testreply*);
|
||||
extern bool_t zdr_NLM4_TESTres (ZDR *, NLM4_TESTres*);
|
||||
extern bool_t zdr_NLM4_TESTargs (ZDR *, NLM4_TESTargs*);
|
||||
extern bool_t zdr_NLM4_CANCres (ZDR *, NLM4_CANCres*);
|
||||
extern bool_t zdr_NLM4_CANCargs (ZDR *, NLM4_CANCargs*);
|
||||
extern bool_t zdr_NLM4_UNLOCKres (ZDR *, NLM4_UNLOCKres*);
|
||||
extern bool_t zdr_NLM4_UNLOCKargs (ZDR *, NLM4_UNLOCKargs*);
|
||||
extern bool_t zdr_NLM4_LOCKres (ZDR *, NLM4_LOCKres*);
|
||||
extern bool_t zdr_NLM4_LOCKargs (ZDR *, NLM4_LOCKargs*);
|
||||
extern bool_t zdr_NLM4_GRANTEDargs (ZDR *, NLM4_GRANTEDargs*);
|
||||
extern bool_t zdr_NLM4_GRANTEDres (ZDR *, NLM4_GRANTEDres*);
|
||||
|
||||
#else /* K&R C */
|
||||
extern bool_t zdr_nlm_fh4 ();
|
||||
extern bool_t zdr_nlm4_oh ();
|
||||
extern bool_t zdr_nlm_cookie ();
|
||||
extern bool_t zdr_nlmstat4 ();
|
||||
extern bool_t zdr_nlm4_holder ();
|
||||
extern bool_t zdr_nlm4_lock ();
|
||||
extern bool_t zdr_nlm4_share ();
|
||||
extern bool_t zdr_nlm4_testres_denied ();
|
||||
extern bool_t zdr_nlm4_testreply ();
|
||||
extern bool_t zdr_NLM4_TESTres ();
|
||||
extern bool_t zdr_NLM4_TESTargs ();
|
||||
extern bool_t zdr_NLM4_CANCres ();
|
||||
extern bool_t zdr_NLM4_CANCargs ();
|
||||
extern bool_t zdr_NLM4_UNLOCKres ();
|
||||
extern bool_t zdr_NLM4_UNLOCKargs ();
|
||||
extern bool_t zdr_NLM4_LOCKres ();
|
||||
extern bool_t zdr_NLM4_LOCKargs ();
|
||||
extern bool_t zdr_NLM4_GRANTEDargs ();
|
||||
extern bool_t zdr_NLM4_GRANTEDres ();
|
||||
|
||||
#endif /* K&R C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_NLM_H_RPCGEN */
|
29
nlm/nlm.c
29
nlm/nlm.c
|
@ -21,8 +21,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
|
@ -32,7 +31,7 @@ int rpc_nlm4_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_NULL, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/null call");
|
||||
return -1;
|
||||
|
@ -51,14 +50,14 @@ int rpc_nlm4_test_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_TESTargs
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_TEST, cb, private_data, (xdrproc_t)xdr_NLM4_TESTres, sizeof(NLM4_TESTres));
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_TEST, cb, private_data, (zdrproc_t)zdr_NLM4_TESTres, sizeof(NLM4_TESTres));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/test call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_NLM4_TESTargs(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode NLM4_TESTargs");
|
||||
if (zdr_NLM4_TESTargs(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode NLM4_TESTargs");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -76,14 +75,14 @@ int rpc_nlm4_lock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_LOCKargs
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_LOCK, cb, private_data, (xdrproc_t)xdr_NLM4_LOCKres, sizeof(NLM4_LOCKres));
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_LOCK, cb, private_data, (zdrproc_t)zdr_NLM4_LOCKres, sizeof(NLM4_LOCKres));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/lock call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_NLM4_LOCKargs(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode NLM4_LOCKargs");
|
||||
if (zdr_NLM4_LOCKargs(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode NLM4_LOCKargs");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -101,14 +100,14 @@ int rpc_nlm4_cancel_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_CANCar
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_CANCEL, cb, private_data, (xdrproc_t)xdr_NLM4_CANCres, sizeof(NLM4_CANCres));
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_CANCEL, cb, private_data, (zdrproc_t)zdr_NLM4_CANCres, sizeof(NLM4_CANCres));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/cancel call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_NLM4_CANCargs(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode NLM4_CANCargs");
|
||||
if (zdr_NLM4_CANCargs(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode NLM4_CANCargs");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -126,14 +125,14 @@ int rpc_nlm4_unlock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_UNLOCK
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_UNLOCK, cb, private_data, (xdrproc_t)xdr_NLM4_UNLOCKres, sizeof(NLM4_UNLOCKres));
|
||||
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_UNLOCK, cb, private_data, (zdrproc_t)zdr_NLM4_UNLOCKres, sizeof(NLM4_UNLOCKres));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/unlock call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdr_NLM4_UNLOCKargs(&pdu->xdr, args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode NLM4_UNLOCKargs");
|
||||
if (zdr_NLM4_UNLOCKargs(&pdu->zdr, args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode NLM4_UNLOCKargs");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
noinst_LTLIBRARIES = libportmap.la
|
||||
|
||||
portmap_SOURCES_GENERATED = libnfs-raw-portmap.c
|
||||
portmap_HEADERS_GENERATED = libnfs-raw-portmap.h
|
||||
portmap_SOURCES_GENERATED =
|
||||
portmap_HEADERS_GENERATED =
|
||||
portmap_GENERATED = $(portmap_SOURCES_GENERATED) $(portmap_HEADERS_GENERATED)
|
||||
|
||||
CLEANFILES = $(portmap_GENERATED) portmap-stamp
|
||||
|
@ -9,12 +9,13 @@ CLEANFILES = $(portmap_GENERATED) portmap-stamp
|
|||
libportmap_la_CPPFLAGS = -I$(abs_top_srcdir)/include
|
||||
libportmap_la_SOURCES = \
|
||||
$(portmap_SOURCES_GENERATED) \
|
||||
portmap.c
|
||||
portmap.c libnfs-raw-portmap.c
|
||||
|
||||
$(portmap_GENERATED) : portmap-stamp
|
||||
portmap-stamp : portmap.x
|
||||
rm -f $(portmap_GENERATED)
|
||||
rpcgen -h @RPCGENFLAGS@ $< > libnfs-raw-portmap.h
|
||||
rpcgen -c @RPCGENFLAGS@ $< | sed -e "s/#include \".*portmap.h\"/#include \"libnfs-raw-portmap.h\"/" > libnfs-raw-portmap.c
|
||||
touch portmap-stamp
|
||||
|
||||
|
||||
compile_rpc:
|
||||
rpcgen -h @RPCGENFLAGS@ portmap.x | sed -e "s/#include <rpc\/rpc.h>//" | sed -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-portmap.h
|
||||
rpcgen -c @RPCGENFLAGS@ portmap.x | sed -e "s/#include \".*portmap.h\"/#include \"libnfs-zdr.h\"\n#include \"libnfs-raw-portmap.h\"/" -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-portmap.c
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs-raw-portmap.h"
|
||||
|
||||
bool_t
|
||||
zdr_pmap_mapping (ZDR *zdrs, pmap_mapping *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
|
||||
if (zdrs->x_op == ZDR_ENCODE) {
|
||||
buf = ZDR_INLINE (zdrs, 4 * BYTES_PER_ZDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!zdr_u_int (zdrs, &objp->prog))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->vers))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->prot))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->port))
|
||||
return FALSE;
|
||||
} else {
|
||||
IZDR_PUT_U_LONG(buf, objp->prog);
|
||||
IZDR_PUT_U_LONG(buf, objp->vers);
|
||||
IZDR_PUT_U_LONG(buf, objp->prot);
|
||||
IZDR_PUT_U_LONG(buf, objp->port);
|
||||
}
|
||||
return TRUE;
|
||||
} else if (zdrs->x_op == ZDR_DECODE) {
|
||||
buf = ZDR_INLINE (zdrs, 4 * BYTES_PER_ZDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!zdr_u_int (zdrs, &objp->prog))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->vers))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->prot))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->port))
|
||||
return FALSE;
|
||||
} else {
|
||||
objp->prog = IZDR_GET_U_LONG(buf);
|
||||
objp->vers = IZDR_GET_U_LONG(buf);
|
||||
objp->prot = IZDR_GET_U_LONG(buf);
|
||||
objp->port = IZDR_GET_U_LONG(buf);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!zdr_u_int (zdrs, &objp->prog))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->vers))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->prot))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->port))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_pmap_call_args (ZDR *zdrs, pmap_call_args *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
|
||||
if (zdrs->x_op == ZDR_ENCODE) {
|
||||
buf = ZDR_INLINE (zdrs, 3 * BYTES_PER_ZDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!zdr_u_int (zdrs, &objp->prog))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->vers))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->proc))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
IZDR_PUT_U_LONG(buf, objp->prog);
|
||||
IZDR_PUT_U_LONG(buf, objp->vers);
|
||||
IZDR_PUT_U_LONG(buf, objp->proc);
|
||||
}
|
||||
if (!zdr_bytes (zdrs, (char **)&objp->args.args_val, (u_int *) &objp->args.args_len, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
} else if (zdrs->x_op == ZDR_DECODE) {
|
||||
buf = ZDR_INLINE (zdrs, 3 * BYTES_PER_ZDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!zdr_u_int (zdrs, &objp->prog))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->vers))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->proc))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
objp->prog = IZDR_GET_U_LONG(buf);
|
||||
objp->vers = IZDR_GET_U_LONG(buf);
|
||||
objp->proc = IZDR_GET_U_LONG(buf);
|
||||
}
|
||||
if (!zdr_bytes (zdrs, (char **)&objp->args.args_val, (u_int *) &objp->args.args_len, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!zdr_u_int (zdrs, &objp->prog))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->vers))
|
||||
return FALSE;
|
||||
if (!zdr_u_int (zdrs, &objp->proc))
|
||||
return FALSE;
|
||||
if (!zdr_bytes (zdrs, (char **)&objp->args.args_val, (u_int *) &objp->args.args_len, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_pmap_call_result (ZDR *zdrs, pmap_call_result *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_u_int (zdrs, &objp->port))
|
||||
return FALSE;
|
||||
if (!zdr_bytes (zdrs, (char **)&objp->res.res_val, (u_int *) &objp->res.res_len, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#ifndef _PORTMAP_H_RPCGEN
|
||||
#define _PORTMAP_H_RPCGEN
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PMAP_PORT 111
|
||||
|
||||
struct pmap_mapping {
|
||||
u_int prog;
|
||||
u_int vers;
|
||||
u_int prot;
|
||||
u_int port;
|
||||
};
|
||||
typedef struct pmap_mapping pmap_mapping;
|
||||
|
||||
struct pmap_call_args {
|
||||
u_int prog;
|
||||
u_int vers;
|
||||
u_int proc;
|
||||
struct {
|
||||
u_int args_len;
|
||||
char *args_val;
|
||||
} args;
|
||||
};
|
||||
typedef struct pmap_call_args pmap_call_args;
|
||||
|
||||
struct pmap_call_result {
|
||||
u_int port;
|
||||
struct {
|
||||
u_int res_len;
|
||||
char *res_val;
|
||||
} res;
|
||||
};
|
||||
typedef struct pmap_call_result pmap_call_result;
|
||||
|
||||
#define PMAP_PROGRAM 100000
|
||||
#define PMAP_V2 2
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define PMAP_NULL 0
|
||||
extern void * pmap_null_2(void *, CLIENT *);
|
||||
extern void * pmap_null_2_svc(void *, struct svc_req *);
|
||||
#define PMAP_SET 1
|
||||
extern bool_t * pmap_set_2(pmap_mapping *, CLIENT *);
|
||||
extern bool_t * pmap_set_2_svc(pmap_mapping *, struct svc_req *);
|
||||
#define PMAP_UNSET 2
|
||||
extern bool_t * pmap_unset_2(pmap_mapping *, CLIENT *);
|
||||
extern bool_t * pmap_unset_2_svc(pmap_mapping *, struct svc_req *);
|
||||
#define PMAP_GETPORT 3
|
||||
extern u_int * pmap_getport_2(pmap_mapping *, CLIENT *);
|
||||
extern u_int * pmap_getport_2_svc(pmap_mapping *, struct svc_req *);
|
||||
#define PMAP_CALLIT 5
|
||||
extern pmap_call_result * pmap_callit_2(pmap_call_args *, CLIENT *);
|
||||
extern pmap_call_result * pmap_callit_2_svc(pmap_call_args *, struct svc_req *);
|
||||
extern int pmap_program_2_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
|
||||
|
||||
#else /* K&R C */
|
||||
#define PMAP_NULL 0
|
||||
extern void * pmap_null_2();
|
||||
extern void * pmap_null_2_svc();
|
||||
#define PMAP_SET 1
|
||||
extern bool_t * pmap_set_2();
|
||||
extern bool_t * pmap_set_2_svc();
|
||||
#define PMAP_UNSET 2
|
||||
extern bool_t * pmap_unset_2();
|
||||
extern bool_t * pmap_unset_2_svc();
|
||||
#define PMAP_GETPORT 3
|
||||
extern u_int * pmap_getport_2();
|
||||
extern u_int * pmap_getport_2_svc();
|
||||
#define PMAP_CALLIT 5
|
||||
extern pmap_call_result * pmap_callit_2();
|
||||
extern pmap_call_result * pmap_callit_2_svc();
|
||||
extern int pmap_program_2_freeresult ();
|
||||
#endif /* K&R C */
|
||||
|
||||
/* the zdr functions */
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
extern bool_t zdr_pmap_mapping (ZDR *, pmap_mapping*);
|
||||
extern bool_t zdr_pmap_call_args (ZDR *, pmap_call_args*);
|
||||
extern bool_t zdr_pmap_call_result (ZDR *, pmap_call_result*);
|
||||
|
||||
#else /* K&R C */
|
||||
extern bool_t zdr_pmap_mapping ();
|
||||
extern bool_t zdr_pmap_call_args ();
|
||||
extern bool_t zdr_pmap_call_result ();
|
||||
|
||||
#endif /* K&R C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_PORTMAP_H_RPCGEN */
|
|
@ -19,8 +19,7 @@
|
|||
#endif/*WIN32*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
|
@ -31,7 +30,7 @@ int rpc_pmap_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_NULL, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for portmap/null call");
|
||||
return -1;
|
||||
|
@ -51,7 +50,7 @@ int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, in
|
|||
struct rpc_pdu *pdu;
|
||||
struct pmap_mapping m;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_GETPORT, cb, private_data, (xdrproc_t)xdr_int, sizeof(uint32_t));
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_GETPORT, cb, private_data, (zdrproc_t)zdr_int, sizeof(uint32_t));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for portmap/getport call");
|
||||
return -1;
|
||||
|
@ -61,8 +60,8 @@ int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, in
|
|||
m.vers = version;
|
||||
m.prot = protocol;
|
||||
m.port = 0;
|
||||
if (xdr_pmap_mapping(&pdu->xdr, &m) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode data for portmap/getport call");
|
||||
if (zdr_pmap_mapping(&pdu->zdr, &m) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode data for portmap/getport call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -1;
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ int rpc_pmap_set_async(struct rpc_context *rpc, int program, int version, int pr
|
|||
struct rpc_pdu *pdu;
|
||||
struct pmap_mapping m;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_SET, cb, private_data, (xdrproc_t)xdr_int, sizeof(uint32_t));
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_SET, cb, private_data, (zdrproc_t)zdr_int, sizeof(uint32_t));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for portmap/set call");
|
||||
return -1;
|
||||
|
@ -91,8 +90,8 @@ int rpc_pmap_set_async(struct rpc_context *rpc, int program, int version, int pr
|
|||
m.vers = version;
|
||||
m.prot = protocol;
|
||||
m.port = port;
|
||||
if (xdr_pmap_mapping(&pdu->xdr, &m) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode data for portmap/set call");
|
||||
if (zdr_pmap_mapping(&pdu->zdr, &m) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode data for portmap/set call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -1;
|
||||
}
|
||||
|
@ -111,7 +110,7 @@ int rpc_pmap_unset_async(struct rpc_context *rpc, int program, int version, int
|
|||
struct rpc_pdu *pdu;
|
||||
struct pmap_mapping m;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_UNSET, cb, private_data, (xdrproc_t)xdr_int, sizeof(uint32_t));
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_UNSET, cb, private_data, (zdrproc_t)zdr_int, sizeof(uint32_t));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for portmap/unset call");
|
||||
return -1;
|
||||
|
@ -121,8 +120,8 @@ int rpc_pmap_unset_async(struct rpc_context *rpc, int program, int version, int
|
|||
m.vers = version;
|
||||
m.prot = protocol;
|
||||
m.port = port;
|
||||
if (xdr_pmap_mapping(&pdu->xdr, &m) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode data for portmap/unset call");
|
||||
if (zdr_pmap_mapping(&pdu->zdr, &m) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode data for portmap/unset call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -1;
|
||||
}
|
||||
|
@ -141,7 +140,7 @@ int rpc_pmap_callit_async(struct rpc_context *rpc, int program, int version, int
|
|||
struct rpc_pdu *pdu;
|
||||
struct pmap_call_args ca;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_CALLIT, cb, private_data, (xdrproc_t)xdr_pmap_call_result, sizeof(pmap_call_result));
|
||||
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_CALLIT, cb, private_data, (zdrproc_t)zdr_pmap_call_result, sizeof(pmap_call_result));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for portmap/callit call");
|
||||
return -1;
|
||||
|
@ -153,8 +152,8 @@ int rpc_pmap_callit_async(struct rpc_context *rpc, int program, int version, int
|
|||
ca.args.args_len = datalen;
|
||||
ca.args.args_val = data;
|
||||
|
||||
if (xdr_pmap_call_args(&pdu->xdr, &ca) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode data for portmap/callit call");
|
||||
if (zdr_pmap_call_args(&pdu->zdr, &ca) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode data for portmap/callit call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
noinst_LTLIBRARIES = librquota.la
|
||||
|
||||
rquota_SOURCES_GENERATED = libnfs-raw-rquota.c
|
||||
rquota_HEADERS_GENERATED = libnfs-raw-rquota.h
|
||||
rquota_SOURCES_GENERATED =
|
||||
rquota_HEADERS_GENERATED =
|
||||
rquota_GENERATED = $(rquota_SOURCES_GENERATED) $(rquota_HEADERS_GENERATED)
|
||||
|
||||
CLEANFILES = $(rquota_GENERATED) rquota-stamp
|
||||
|
@ -9,12 +9,13 @@ CLEANFILES = $(rquota_GENERATED) rquota-stamp
|
|||
librquota_la_CPPFLAGS = -I$(abs_top_srcdir)/include
|
||||
librquota_la_SOURCES = \
|
||||
$(rquota_SOURCES_GENERATED) \
|
||||
rquota.c
|
||||
rquota.c libnfs-raw-rquota.c
|
||||
|
||||
$(rquota_GENERATED) : rquota-stamp
|
||||
rquota-stamp : rquota.x
|
||||
rm -f $(rquota_GENERATED)
|
||||
rpcgen -h @RPCGENFLAGS@ $< > libnfs-raw-rquota.h
|
||||
rpcgen -c @RPCGENFLAGS@ $< | sed -e "s/#include \".*rquota.h\"/#include \"libnfs-raw-rquota.h\"/" > libnfs-raw-rquota.c
|
||||
touch rquota-stamp
|
||||
|
||||
compile_rpc:
|
||||
rpcgen -h @RPCGENFLAGS@ rquota.x | sed -e "s/#include <rpc\/rpc.h>//" | sed -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-rquota.h
|
||||
rpcgen -c @RPCGENFLAGS@ rquota.x | sed -e "s/#include \".*rquota.h\"/#include \"libnfs-xdr.h\"\n#include \"libnfs-raw-rquota.h\"/" -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-rquota.c
|
||||
|
|
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs-raw-rquota.h"
|
||||
|
||||
bool_t
|
||||
zdr_rquotastat (ZDR *zdrs, rquotastat *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_enum (zdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_exportpath (ZDR *zdrs, exportpath *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_string (zdrs, objp, RQUOTAPATHLEN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_GETQUOTA1args (ZDR *zdrs, GETQUOTA1args *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_exportpath (zdrs, &objp->export))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->uid))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_quotatype (ZDR *zdrs, quotatype *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_enum (zdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_GETQUOTA2args (ZDR *zdrs, GETQUOTA2args *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_exportpath (zdrs, &objp->export))
|
||||
return FALSE;
|
||||
if (!zdr_quotatype (zdrs, &objp->type))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->uid))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_GETQUOTA1res_ok (ZDR *zdrs, GETQUOTA1res_ok *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
|
||||
if (zdrs->x_op == ZDR_ENCODE) {
|
||||
buf = ZDR_INLINE (zdrs, 10 * BYTES_PER_ZDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!zdr_int (zdrs, &objp->bsize))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->active))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->bhardlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->bsoftlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->curblocks))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->fhardlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->fsoftlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->curfiles))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->btimeleft))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->ftimeleft))
|
||||
return FALSE;
|
||||
} else {
|
||||
IZDR_PUT_LONG(buf, objp->bsize);
|
||||
IZDR_PUT_LONG(buf, objp->active);
|
||||
IZDR_PUT_LONG(buf, objp->bhardlimit);
|
||||
IZDR_PUT_LONG(buf, objp->bsoftlimit);
|
||||
IZDR_PUT_LONG(buf, objp->curblocks);
|
||||
IZDR_PUT_LONG(buf, objp->fhardlimit);
|
||||
IZDR_PUT_LONG(buf, objp->fsoftlimit);
|
||||
IZDR_PUT_LONG(buf, objp->curfiles);
|
||||
IZDR_PUT_LONG(buf, objp->btimeleft);
|
||||
IZDR_PUT_LONG(buf, objp->ftimeleft);
|
||||
}
|
||||
return TRUE;
|
||||
} else if (zdrs->x_op == ZDR_DECODE) {
|
||||
buf = ZDR_INLINE (zdrs, 10 * BYTES_PER_ZDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!zdr_int (zdrs, &objp->bsize))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->active))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->bhardlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->bsoftlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->curblocks))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->fhardlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->fsoftlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->curfiles))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->btimeleft))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->ftimeleft))
|
||||
return FALSE;
|
||||
} else {
|
||||
objp->bsize = IZDR_GET_LONG(buf);
|
||||
objp->active = IZDR_GET_LONG(buf);
|
||||
objp->bhardlimit = IZDR_GET_LONG(buf);
|
||||
objp->bsoftlimit = IZDR_GET_LONG(buf);
|
||||
objp->curblocks = IZDR_GET_LONG(buf);
|
||||
objp->fhardlimit = IZDR_GET_LONG(buf);
|
||||
objp->fsoftlimit = IZDR_GET_LONG(buf);
|
||||
objp->curfiles = IZDR_GET_LONG(buf);
|
||||
objp->btimeleft = IZDR_GET_LONG(buf);
|
||||
objp->ftimeleft = IZDR_GET_LONG(buf);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!zdr_int (zdrs, &objp->bsize))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->active))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->bhardlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->bsoftlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->curblocks))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->fhardlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->fsoftlimit))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->curfiles))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->btimeleft))
|
||||
return FALSE;
|
||||
if (!zdr_int (zdrs, &objp->ftimeleft))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
zdr_GETQUOTA1res (ZDR *zdrs, GETQUOTA1res *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
if (!zdr_rquotastat (zdrs, &objp->status))
|
||||
return FALSE;
|
||||
switch (objp->status) {
|
||||
case RQUOTA_OK:
|
||||
if (!zdr_GETQUOTA1res_ok (zdrs, &objp->GETQUOTA1res_u.quota))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#ifndef _RQUOTA_H_RPCGEN
|
||||
#define _RQUOTA_H_RPCGEN
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RQUOTAPATHLEN 1024
|
||||
|
||||
enum rquotastat {
|
||||
RQUOTA_OK = 1,
|
||||
RQUOTA_NOQUOTA = 2,
|
||||
RQUOTA_EPERM = 3,
|
||||
};
|
||||
typedef enum rquotastat rquotastat;
|
||||
|
||||
typedef char *exportpath;
|
||||
|
||||
struct GETQUOTA1args {
|
||||
exportpath export;
|
||||
int uid;
|
||||
};
|
||||
typedef struct GETQUOTA1args GETQUOTA1args;
|
||||
|
||||
enum quotatype {
|
||||
RQUOTA_TYPE_UID = 0,
|
||||
RQUOTA_TYPE_GID = 1,
|
||||
};
|
||||
typedef enum quotatype quotatype;
|
||||
|
||||
struct GETQUOTA2args {
|
||||
exportpath export;
|
||||
quotatype type;
|
||||
int uid;
|
||||
};
|
||||
typedef struct GETQUOTA2args GETQUOTA2args;
|
||||
|
||||
struct GETQUOTA1res_ok {
|
||||
int bsize;
|
||||
int active;
|
||||
int bhardlimit;
|
||||
int bsoftlimit;
|
||||
int curblocks;
|
||||
int fhardlimit;
|
||||
int fsoftlimit;
|
||||
int curfiles;
|
||||
int btimeleft;
|
||||
int ftimeleft;
|
||||
};
|
||||
typedef struct GETQUOTA1res_ok GETQUOTA1res_ok;
|
||||
|
||||
struct GETQUOTA1res {
|
||||
rquotastat status;
|
||||
union {
|
||||
GETQUOTA1res_ok quota;
|
||||
} GETQUOTA1res_u;
|
||||
};
|
||||
typedef struct GETQUOTA1res GETQUOTA1res;
|
||||
|
||||
#define RQUOTA_PROGRAM 100011
|
||||
#define RQUOTA_V1 1
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define RQUOTA1_NULL 0
|
||||
extern void * rquota1_null_1(void *, CLIENT *);
|
||||
extern void * rquota1_null_1_svc(void *, struct svc_req *);
|
||||
#define RQUOTA1_GETQUOTA 1
|
||||
extern GETQUOTA1res * rquota1_getquota_1(GETQUOTA1args *, CLIENT *);
|
||||
extern GETQUOTA1res * rquota1_getquota_1_svc(GETQUOTA1args *, struct svc_req *);
|
||||
#define RQUOTA1_GETACTIVEQUOTA 2
|
||||
extern GETQUOTA1res * rquota1_getactivequota_1(GETQUOTA1args *, CLIENT *);
|
||||
extern GETQUOTA1res * rquota1_getactivequota_1_svc(GETQUOTA1args *, struct svc_req *);
|
||||
extern int rquota_program_1_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
|
||||
|
||||
#else /* K&R C */
|
||||
#define RQUOTA1_NULL 0
|
||||
extern void * rquota1_null_1();
|
||||
extern void * rquota1_null_1_svc();
|
||||
#define RQUOTA1_GETQUOTA 1
|
||||
extern GETQUOTA1res * rquota1_getquota_1();
|
||||
extern GETQUOTA1res * rquota1_getquota_1_svc();
|
||||
#define RQUOTA1_GETACTIVEQUOTA 2
|
||||
extern GETQUOTA1res * rquota1_getactivequota_1();
|
||||
extern GETQUOTA1res * rquota1_getactivequota_1_svc();
|
||||
extern int rquota_program_1_freeresult ();
|
||||
#endif /* K&R C */
|
||||
#define RQUOTA_V2 2
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define RQUOTA2_NULL 0
|
||||
extern void * rquota2_null_2(void *, CLIENT *);
|
||||
extern void * rquota2_null_2_svc(void *, struct svc_req *);
|
||||
#define RQUOTA2_GETQUOTA 1
|
||||
extern GETQUOTA1res * rquota2_getquota_2(GETQUOTA2args *, CLIENT *);
|
||||
extern GETQUOTA1res * rquota2_getquota_2_svc(GETQUOTA2args *, struct svc_req *);
|
||||
#define RQUOTA2_GETACTIVEQUOTA 2
|
||||
extern GETQUOTA1res * rquota2_getactivequota_2(GETQUOTA2args *, CLIENT *);
|
||||
extern GETQUOTA1res * rquota2_getactivequota_2_svc(GETQUOTA2args *, struct svc_req *);
|
||||
extern int rquota_program_2_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
|
||||
|
||||
#else /* K&R C */
|
||||
#define RQUOTA2_NULL 0
|
||||
extern void * rquota2_null_2();
|
||||
extern void * rquota2_null_2_svc();
|
||||
#define RQUOTA2_GETQUOTA 1
|
||||
extern GETQUOTA1res * rquota2_getquota_2();
|
||||
extern GETQUOTA1res * rquota2_getquota_2_svc();
|
||||
#define RQUOTA2_GETACTIVEQUOTA 2
|
||||
extern GETQUOTA1res * rquota2_getactivequota_2();
|
||||
extern GETQUOTA1res * rquota2_getactivequota_2_svc();
|
||||
extern int rquota_program_2_freeresult ();
|
||||
#endif /* K&R C */
|
||||
|
||||
/* the zdr functions */
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
extern bool_t zdr_rquotastat (ZDR *, rquotastat*);
|
||||
extern bool_t zdr_exportpath (ZDR *, exportpath*);
|
||||
extern bool_t zdr_GETQUOTA1args (ZDR *, GETQUOTA1args*);
|
||||
extern bool_t zdr_quotatype (ZDR *, quotatype*);
|
||||
extern bool_t zdr_GETQUOTA2args (ZDR *, GETQUOTA2args*);
|
||||
extern bool_t zdr_GETQUOTA1res_ok (ZDR *, GETQUOTA1res_ok*);
|
||||
extern bool_t zdr_GETQUOTA1res (ZDR *, GETQUOTA1res*);
|
||||
|
||||
#else /* K&R C */
|
||||
extern bool_t zdr_rquotastat ();
|
||||
extern bool_t zdr_exportpath ();
|
||||
extern bool_t zdr_GETQUOTA1args ();
|
||||
extern bool_t zdr_quotatype ();
|
||||
extern bool_t zdr_GETQUOTA2args ();
|
||||
extern bool_t zdr_GETQUOTA1res_ok ();
|
||||
extern bool_t zdr_GETQUOTA1res ();
|
||||
|
||||
#endif /* K&R C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_RQUOTA_H_RPCGEN */
|
|
@ -21,8 +21,7 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include "libnfs-zdr.h"
|
||||
#include "libnfs.h"
|
||||
#include "libnfs-raw.h"
|
||||
#include "libnfs-private.h"
|
||||
|
@ -55,7 +54,7 @@ int rpc_rquota1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_dat
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V1, RQUOTA1_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V1, RQUOTA1_NULL, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota1/null call");
|
||||
return -1;
|
||||
|
@ -75,7 +74,7 @@ int rpc_rquota1_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export,
|
|||
struct rpc_pdu *pdu;
|
||||
GETQUOTA1args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V1, RQUOTA1_GETQUOTA, cb, private_data, (xdrproc_t)xdr_GETQUOTA1res, sizeof(GETQUOTA1res));
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V1, RQUOTA1_GETQUOTA, cb, private_data, (zdrproc_t)zdr_GETQUOTA1res, sizeof(GETQUOTA1res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota1/getquota call");
|
||||
return -1;
|
||||
|
@ -84,8 +83,8 @@ int rpc_rquota1_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export,
|
|||
args.export = export;
|
||||
args.uid = uid;
|
||||
|
||||
if (xdr_GETQUOTA1args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode GETQUOTA1args");
|
||||
if (zdr_GETQUOTA1args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode GETQUOTA1args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -104,7 +103,7 @@ int rpc_rquota1_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *e
|
|||
struct rpc_pdu *pdu;
|
||||
GETQUOTA1args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V1, RQUOTA1_GETACTIVEQUOTA, cb, private_data, (xdrproc_t)xdr_GETQUOTA1res, sizeof(GETQUOTA1res));
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V1, RQUOTA1_GETACTIVEQUOTA, cb, private_data, (zdrproc_t)zdr_GETQUOTA1res, sizeof(GETQUOTA1res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota1/getactivequota call");
|
||||
return -1;
|
||||
|
@ -113,8 +112,8 @@ int rpc_rquota1_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *e
|
|||
args.export = export;
|
||||
args.uid = uid;
|
||||
|
||||
if (xdr_GETQUOTA1args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode GETQUOTA1args");
|
||||
if (zdr_GETQUOTA1args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode GETQUOTA1args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -133,7 +132,7 @@ int rpc_rquota2_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_dat
|
|||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V2, RQUOTA2_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V2, RQUOTA2_NULL, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota2/null call");
|
||||
return -1;
|
||||
|
@ -153,7 +152,7 @@ int rpc_rquota2_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export,
|
|||
struct rpc_pdu *pdu;
|
||||
GETQUOTA2args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V2, RQUOTA2_GETQUOTA, cb, private_data, (xdrproc_t)xdr_GETQUOTA1res, sizeof(GETQUOTA1res));
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V2, RQUOTA2_GETQUOTA, cb, private_data, (zdrproc_t)zdr_GETQUOTA1res, sizeof(GETQUOTA1res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota2/getquota call");
|
||||
return -1;
|
||||
|
@ -163,8 +162,8 @@ int rpc_rquota2_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export,
|
|||
args.type = type;
|
||||
args.uid = uid;
|
||||
|
||||
if (xdr_GETQUOTA2args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode GETQUOTA2args");
|
||||
if (zdr_GETQUOTA2args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode GETQUOTA2args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -183,7 +182,7 @@ int rpc_rquota2_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *e
|
|||
struct rpc_pdu *pdu;
|
||||
GETQUOTA2args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V2, RQUOTA2_GETACTIVEQUOTA, cb, private_data, (xdrproc_t)xdr_GETQUOTA1res, sizeof(GETQUOTA1res));
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V2, RQUOTA2_GETACTIVEQUOTA, cb, private_data, (zdrproc_t)zdr_GETQUOTA1res, sizeof(GETQUOTA1res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota2/getactivequota call");
|
||||
return -1;
|
||||
|
@ -193,8 +192,8 @@ int rpc_rquota2_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *e
|
|||
args.type = type;
|
||||
args.uid = uid;
|
||||
|
||||
if (xdr_GETQUOTA2args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode GETQUOTA2args");
|
||||
if (zdr_GETQUOTA2args(&pdu->zdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "ZDR error: Failed to encode GETQUOTA2args");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue