summaryrefslogtreecommitdiff
path: root/fs/ceph/buffer.c
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2010-02-03 03:11:19 +0300
committerSage Weil <sage@newdream.net>2010-02-11 02:04:39 +0300
commitc7e337d6490d6f2f5e66ddf1b04d00b0dbd10108 (patch)
tree3a2e12219e38e807c71d8b2c30b89e7efbe82bdd /fs/ceph/buffer.c
parent79788c698b290426320e60374ed1324e4b5c69eb (diff)
downloadlinux-c7e337d6490d6f2f5e66ddf1b04d00b0dbd10108.tar.xz
ceph: buffer decoding helpers
Helper for decoding into a ceph_buffer, and other misc decoding helpers we will need. Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/buffer.c')
-rw-r--r--fs/ceph/buffer.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/ceph/buffer.c b/fs/ceph/buffer.c
index 2576bd452cb8..b98086c7aeba 100644
--- a/fs/ceph/buffer.c
+++ b/fs/ceph/buffer.c
@@ -1,6 +1,7 @@
#include "ceph_debug.h"
#include "buffer.h"
+#include "decode.h"
struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp)
{
@@ -59,3 +60,19 @@ int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp)
return 0;
}
+int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end)
+{
+ size_t len;
+
+ ceph_decode_need(p, end, sizeof(u32), bad);
+ len = ceph_decode_32(p);
+ dout("decode_buffer len %d\n", (int)len);
+ ceph_decode_need(p, end, len, bad);
+ *b = ceph_buffer_new(len, GFP_NOFS);
+ if (!*b)
+ return -ENOMEM;
+ ceph_decode_copy(p, (*b)->vec.iov_base, len);
+ return 0;
+bad:
+ return -EINVAL;
+}