svn commit: r192944 - in user/kmacy/releng_7_2_fcs/sys: cddl/contrib/opensolaris/uts/common/rpc modules/zfs rpc xdr

Kip Macy kmacy at FreeBSD.org
Thu May 28 00:44:45 UTC 2009


Author: kmacy
Date: Thu May 28 00:44:44 2009
New Revision: 192944
URL: http://svn.freebsd.org/changeset/base/192944

Log:
  - add FreeBSD implementation of xdrmem_control needed by zfs
  - have zfs define xdr_ops using FreeBSD's definition
  - remove solaris xdr files from zfs compile

Modified:
  user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h
  user/kmacy/releng_7_2_fcs/sys/modules/zfs/Makefile
  user/kmacy/releng_7_2_fcs/sys/rpc/xdr.h
  user/kmacy/releng_7_2_fcs/sys/xdr/xdr_mem.c

Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h	Thu May 28 00:38:24 2009	(r192943)
+++ user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h	Thu May 28 00:44:44 2009	(r192944)
@@ -121,6 +121,7 @@ typedef struct XDR {
  * Changes must be reviewed by Solaris File Sharing
  * Changes must be communicated to contract-2003-523 at sun.com
  */
+#ifndef __FreeBSD__	
 struct xdr_ops {
 #ifdef __STDC__
 #if !defined(_KERNEL)
@@ -168,6 +169,28 @@ struct xdr_ops {
 #endif
 };
 
+#else /* FreeBSD */
+struct xdr_ops {
+	/* get a long from underlying stream */
+	bool_t	(*x_getint32)(struct XDR *, int32_t *);
+	/* put a long to " */
+	bool_t	(*x_putint32)(struct XDR *, const int32_t *);
+	/* get some bytes from " */
+	bool_t	(*x_getbytes)(struct XDR *, char *, u_int);
+	/* put some bytes to " */
+	bool_t	(*x_putbytes)(struct XDR *, const char *, u_int);
+	/* returns bytes off from beginning */
+	u_int	(*x_getpostn)(struct XDR *);
+	/* lets you reposition the stream */
+	bool_t  (*x_setpostn)(struct XDR *, u_int);
+	/* buf quick ptr to buffered data */
+	int32_t *(*x_inline)(struct XDR *, u_int);
+	/* free privates of this xdr_stream */
+	void	(*x_destroy)(struct XDR *);
+	bool_t	(*x_control)(struct XDR *, int, void *);
+};
+#endif
+	
 /*
  * Operations defined on a XDR handle
  *

Modified: user/kmacy/releng_7_2_fcs/sys/modules/zfs/Makefile
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/modules/zfs/Makefile	Thu May 28 00:38:24 2009	(r192943)
+++ user/kmacy/releng_7_2_fcs/sys/modules/zfs/Makefile	Thu May 28 00:44:44 2009	(r192944)
@@ -43,10 +43,10 @@ SRCS+=	list.c
 SRCS+=	nvpair_alloc_system.c
 SRCS+=	taskq.c
 
-.PATH:	${SUNW}/uts/common/rpc
-SRCS+=	opensolaris_xdr.c
-SRCS+=	opensolaris_xdr_array.c
-SRCS+=	opensolaris_xdr_mem.c
+#.PATH:	${SUNW}/uts/common/rpc
+#SRCS+=	opensolaris_xdr.c
+#SRCS+=	opensolaris_xdr_array.c
+#SRCS+=	opensolaris_xdr_mem.c
 
 .PATH:	${SUNW}/uts/common/zmod
 SRCS+=	adler32.c

Modified: user/kmacy/releng_7_2_fcs/sys/rpc/xdr.h
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/rpc/xdr.h	Thu May 28 00:38:24 2009	(r192943)
+++ user/kmacy/releng_7_2_fcs/sys/rpc/xdr.h	Thu May 28 00:44:44 2009	(r192944)
@@ -338,6 +338,22 @@ typedef struct netobj netobj;
 extern bool_t   xdr_netobj(XDR *, struct netobj *);
 
 /*
+ * These are XDR control operators
+ */
+
+#define	XDR_GET_BYTES_AVAIL 	1
+#define	XDR_PEEK		2
+#define	XDR_SKIPBYTES		3
+
+struct xdr_bytesrec {
+	bool_t xc_is_last_record;
+	size_t xc_num_avail;
+};
+
+typedef struct xdr_bytesrec xdr_bytesrec;
+
+
+/*
  * These are the public routines for the various implementations of
  * xdr streams.
  */

Modified: user/kmacy/releng_7_2_fcs/sys/xdr/xdr_mem.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/xdr/xdr_mem.c	Thu May 28 00:38:24 2009	(r192943)
+++ user/kmacy/releng_7_2_fcs/sys/xdr/xdr_mem.c	Thu May 28 00:44:44 2009	(r192944)
@@ -68,7 +68,8 @@ static u_int xdrmem_getpos(XDR *);
 static bool_t xdrmem_setpos(XDR *, u_int);
 static int32_t *xdrmem_inline_aligned(XDR *, u_int);
 static int32_t *xdrmem_inline_unaligned(XDR *, u_int);
-
+static bool_t xdrmem_control(XDR *xdrs, int request, void *info);
+	
 static const struct	xdr_ops xdrmem_ops_aligned = {
 	xdrmem_getint32_aligned,
 	xdrmem_putint32_aligned,
@@ -77,7 +78,8 @@ static const struct	xdr_ops xdrmem_ops_a
 	xdrmem_getpos,
 	xdrmem_setpos,
 	xdrmem_inline_aligned,
-	xdrmem_destroy
+	xdrmem_destroy,
+	xdrmem_control
 };
 
 static const struct	xdr_ops xdrmem_ops_unaligned = {
@@ -88,7 +90,8 @@ static const struct	xdr_ops xdrmem_ops_u
 	xdrmem_getpos,
 	xdrmem_setpos,
 	xdrmem_inline_unaligned,
-	xdrmem_destroy
+	xdrmem_destroy,
+	xdrmem_control
 };
 
 /*
@@ -230,3 +233,45 @@ xdrmem_inline_unaligned(XDR *xdrs, u_int
 
 	return (0);
 }
+
+static bool_t
+xdrmem_control(XDR *xdrs, int request, void *info)
+{
+	xdr_bytesrec *xptr;
+	int32_t *l;
+	int len;
+
+	switch (request) {
+
+	case XDR_GET_BYTES_AVAIL:
+		xptr = (xdr_bytesrec *)info;
+		xptr->xc_is_last_record = TRUE;
+		xptr->xc_num_avail = xdrs->x_handy;
+		return (TRUE);
+
+	case XDR_PEEK:
+		/*
+		 * Return the next 4 byte unit in the XDR stream.
+		 */
+		if (xdrs->x_handy < sizeof (int32_t))
+			return (FALSE);
+		l = (int32_t *)info;
+		*l = (int32_t)ntohl((uint32_t)
+		    (*((int32_t *)(xdrs->x_private))));
+		return (TRUE);
+
+	case XDR_SKIPBYTES:
+		/*
+		 * Skip the next N bytes in the XDR stream.
+		 */
+		l = (int32_t *)info;
+		len = RNDUP((int)(*l));
+		if (xdrs->x_handy < len)
+			return (FALSE);
+		xdrs->x_handy -= len;
+		xdrs->x_private = (char *)xdrs->x_private + len;
+		return (TRUE);
+
+	}
+	return (FALSE);
+}


More information about the svn-src-user mailing list