From: Andreas Gruenbacher <agruen@suse.de>
To: Andrew Morton <akpm@osdl.org>, lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/11] sunrpc-xdr-words
Date: Mon, 26 Apr 2004 12:28:48 +0200 [thread overview]
Message-ID: <1082975183.3295.74.camel@winden.suse.de> (raw)
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
next reply other threads:[~2004-04-26 10:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-26 10:28 Andreas Gruenbacher [this message]
2004-04-27 21:19 ` J. Bruce Fields
2004-04-27 22:37 ` Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1082975183.3295.74.camel@winden.suse.de \
--to=agruen@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®