Modify p9_deserialize_fcall to read from p9_fcall's internal buffer instead
of specifying an external one. Add functions that copy raw data to and from
a fcall.
Signed-off-by: Latchesar Ionkov <[email protected]>
---
include/net/9p/9p.h | 4 +++-
net/9p/conv.c | 34 ++++++++++++++++++++++++++++------
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index 86fee63..8de6eef 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -381,9 +381,11 @@ extern struct kset p9_subsys;
int p9_deserialize_stat(void *buf, u32 buflen, struct p9_stat *stat,
int dotu);
-int p9_deserialize_fcall(void *buf, u32 buflen, struct p9_fcall *fc, int dotu);
+int p9_deserialize_fcall(struct p9_fcall *fc, int dotu);
void p9_set_tag(struct p9_fcall *fc, u16 tag);
struct p9_fcall *p9_fcall_alloc(u32 size);
+int p9_fcall_get(char *dst, int dstlen, struct p9_fcall *fc);
+int p9_fcall_put(struct p9_fcall *fc, char *src, int srclen);
struct p9_fcall *p9_create_tversion(u32 msize, char *version);
struct p9_fcall *p9_create_tattach(u32 fid, u32 afid, char *uname,
char *aname, u32 n_uname, int dotu);
diff --git a/net/9p/conv.c b/net/9p/conv.c
index 3627753..74d57c7 100644
--- a/net/9p/conv.c
+++ b/net/9p/conv.c
@@ -322,18 +322,20 @@ EXPORT_SYMBOL(p9_deserialize_stat);
*
*/
-int
-p9_deserialize_fcall(void *buf, u32 buflen, struct p9_fcall *rcall,
- int dotu)
+int p9_deserialize_fcall(struct p9_fcall *rcall, int dotu)
{
-
+ u32 size;
struct cbuf buffer;
struct cbuf *bufp = &buffer;
int i = 0;
- buf_init(bufp, buf, buflen);
+ buf_init(bufp, rcall->sdata, rcall->size);
- rcall->size = buf_get_int32(bufp);
+ size = buf_get_int32(bufp);
+ if (size > rcall->size)
+ return -EPROTO;
+
+ rcall->size = size;
rcall->id = buf_get_int8(bufp);
rcall->tag = buf_get_int16(bufp);
@@ -941,3 +943,23 @@ error:
return fc;
}
EXPORT_SYMBOL(p9_create_twstat);
+
+int p9_fcall_get(char *dst, int dstlen, struct p9_fcall *fc)
+{
+ if (dstlen > fc->size)
+ dstlen = fc->size;
+
+ memmove(dst, fc->sdata, dstlen);
+ return dstlen;
+}
+EXPORT_SYMBOL(p9_fcall_get);
+
+int p9_fcall_put(struct p9_fcall *fc, char *src, int srclen)
+{
+ if (srclen > fc->size)
+ return -ENOMEM;
+
+ memmove(fc->sdata, src, srclen);
+ return srclen;
+}
+EXPORT_SYMBOL(p9_fcall_put);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]