mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 4/11] sunrpc-xdr-words
@ 2004-04-26 10:28 Andreas Gruenbacher
  2004-04-27 21:19 ` J. Bruce Fields
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Gruenbacher @ 2004-04-26 10:28 UTC (permalink / raw)
  To: Andrew Morton, lkml

Encode 32-bit words in xdr_buf's

  Andreas Gruenbacher <agruen@suse.de>, SUSE Labs

Index: linux-2.6.6-rc2/include/linux/sunrpc/xdr.h
===================================================================
--- linux-2.6.6-rc2.orig/include/linux/sunrpc/xdr.h	2004-04-20 23:30:31.000000000 +0200
+++ linux-2.6.6-rc2/include/linux/sunrpc/xdr.h	2004-04-24 22:07:00.013155968 +0200
@@ -153,6 +153,9 @@
 extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, int, int);
 extern int xdr_buf_read_netobj(struct xdr_buf *, struct xdr_netobj *, int);
 extern int read_bytes_from_xdr_buf(struct xdr_buf *buf, int base, void *obj, int len);
+extern int read_u32_from_xdr_buf(struct xdr_buf *, int, u32 *);
+extern int write_bytes_to_xdr_buf(struct xdr_buf *, int, void *, int);
+extern int write_u32_to_xdr_buf(struct xdr_buf *, int, u32);
 
 /*
  * Helper structure for copying from an sk_buff.
Index: linux-2.6.6-rc2/net/sunrpc/sunrpc_syms.c
===================================================================
--- linux-2.6.6-rc2.orig/net/sunrpc/sunrpc_syms.c	2004-04-20 23:30:00.000000000 +0200
+++ linux-2.6.6-rc2/net/sunrpc/sunrpc_syms.c	2004-04-24 22:07:00.010156424 +0200
@@ -132,6 +132,9 @@
 EXPORT_SYMBOL(xdr_buf_subsegment);
 EXPORT_SYMBOL(xdr_buf_read_netobj);
 EXPORT_SYMBOL(read_bytes_from_xdr_buf);
+EXPORT_SYMBOL(read_u32_from_xdr_buf);
+EXPORT_SYMBOL(write_bytes_to_xdr_buf);
+EXPORT_SYMBOL(write_u32_to_xdr_buf);
 
 /* Debugging symbols */
 #ifdef RPC_DEBUG
Index: linux-2.6.6-rc2/net/sunrpc/xdr.c
===================================================================
--- linux-2.6.6-rc2.orig/net/sunrpc/xdr.c	2004-04-20 23:29:43.000000000 +0200
+++ linux-2.6.6-rc2/net/sunrpc/xdr.c	2004-04-24 22:08:19.476075768 +0200
@@ -990,7 +990,7 @@
 	return status;
 }
 
-static int
+int
 read_u32_from_xdr_buf(struct xdr_buf *buf, int base, u32 *obj)
 {
 	u32	raw;
@@ -1003,6 +1003,41 @@
 	return 0;
 }
 
+/* obj is assumed to point to allocated memory of size at least len: */
+int
+write_bytes_to_xdr_buf(struct xdr_buf *buf, int base, void *obj, int len)
+{
+	struct xdr_buf subbuf;
+	int this_len;
+	int status;
+
+	status = xdr_buf_subsegment(buf, &subbuf, base, len);
+	if (status)
+		goto out;
+	this_len = min(len, (int)subbuf.head[0].iov_len);
+	memcpy(subbuf.head[0].iov_base, obj, this_len);
+	len -= this_len;
+	obj += this_len;
+	this_len = min(len, (int)subbuf.page_len);
+	if (this_len)
+		_copy_to_pages(subbuf.pages, subbuf.page_base, obj, this_len);
+	len -= this_len;
+	obj += this_len;
+	this_len = min(len, (int)subbuf.tail[0].iov_len);
+	memcpy(subbuf.tail[0].iov_base, obj, this_len);
+out:
+	return status;
+}
+
+int
+write_u32_to_xdr_buf(struct xdr_buf *buf, int base, u32 obj)
+{
+	int	status;
+
+	obj = htonl(obj);
+	return write_bytes_to_xdr_buf(buf, base, &obj, sizeof(obj));
+}
+
 /* If the netobj starting offset bytes from the start of xdr_buf is contained
  * entirely in the head or the tail, set object to point to it; otherwise
  * try to find space for it at the end of the tail, copy it there, and



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/11] sunrpc-xdr-words
  2004-04-26 10:28 [PATCH 4/11] sunrpc-xdr-words Andreas Gruenbacher
@ 2004-04-27 21:19 ` J. Bruce Fields
  2004-04-27 22:37   ` Andreas Gruenbacher
  0 siblings, 1 reply; 3+ messages in thread
From: J. Bruce Fields @ 2004-04-27 21:19 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: Andrew Morton, lkml

On Mon, Apr 26, 2004 at 12:28:48PM +0200, Andreas Gruenbacher wrote:
> Encode 32-bit words in xdr_buf's
> +extern int read_u32_from_xdr_buf(struct xdr_buf *, int, u32 *);

Note that the same function is defined as a static inline in
net/sunrpc/auth_gss/svcauth_gss.c, so gcc will complain if
CONFIG_SUNRPC_GSS is also defined.

--Bruce Fields

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/11] sunrpc-xdr-words
  2004-04-27 21:19 ` J. Bruce Fields
@ 2004-04-27 22:37   ` Andreas Gruenbacher
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Gruenbacher @ 2004-04-27 22:37 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: lkml

Hi Bruce,

thanks, we can move both functions into include/linux/sunrpc/xdr.h; they are 
trivial enough.

On Tuesday 27 April 2004 23:19, J. Bruce Fields wrote:
> On Mon, Apr 26, 2004 at 12:28:48PM +0200, Andreas Gruenbacher wrote:
> > Encode 32-bit words in xdr_buf's
> > +extern int read_u32_from_xdr_buf(struct xdr_buf *, int, u32 *);
>
> Note that the same function is defined as a static inline in
> net/sunrpc/auth_gss/svcauth_gss.c, so gcc will complain if
> CONFIG_SUNRPC_GSS is also defined.
>
> --Bruce Fields

Cheers,
-- 
Andreas Gruenbacher <agruen@suse.de>
SUSE Labs, SUSE LINUX AG

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-04-27 22:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-26 10:28 [PATCH 4/11] sunrpc-xdr-words Andreas Gruenbacher
2004-04-27 21:19 ` J. Bruce Fields
2004-04-27 22:37   ` Andreas Gruenbacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®